public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Matthias Fechner <idefix@fechner•net>
To: linuxppc-embedded@ozlabs•org
Subject: Re: Howto set DIO on MPC-5200 Lite
Date: Thu, 22 Mar 2007 21:04:53 +0100	[thread overview]
Message-ID: <20070322200453.GA76755@server.idefix.lan> (raw)
In-Reply-To: <918EB199DDDFFA42BEA2EB3A1C6021F360C085@CORREO>

Hello Josu,

* Josu Onandia <jonandia@aotek•es> [19-03-07 14:18]:
> Some sample code. Hope this helps.

thx a lot for all your help I love that mailinglist :)

Here is a very small kernel module for the icecube board.
It activates the LED 1 and 3 after module has been loaded
and off again if module has been removed.
Maybe that helps someone else:

#include <linux/module.h>
#include <asm/mpc52xx.h>

#define MPC5xxx_GPIO MPC52xx_VA(MPC52xx_GPIO_OFFSET)

static void psc6_configure_pins(void)
{
   struct mpc52xx_gpio *config;
   config = (struct mpc52xx_gpio*) MPC5xxx_GPIO;
         
   printk("Address: %X\n",(u32)&config->port_config);
   printk("Configure port\n");
   config->port_config &= ~(0x00700000);
		     
   printk("Set IRDA to GPIO\n");
   config->simple_gpioe |= 0x30000000;
			      
   printk("Set pins to CMOS output\n");
   config->simple_ode &= ~(0x30000000);
				       
   printk("Set simple GPIO data direction register\n");
   config->simple_ddr |= 0x30000000;
 }
   
// the pins are active low, so we invert it
static void psc6_pin_on(unsigned int pin)
{
   struct mpc52xx_gpio *config;
   config = (struct mpc52xx_gpio*) MPC5xxx_GPIO;
   printk("Set LEDs %i\n",pin);
   config->simple_dvo &= ~(1 << (pin+28));
}
	       
// the pins are active low, so we invert it
static void psc6_pin_off(unsigned int pin)
{
   struct mpc52xx_gpio *config;
   config = (struct mpc52xx_gpio*) MPC5xxx_GPIO;
   printk("Clear LED %i\n",pin);
   config->simple_dvo |= (1 << (pin+28));
}
			   
static int icecube_led_init(void)
{
   printk("Module Blink LED loaded\n");
   printk("Set LEDs on\n");
   psc6_configure_pins();
   psc6_pin_on(0);
   psc6_pin_on(1);
   return 0;
}
						
static void icecube_led_cleanup(void)
{
   printk("Module Blink LED unloaded\n");
   psc6_pin_off(0);
   psc6_pin_off(1);
}
      
MODULE_AUTHOR("Matthias Fechner <idefix@fechner•net>");
MODULE_DESCRIPTION("Driver to switch LED on icecube board after driver loaded successfully and switch LEDs of after driver unloaded successfully.");
MODULE_LICENSE("GPL");

module_init(icecube_led_init);
module_exit(icecube_led_cleanup);



Best regards,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

  parent reply	other threads:[~2007-03-22 20:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-19 13:18 Howto set DIO on MPC-5200 Lite Josu Onandia
2007-03-19 18:16 ` Matthias Fechner
2007-03-22 20:04 ` Matthias Fechner [this message]
2007-03-22 22:48   ` Steven Kaiser
2007-03-23 12:02     ` Sylvain Munaut
  -- strict thread matches above, loose matches on Subject: below --
2007-03-19  7:31 Matthias Fechner
2007-03-19  8:16 ` Sylvain Munaut
2007-03-19  8:45 ` Pedro Luis D. L.
2007-03-19  9:48   ` Matthias Fechner
2007-03-19 10:12     ` Pedro Luis D. L.
2007-03-19 10:14     ` Sylvain Munaut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070322200453.GA76755@server.idefix.lan \
    --to=idefix@fechner$(echo .)net \
    --cc=linuxppc-embedded@ozlabs$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox