LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Accessing GPIO-pins on a MPC8308E RDB (powerpc) (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/accessing-gpio-pins-on-a-mpc8308e-rdb-powerpc-830599/)

Amys 09-06-2010 09:32 AM

Accessing GPIO-pins on a MPC8308E RDB (powerpc)
 
As the subject says, I am attempting to access the GPIO-pins on a MPC8308 through /sys/class/gpio, and I suspect I am doing something elementary wrong.
For instance:
Code:

echo 0 > /sys/class/gpio/export
produces a
Code:

gpio_request: gpio-0 (sysfs) status -22
Does anyone know how I can find the correct GPIO-numbers to send to export? According to the mpc8308-documentation, it seems that the numbers should be in the range 0-15, but export produces the same error as above with all numbers in this range.

I am quite new to playing with embedded systems, so a nudge in the right direction would be highly appreciated :)


##system information:##
uname -a:
Quote:

Linux mpc8308erdb 2.6.29.6-rt23 #17 Mon Sep 6 15:32:40 CEST 2010 ppc unknown
GPIO-related info in <..>/arch/powerpc/boot/mpc8308erdb.dts:
Code:

gpio@c00 {
  device_type = "gpio";
  compatible = "fsl,mpc8315-gpio";
  reg = <0xc00 0x18>;
  interrupt-parent = < &ipic >;
};


jiml8 09-06-2010 11:41 AM

Try it as root.

Amys 09-06-2010 02:56 PM

Thank you for the reply. All commands were run as root, I should probably have mentioned that.

Amys 09-07-2010 06:03 AM

Anyone?
I would welcome any suggestions as to how I can communicate with the GPIO-pins, it doesn't have to be through /sys (my ultimate goal is to create a char device driver, and I thought /sys/class/gpio would be a nice place to start in order to verify that GPIO worked as expected).

My (somewhat vague) theory is that I have to add something to <..>/arch/powerpc/platforms/83xx/mpc830x_rdb.c, but I have no idea what I need to add.

Extensive googling led me to try the driver found here: http://docs.blackfin.uclinux.org/dok...rs:simple-gpio, and I added this to mpc830x_rdb.c:
Code:

static struct resource foo_resources[] = {
        {.start = 0},
        {.end = 5},
        {.flags = IORESOURCE_IRQ},
};
static struct platform_device foo_dev = {
        .name = "simple-gpio",
        .num_resources = 1,
        .resource = &foo_resources
};

When insmod'ing (after recompiling the kernel) nothing happens (the init-method is executed, but the device does not show up in /proc/devices). Also, its probe-method is never executed (I tested with adding print-statements to the code).
All this leads me to suspect that the source of the problem lies in either mpc8308erdb.dts or mpc830x_rdb.c, but I have no idea whatsoever as to how I should debug this any further..


More details: kernel is compiled with both CONFIG_QUICC_ENGINE and CONFIG_SIMPLE_GPIO set to yes (and also various relevant SYSFS-flags).

Amys 09-10-2010 07:52 AM

Just in case some other poor soul have a similar problem and comes across this thread, this is how I made it work:

* Make sure the pin you are measuring on is actually active (I had to modify the SICRH-register to do this)
(It is probably wise to test that GPIO actually works by using devmem or similar to write directly to the memory locations used by GPIO and measure the output by using an oscilloscope, leds or similar)

* Be inspired by <..>/drivers/gpio/xilinx_gpio.c and modify it to suit the MPC8308-board, and use this to control the pins.

I am still not able to use sysfs to control gpio, but as long as my driver works I'm happy :)


All times are GMT -5. The time now is 02:33 PM.