Wednesday, April 3, 2013

How to access the Super IO registers

Method: use normal I/O Index/Data Access

SIO Index: 0x0E
SIO DATA: 0x0F

Super I/O controller is connected to Southbridge, and it supports low speed devices including serial port, PS/2 keyboard/mouse, and parallel port.

All of the devices on Super I/O controller is identified by Logical Device Number (LDN). For example, Keyboard can be assigned as LDN 5, and Serial port COM1 has LDN 2.

In order to access Super I/O registers, please follow steps as below:

1. Use key config to open the access right.

2. Select LDN

3. Read/Write using normal outb/inb instruction.

Below is a sample code working on my machine. It is just a user program. We can use Tool rweverything to verify the result.


#define SIO_INDEX 0x2E
#define SIO_DATA SIO_INDEX+1
u8 byte;

// What the heck is this?
// some secret config key to open the access right
outb(0x87, SIO_INDEX);
outb(0x01, SIO_INDEX);
outb(0x55, SIO_INDEX);
outb(0x55, SIO_INDEX);

// set the Logical Device to keyboard
 // 7th bit of the configuration
outb(0x07, SIO_INDEX);
outb(0x05, SIO_DATA);

printk(BIOS_DEBUG, "\n\nKeybard Super IO configration:");
// print Super IO configuration
for(i=0; i<0x100; i++)
{
   outb(i, SIO_INDEX);
   byte = inb(SIO_DATA);
   if(i%16==0)
printk(BIOS_DEBUG, "\n");
   printk(BIOS_DEBUG, "%x ", byte);
}

// set the Logical Device to mouse
 // 7th bit of the config
outb(0x07, SIO_INDEX);
outb(0x06, SIO_DATA);

printk(BIOS_DEBUG, "\n\nMouse Super IO configration:");
// print Super IO configuration
for(i=0; i<0x100; i++)
{
   outb(i, SIO_INDEX);
   byte = inb(SIO_DATA);
   if(i%16==0)
printk(BIOS_DEBUG, "\n");
   printk(BIOS_DEBUG, "%x ", byte);
}

More info:
http://coreboot.blogspot.com/2009/01/coreboot-superio.html

No comments: