LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 09-06-2010, 09:32 AM   #1
Amys
LQ Newbie
 
Registered: Sep 2010
Distribution: Ubuntu
Posts: 6

Rep: Reputation: 0
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 >;
};
 
Old 09-06-2010, 11:41 AM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Try it as root.
 
Old 09-06-2010, 02:56 PM   #3
Amys
LQ Newbie
 
Registered: Sep 2010
Distribution: Ubuntu
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you for the reply. All commands were run as root, I should probably have mentioned that.
 
Old 09-07-2010, 06:03 AM   #4
Amys
LQ Newbie
 
Registered: Sep 2010
Distribution: Ubuntu
Posts: 6

Original Poster
Rep: Reputation: 0
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).
 
Old 09-10-2010, 07:52 AM   #5
Amys
LQ Newbie
 
Registered: Sep 2010
Distribution: Ubuntu
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can i use I/o Port pins of a processor as four SPI pins? i sunr2007 Linux - Embedded & Single-board computer 3 08-20-2009 01:23 AM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM
can broken pins on a HD be repaired/replaced? newbiesforever General 7 02-12-2009 07:04 PM
Implementing RDB in Linux pr4pyaar Programming 0 03-02-2007 04:36 AM
Tri-state pins kamransoomro84 General 2 07-23-2005 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 11:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration