Skip to contentSkip to conversation

GPIO on the Au1500

DISCUSSION Gilad Rom 4 participants 10 messages Nov 12, 2004 – Nov 16, 2004 MIPS

lore
Share & tools
lore

Gilad Rom

author
#0 lore raw

Hello,

I am trying to use the au1000_gpio driver, but I'm a little clueless as to how it is meant to be used. Can I use the GPIO ioctl's from a userland program, or must I write a kernel module?

Thank you,
Gilad Rom
Romat Telecom

#1 lore raw
Quoted 6 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but I'm a little clueless as to how it is meant to be used. Can I use the GPIO ioctl's from a userland program, or must I write a kernel module?

I'll see if I can dig up some docs and the example userland program this weekend. That driver hasn't been tested in a while though.

Pete

Quoted 6 lines

Thank you,
Gilad Rom
Romat Telecom

author
#2 lore raw

Thanks. Can't I just mmap /dev/mem and use the
GPIO offset from SYS_BASE?

Gilad.

----- Original Message ----- From: "Pete Popov" <[email protected]>
To: "Gilad Rom" <[email protected]>; <[email protected]>
Sent: Friday, November 12, 2004 8:13 PM
Subject: Re: GPIO on the Au1500

Quoted 21 lines
Quoted 4 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but I'm a
little clueless as to how it is meant to be used. Can I use the GPIO ioctl's from a userland program, or must I write a kernel module?

I'll see if I can dig up some docs and the example userland program this weekend. That driver hasn't been tested in a while though.

Pete

Quoted 6 lines

Thank you,
Gilad Rom
Romat Telecom

author
#3 lore raw

Replying to myself -

I've composed a small program which mmap()'s SYS_BASE and then tries to read at the appropriate GPIO offset, as defined in the Au1500 databook.

For some reason, I keep getting that magical value, 0x10000001 for EVERY address I try to read, be it SYS_BASE (0xB1900000) or every other address. (for example, I've tried reading the MAC address from the MAC0 base address
of 0xB1500000, offset 0x0008, and I always get 0x10000001).

Any reason I shouldn't succeed in reading the au1500 hardware addresses through /dev/mem?

Attached is the code I'm using:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>

#define SYS_BASE 0xB1900000

int
main () {
volatile unsigned long *base;
unsigned char val;
int f, i;

f = open ("/dev/mem", O_RDWR | O_SYNC);
if (f < 0) {
perror ("fopen");
exit (-1);
}

base = (unsigned long *) mmap (NULL,
getpagesize (),
PROT_READ | PROT_WRITE,
MAP_SHARED,
f,
SYS_BASE);

if (base == (unsigned long *) (-1)) {
perror ("mmap");
exit (-1);
}

printf ("data at %p: 0x%x\n", base, (unsigned long) *base);

*base = 0xffffffff;
       printf ("data at %p: 0x%x\n", base, (unsigned long) *base);

close (f);
return (0);
}

Thanks!
Gilad.

----- Original Message ----- From: "Gilad Rom" <[email protected]>
To: <[email protected]>; <[email protected]>
Sent: Sunday, November 14, 2004 10:35 AM
Subject: Re: GPIO on the Au1500

Quoted 34 lines

Thanks. Can't I just mmap /dev/mem and use the
GPIO offset from SYS_BASE?

Gilad.

----- Original Message -----
From: "Pete Popov" <[email protected]>
To: "Gilad Rom" <[email protected]>; <[email protected]>
Sent: Friday, November 12, 2004 8:13 PM
Subject: Re: GPIO on the Au1500

Quoted 21 lines
Quoted 4 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but I'm a
little clueless as to how it is meant to be used. Can I use the GPIO ioctl's from a userland program, or must I write a kernel module?

I'll see if I can dig up some docs and the example userland program this weekend. That driver hasn't been tested in a while though.

Pete

Quoted 6 lines

Thank you,
Gilad Rom
Romat Telecom

#5 lore raw
In reply to Gilad Rom

Hi Gilad,

A little while ago I wrote my own GPIO driver for the Au1000, mainly as a learning experience. I never bothered to release it because a driver already exists and I thought it was working. I'm not sure if it will work on the Au1550, but if you're interested you can find the source code here:

