Date: Tue, 27 Nov 2007 19:19:50 +1030 From: Benjamin Close <Benjamin.Close@clearchain.com> To: Joshua Hyatt <j.dough@hotmail.com> Cc: freebsd-drivers@freebsd.org Subject: Re: GPIO Message-ID: <474BDA2E.7060003@clearchain.com> In-Reply-To: <BAY144-W40CE00CF7F84872ACF754FFA8C0@phx.gbl> References: <BAY144-W40CE00CF7F84872ACF754FFA8C0@phx.gbl>
next in thread | previous in thread | raw e-mail | index | archive | help
Joshua Hyatt wrote: > I have a Soekris Net4801 computer running FreeBSD 6.2, which is an x86-based system using the AMD Geode SC1100 processor. It has a number of GPIO connections directly connected to the processor that I am interested in using. > > However, I am unfamiliar with writing a driver for FreeBSD, and all of my attempts thus far have resulted in failure. There is a led driver that uses the SPIO of the SC1100 for FreeBSD that works, with the source code located at /usr/src/sys/dev/led/, but it is write-only. > > If someone could guide me in adding a function to read the status of the gpio connection to led.c, or has a better suggestion of how to do this, it would be greatly appreciated. > > Thanks, > Joshua Hyatt > Hi Joshua, I think the bit you might be missing is dev/led is merely an intermediate driver that other drivers use. Things like dev/auxio make use of dev/led via led_create(). Hence if you look in dev/auxio/auxio.c at the auxio_led_func you can see that the function is actually doing both a read and write of the bus via auxio_led_read & auxio_led_write. In general, to read from general io registers you need to to use one of the bus_space * methods (BUS_SPACE(9)) but before you can do that you need to setup a bus resource via bus_alloc_resource_any. And perhaps an interrupt if required. Have a look at tha auxio driver, it'll probably make things a lot clearer - dev/led would have left you wondering where the actual work was done :) Cheers, Benjamin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?474BDA2E.7060003>