Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5916
-gerrit
commit 3060582c2f767b79711b98e65d7ecebede52cd1f
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Mon Jun 2 12:20:11 2014 +1000
superio/smsc/kbc1100: Virtually rewrite support and fix mainboards
1. Remove #include .c in romstage.
2. Make romstage component symbols linker-time.
3. Provide header guards and prototypes in superio romstage support.
4. Correct function type-signatures to be static/non-static where
appropriate, avoid 'pretend optimisations' by unnecessarily inlining
functions.
5. Separate out UART enable from various other PNP hard coding
Change-Id: I9b8dad7c02d802e97db73ddf2913d5c6bb33a419
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/mainboard/amd/inagua/Kconfig | 4 --
src/mainboard/amd/inagua/romstage.c | 7 ++-
src/mainboard/amd/torpedo/Kconfig | 4 --
src/mainboard/amd/torpedo/romstage.c | 6 +-
src/superio/smsc/kbc1100/Makefile.inc | 1 +
src/superio/smsc/kbc1100/early_init.c | 80 +++++++++++++++++++++++++++
src/superio/smsc/kbc1100/kbc1100.h | 10 ++++
src/superio/smsc/kbc1100/kbc1100_early_init.c | 75 -------------------------
8 files changed, 100 insertions(+), 87 deletions(-)
diff --git a/src/mainboard/amd/inagua/Kconfig b/src/mainboard/amd/inagua/Kconfig
index 1e11f9f..279c7ef 100644
--- a/src/mainboard/amd/inagua/Kconfig
+++ b/src/mainboard/amd/inagua/Kconfig
@@ -69,10 +69,6 @@ config RAMBASE
hex
default 0x200000
-config SIO_PORT
- hex
- default 0x2e
-
config DRIVERS_PS2_KEYBOARD
bool
default y
diff --git a/src/mainboard/amd/inagua/romstage.c b/src/mainboard/amd/inagua/romstage.c
index a304d31..bd1b810 100644
--- a/src/mainboard/amd/inagua/romstage.c
+++ b/src/mainboard/amd/inagua/romstage.c
@@ -33,11 +33,13 @@
#include "cpu/amd/car.h"
#include "agesawrapper.h"
#include "cpu/x86/bist.h"
-#include "superio/smsc/kbc1100/kbc1100_early_init.c"
+#include <superio/smsc/kbc1100/kbc1100.h>
#include "cpu/x86/lapic.h"
#include <sb_cimx.h>
#include "SBPLATFORM.h"
+#define SERIAL_DEV PNP_DEV(0x2e, SMSCSUPERIO_SP1)
+
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
{
u32 val;
@@ -57,7 +59,8 @@ void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
sb_Poweron_Init();
post_code(0x31);
- kbc1100_early_init(CONFIG_SIO_PORT);
+ kbc1100_early_init();
+ kbc1100_early_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
console_init();
}
diff --git a/src/mainboard/amd/torpedo/Kconfig b/src/mainboard/amd/torpedo/Kconfig
index 62ce043..6013df7 100644
--- a/src/mainboard/amd/torpedo/Kconfig
+++ b/src/mainboard/amd/torpedo/Kconfig
@@ -79,10 +79,6 @@ config RAMBASE
hex
default 0x200000
-config SIO_PORT
- hex
- default 0x2e
-
config ONBOARD_VGA_IS_PRIMARY
bool
default y
diff --git a/src/mainboard/amd/torpedo/romstage.c b/src/mainboard/amd/torpedo/romstage.c
index dcab52b..53f1c84 100644
--- a/src/mainboard/amd/torpedo/romstage.c
+++ b/src/mainboard/amd/torpedo/romstage.c
@@ -30,13 +30,14 @@
#include "cpu/amd/car.h"
#include "agesawrapper.h"
#include "cpu/x86/bist.h"
-#include "superio/smsc/kbc1100/kbc1100_early_init.c"
+#include <superio/smsc/kbc1100/kbc1100.h>
#include "cpu/x86/lapic.h"
#include "sb_cimx.h"
#include "SbPlatform.h"
#include <arch/cpu.h>
#include "platform_cfg.h"
+#define SERIAL_DEV PNP_DEV(0x2e, SMSCSUPERIO_SP1)
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
{
@@ -57,7 +58,8 @@ void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
post_code(0x31);
- kbc1100_early_init(CONFIG_SIO_PORT);
+ kbc1100_early_init();
+ kbc1100_early_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
post_code(0x32);
post_code(0x33);
diff --git a/src/superio/smsc/kbc1100/Makefile.inc b/src/superio/smsc/kbc1100/Makefile.inc
index 603d24e..c3385a6 100644
--- a/src/superio/smsc/kbc1100/Makefile.inc
+++ b/src/superio/smsc/kbc1100/Makefile.inc
@@ -17,4 +17,5 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
+romstage-$(CONFIG_SUPERIO_SMSC_KBC1100) += early_init.c
ramstage-$(CONFIG_SUPERIO_SMSC_KBC1100) += superio.c
diff --git a/src/superio/smsc/kbc1100/early_init.c b/src/superio/smsc/kbc1100/early_init.c
new file mode 100644
index 0000000..9862877
--- /dev/null
+++ b/src/superio/smsc/kbc1100/early_init.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2011 Advanced Micro Devices, Inc.
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ *
+ * 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; version 2 of the License.
+ *
+ * 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
+ */
+
+/* Pre-RAM driver for the SMSC KBC1100 Super I/O chip */
+
+#include <arch/io.h>
+#include <device/pnp.h>
+#include <stdint.h>
+
+#include "kbc1100.h"
+
+static void pnp_enter_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0x55, port);
+}
+
+static void pnp_exit_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(0xaa, port);
+}
+
+void kbc1100_early_serial(device_t dev, u16 iobase)
+{
+ pnp_enter_conf_state(dev);
+ /* Serial IRQ enabled */
+ u16 port = dev >> 8;
+ outb(0x25, port);
+ outb(0x04, port + 1);
+ /* .. */
+ pnp_set_logical_device(dev);
+ pnp_set_enable(dev, 0);
+ pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
+ pnp_set_enable(dev, 1);
+ pnp_exit_conf_state(dev);
+}
+
+void kbc1100_early_init(void)
+{
+ device_t dev;
+ dev = PNP_DEV (port, KBC1100_KBC);
+ pnp_enter_conf_state(dev);
+
+ /* Enable keyboard */
+ pnp_set_logical_device(dev);
+ pnp_set_enable(dev, 0);
+ pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
+ pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
+ pnp_set_irq(dev, 0x70, 1); /* IRQ 1 */
+ pnp_set_irq(dev, 0x72, 12); /* IRQ 12 */
+ pnp_set_enable(dev, 1);
+
+ /* Enable EC Channel 0 */
+ dev = PNP_DEV (port, KBC1100_EC0);
+ pnp_set_logical_device(dev);
+ pnp_set_enable(dev, 1);
+
+ pnp_exit_conf_state(dev);
+
+ /* disable the 1s timer */
+ outb(0xE7, 0x64);
+}
diff --git a/src/superio/smsc/kbc1100/kbc1100.h b/src/superio/smsc/kbc1100/kbc1100.h
index 3fe6327..3389836 100644
--- a/src/superio/smsc/kbc1100/kbc1100.h
+++ b/src/superio/smsc/kbc1100/kbc1100.h
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2011 Advanced Micro Devices, Inc.
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
*
* 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
@@ -17,6 +18,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifndef SUPERIO_SMSC_KBC1100_H
+#define SUPERIO_SMSC_KBC1100_H
+
+#include <arch/io.h>
+#include <stdint.h>
+
#define KBC1100_PM1 1 /* PM1 */
#define SMSCSUPERIO_SP1 4 /* Com1 */
#define SMSCSUPERIO_SP2 5 /* Com2 */
@@ -29,4 +36,7 @@
#define KBC1100_EC1 0x0D /* EC Channel 1 */
#define KBC1100_EC2 0x0E /* EC Channel 2 */
+void kbc1100_early_serial(device_t dev, u16 iobase);
+void kbc1100_early_init(void);
+#endif /* SUPERIO_SMSC_KBC1100_H */
diff --git a/src/superio/smsc/kbc1100/kbc1100_early_init.c b/src/superio/smsc/kbc1100/kbc1100_early_init.c
deleted file mode 100644
index 5d74c32..0000000
--- a/src/superio/smsc/kbc1100/kbc1100_early_init.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2011 Advanced Micro Devices, Inc.
- *
- * 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; version 2 of the License.
- *
- * 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
- */
-
-/* Pre-RAM driver for the SMSC KBC1100 Super I/O chip */
-
-#include <arch/io.h>
-#include "kbc1100.h"
-
-static inline void pnp_enter_conf_state(device_t dev)
-{
- unsigned port = dev>>8;
- outb(0x55, port);
-}
-
-static void pnp_exit_conf_state(device_t dev)
-{
- unsigned port = dev>>8;
- outb(0xaa, port);
-}
-
-static inline void kbc1100_early_init(unsigned port)
-{
- device_t dev;
- dev = PNP_DEV (port, KBC1100_KBC);
-
- pnp_enter_conf_state(dev);
-
- /* Serial IRQ enabled */
- outb(0x25, port);
- outb(0x04, port + 1);
-
- /* Enable SMSC UART 0 */
- dev = PNP_DEV (port, SMSCSUPERIO_SP1);
- pnp_set_logical_device(dev);
- pnp_set_enable(dev, 0);
- pnp_set_iobase(dev, PNP_IDX_IO0, CONFIG_TTYS0_BASE);
- pnp_set_enable(dev, 1);
-
- /* Enable keyboard */
- dev = PNP_DEV (port, KBC1100_KBC);
- pnp_set_logical_device(dev);
- pnp_set_enable(dev, 0);
- pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
- pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
- pnp_set_irq(dev, 0x70, 1); /* IRQ 1 */
- pnp_set_irq(dev, 0x72, 12); /* IRQ 12 */
- pnp_set_enable(dev, 1);
-
- /* Enable EC Channel 0 */
- dev = PNP_DEV (port, KBC1100_EC0);
- pnp_set_logical_device(dev);
- pnp_set_enable(dev, 1);
-
- pnp_exit_conf_state(dev);
-
- /* disable the 1s timer */
- outb(0xE7, 0x64);
-}
-
Felix Held (felix-coreboot(a)felixheld.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5909
-gerrit
commit 7b7323c97cddb5d44e1ae8751984169fda488b8a
Author: Felix Held <felix-coreboot(a)felixheld.de>
Date: Sun Jun 1 21:44:43 2014 +0200
superio/nuvoton: factor out generic romstage components
The romstage of Nuvoton Super I/O chips (but not Nuvoton BMC chips)
is identical, so the early_serial.c file can be moved under
nuvoton/common.
The Nuvoton BMC chip WPCM450 is however left untouched.
Change-Id: I4663176c1003b24a49a9fe5f9ebd27a1963b5565
Signed-off-by: Felix Held <felix-coreboot(a)felixheld.de>
---
src/superio/nuvoton/Kconfig | 7 +++
src/superio/nuvoton/Makefile.inc | 3 ++
src/superio/nuvoton/common/early_serial.c | 75 +++++++++++++++++++++++++++++++
src/superio/nuvoton/common/nuvoton.h | 30 +++++++++++++
src/superio/nuvoton/nct5104d/Makefile.inc | 1 -
src/superio/nuvoton/nct5104d/early_init.c | 46 -------------------
src/superio/nuvoton/nct5104d/nct5104d.h | 2 -
7 files changed, 115 insertions(+), 49 deletions(-)
diff --git a/src/superio/nuvoton/Kconfig b/src/superio/nuvoton/Kconfig
index 142738d..350c8dd 100644
--- a/src/superio/nuvoton/Kconfig
+++ b/src/superio/nuvoton/Kconfig
@@ -17,7 +17,14 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+# Generic Nuvoton romstage driver - Just enough UART initialisation code for
+# romstage.
+config SUPERIO_NUVOTON_COMMON_ROMSTAGE
+ bool
+
config SUPERIO_NUVOTON_WPCM450
bool
+
config SUPERIO_NUVOTON_NCT5104D
bool
+ select SUPERIO_NUVOTON_COMMON_ROMSTAGE
diff --git a/src/superio/nuvoton/Makefile.inc b/src/superio/nuvoton/Makefile.inc
index 18025c9..1ce6963 100644
--- a/src/superio/nuvoton/Makefile.inc
+++ b/src/superio/nuvoton/Makefile.inc
@@ -17,5 +17,8 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+## include generic nuvoton pre-ram stage driver
+romstage-$(CONFIG_SUPERIO_NUVOTON_COMMON_ROMSTAGE) += common/early_serial.c
+
subdirs-$(CONFIG_SUPERIO_NUVOTON_WPCM450) += wpcm450
subdirs-$(CONFIG_SUPERIO_NUVOTON_NCT5104D) += nct5104d
diff --git a/src/superio/nuvoton/common/early_serial.c b/src/superio/nuvoton/common/early_serial.c
new file mode 100644
index 0000000..1cbcee8
--- /dev/null
+++ b/src/superio/nuvoton/common/early_serial.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2011 Advanced Micro Devices, Inc.
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ * Copyright (C) 2014 Felix Held <felix-coreboot(a)felixheld.de>
+ *
+ * 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
+ */
+
+/*
+ * A generic romstage (pre-ram) driver for Nuvoton variant Super I/O chips.
+ *
+ * The following is derived directly from the vendor Nuvoton's data-sheets:
+ *
+ * To toggle between `configuration mode` and `normal operation mode` as to
+ * manipulate the various LDN's in Nuvoton Super I/O's we are required to
+ * pass magic numbers `passwords keys`.
+ *
+ * NUVOTON_ENTRY_KEY := enable configuration : 0x87
+ * NUVOTON_EXIT_KEY := disable configuration : 0xAA
+ *
+ * To modify a LDN's configuration register, we use the index port to select
+ * the index of the LDN and then write to the data port to alter the
+ * parameters. A default index, data port pair is 0x4E, 0x4F respectively, a
+ * user modified pair is 0x2E, 0x2F respectively.
+ *
+ */
+
+#include <arch/io.h>
+#include <device/pnp.h>
+#include <stdint.h>
+#include "nuvoton.h"
+
+#define NUVOTON_ENTRY_KEY 0x87
+#define NUVOTON_EXIT_KEY 0xAA
+
+/* Enable configuration: pass entry key '0x87' into index port dev
+ * two times. */
+static void pnp_enter_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(NUVOTON_ENTRY_KEY, port);
+ outb(NUVOTON_ENTRY_KEY, port);
+}
+
+/* Disable configuration: pass exit key '0xAA' into index port dev. */
+static void pnp_exit_conf_state(device_t dev)
+{
+ u16 port = dev >> 8;
+ outb(NUVOTON_EXIT_KEY, port);
+}
+
+/* Bring up early serial debugging output before the RAM is initialized. */
+void nuvoton_enable_serial(device_t dev, u16 iobase)
+{
+ pnp_enter_conf_state(dev);
+ pnp_set_logical_device(dev);
+ pnp_set_enable(dev, 0);
+ pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
+ pnp_set_enable(dev, 1);
+ pnp_exit_conf_state(dev);
+}
diff --git a/src/superio/nuvoton/common/nuvoton.h b/src/superio/nuvoton/common/nuvoton.h
new file mode 100644
index 0000000..e9e8d4b
--- /dev/null
+++ b/src/superio/nuvoton/common/nuvoton.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+ * Copyright (C) 2014 Felix Held <felix-coreboot(a)felixheld.de>
+ *
+ * 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_NUVOTON_COMMON_ROMSTAGE_H
+#define SUPERIO_NUVOTON_COMMON_ROMSTAGE_H
+
+#include <arch/io.h>
+#include <stdint.h>
+
+void nuvoton_enable_serial(device_t dev, u16 iobase);
+
+#endif /* SUPERIO_NUVOTON_COMMON_ROMSTAGE_H */
diff --git a/src/superio/nuvoton/nct5104d/Makefile.inc b/src/superio/nuvoton/nct5104d/Makefile.inc
index 7c97d05..fcb5ec2 100644
--- a/src/superio/nuvoton/nct5104d/Makefile.inc
+++ b/src/superio/nuvoton/nct5104d/Makefile.inc
@@ -18,5 +18,4 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
-romstage-$(CONFIG_SUPERIO_NUVOTON_NCT5104D) += early_init.c
ramstage-$(CONFIG_SUPERIO_NUVOTON_NCT5104D) += superio.c
diff --git a/src/superio/nuvoton/nct5104d/early_init.c b/src/superio/nuvoton/nct5104d/early_init.c
deleted file mode 100644
index f3d8990..0000000
--- a/src/superio/nuvoton/nct5104d/early_init.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2011 Advanced Micro Devices, Inc.
- *
- * 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 <arch/io.h>
-#include <device/pnp.h>
-#include "nct5104d.h"
-
-static void pnp_enter_extended_mode(device_t dev)
-{
- u16 port = dev >> 8;
- outb(0x87,port);
- outb(0x87,port);
-}
-
-static void pnp_exit_extended_mode(device_t dev)
-{
- u16 port = dev >> 8;
- outb(0xaa,port);
-}
-
-void nct5104d_enable_serial(device_t dev, u16 iobase)
-{
- pnp_enter_extended_mode(dev);
- pnp_set_logical_device(dev);
- pnp_set_enable(dev,0);
- pnp_set_iobase(dev,PNP_IDX_IO0, iobase);
- pnp_set_enable(dev,1);
- pnp_exit_extended_mode(dev);
-}
diff --git a/src/superio/nuvoton/nct5104d/nct5104d.h b/src/superio/nuvoton/nct5104d/nct5104d.h
index 98baf81..5c30e02 100644
--- a/src/superio/nuvoton/nct5104d/nct5104d.h
+++ b/src/superio/nuvoton/nct5104d/nct5104d.h
@@ -37,6 +37,4 @@
#define NCT5104D_GPIO1 ((1 << 8) | NCT5104D_GPIO_V)
#define NCT5104D_GPIO6 ((6 << 8) | NCT5104D_GPIO_V)
-void nct5104d_enable_serial(device_t dev, u16 iobase);
-
#endif /* SUPERIO_NUVOTON_NCT5104D_NCT5104D_H */
Felix Held (felix-coreboot(a)felixheld.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5450
-gerrit
commit 800e168c6049dc1c4a43969673e471c55db762c9
Author: Felix Held <felix-coreboot(a)felixheld.de>
Date: Sun Jun 1 19:17:33 2014 +0200
add support for nct6776
nct6776d and nct6776f are just two different package variants
Change-Id: If6686ea0a1cd6be537e286699b4ee8f88ba8ad7c
Signed-off-by: Felix Held <felix-coreboot(a)felixheld.de>
---
src/superio/nuvoton/Kconfig | 5 ++
src/superio/nuvoton/Makefile.inc | 1 +
src/superio/nuvoton/nct6776d/Makefile.inc | 22 +++++++++
src/superio/nuvoton/nct6776d/nct6776d.h | 60 +++++++++++++++++++++++
src/superio/nuvoton/nct6776d/superio.c | 79 +++++++++++++++++++++++++++++++
5 files changed, 167 insertions(+)
diff --git a/src/superio/nuvoton/Kconfig b/src/superio/nuvoton/Kconfig
index 350c8dd..c6c547b 100644
--- a/src/superio/nuvoton/Kconfig
+++ b/src/superio/nuvoton/Kconfig
@@ -28,3 +28,8 @@ config SUPERIO_NUVOTON_WPCM450
config SUPERIO_NUVOTON_NCT5104D
bool
select SUPERIO_NUVOTON_COMMON_ROMSTAGE
+
+config SUPERIO_NUVOTON_NCT6776D
+ bool
+ select SUPERIO_NUVOTON_COMMON_ROMSTAGE
+
diff --git a/src/superio/nuvoton/Makefile.inc b/src/superio/nuvoton/Makefile.inc
index 1ce6963..ad7cac7 100644
--- a/src/superio/nuvoton/Makefile.inc
+++ b/src/superio/nuvoton/Makefile.inc
@@ -22,3 +22,4 @@ romstage-$(CONFIG_SUPERIO_NUVOTON_COMMON_ROMSTAGE) += common/early_serial.c
subdirs-$(CONFIG_SUPERIO_NUVOTON_WPCM450) += wpcm450
subdirs-$(CONFIG_SUPERIO_NUVOTON_NCT5104D) += nct5104d
+subdirs-$(CONFIG_SUPERIO_NUVOTON_NCT6776D) += nct6776d
diff --git a/src/superio/nuvoton/nct6776d/Makefile.inc b/src/superio/nuvoton/nct6776d/Makefile.inc
new file mode 100755
index 0000000..aacfa31
--- /dev/null
+++ b/src/superio/nuvoton/nct6776d/Makefile.inc
@@ -0,0 +1,22 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2011 - 2012 Advanced Micro Devices, Inc.
+## Copyright (C) 2014 Felix Held <felix-coreboot(a)felixheld.de>
+##
+## 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
+##
+
+ramstage-$(CONFIG_SUPERIO_NUVOTON_NCT6776D) += superio.c
diff --git a/src/superio/nuvoton/nct6776d/nct6776d.h b/src/superio/nuvoton/nct6776d/nct6776d.h
new file mode 100755
index 0000000..00e45de
--- /dev/null
+++ b/src/superio/nuvoton/nct6776d/nct6776d.h
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Felix Held <felix-coreboot(a)felixheld.de>
+ *
+ * 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_NUVOTON_NCT6776D_NCT6776D_H
+#define SUPERIO_NUVOTON_NCT6776D_NCT6776D_H
+
+/* Logical Device Numbers (LDN). */
+#define NCT6776D_FDC 0x00 /* Floppy */
+#define NCT6776D_PP 0x01 /* Parallel port */
+#define NCT6776D_SP1 0x02 /* Com1 */
+#define NCT6776D_SP2 0x03 /* Com2 & IR */
+#define NCT6776D_KBC 0x05 /* PS/2 keyboard and mouse */
+#define NCT6776D_CIR 0x06
+#define NCT6776D_GPIO6789_V 0x07
+#define NCT6776D_WDT1_GPIO01A_V 0x08
+#define NCT6776D_GPIO1234567_V 0x09
+#define NCT6776D_ACPI 0x0A
+#define NCT6776D_HWM_FPLED 0x0B /* Hardware monitor & front LED */
+#define NCT6776D_VID 0x0D
+#define NCT6776D_CIRWKUP 0x0E /* CIR wakeup */
+#define NCT6776D_GPIO_PP_OD 0x0F /* GPIO Push-Pull/Open drain select */
+#define NCT6776D_SVID 0x14
+#define NCT6776D_DSLP 0x16 /* Deep sleep */
+#define NCT6776D_GPIOA_LDN 0x17
+
+/* virtual LDN for GPIO and WDT */
+#define NCT6776D_WDT1 ((0<<8) | NCT6776D_WDT1_GPIO01A_V)
+
+#define NCT6776D_GPIOBASE ((0<<8) | NCT6776D_WDT1_GPIO01A_V) //?
+
+#define NCT6776D_GPIO0 ((1<<8) | NCT6776D_WDT1_GPIO01A_V)
+#define NCT6776D_GPIO1 ((1<<8) | NCT6776D_GPIO1234567_V)
+#define NCT6776D_GPIO2 ((2<<8) | NCT6776D_GPIO1234567_V)
+#define NCT6776D_GPIO3 ((3<<8) | NCT6776D_GPIO1234567_V)
+#define NCT6776D_GPIO4 ((4<<8) | NCT6776D_GPIO1234567_V)
+#define NCT6776D_GPIO5 ((5<<8) | NCT6776D_GPIO1234567_V)
+#define NCT6776D_GPIO6 ((6<<8) | NCT6776D_GPIO1234567_V)
+#define NCT6776D_GPIO7 ((7<<8) | NCT6776D_GPIO1234567_V)
+#define NCT6776D_GPIO8 ((0<<8) | NCT6776D_GPIO6789_V)
+#define NCT6776D_GPIO9 ((1<<8) | NCT6776D_GPIO6789_V)
+#define NCT6776D_GPIOA ((2<<8) | NCT6776D_WDT1_GPIO01A_V)
+
+#endif
diff --git a/src/superio/nuvoton/nct6776d/superio.c b/src/superio/nuvoton/nct6776d/superio.c
new file mode 100755
index 0000000..6d1ed58
--- /dev/null
+++ b/src/superio/nuvoton/nct6776d/superio.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2011 Advanced Micro Devices, Inc.
+ * Copyright (C) 2014 Felix Held <felix-coreboot(a)felixheld.de>
+ *
+ * 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 <arch/io.h>
+#include <device/pnp.h>
+#include <superio/conf_mode.h>
+#include <stdlib.h>
+#include "nct6776d.h"
+
+static void nct6776d_init(device_t dev)
+{
+}
+
+static struct device_operations ops = {
+ .read_resources = pnp_read_resources,
+ .set_resources = pnp_set_resources,
+ .enable_resources = pnp_enable_resources,
+ .enable = pnp_alt_enable,
+ .init = nct6776d_init,
+ .ops_pnp_mode = &pnp_conf_mode_8787_aa,
+};
+
+static struct pnp_info pnp_dev_info[] = { //TODO: smbus: io, irq?
+ { &ops, NCT6776D_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x0ff8, 0}, },
+ { &ops, NCT6776D_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x0ff8, 0}, },
+ { &ops, NCT6776D_SP1, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
+ { &ops, NCT6776D_SP2, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
+ { &ops, NCT6776D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, {0x0fff, 0}, {0x0fff, 4}, },
+ { &ops, NCT6776D_CIR, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
+ { &ops, NCT6776D_ACPI},
+ { &ops, NCT6776D_HWM_FPLED, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x0ffe, 0}, {0x0ffe, 4},},//4?
+ { &ops, NCT6776D_VID},
+ { &ops, NCT6776D_CIRWKUP, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },//?
+ { &ops, NCT6776D_GPIO_PP_OD},
+ { &ops, NCT6776D_SVID},
+ { &ops, NCT6776D_DSLP},
+ { &ops, NCT6776D_GPIOA_LDN},
+ { &ops, NCT6776D_WDT1},
+ { &ops, NCT6776D_GPIOBASE, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },//?
+ { &ops, NCT6776D_GPIO0},
+ { &ops, NCT6776D_GPIO1},
+ { &ops, NCT6776D_GPIO2},
+ { &ops, NCT6776D_GPIO3},
+ { &ops, NCT6776D_GPIO4},
+ { &ops, NCT6776D_GPIO5},
+ { &ops, NCT6776D_GPIO6},
+ { &ops, NCT6776D_GPIO7},
+ { &ops, NCT6776D_GPIO8},
+ { &ops, NCT6776D_GPIO9},
+ { &ops, NCT6776D_GPIOA},
+};
+
+static void enable_dev(struct device *dev)
+{
+ pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
+}
+
+struct chip_operations superio_nuvoton_nct6776d_ops = {
+ CHIP_NAME("NUVOTON NCT6776D Super I/O")
+ .enable_dev = enable_dev,
+};