* IBM OCP GPIO driver for linux 2.6
@ 2006-08-03 11:15 Jean-Baptiste Maneyrol
2006-08-03 13:53 ` Dale Farnsworth
2006-08-03 13:54 ` Arnd Bergmann
0 siblings, 2 replies; 4+ messages in thread
From: Jean-Baptiste Maneyrol @ 2006-08-03 11:15 UTC (permalink / raw)
To: linuxppc-embedded
Hello everyone, I'm a newbie here!
I'm porting a custom PPC 405GP card based on a Walnut from Montavista
Linux 3.0 (kernel 2.4.18) to linux 2.6, and I was wondering if there is
a port of the IBM OCP GPIO driver (a char driver providing
device /dev/gpio, major 10 minor 185). The driver was written by Armin
Kuster, and it doesn't exist in the stock kernel 2.6.17.7.
Let me known if a port exists, or if there is a new way of accessing the
PPC 405GP GPIO under linux 2.6. Otherwise, I will port this driver using
the IBM IIC driver as an example (for the things about OCP). In this
case, do anybody know where I can have the last version of this driver
(I have v 1.7 (07/25/02)) ?
Thanks for all!
Jean-Baptiste Maneyrol
Teamlog - France
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: IBM OCP GPIO driver for linux 2.6
2006-08-03 11:15 IBM OCP GPIO driver for linux 2.6 Jean-Baptiste Maneyrol
@ 2006-08-03 13:53 ` Dale Farnsworth
2006-08-03 13:54 ` Arnd Bergmann
1 sibling, 0 replies; 4+ messages in thread
From: Dale Farnsworth @ 2006-08-03 13:53 UTC (permalink / raw)
To: jean-baptiste.maneyrol, Linuxppc-embedded
In article <1154603751.17247.10.camel@jb-portable> you write:
> I'm porting a custom PPC 405GP card based on a Walnut from Montavista
> Linux 3.0 (kernel 2.4.18) to linux 2.6, and I was wondering if there is
> a port of the IBM OCP GPIO driver (a char driver providing
> device /dev/gpio, major 10 minor 185). The driver was written by Armin
> Kuster, and it doesn't exist in the stock kernel 2.6.17.7.
>
> Let me known if a port exists, or if there is a new way of accessing the
> PPC 405GP GPIO under linux 2.6.
The recommended way of accessing GPIO registers is to mmap them
and manipulate them directly in user space.
Below, I've included a quick hack that blinks a LED on a Walnut-like
board.
-Dale
#include <stdint.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#define GPIO_PAGE_ADDR 0xef600000
#define OUTPUT_REG 0x0700
#define TRISTATE_REG 0x0704
#define OPENDRAIN_REG 0x0718
#define INPUT_REG 0x071c
#define MEDIA_LED_BIT 0x20000000
#define reg_addr(p, o) ((uint32_t *)((void *)p + o))
int main(int argc, char *argv[])
{
int i;
uint32_t *p;
char *filename = "/dev/mem";
void *addr = 0;
size_t length = 4096;
int prot = PROT_READ | PROT_WRITE;
int flags = MAP_SHARED;
int fd = open(filename, O_RDWR);
off_t offset = (off_t)GPIO_PAGE_ADDR;
if (fd < 0) {
perror("open");
return 1;
}
p = mmap(addr, length, prot, flags, fd, offset);
if (p == MAP_FAILED) {
perror("mmap");
return 4;
}
/* drive led output */
*reg_addr(p, TRISTATE_REG) |= MEDIA_LED_BIT;
/* blink media led 10 times */
for (i = 0; i < 10; i++) {
/* turn media led on */
*reg_addr(p, OUTPUT_REG) &= ~MEDIA_LED_BIT;
sleep(1);
/* turn media led off */
*reg_addr(p, OUTPUT_REG) |= MEDIA_LED_BIT;
sleep(1);
}
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: IBM OCP GPIO driver for linux 2.6
2006-08-03 11:15 IBM OCP GPIO driver for linux 2.6 Jean-Baptiste Maneyrol
2006-08-03 13:53 ` Dale Farnsworth
@ 2006-08-03 13:54 ` Arnd Bergmann
1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2006-08-03 13:54 UTC (permalink / raw)
To: linuxppc-embedded; +Cc: Jean-Baptiste Maneyrol
On Thursday 03 August 2006 13:15, Jean-Baptiste Maneyrol wrote:
> Let me known if a port exists, or if there is a new way of accessing the
> PPC 405GP GPIO under linux 2.6. Otherwise, I will port this driver using
> the IBM IIC driver as an example (for the things about OCP). In this
> case, do anybody know where I can have the last version of this driver
> (I have v 1.7 (07/25/02)) ?
The only OCP drivers that exist in the tree are for emac and iic.
Those will probably be converted to use something like of_platform_device
in the future, as soon as 4xx gets converted to arch/powerpc.
If you need to port the driver now, it's probably a good idea to use
a platform_driver instead of an ocp driver for it.
Arnd <><
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: IBM OCP GPIO driver for linux 2.6
@ 2006-08-03 18:25 Milton Miller
0 siblings, 0 replies; 4+ messages in thread
From: Milton Miller @ 2006-08-03 18:25 UTC (permalink / raw)
To: dale, jean-baptiste.maneyrol, Linuxppc-embedded
On Thu Aug 3 2006 08:53:00 AM CDT, Dale Farnsworth wrote:
> The recommended way of accessing GPIO registers is to mmap them
> and manipulate them directly in user space.
> /* turn media led on */
> *reg_addr(p, OUTPUT_REG) &= ~MEDIA_LED_BIT;
> sleep(1);
> /* turn media led off */
> *reg_addr(p, OUTPUT_REG) |= MEDIA_LED_BIT;
Very racy if you need different bits in the same word controlled by different programs.
milton
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-08-03 18:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-03 11:15 IBM OCP GPIO driver for linux 2.6 Jean-Baptiste Maneyrol
2006-08-03 13:53 ` Dale Farnsworth
2006-08-03 13:54 ` Arnd Bergmann
-- strict thread matches above, loose matches on Subject: below --
2006-08-03 18:25 Milton Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).