OpenWrt Forum Archive

Topic: Driver for the GPIO's of AR5315 in /proc ...

The content of this topic has been archived between 29 Mar 2018 and 24 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,
I've used some bad weather here to write a small kernelmod for the AR5315. It puts the GPIO pins into an /proc/gpio directory.
You can also write to them e.g. by "echo 1 > /proc/gpio/2_dir; echo 1 > /proc/gpio/2_out", which turns the wlan-led on (at least for the fonera device).

For the source and binaries look at this ugly webspace:
http://fghhgh.150m.com/

My question is, how is the nice way to get this into the buildroot (Kamikaze)?
a) as a patch in target/linux/atheros-2.6/
b) as an autonomous kmod_package (such as madwifi)
c) no way, because there are better implementations pending ...


bye,
olg

PS: a screenshoot is attached ...

root@OpenWrt:~# insmod proc_gpio.ko
root@OpenWrt:~# cat /proc/gpio/
/proc/gpio/0_dir    /proc/gpio/13_dir   /proc/gpio/17_dir   /proc/gpio/20_dir   /proc/gpio/4_dir    /proc/gpio/8_dir
/proc/gpio/0_in     /proc/gpio/13_in    /proc/gpio/17_in    /proc/gpio/20_in    /proc/gpio/4_in     /proc/gpio/8_in
/proc/gpio/0_out    /proc/gpio/13_out   /proc/gpio/17_out   /proc/gpio/20_out   /proc/gpio/4_out    /proc/gpio/8_out
/proc/gpio/10_dir   /proc/gpio/14_dir   /proc/gpio/18_dir   /proc/gpio/21_dir   /proc/gpio/5_dir    /proc/gpio/9_dir
/proc/gpio/10_in    /proc/gpio/14_in    /proc/gpio/18_in    /proc/gpio/21_in    /proc/gpio/5_in     /proc/gpio/9_in
/proc/gpio/10_out   /proc/gpio/14_out   /proc/gpio/18_out   /proc/gpio/21_out   /proc/gpio/5_out    /proc/gpio/9_out
/proc/gpio/11_dir   /proc/gpio/15_dir   /proc/gpio/19_dir   /proc/gpio/2_dir    /proc/gpio/6_dir    /proc/gpio/info
/proc/gpio/11_in    /proc/gpio/15_in    /proc/gpio/19_in    /proc/gpio/2_in     /proc/gpio/6_in
/proc/gpio/11_out   /proc/gpio/15_out   /proc/gpio/19_out   /proc/gpio/2_out    /proc/gpio/6_out
/proc/gpio/12_dir   /proc/gpio/16_dir   /proc/gpio/1_dir    /proc/gpio/3_dir    /proc/gpio/7_dir
/proc/gpio/12_in    /proc/gpio/16_in    /proc/gpio/1_in     /proc/gpio/3_in     /proc/gpio/7_in
/proc/gpio/12_out   /proc/gpio/16_out   /proc/gpio/1_out    /proc/gpio/3_out    /proc/gpio/7_out
root@OpenWrt:~# cat /proc/gpio/info
GPIO_IN   0X7FFF20
GPIO_OUT  0X05C764
GPIO_DIR  0X1FFF25
root@OpenWrt:~#

I get 'File not found!' if I browse to http://fghhgh.150m.com/proc_gpio.c

Only with the binary modules it's a piece of useless crap...

Anyway, I would write a patch which can be applied to the buildroot and finally creates a kmod-* package. Probably take the switch driver as an example.

(Last edited by forum2006 on 8 Jan 2007, 00:44)

Uhmm, try it again now. (i think you have to go over the main page fghhgh.150m.com, instead of using the direct link)
If you've got the opportunity to host this files properly, i would appreciate that.

And thanks for the advice, i will look at Package/kmod-switch ...

http://kwzs.be/~kevin/ar531x/
proc_gpio.o was not found on your site

i've been meaning to write a driver like this myself, but haven't got around to actually doing it yet smile maybe I won't have to now. my plan is to port the mmc driver for use on atheros based devices.

Hi Kevin,
thanks for hosting these files, I've put some new stuff on http://fghhgh.150m.com/ and I'll try to get a ticket now, merging those lines of code into kamikaze...
bye

PS: Have you already some work done in the mmc topic?

Since you are obviously knowing how GPIOs work, do you think you could get SD cards running too?

http://forum.openwrt.org/viewtopic.php?id=8543

This would allow the Fonera to have some storage... and the GPIO pins are all there.

olg, you you please give a little more info about pin 5 and 6 both to the reset switch, but i can't identify where u talk from (!)... pin 5 the one near to r113?
may you could take a picture and mark it?

already done soldering job on fonera, but not shure if i identify it rigth... sad don't won't to brun something up

http://ipkg.k1k2.de/files/spi_sd.jpg
http://ipkg.k1k2.de/files/sw1.jpg
sorry for low quality of the sw1 pic and soldering. only good old weller wecp-20...

only wires for the gpio pins, no power and gnd wired.
other side i'd like to fix this http://uanr.com/sdfloppy/

(Last edited by heini on 11 Jan 2007, 18:13)

identify by testing with a multimeter or other high-resistance device of testing, and send a signal you can recognize with that device, by using the driver.

