RE: Howto set DIO on MPC-5200 Lite

5 messages, 4 authors, 2007-03-23 · open the first message on its own page

RE: Howto set DIO on MPC-5200 Lite

From: Josu Onandia <hidden>
Date: 2007-03-19 13:58:30

Some sample code. Hope this helps.

Regards

Josu Onandia

//   PSC2_0  ---->  J20 pin 2
//   PSC2_1  ---->  J20 pin 4
//   PSC2_2  ---->  J20 pin 6
//   PSC2_3  ---->  J20 pin 8
//
//   GND ---- J20 pins 15,17,19,20

static void psc2_configure_pins(void)
{
	struct mpc5xxx_gpio *gpio;
	
	gpio = (struct mpc5xxx_gpio*) MPC5xxx_GPIO;
	
	gpio->port_config &= ~(0x00000070);
	gpio->simple_gpioe |= 0x000000F0;
	gpio->simple_ode &= ~0x000000F0;
	gpio->simple_ddr |= 0x000000F0;
}
/* PSC2   0 to 3 pins */
static inline void psc2_pin_on(int pin)
{
	struct mpc5xxx_gpio *gpio;
	
	if((pin < 0) || (pin > 3))
		return;
	gpio = (struct mpc5xxx_gpio*) MPC5xxx_GPIO;
	gpio->simple_dvo |= (1 << (pin + 4));
}
static inline void psc2_pin_off(int pin)
{
	struct mpc5xxx_gpio *gpio;
	
	if((pin < 0) || (pin > 3))
		return;
	
	gpio = (struct mpc5xxx_gpio*) MPC5xxx_GPIO;
	
	gpio->simple_dvo &= ~ (1 << (pin + 4));
}



-----Mensaje original-----
De: linuxppc-embedded-bounces+jonandia=aotek.es@ozlabs.org en nombre de Matthias Fechner
Enviado el: lun 19/03/2007 8:31
Para: linuxppc-embedded@ozlabs.org
Asunto: Howto set DIO on MPC-5200 Lite
 
Hi,

how can I set the DIO ports from a MPC-5200 Lite?


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
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

Re: Howto set DIO on MPC-5200 Lite

From: Matthias Fechner <hidden>
Date: 2007-03-19 18:16:35

Hello Josu,

* Josu Onandia [off-list ref] [19-03-07 14:18]:
Some sample code. Hope this helps.

//   PSC2_0  ---->  J20 pin 2
//   PSC2_1  ---->  J20 pin 4
//   PSC2_2  ---->  J20 pin 6
//   PSC2_3  ---->  J20 pin 8
//
//   GND ---- J20 pins 15,17,19,20
thx a lot for your code.
My problem is I have no documentation of the icecube board so I have
no idea which pin is connect to each other.

Have you possibly a documentation or schemtics from the icecube board
which you send send me?

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

Re: Howto set DIO on MPC-5200 Lite

From: Matthias Fechner <hidden>
Date: 2007-03-22 20:05:06

Hello Josu,