http://members.rogers.com/charles.eidsness/au1000_gpio.c
http://members.rogers.com/charles.eidsness/au1000_gpio.h

Cheers,
Charles

Quoted 36 lines · Gilad Rom

Thanks. Can't I just mmap /dev/mem and use the
GPIO offset from SYS_BASE?

Gilad.

----- Original Message ----- From: "Pete Popov" <[email protected]>
To: "Gilad Rom" <[email protected]>; <[email protected]>
Sent: Friday, November 12, 2004 8:13 PM
Subject: Re: GPIO on the Au1500

Quoted 22 lines
Quoted 4 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but I'm a
little clueless as to how it is meant to be used. Can I use the GPIO ioctl's from a userland program, or must I write a kernel module?

I'll see if I can dig up some docs and the example userland program this weekend. That driver hasn't been tested in a while though.

Pete

Quoted 6 lines

Thank you,
Gilad Rom
Romat Telecom

#6 lore raw

--- Charles Eidsness <[email protected]>

Quoted 6 lines · wrote:

Hi Gilad,

A little while ago I wrote my own GPIO driver for the Au1000, mainly as a learning experience. I never bothered to release it because a driver already exists and I thought it was working.

It was, a long time ago, when it was written for the Au1000. I had a user app and doc somewhere but can't find it anymore. The driver didn't support gpio2 and was, in general, stale. So perhaps your driver will help Gilad.

Pete

Quoted 6 lines

I'm not sure if it will
work on the Au1550, but if you're interested you can find the source
code here:

http://members.rogers.com/charles.eidsness/au1000_gpio.c

Quoted 1 line

http://members.rogers.com/charles.eidsness/au1000_gpio.h

Quoted 51 lines

Cheers,
Charles

Quoted 6 lines · Gilad Rom

Thanks. Can't I just mmap /dev/mem and use the
GPIO offset from SYS_BASE?

Gilad.

----- Original Message ----- From: "Pete Popov"

<[email protected]>

Quoted 1 line

To: "Gilad Rom" <[email protected]>;

<[email protected]>

Quoted 10 lines

Sent: Friday, November 12, 2004 8:13 PM
Subject: Re: GPIO on the Au1500

Quoted 6 lines
Quoted 3 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but

I'm a

Quoted 1 line
Quoted 1 line
Quoted 1 line

little clueless as to how it is meant to be

used. Can I use the GPIO

Quoted 1 line
Quoted 1 line
Quoted 1 line

ioctl's from a userland program, or must I write

a kernel module?

Quoted 3 lines
Quoted 3 lines

I'll see if I can dig up some docs and the

example

Quoted 1 line
Quoted 1 line

userland program this weekend. That driver hasn't

been

Quoted 14 lines
Quoted 11 lines

tested in a while though.

Pete

Quoted 6 lines

Thank you,
Gilad Rom
Romat Telecom

author
#7 lore raw

Thank you for the driver, I'm using it as a reference.

Still, I am trying to acccess the GPIO ports of the Au1500 using /dev/mem, but I keep getting these odd values (see previous messages to this list)

Do you think it is possible, or should I stick to using the driver?

Thank you,
Gilad.

----- Original Message ----- From: "Pete Popov" <[email protected]>
To: <[email protected]>; "Gilad Rom" <[email protected]>
Cc: <[email protected]>
Sent: Sunday, November 14, 2004 8:45 PM
Subject: Re: GPIO on the Au1500

Quoted 77 lines

--- Charles Eidsness <[email protected]>

Quoted 4 lines · wrote:

Hi Gilad,

A little while ago I wrote my own GPIO driver for
the Au1000, mainly as a learning experience. I never bothered to release it because a driver already exists and I thought it was working.

It was, a long time ago, when it was written for the Au1000. I had a user app and doc somewhere but can't find it anymore. The driver didn't support gpio2 and was, in general, stale. So perhaps your driver will help Gilad.

Pete

Quoted 4 lines

I'm not sure if it will work on the Au1550, but if you're interested you can find the source code here:

http://members.rogers.com/charles.eidsness/au1000_gpio.c

Quoted 1 line

http://members.rogers.com/charles.eidsness/au1000_gpio.h

Quoted 51 lines

Cheers,
Charles

Quoted 6 lines · Gilad Rom

Thanks. Can't I just mmap /dev/mem and use the
GPIO offset from SYS_BASE?

Gilad.

----- Original Message ----- From: "Pete Popov"

<[email protected]>

Quoted 1 line

To: "Gilad Rom" <[email protected]>;

<[email protected]>

Quoted 10 lines

Sent: Friday, November 12, 2004 8:13 PM
Subject: Re: GPIO on the Au1500

Quoted 6 lines
Quoted 3 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but

I'm a

Quoted 1 line
Quoted 1 line
Quoted 1 line

little clueless as to how it is meant to be

used. Can I use the GPIO

Quoted 1 line
Quoted 1 line
Quoted 1 line

ioctl's from a userland program, or must I write

a kernel module?

Quoted 3 lines
Quoted 3 lines

I'll see if I can dig up some docs and the

example

Quoted 1 line
Quoted 1 line

userland program this weekend. That driver hasn't

been

Quoted 14 lines
Quoted 11 lines

tested in a while though.

Pete

Quoted 6 lines

Thank you,
Gilad Rom
Romat Telecom

#8 lore raw

Hi Gilad,

I'd be really surprised if it's possible. I think that those addresses are beyond the valid physical address range for the mem driver. Even if it did work I personally wouldn't feel comfortable doing that sort of thing. You could inadvertently cause a lot of nasty things to happen. Maybe someone else has a different (better) opinion.

If you do use my driver I uploaded the wrong header file yesterday. I've now uploaded the correct one.

Cheers,
Charles

Quoted 94 lines · Gilad Rom

Thank you for the driver, I'm using it as a reference.

Still, I am trying to acccess the GPIO ports of the Au1500 using /dev/mem, but I keep getting these odd values (see previous messages to this list)

Do you think it is possible, or should I stick to using the driver?

Thank you,
Gilad.

----- Original Message ----- From: "Pete Popov" <[email protected]>
To: <[email protected]>; "Gilad Rom" <[email protected]>
Cc: <[email protected]>
Sent: Sunday, November 14, 2004 8:45 PM
Subject: Re: GPIO on the Au1500

Quoted 72 lines

--- Charles Eidsness <[email protected]>

Quoted 4 lines · wrote:

Hi Gilad,

A little while ago I wrote my own GPIO driver for
the Au1000, mainly as a learning experience. I never bothered to release it because a driver already exists and I thought it was working.

It was, a long time ago, when it was written for the Au1000. I had a user app and doc somewhere but can't find it anymore. The driver didn't support gpio2 and was, in general, stale. So perhaps your driver will help Gilad.

Pete

Quoted 4 lines

I'm not sure if it will work on the Au1550, but if you're interested you can find the source code here:

http://members.rogers.com/charles.eidsness/au1000_gpio.c

Quoted 1 line

http://members.rogers.com/charles.eidsness/au1000_gpio.h

Quoted 43 lines

Cheers,
Charles

Quoted 4 lines · Gilad Rom

Thanks. Can't I just mmap /dev/mem and use the
GPIO offset from SYS_BASE?

Quoted 2 lines

Gilad.
----- Original Message ----- From: "Pete Popov"

<[email protected]>

Quoted 1 line

To: "Gilad Rom" <[email protected]>;

<[email protected]>

Quoted 8 lines

Sent: Friday, November 12, 2004 8:13 PM
Subject: Re: GPIO on the Au1500

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 3 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but

I'm a

Quoted 1 line
Quoted 1 line
Quoted 1 line

little clueless as to how it is meant to be

used. Can I use the GPIO >>> ioctl's from a userland program, or must I write a kernel module?

Quoted 3 lines
Quoted 3 lines

I'll see if I can dig up some docs and the

example

Quoted 1 line
Quoted 1 line

userland program this weekend. That driver hasn't

been

Quoted 12 lines
Quoted 12 lines

tested in a while though.

Pete

Quoted 8 lines

