White Papers

5
ACCESS THE GPO (OUTPUT) PINS
The eight output pins GPIO 8 OUT (GPO0, GPO1,… and GPO7) are controlled on the virtual device 8 on the Super IO chip. To control
the GPIO pins, select the device first.
See the example which writes the data value 8 to the register 07h on the chip.
outb(0x07, LPC_ADDR_PORT);
outb(8, LPC_DATA_PORT);
In the following example, the address of the register is written to the port 2Eh (i.e. LPC_ADDR_PORT). The data is written to the port
2Fh (i.e. LPC_DATA_PORT).
As these operations are frequently required, you can write a dedicated function for register-write for future use.
void lpc_reg_write(int reg, int val)
{
outb(reg, LPC_ADDR_PORT);
outb(val, LPC_DATA_PORT);
}
...
// Select device 8
lpc_reg_write(0x07, 8); // write value 8 to register 0x07
Write a dedicated function for register-read:
int lpc_reg_read(int reg)
{
outb(reg, LPC_ADDR_PORT);
return inb(LPC_DATA_PORT);
}
To change the levels of the GPO pins, write a byte to the register E1h after the virtual device has been selected.
Each bit in the byte specifies the level of a GPO pin as shown in the table:
GPO7 GPO6 GPO5 GPO4 GPO3 GPO2 GPO1 GPO0
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
For example, the value 0x01 (“0000 0001” in binary) sets the first pin to high and sets the upper 7 pins to low:
lpc_reg_write(0xE1, 0x01);