Hmm, i dont know whats exactly about pin 5. I've named it so, only because it's mentioned in the headerfiles of the AR5315 as "AR5315_RESET_GPIO". I think it can be used to reboot your router, so try to write at it... (also take a look on the other sources in arch/mips/ar531x)


bye,
olg

Nice! keep up the good work...
I will try to locate all GPIO's (gpio5) on the fonera, and post pictures on them tomorrow...

I'm waiting for the SD-Card mod... The guy who fixes it will be my GOD big_smile

slot easy and cheap.
just cut of the rest.
outside
inside slot is not wired ready, will do next days.
gpio's 0,1,3,4,7 can be toggled without any "reaction" of fonera. only multimeter toggles... wink

(Last edited by heini on 16 Jan 2007, 00:09)

any progress?? saw some miniSD 256MB here in sweden for 40kr = $5-6

is it hard to port the mmc.c to atheros chipset, or do you have to make a new one? (i'm little newbie at that stuff)...

may the force(=Linux) be with you

The problem may be porting it to kernel version 2.6

nbd toled, old broadcom mmc support isn't a driver... it is a hack... it's done with broadcom api's.
so no chance to port it.

we have to find somebody, who's ABLE to write a new one AND have to TIME to do...

so you know which broadcomm specific api?

heini wrote:

we have to find somebody, who's ABLE to write a new one AND have to TIME to do...

that seems almost impossible sad

I'm playing with the mmc code and hope a nice port to 2.6/Atheros can be done...
I'd would be nice if Rob Wentworth  (uanr.com) could make his improvements to the code public, if someone would contact him and ask nicely...

A question to those, who know the buildrootsystem well:

I made some configuration menu by:

Makefile
---------
...
define Package/kmod-mmc/config
    menu "GPIO config"
        depends on PACKAGE_kmod-mmc
        source "$(SOURCE)/config/Config.in"
    endmenu
endef
...

Config.in
----------
config KMOD_MMC_GPIO_DI
    int "GPIO DI"
    default 5 if LINUX_2_6_ATHEROS || LINUX_2_4_AR531X
    default 5 if LINUX_2_6_BRCM || LINUX_2_4_BRCM
...

So how could I access those values in code? I've tried the defines "CONFIG_KMOD_MMC_GPIO_DI" and "KMOD_MMC_GPIO_DI", but:

error: `CONFIG_KMOD_MMC_GPIO_DI' undeclared (first use in this function)

And, btw are there other defines to seperate e.g. between 2.4/2.4 or kernel arch (broadcom/atheros)?


bye,
olg

your going to have more problems then that smile, even if you do get your configuration worked out, which seems to be the problem, there's enough differences between the block device api in 2.4 and 2.6 that the driver will not compile or work without an overhaul

the code used to control the gpios must of course be changed, also, but that's a straightforward task

a sample makefile if your not using buildroot:
ifeq ($(KERNELRELEASE),)
    KERNELDIR ?= /home/kevin/src/linux-2.6.19.2
    PWD := $(shell pwd)

modules:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

modules_install:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

clean:
        rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

.PHONY: modules modules_install clean

else
    obj-m := mmc.o
endif

(Last edited by Kevin on 19 Jan 2007, 14:39)

Uhm... right, it seems to be an bigger task..  (http://lwn.net/Articles/58719/). Maybe an complete rewrite for 2.6 should be done? Perhaps as a comunity project, with own repository?


Again, the config problem:
I'd like to access the options I've choosen in the c-file as preprocessor defines, as I saw it e.g. in the busybox package source. But it gave me an error, so I thougth I have to e.g. include something special. But maybe the config values have to be passed simply via the -D option in the Makefile..

bye

No capable person able to write a mmc card driver for linux 2.6?

olg,
I am trying to load the modules at http://fghhgh.150m.com/proc_gpio.ko , but it doesn,t work with the current version of kamikaze linux,
could you post the same module compiled for the current version of kamikaze or some info about compiling ?
Follows the messages from my fonera

root@OpenWrt:~# wget "http://fghhgh.150m.com/proc_gpio.ko"
Connecting to fghhgh.150m.com [209.63.57.10:80]
proc_gpio.ko         100% |******************************************************|  5305    --:--:-- ETA
root@OpenWrt:~# insmod proc_gpio.ko
insmod: cannot insert 'proc_gpio.ko': Success (8): Success
root@OpenWrt:~# uname -a
Linux OpenWrt 2.6.19.2 #21 Wed Feb 7 07:39:03 CET 2007 mips unknown
root@OpenWrt:~#

Regards
PS:
I have in mind to use two GPIO pins to drive an i2c bus to grab data from some sensors, so the first step is to compile this module.
(sorry for my bad english )

@all:

there will be a kernel-space gpio interface in the future...
if it's there once, more work on the sd/mmc driver can be done.
i know person how will do it, but his todo is got not the shortest... wink
if i get more info, i'll notice here asap.

(Last edited by heini on 9 Feb 2007, 12:46)

Hi,
@zlabs: My building machine is currently down, but you can easily build it your own... Take a look at the documentation, check out the "trunk" and the "package" tree and apply https://dev.openwrt.org/attachment/tick … gpio.patch
(I hope it still compiles flawlessly.)

Regarding to the mmc topic I ported a SDIO implementation, but I haven't been able to test it myself yet. If anybody likes to play with it (ugly code, but compiles), I could mail it to someone, otherwise  I'll try to complete it in about three weeks...

Bye,
olg