Thank you,
Gilad Rom
Romat Telecom

author
#9 lore raw

Thanks Charles.

First of all, I managed to get it working today, (mmapping /dev/mem) so it is possible ;)

Secondly, I am using the GPIO ports for our own custom design, so I am not exposing /dev/mem to all kinds of nasty userland apps.

Gilad.

----- Original Message ----- From: "Charles Eidsness" <[email protected]>
To: "Gilad Rom" <[email protected]>
Cc: <[email protected]>
Sent: Monday, November 15, 2004 6:17 PM
Subject: Re: GPIO on the Au1500

Quoted 104 lines

Hi Gilad,

I'd be really surprised if it's possible. I think that those addresses are beyond the valid physical address range for the mem driver. Even if it did work I personally wouldn't feel comfortable doing that sort of thing. You could inadvertently cause a lot of nasty things to happen. Maybe someone else has a different (better) opinion.

If you do use my driver I uploaded the wrong header file yesterday. I've now uploaded the correct one.

Cheers,
Charles

Quoted 94 lines · Gilad Rom

Thank you for the driver, I'm using it as a reference.

Still, I am trying to acccess the GPIO ports of the Au1500 using /dev/mem, but I keep getting these odd values (see previous messages to this list)

Do you think it is possible, or should I stick to using the driver?

Thank you,
Gilad.

----- Original Message ----- From: "Pete Popov" <[email protected]>
To: <[email protected]>; "Gilad Rom" <[email protected]>
Cc: <[email protected]>
Sent: Sunday, November 14, 2004 8:45 PM
Subject: Re: GPIO on the Au1500

Quoted 72 lines

--- Charles Eidsness <[email protected]>

Quoted 4 lines · wrote:

Hi Gilad,

A little while ago I wrote my own GPIO driver for
the Au1000, mainly as a learning experience. I never bothered to release it because a driver already exists and I thought it was working.

It was, a long time ago, when it was written for the Au1000. I had a user app and doc somewhere but can't find it anymore. The driver didn't support gpio2 and was, in general, stale. So perhaps your driver will help Gilad.

Pete

Quoted 4 lines

I'm not sure if it will work on the Au1550, but if you're interested you can find the source code here:

http://members.rogers.com/charles.eidsness/au1000_gpio.c

Quoted 1 line

http://members.rogers.com/charles.eidsness/au1000_gpio.h

Quoted 43 lines

Cheers,
Charles

Quoted 4 lines · Gilad Rom

Thanks. Can't I just mmap /dev/mem and use the
GPIO offset from SYS_BASE?

Quoted 2 lines

Gilad.
----- Original Message ----- From: "Pete Popov"

<[email protected]>

Quoted 1 line

To: "Gilad Rom" <[email protected]>;

<[email protected]>

Quoted 8 lines

Sent: Friday, November 12, 2004 8:13 PM
Subject: Re: GPIO on the Au1500

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 3 lines · --- Gilad Rom

Hello,

I am trying to use the au1000_gpio driver, but

I'm a

Quoted 1 line
Quoted 1 line
Quoted 1 line

little clueless as to how it is meant to be

used. Can I use the GPIO >>> ioctl's from a userland program, or must I write a kernel module?

Quoted 3 lines
Quoted 3 lines

I'll see if I can dig up some docs and the

example

Quoted 1 line
Quoted 1 line

userland program this weekend. That driver hasn't

been

Quoted 12 lines
Quoted 12 lines

tested in a while though.

Pete

Quoted 8 lines

Thank you,
Gilad Rom
Romat Telecom

#4 lore raw
In reply to Gilad Rom
Quoted 1 line · Gilad Rom

For some reason, I keep getting that magical value, 0x10000001 for EVERY address I try to read, be it SYS_BASE (0xB1900000) or every other address.

It's not working because that is not the address of the device(s). The 0xB1900000 is the Kernel Virtual address of these devices, the real physical address, and the one you have to use with mmap() is the system control block address 0x11900000.

Just be very, very careful with user space access of any IO using this method. The kernel can ensure atomic updates using various methods, but user applications can't and may cause system failures. This is why a GPIO driver is a much better approach.

	-- Dan