diff -Naur src/superio/foo/it8671f/chip.h src/superio/ITE/it8671f/chip.h --- src/superio/foo/it8671f/chip.h 1970-01-01 01:00:00.000000000 +0100 +++ src/superio/ITE/it8671f/chip.h 2006-08-06 21:18:48.000000000 +0200 @@ -0,0 +1,42 @@ +/* + * Copyright (C) xxxx ???? + * Copyright (C) 2006 Uwe Hermann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _SUPERIO_ITE_IT8671F +#define _SUPERIO_ITE_IT8671F + +// TODO: Unused? +// #ifndef SIO_COM1 +// #define SIO_COM1_BASE 0x3F8 +// #endif +// #ifndef SIO_COM2 +// #define SIO_COM2_BASE 0x2F8 +// #endif + +#include +#include + +extern struct chip_operations superio_ITE_it8671f_ops; + +struct superio_ITE_it8671f_config { + struct uart8250 com1, com2; + struct pc_keyboard keyboard; +}; + +#endif /* _SUPERIO_ITE_IT8671F */ + diff -Naur src/superio/foo/it8671f/Config.lb src/superio/ITE/it8671f/Config.lb --- src/superio/foo/it8671f/Config.lb 1970-01-01 01:00:00.000000000 +0100 +++ src/superio/ITE/it8671f/Config.lb 2006-08-06 21:18:48.000000000 +0200 @@ -0,0 +1,2 @@ +config chip.h +object superio.o diff -Naur src/superio/foo/it8671f/it8671f_early_serial.c src/superio/ITE/it8671f/it8671f_early_serial.c --- src/superio/foo/it8671f/it8671f_early_serial.c 1970-01-01 01:00:00.000000000 +0100 +++ src/superio/ITE/it8671f/it8671f_early_serial.c 2006-08-06 21:18:48.000000000 +0200 @@ -0,0 +1,30 @@ +/* + * Copyright (C) xxxx ???? + * Copyright (C) 2006 Uwe Hermann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "it8671f.h" + +static void it8671f_enable_serial(device_t dev, unsigned iobase) +{ + pnp_set_logical_device(dev); + pnp_set_enable(dev, 1); + pnp_set_iobase(dev, PNP_IDX_IO0, iobase); + pnp_set_enable(dev, 1); +} + diff -Naur src/superio/foo/it8671f/it8671f.h src/superio/ITE/it8671f/it8671f.h --- src/superio/foo/it8671f/it8671f.h 1970-01-01 01:00:00.000000000 +0100 +++ src/superio/ITE/it8671f/it8671f.h 2006-08-06 21:18:48.000000000 +0200 @@ -0,0 +1,36 @@ +/* + * Copyright (C) xxxx ???? + * Copyright (C) 2006 Uwe Hermann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// TODO: Untested, cut'n'pasted from some other file so it's probably wrong. +// #define IT8671F_FDC 0x00 /* Floppy */ +// #define IT8671F_PP 0x01 /* Parallel port */ +#define IT8671F_SP2 0x02 /* Com2 */ +#define IT8671F_SP1 0x03 /* Com1 */ +// #define IT8671F_SWC 0x04 +// #define IT8671F_KBCM 0x05 /* Mouse */ +#define IT8671F_KBCK 0x06 /* Keyboard */ +// #define IT8671F_GPIO 0x07 +// #define IT8671F_ACB 0x08 +// #define IT8671F_FSCM 0x09 +// #define IT8671F_WDT 0x0A +// #define IT8671F_GMP 0x0B +// #define IT8671F_MIDI 0x0C +// #define IT8671F_VLM 0x0D +// #define IT8671F_TMS 0x0E + diff -Naur src/superio/foo/it8671f/setup_serial.inc src/superio/ITE/it8671f/setup_serial.inc --- src/superio/foo/it8671f/setup_serial.inc 1970-01-01 01:00:00.000000000 +0100 +++ src/superio/ITE/it8671f/setup_serial.inc 2006-08-06 21:18:48.000000000 +0200 @@ -0,0 +1,154 @@ +/* + * Enable the peripheral devices on the IT8671F Super IO chip + */ + +/* The base address is 0x3F0, 0x3bd or 0x370, depending on config bytes */ + +#define SIO_BASE $0x3f0 +#define SIO_INDEX SIO_BASE +#define SIO_DATA SIO_BASE+1 + +#define SIO_READ(ldn, index) \ + mov SIO_BASE, %dx ; \ + mov $0x07, %al ; \ + outb %al, %dx ; \ + inc %dx ; \ + mov ldn, %al ; \ + outb %al, %dx ; \ + dec %dx ; \ + mov index, %al ; \ + outb %al, %dx ; \ + inc %dx ; \ + inb %dx, %al ; + +#define SIO_WRITE(ldn, index, data) \ + mov SIO_BASE, %dx ; \ + mov $0x07, %al ; \ + outb %al, %dx ; \ + inc %dx ; \ + mov ldn, %al ; \ + outb %al, %dx ; \ + dec %dx ; \ + mov index, %al ; \ + outb %al, %dx ; \ + inc %dx ; \ + mov data, %al ; \ + outb %al, %dx ; + + + /* Perform MB PnP setup to put the SIO chip at 0x3f0 */ + + /* Base address 0x3f0 : 0x86 0x80 0x55 0x55 */ + /* Base address 0x3bd : 0x86 0x80 0x55 0xaa */ + /* Base address 0x370 : 0x86 0x80 0xaa 0x55 */ + + mov $0x279, %dx + mov $0x86, %al + outb %al, %dx + mov $0x80, %al + outb %al, %dx + mov $0x55, %al + outb %al, %dx + mov $0x55, %al + outb %al, %dx + + /* Enter the configuration state */ + + mov SIO_BASE, %dx + + /* 6a, b5, da, ed : f6, fb, 7d, be */ + + mov $0x6a, %al + outb %al, %dx + mov $0xb5, %al + outb %al, %dx + mov $0xda, %al + outb %al, %dx + mov $0xed, %al + outb %al, %dx + + mov $0xf6, %al + outb %al, %dx + mov $0xfb, %al + outb %al, %dx + mov $0x7d, %al + outb %al, %dx + mov $0xbe, %al + outb %al, %dx + + /* df, 6f, 37, 1b : 0d, 86, c3, 61 */ + + mov $0xdf, %al + outb %al, %dx + mov $0x6f, %al + outb %al, %dx + mov $0x37, %al + outb %al, %dx + mov $0x1b, %al + outb %al, %dx + + mov $0x0d, %al + outb %al, %dx + mov $0x86, %al + outb %al, %dx + mov $0xc3, %al + outb %al, %dx + mov $0x61, %al + outb %al, %dx + + /* b0, 58, 2c, 16 : 8b, 45, a2, d1 */ + + mov $0xb0, %al + outb %al, %dx + mov $0x58, %al + outb %al, %dx + mov $0x2c, %al + outb %al, %dx + mov $0x16, %al + outb %al, %dx + + mov $0x8b, %al + outb %al, %dx + mov $0x45, %al + outb %al, %dx + mov $0xa2, %al + outb %al, %dx + mov $0xd1, %al + outb %al, %dx + + /* e8, 74, 3a, 9d : ce, e7, 73, 39 */ + + mov $0xe8, %al + outb %al, %dx + mov $0x74, %al + outb %al, %dx + mov $0x3a, %al + outb %al, %dx + mov $0x9d, %al + outb %al, %dx + + mov $0xce, %al + outb %al, %dx + mov $0xe7, %al + outb %al, %dx + mov $0x73, %al + outb %al, %dx + mov $0x39, %al + outb %al, %dx + + /* Enable parallel port, serial 1, serial port 2, Floppy */ + + SIO_WRITE($0x00, $0x23, $0x0f) + + /* Activate serial port 1 and 2 */ + + SIO_WRITE($0x01, $0x30, $0x1) + SIO_WRITE($0x02, $0x30, $0x1) + + /* Select 24MHz CLKIN and clear software suspend mode */ + + SIO_WRITE($0x00, $0x24, $0x00) + + /* Exit the configuration state */ + + SIO_WRITE($0x00, $0x02, $0x02); diff -Naur src/superio/foo/it8671f/superio.c src/superio/ITE/it8671f/superio.c --- src/superio/foo/it8671f/superio.c 1970-01-01 01:00:00.000000000 +0100 +++ src/superio/ITE/it8671f/superio.c 2006-08-06 21:21:22.000000000 +0200 @@ -0,0 +1,91 @@ +/* + * Copyright (C) xxxx ???? + * Copyright (C) 2006 Uwe Hermann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// #include +// #include +// #include +// #include +// #include +// #include +#include +#include +#include "chip.h" +#include "it8671f.h" + +static void init(device_t dev) +{ + struct superio_ITE_it8671f_config *conf; + struct resource *res0, *res1; + + if (!dev->enabled) { + return; + } + + conf = dev->chip_info; + + switch(dev->path.u.pnp.device) { + case IT8671F_SP1: + res0 = find_resource(dev, PNP_IDX_IO0); + init_uart8250(res0->base, &conf->com1); + break; + case IT8671F_SP2: + res0 = find_resource(dev, PNP_IDX_IO0); + init_uart8250(res0->base, &conf->com2); + break; + case IT8671F_KBCK: + res0 = find_resource(dev, PNP_IDX_IO0); + res1 = find_resource(dev, PNP_IDX_IO1); + init_pc_keyboard(res0->base, res1->base, &conf->keyboard); + break; + } +} + +static struct device_operations ops = { + .read_resources = pnp_read_resources, + .set_resources = pnp_set_resources, + .enable_resources = pnp_enable_resources, + .enable = pnp_enable, + .init = init, +}; + +// TODO. +static struct pnp_info pnp_dev_info[] = { +// { &ops, IT8671F_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0x07fa, 0}, }, +// { &ops, IT8671F_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0x04f8, 0}, }, + { &ops, IT8671F_SP2, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_DRQ1, { 0x7f8, 0 }, }, + { &ops, IT8671F_SP1, PNP_IO0 | PNP_IRQ0, { 0x7f8, 0 }, }, +// { &ops, IT8671F_SWC, PNP_IO0 | PNP_IRQ0, { 0xfff0, 0 }, }, +// { &ops, IT8671F_KBCM, PNP_IRQ0 }, +{ &ops, IT8671F_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, { 0x7f8, 0 }, { 0x7f8, 0x4}, }, +// { &ops, IT8671F_GPIO, PNP_IO0 | PNP_IRQ0, { 0xfff8, 0 } }, +// { &ops, IT8671F_XBUS, PNP_IO0 | PNP_IRQ0, { 0xffe0, 0 } }, +// { &ops, IT8671F_RTC, PNP_IO0 | PNP_IO1, { 0xfffe, 0 }, {0xfffe, 0x4} }, +}; + +static void enable_dev(struct device *dev) +{ + pnp_enable_devices(dev, &pnp_ops, + sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info); +} + +struct chip_operations superio_ITE_it8671f_ops = { + CHIP_NAME("ITE it8671f") + .enable_dev = enable_dev, +}; +