[coreboot] SuperI/O Access (Kernelspace)

Peter Stuge peter at stuge.se
Fri Apr 15 02:07:11 CEST 2011

Jeremy Moles wrote:
> working great now .. via userspace
> However, I'd like to be able to toggle the power on via a kernel
> driver as well,


> but I'm having trouble accessing the same memory range from
> kernelspace.
> For example:
> 	iotools io_read8 0xA00

io_read8 is not a memory access, it is an I/O access. x86 has two
different address spaces on the bus, and different instructions to
access them.

The superio is not memory mapped..

> When I try to do the same thing in the kernel:
> 	unsigned short  b;
> 	unsigned short* ptr = (unsigned short*)(0xA00);
> 	if(access_ok(VERIFY_READ, ptr, 8)) {
> 		get_user(b, ptr);
> ...I immediately get a segfault.

..so that's not the way to reach it. Last time I did this I used
inb() and outb(). Remember to use barriers as neccessary and also
make sure that request_region() succeeds before you touch any

The proper way to implement GPIO support is btw to write a gpio class
driver for it. There are lots of gpio drivers already in the kernel.
I would actually not be surprised if your chip is already supported
by one of them, and if not one could probably be extended easily. The
GPIO drivers are exposed to userspace via sysfs.

Again; why does your other kernel driver need to deal with this GPIO?
This smells like a questionable design decision was made somewhere in
the chain. Better fix that sooner than later in that case..


More information about the coreboot mailing list