* Josu Onandia [off-list ref] [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 [off-list ref]");
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

RE: Howto set DIO on MPC-5200 Lite

From: Steven Kaiser <hidden>
Date: 2007-03-22 22:48:44

This DIO on MPC-5200 thread brings up a related question that has been
nagging me for a while.

I built a custom MPC5200B board based on the Lite5200B, and run a 2.4 kernel
using the ELDK.  My hardware does not include PCI, but instead uses the
LocalPlus as a custom 18-bit external parallel bus to drive a bunch of
custom peripherals.  I added some GPIO (PSC6_0 thru PSC6_3) to this custom
external bus to allow interrupts, signaling, and various types of control.
All's well.  Now I would like to add more control lines, and even serial
interfaces to my custom bus.

But what holds me back is I am not entirely sure what 5200B peripherals the
stock linux kernel uses, and which ones are free for users to write their
own drivers and take over.  I currently use a 2.4 kernel, but someday [soon]
will move up to a 2.6 kernel.  I just want to download the basic ELDK
kernel, insmod my custom drivers, and go.  I would hate to find out the pins
I have taken over require me to hack up and reconfigure the kernel (since
I'm not so intimate with Linux yet this scares me if something goes wrong).

For example, in another thread people here are talking about a power down
feature in 2.6 for the MPC5200B.  Does this new feature use any GPIO lines I
should leave alone as reserved for linux use?  The LITE5200B has some queer
ad-hoc network hack using PSC2_4 to power down the board's voltage
regulators, but linux 2.4 knows nothing of this and removing the zero ohm
resistor (R88) allows me to use that pin for my own purposes (At least
emperically linux 2.4 doesn't seem to mind me programming that pin).

Looks like from the DIO discussion here that PSC2_0 thru PSC2_3, and PSC6_0
thru PSC6_3 pins are clearly free.  In general it looks like PSC2 (5 lines),
PSC3 (10 lines), and PSC6 (4 lines) are free for user use.  Linux expects a
UART on PSC1, and PSC4 and PSC5 pins are taken over by Ethernet, so those
lines are off limits.  Am I correct so far?

Are the TIMER_0 thru TIMER_7 lines used at all by the linux kernel?  I
thirst after 2 timers for my custom bus.

If I don't use PCI, can I take over IRQ_0 thru IRQ_3 without disrupting the
normal operation of the 2.4 or 2.6 kernel?  Some of the GPIO lines work fine
as interrupts so this is not so critical, but it would be nice to know.

EFIKA seems to have some sort of battery backed RTC to keep date and time,
but without a schematic I can't be sure what it is.  Would be nice if the
LITE500B had something like this.  What 5200B chip pins does EFIKA use for
this?  Maybe should reserve these pins for a future RTC in the EFIKA
tradition.

So my general question is this: What pins on the 5200B are free for external
use by the user (i.e. what pins are reserved by the linux 2.4 and 2.6 stock
kernels for internal use)?

Steve Kaiser
-----Original Message-----
From: linuxppc-embedded-bounces+skaiser.uci=gmail.com@ozlabs.org
[mailto:linuxppc-embedded-bounces+skaiser.uci=gmail.com@ozlabs.org] On
Behalf Of Matthias Fechner
Sent: Thursday, March 22, 2007 1:05 PM
To: linuxppc-embedded@ozlabs.org
Subject: Re: Howto set DIO on MPC-5200 Lite

Hello Josu,

* Josu Onandia [off-list ref] [19-03-07 14:18]:
quoted
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 [off-list ref]");
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
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

Re: Howto set DIO on MPC-5200 Lite

From: Sylvain Munaut <hidden>
Date: 2007-03-23 12:03:02

Steven Kaiser wrote:
EFIKA seems to have some sort of battery backed RTC to keep date and time,
but without a schematic I can't be sure what it is.  Would be nice if the
LITE500B had something like this.  What 5200B chip pins does EFIKA use for
this?  Maybe should reserve these pins for a future RTC in the EFIKA
tradition.
  
The EFIKA has a small PIC that serves for power up / down and to keep time.
I think it's on a I2C bus but I don't know if they implemented it with
the embedded I2C controller or by bitbanging some GPIO.
(never saw the schema so that's and educated guess ...)
So my general question is this: What pins on the 5200B are free for external
use by the user (i.e. what pins are reserved by the linux 2.4 and 2.6 stock
kernels for internal use)?
  
I can only speak for 2.6 and AFAIK it's none ...

Anyway you will need to write your own board file and your own device
tree and have your boot loader set port_config appropriatly. From there
you can free any pin you want (provided  that pin is not used by a
function you want of course ...)

The lines used for PCI IRQ are specified for the Lite5200 and Lite5200B
in their device tree (or in the board file if you still use arch/ppc).
So when you write those files for your board, just make sure it match
your board.

    Sylvain
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help