summaryrefslogtreecommitdiff
path: root/src/superio/ite/it8716f
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2010-11-08 15:16:30 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2010-11-08 15:16:30 +0000
commit5c6bae213ea55e1436e010706560d86120b0b286 (patch)
tree48373faf8bc3a9e0628eeb1002508402c5b9299e /src/superio/ite/it8716f
parent6018e1ba7f797db3a7f1ae34bdb10ec1fa5c8a6c (diff)
downloadcoreboot-5c6bae213ea55e1436e010706560d86120b0b286.tar.xz
Random ITE Super I/O fixes.
- Drop some of the less useful / outdated / duplicated comments. - Simplify and streamline some code to look like the other Super I/Os. - Use u8/16/etc. everywhere. - ITE IT8718F: Add missing GPIO LDN. - Add missing braces around SIO_DATA #defines, potential bug even. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6047 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/superio/ite/it8716f')
-rw-r--r--src/superio/ite/it8716f/Makefile.inc2
-rw-r--r--src/superio/ite/it8716f/chip.h6
-rw-r--r--src/superio/ite/it8716f/it8716f.h13
-rw-r--r--src/superio/ite/it8716f/it8716f_early_init.c2
-rw-r--r--src/superio/ite/it8716f/it8716f_early_serial.c22
-rw-r--r--src/superio/ite/it8716f/superio.c44
6 files changed, 35 insertions, 54 deletions
diff --git a/src/superio/ite/it8716f/Makefile.inc b/src/superio/ite/it8716f/Makefile.inc
index 136e79b9cb..d5f717d452 100644
--- a/src/superio/ite/it8716f/Makefile.inc
+++ b/src/superio/ite/it8716f/Makefile.inc
@@ -18,5 +18,5 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
-#config chip.h
ramstage-$(CONFIG_SUPERIO_ITE_IT8716F) += superio.c
+
diff --git a/src/superio/ite/it8716f/chip.h b/src/superio/ite/it8716f/chip.h
index b7136f7a59..be6e0a10c1 100644
--- a/src/superio/ite/it8716f/chip.h
+++ b/src/superio/ite/it8716f/chip.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _SUPERIO_ITE_IT8716F
-#define _SUPERIO_ITE_IT8716F
+#ifndef SUPERIO_ITE_IT8716F_CHIP_H
+#define SUPERIO_ITE_IT8716F_CHIP_H
#include <device/device.h>
#include <pc80/keyboard.h>
@@ -32,4 +32,4 @@ struct superio_ite_it8716f_config {
struct pc_keyboard keyboard;
};
-#endif /* _SUPERIO_ITE_IT8716F */
+#endif
diff --git a/src/superio/ite/it8716f/it8716f.h b/src/superio/ite/it8716f/it8716f.h
index 2d72a17554..88e44c219d 100644
--- a/src/superio/ite/it8716f/it8716f.h
+++ b/src/superio/ite/it8716f/it8716f.h
@@ -19,7 +19,6 @@
*/
/* Datasheet: http://www.ite.com.tw/product_info/PC/Brief-IT8716_2.asp */
-/* Status: Untested on real hardware, but it compiles. */
#ifndef SUPERIO_ITE_IT8716F_IT8716F_H
#define SUPERIO_ITE_IT8716F_IT8716F_H
@@ -29,22 +28,22 @@
#define IT8716F_SP2 0x02 /* Com2 */
#define IT8716F_PP 0x03 /* Parallel port */
#define IT8716F_EC 0x04 /* Environment controller */
-#define IT8716F_KBCK 0x05 /* Keyboard */
-#define IT8716F_KBCM 0x06 /* Mouse */
+#define IT8716F_KBCK 0x05 /* PS/2 keyboard */
+#define IT8716F_KBCM 0x06 /* PS/2 mouse */
#define IT8716F_GPIO 0x07 /* GPIO */
#define IT8716F_MIDI 0x08 /* MIDI port */
#define IT8716F_GAME 0x09 /* GAME port */
#define IT8716F_IR 0x0a /* Consumer IR */
#if defined(CONFIG_SUPERIO_ITE_IT8716F_OVERRIDE_FANCTL) && CONFIG_SUPERIO_ITE_IT8716F_OVERRIDE_FANCTL
-/* provided by mainboard, called by it8716f superio.c */
-void init_ec(uint16_t base);
+/* Provided by mainboard, called by IT8716F superio.c. */
+void init_ec(u16 base);
#endif
#if defined(__PRE_RAM__) && !defined(__ROMCC__)
void it8716f_disable_dev(device_t dev);
-void it8716f_enable_dev(device_t dev, unsigned iobase);
-void it8716f_enable_serial(device_t dev, unsigned iobase);
+void it8716f_enable_dev(device_t dev, u16 iobase);
+void it8716f_enable_serial(device_t dev, u16 iobase);
#endif
#endif
diff --git a/src/superio/ite/it8716f/it8716f_early_init.c b/src/superio/ite/it8716f/it8716f_early_init.c
index 6f268d97fe..5023dd865b 100644
--- a/src/superio/ite/it8716f/it8716f_early_init.c
+++ b/src/superio/ite/it8716f/it8716f_early_init.c
@@ -28,7 +28,7 @@ void it8716f_disable_dev(device_t dev)
pnp_set_enable(dev, 0);
}
-void it8716f_enable_dev(device_t dev, unsigned iobase)
+void it8716f_enable_dev(device_t dev, u16 iobase)
{
pnp_set_logical_device(dev);
pnp_set_enable(dev, 0);
diff --git a/src/superio/ite/it8716f/it8716f_early_serial.c b/src/superio/ite/it8716f/it8716f_early_serial.c
index 8df4aa22da..747ca3074e 100644
--- a/src/superio/ite/it8716f/it8716f_early_serial.c
+++ b/src/superio/ite/it8716f/it8716f_early_serial.c
@@ -27,7 +27,7 @@
/* The base address is 0x2e or 0x4e, depending on config bytes. */
#define SIO_BASE 0x2e
#define SIO_INDEX SIO_BASE
-#define SIO_DATA SIO_BASE+1
+#define SIO_DATA (SIO_BASE + 1)
/* Global configuration registers. */
#define IT8716F_CONFIG_REG_CC 0x02 /* Configure Control (write-only). */
@@ -36,30 +36,22 @@
#define IT8716F_CONFIG_REG_CLOCKSEL 0x23 /* Clock Selection. */
#define IT8716F_CONFIG_REG_SWSUSP 0x24 /* Software Suspend, Flash I/F. */
-#define IT8716F_CONFIGURATION_PORT 0x2e /* Write-only. */
-
-/* Perform MB PnP setup to put the SIO chip at 0x2e. */
-/* Base address 0x2e: 0x87 0x01 0x55 0x55. */
-/* Base address 0x4e: 0x87 0x01 0x55 0xaa. */
-static inline void pnp_enter_ext_func_mode(device_t dev)
+static void pnp_enter_ext_func_mode(device_t dev)
{
- unsigned port = dev >> 8;
+ u16 port = dev >> 8;
+
outb(0x87, port);
outb(0x01, port);
outb(0x55, port);
- if (port == 0x4e) {
- outb(0xaa, port);
- } else {
- outb(0x55, port);
- }
+ outb((port == 0x4e) ? 0xaa : 0x55, port);
}
static void pnp_exit_ext_func_mode(device_t dev)
{
- pnp_write_config(dev, 0x02, 0x02);
+ pnp_write_config(dev, IT8716F_CONFIG_REG_CC, 0x02);
}
-void it8716f_enable_serial(device_t dev, unsigned iobase)
+void it8716f_enable_serial(device_t dev, u16 iobase)
{
pnp_enter_ext_func_mode(dev);
pnp_set_logical_device(dev);
diff --git a/src/superio/ite/it8716f/superio.c b/src/superio/ite/it8716f/superio.c
index a365bf764e..0d4ee68c79 100644
--- a/src/superio/ite/it8716f/superio.c
+++ b/src/superio/ite/it8716f/superio.c
@@ -31,19 +31,14 @@
#include "chip.h"
#include "it8716f.h"
-/* Base address 0x2e: 0x87 0x01 0x55 0x55. */
-/* Base address 0x4e: 0x87 0x01 0x55 0xaa. */
static void pnp_enter_ext_func_mode(device_t dev)
{
- outb(0x87, dev->path.pnp.port);
- outb(0x01, dev->path.pnp.port);
- outb(0x55, dev->path.pnp.port);
-
- if (dev->path.pnp.port == 0x4e) {
- outb(0xaa, dev->path.pnp.port);
- } else {
- outb(0x55, dev->path.pnp.port);
- }
+ u16 port = dev->path.pnp.port;
+
+ outb(0x87, port);
+ outb(0x01, port);
+ outb(0x55, port);
+ outb((port == 0x4e) ? 0xaa : 0x55, port);
}
static void pnp_exit_ext_func_mode(device_t dev)
@@ -52,45 +47,41 @@ static void pnp_exit_ext_func_mode(device_t dev)
}
#if !defined(CONFIG_SUPERIO_ITE_IT8716F_OVERRIDE_FANCTL) || !CONFIG_SUPERIO_ITE_IT8716F_OVERRIDE_FANCTL
-static void pnp_write_index(uint16_t port_base, uint8_t reg, uint8_t value)
+static void pnp_write_index(u16 port_base, u8 reg, u8 value)
{
outb(reg, port_base);
outb(value, port_base + 1);
}
-static uint8_t pnp_read_index(uint16_t port_base, uint8_t reg)
+static u8 pnp_read_index(u16 port_base, u8 reg)
{
outb(reg, port_base);
return inb(port_base + 1);
}
-static void init_ec(uint16_t base)
+static void init_ec(u16 base)
{
- uint8_t value;
+ u8 value;
- /* Read out current value of FAN_CTL control register (0x14). */
+ /* Read out current value of FAN_CTL (0x14). */
value = pnp_read_index(base, 0x14);
printk(BIOS_DEBUG, "FAN_CTL: reg = 0x%04x, read value = 0x%02x\n",
- base + 0x14, value);
+ base + 0x14, value);
- /* Set FAN_CTL control register (0x14) polarity to high, and
- activate fans 1, 2 and 3. */
+ /* Set FAN_CTL (0x14) polarity to high, activate fans 1, 2 and 3. */
pnp_write_index(base, 0x14, value | 0x87);
printk(BIOS_DEBUG, "FAN_CTL: reg = 0x%04x, writing value = 0x%02x\n",
- base + 0x14, value | 0x87);
+ base + 0x14, value | 0x87);
}
#endif
static void it8716f_init(device_t dev)
{
- struct superio_ite_it8716f_config *conf;
+ struct superio_ite_it8716f_config *conf = dev->chip_info;
struct resource *res0, *res1;
- if (!dev->enabled) {
+ if (!dev->enabled)
return;
- }
-
- conf = dev->chip_info;
/* TODO: FDC, PP, KBCM, MIDI, GAME, IR. */
switch (dev->path.pnp.device) {
@@ -163,8 +154,7 @@ static struct pnp_info pnp_dev_info[] = {
static void enable_dev(struct device *dev)
{
- pnp_enable_devices(dev, &ops,
- ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
+ pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
}
struct chip_operations superio_ite_it8716f_ops = {