LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-29-2012, 04:14 AM   #1
LiveGen
LQ Newbie
 
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
Access to gpio ressources (kernel space) (no gpiolib)


Hi everyone,

i am very beginner about the linux kernel and all that stuff.

I am using an Olimex lpc-h3131 board and i would like to develop a "gpio driver". For support, i have the linux device driver book chapter 9 "Commucating with hardware". Of course, gpiolib is not available.

For my first step, i have a led on the GPIO17 (adress 0x130031CB), i try to read the value on this pin. But it seems i don't do it correctly because the value read is always 0, even if the led is turned on ...

Any advices ?

you can find below a part of my driver :

Code:
#define GPIO_BASE 0x130031CB
void *map;

if(request_region(GPIO_BASE, 1, "parr_driver") != NULL)
{
	printk(KERN_ALERT "parr_driver : the adress GPIO16 is now reserved \n");

	if(request_mem_region(GPIO_BASE, 1, "parr_driver") != NULL)
	{
		printk(KERN_ALERT "parr_driver : the memory GPIO16 is now reserved \n");


		map = ioremap(GPIO_BASE, 1);

		if(map != NULL)
		{
			int byte = 0;
			printk(KERN_ALERT "parr_driver : ioremap worked : %p \n", map);
			byte = readb(map);
			printk(KERN_ALERT "parr_driver : byte : %i \n", byte);
		}
		else
		{
			printk(KERN_ALERT "parr_driver : ioremap failed \n");
		}	
	}
	else
	{
		printk(KERN_ALERT "parr_driver : the memory GPIO16 can't be reserved \n");
        }	
}
else
{
	printk(KERN_ALERT "parr_driver : the adress GPIO16 can't be reserved \n");
}
My output is the folowing :

Quote:
parr_driver : the adress GPIO16 is now reserved
parr_driver : the memory GPIO16 is now reserved
parr_driver : ioremap worked : c286a1cb
parr_driver : byte : 0
Documentation of the board :
http://www.olimex.com/dev/pdf/ARM/LPC/LPC-H3131.pdf
Documentation of the µC
http://ics.nxp.com/support/documents...30.lpc3131.pdf

My board is running under linux 2.6.33

Thanks for any helps, Livegen.
--------
second thread
Hi everyone,

i am very beginner in linux kernel and all that stuff.

I am developping a gpio driver for my Olimex lpc-h3131. the goal of this driver is to show the pin status. For support, i have the linux device driver book (chapter 9) "Communicating with the hardware".

I have done my driver and try to read the status on Pin 0x130031CB, a led is put on this pin. But it seems it don't work, because the value read is always 0 even if the led is turned on....

Any can help me ?

I am running under linux 2.6.33 patched for my board.

Documentation of the µC
http://ics.nxp.com/support/documents...30.lpc3131.pdf

Documentation of the board
http://www.olimex.com/dev/pdf/ARM/LPC/LPC-H3131.pdf

Livegen

Last edited by onebuck; 03-29-2012 at 07:40 AM. Reason: integrate two threads
 
Old 04-03-2012, 11:15 PM   #2
cnxsoft
Member
 
Registered: Nov 2010
Location: Thailand
Distribution: Fedora 12, Ubuntu 10.10
Posts: 167

Rep: Reputation: 29
I'm not sure if this is the case here, but it's not always possible to read the value of the output pin in a processor. To read the value, make sure the pin is set to input.
 
  


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
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 03:57 PM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM
GPIO access from users pace? ra2008 Linux - Embedded & Single-board computer 13 08-05-2008 08:48 AM
Gpio Twiddling In Embedded Linux? or How to access PCI memory space regs? jds-linux Programming 1 07-11-2004 02:17 AM

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

All times are GMT -5. The time now is 07:50 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