Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3073
-gerrit
commit 738bf0f8f36eac99e6be0b470f7a8fc471535145
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Thu Apr 11 15:03:28 2013 -0700
Exynos5250: add a microsecond timer
Add a microsecond timer, its declaration, the function to start it,
and its usage. To start it, one calls microsecond() for any reason,
using the result or not. From that point on, it returns microseconds
from the first call.
We show its use in romstage. You want it started very early.
Finally, the delay.h changed having been (ironically) delayed,
we create time.h and have it hold one declaration, for the
microseconds prototype.
Change-Id: I19cbc2bb0089a3de88cfb94276266af38b9363c5
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
src/cpu/samsung/exynos5250/Kconfig | 8 +++
src/cpu/samsung/exynos5250/Makefile.inc | 2 +
src/cpu/samsung/exynos5250/mct.c | 122 ++++++++++++++++++++++++++++++++
src/include/time.h | 28 ++++++++
src/mainboard/google/snow/romstage.c | 5 ++
5 files changed, 165 insertions(+)
diff --git a/src/cpu/samsung/exynos5250/Kconfig b/src/cpu/samsung/exynos5250/Kconfig
index cc67abd..a63ccd7 100644
--- a/src/cpu/samsung/exynos5250/Kconfig
+++ b/src/cpu/samsung/exynos5250/Kconfig
@@ -97,3 +97,11 @@ config SYS_TEXT_BASE
config COREBOOT_TABLES_SIZE
hex
default 0x4000000
+
+config MCT_ADDRESS
+ hex
+ default 0x101c0000
+
+config MCT_HZ
+ int
+ default 24000000
diff --git a/src/cpu/samsung/exynos5250/Makefile.inc b/src/cpu/samsung/exynos5250/Makefile.inc
index 74bc871..6652328 100644
--- a/src/cpu/samsung/exynos5250/Makefile.inc
+++ b/src/cpu/samsung/exynos5250/Makefile.inc
@@ -16,6 +16,7 @@ romstage-y += pinmux.c # required by s3c24x0_i2c (exynos5-common) and uart.
romstage-y += dmc_common.c
romstage-y += dmc_init_ddr3.c
romstage-y += power.c
+romstage-y += mct.c
romstage-$(CONFIG_EARLY_CONSOLE) += soc.c
romstage-$(CONFIG_EARLY_CONSOLE) += uart.c
@@ -27,6 +28,7 @@ ramstage-y += power.c
ramstage-y += soc.c
ramstage-$(CONFIG_CONSOLE_SERIAL_UART) += uart.c
ramstage-y += cpu.c
+ramstage-y += mct.c
#ramstage-$(CONFIG_SATA_AHCI) += sata.c
diff --git a/src/cpu/samsung/exynos5250/mct.c b/src/cpu/samsung/exynos5250/mct.c
new file mode 100644
index 0000000..8342982
--- /dev/null
+++ b/src/cpu/samsung/exynos5250/mct.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <arch/io.h>
+#include <stdint.h>
+#include <time.h>
+
+struct __attribute__((packed)) mct_regs
+{
+ uint32_t mct_cfg;
+ uint8_t reserved0[0xfc];
+ uint32_t g_cnt_l;
+ uint32_t g_cnt_u;
+ uint8_t reserved1[0x8];
+ uint32_t g_cnt_wstat;
+ uint8_t reserved2[0xec];
+ uint32_t g_comp0_l;
+ uint32_t g_comp0_u;
+ uint32_t g_comp0_addr_incr;
+ uint8_t reserved3[0x4];
+ uint32_t g_comp1_l;
+ uint32_t g_comp1_u;
+ uint32_t g_comp1_addr_incr;
+ uint8_t reserved4[0x4];
+ uint32_t g_comp2_l;
+ uint32_t g_comp2_u;
+ uint32_t g_comp2_addr_incr;
+ uint8_t reserved5[0x4];
+ uint32_t g_comp3_l;
+ uint32_t g_comp3_u;
+ uint32_t g_comp3_addr_incr;
+ uint8_t reserved6[0x4];
+ uint32_t g_tcon;
+ uint32_t g_int_cstat;
+ uint32_t g_int_enb;
+ uint32_t g_wstat;
+ uint8_t reserved7[0xb0];
+ uint32_t l0_tcntb;
+ uint32_t l0_tcnto;
+ uint32_t l0_icntb;
+ uint32_t l0_icnto;
+ uint32_t l0_frcntb;
+ uint32_t l0_frcnto;
+ uint8_t reserved8[0x8];
+ uint32_t l0_tcon;
+ uint8_t reserved9[0xc];
+ uint32_t l0_int_cstat;
+ uint32_t l0_int_enb;
+ uint8_t reserved10[0x8];
+ uint32_t l0_wstat;
+ uint8_t reserved11[0xbc];
+ uint32_t l1_tcntb;
+ uint32_t l1_tcnto;
+ uint32_t l1_icntb;
+ uint32_t l1_icnto;
+ uint32_t l1_frcntb;
+ uint32_t l1_frcnto;
+ uint8_t reserved12[0x8];
+ uint32_t l1_tcon;
+ uint8_t reserved13[0xc];
+ uint32_t l1_int_cstat;
+ uint32_t l1_int_enb;
+ uint8_t reserved14[0x8];
+ uint32_t l1_wstat;
+};
+
+/* I would prefer not to export these for now. */
+static uint64_t timer_hz(void)
+{
+ return CONFIG_MCT_HZ;
+}
+
+static int enabled = 0;
+static struct mct_regs *const mct =
+ (struct mct_regs *)CONFIG_MCT_ADDRESS;
+
+static uint64_t timer_raw_value(void)
+{
+ if (!enabled) {
+ writel(readl(&mct->g_tcon) | (0x1 << 8), &mct->g_tcon);
+ enabled = 1;
+ }
+
+ uint64_t upper = readl(&mct->g_cnt_u);
+ uint64_t lower = readl(&mct->g_cnt_l);
+
+ return (upper << 32) | lower;
+}
+
+void timer_start(void)
+{
+ writel(readl(&mct->g_tcon) | (0x1 << 8), &mct->g_tcon);
+ enabled = 1;
+}
+
+u32 timer_us(void)
+{
+ uint64_t raw = timer_raw_value();
+ uint32_t ticks_per_microsecond = timer_hz()/1000000;
+ uint32_t usec = raw / ticks_per_microsecond;
+ return usec;
+}
+
diff --git a/src/include/time.h b/src/include/time.h
new file mode 100644
index 0000000..6bd9e08
--- /dev/null
+++ b/src/include/time.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, 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
+ */
+
+#ifndef TIME_H
+#define TIME_H
+
+#if !defined( __ROMCC__)
+
+void timer_start(void);
+u32 timer_us(void);
+#endif
+#endif /* TIME_H */
diff --git a/src/mainboard/google/snow/romstage.c b/src/mainboard/google/snow/romstage.c
index 7a26ed9..b1cc0fd 100644
--- a/src/mainboard/google/snow/romstage.c
+++ b/src/mainboard/google/snow/romstage.c
@@ -36,6 +36,7 @@
#include <cpu/samsung/exynos5250/clock_init.h>
#include <console/console.h>
#include <arch/stages.h>
+#include <time.h>
#include <drivers/maxim/max77686/max77686.h>
#include <device/i2c.h>
@@ -150,6 +151,10 @@ void main(void)
struct arm_clk_ratios *arm_ratios;
int ret;
void *entry;
+ /* kick off the microsecond timer. We want to do this as early
+ * as we can.
+ */
+ timer_start();
clock_set_rate(PERIPH_ID_SPI1, 50000000); /* set spi clock to 50Mhz */
Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3073
-gerrit
commit ee5ceb5a3061bc1988ecfaf4e2fb55a6df2c8a23
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Thu Apr 11 15:03:28 2013 -0700
Exynos5250: add a microsecond timer
Add a microsecond timer, its declaration, the function to start it,
and its usage. To start it, one calls microsecond() for any reason,
using the result or not. From that point on, it returns microseconds
from the first call.
We show its use in romstage. You want it started very early.
Finally, the delay.h changed having been (ironically) delayed,
we create time.h and have it hold one declaration, for the
microseconds prototype.
Change-Id: I19cbc2bb0089a3de88cfb94276266af38b9363c5
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
src/cpu/samsung/exynos5250/Kconfig | 8 +++
src/cpu/samsung/exynos5250/Makefile.inc | 2 +
src/cpu/samsung/exynos5250/mct.c | 122 ++++++++++++++++++++++++++++++++
src/include/time.h | 28 ++++++++
src/mainboard/google/snow/romstage.c | 5 ++
5 files changed, 165 insertions(+)
diff --git a/src/cpu/samsung/exynos5250/Kconfig b/src/cpu/samsung/exynos5250/Kconfig
index cc67abd..a63ccd7 100644
--- a/src/cpu/samsung/exynos5250/Kconfig
+++ b/src/cpu/samsung/exynos5250/Kconfig
@@ -97,3 +97,11 @@ config SYS_TEXT_BASE
config COREBOOT_TABLES_SIZE
hex
default 0x4000000
+
+config MCT_ADDRESS
+ hex
+ default 0x101c0000
+
+config MCT_HZ
+ int
+ default 24000000
diff --git a/src/cpu/samsung/exynos5250/Makefile.inc b/src/cpu/samsung/exynos5250/Makefile.inc
index 74bc871..6652328 100644
--- a/src/cpu/samsung/exynos5250/Makefile.inc
+++ b/src/cpu/samsung/exynos5250/Makefile.inc
@@ -16,6 +16,7 @@ romstage-y += pinmux.c # required by s3c24x0_i2c (exynos5-common) and uart.
romstage-y += dmc_common.c
romstage-y += dmc_init_ddr3.c
romstage-y += power.c
+romstage-y += mct.c
romstage-$(CONFIG_EARLY_CONSOLE) += soc.c
romstage-$(CONFIG_EARLY_CONSOLE) += uart.c
@@ -27,6 +28,7 @@ ramstage-y += power.c
ramstage-y += soc.c
ramstage-$(CONFIG_CONSOLE_SERIAL_UART) += uart.c
ramstage-y += cpu.c
+ramstage-y += mct.c
#ramstage-$(CONFIG_SATA_AHCI) += sata.c
diff --git a/src/cpu/samsung/exynos5250/mct.c b/src/cpu/samsung/exynos5250/mct.c
new file mode 100644
index 0000000..98b8ca8
--- /dev/null
+++ b/src/cpu/samsung/exynos5250/mct.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <arch/io.h>
+#include <stdint.h>
+#include <time.h>
+
+typedef struct __attribute__((packed)) mct_regs
+{
+ uint32_t mct_cfg;
+ uint8_t reserved0[0xfc];
+ uint32_t g_cnt_l;
+ uint32_t g_cnt_u;
+ uint8_t reserved1[0x8];
+ uint32_t g_cnt_wstat;
+ uint8_t reserved2[0xec];
+ uint32_t g_comp0_l;
+ uint32_t g_comp0_u;
+ uint32_t g_comp0_addr_incr;
+ uint8_t reserved3[0x4];
+ uint32_t g_comp1_l;
+ uint32_t g_comp1_u;
+ uint32_t g_comp1_addr_incr;
+ uint8_t reserved4[0x4];
+ uint32_t g_comp2_l;
+ uint32_t g_comp2_u;
+ uint32_t g_comp2_addr_incr;
+ uint8_t reserved5[0x4];
+ uint32_t g_comp3_l;
+ uint32_t g_comp3_u;
+ uint32_t g_comp3_addr_incr;
+ uint8_t reserved6[0x4];
+ uint32_t g_tcon;
+ uint32_t g_int_cstat;
+ uint32_t g_int_enb;
+ uint32_t g_wstat;
+ uint8_t reserved7[0xb0];
+ uint32_t l0_tcntb;
+ uint32_t l0_tcnto;
+ uint32_t l0_icntb;
+ uint32_t l0_icnto;
+ uint32_t l0_frcntb;
+ uint32_t l0_frcnto;
+ uint8_t reserved8[0x8];
+ uint32_t l0_tcon;
+ uint8_t reserved9[0xc];
+ uint32_t l0_int_cstat;
+ uint32_t l0_int_enb;
+ uint8_t reserved10[0x8];
+ uint32_t l0_wstat;
+ uint8_t reserved11[0xbc];
+ uint32_t l1_tcntb;
+ uint32_t l1_tcnto;
+ uint32_t l1_icntb;
+ uint32_t l1_icnto;
+ uint32_t l1_frcntb;
+ uint32_t l1_frcnto;
+ uint8_t reserved12[0x8];
+ uint32_t l1_tcon;
+ uint8_t reserved13[0xc];
+ uint32_t l1_int_cstat;
+ uint32_t l1_int_enb;
+ uint8_t reserved14[0x8];
+ uint32_t l1_wstat;
+} mct_regs;
+
+/* I would prefer not to export these for now. */
+static uint64_t timer_hz(void)
+{
+ return CONFIG_MCT_HZ;
+}
+
+static int enabled = 0;
+static mct_regs *const mct =
+ (mct_regs *)CONFIG_MCT_ADDRESS;
+
+static uint64_t timer_raw_value(void)
+{
+ if (!enabled) {
+ writel(readl(&mct->g_tcon) | (0x1 << 8), &mct->g_tcon);
+ enabled = 1;
+ }
+
+ uint64_t upper = readl(&mct->g_cnt_u);
+ uint64_t lower = readl(&mct->g_cnt_l);
+
+ return (upper << 32) | lower;
+}
+
+void timer_start(void)
+{
+ writel(readl(&mct->g_tcon) | (0x1 << 8), &mct->g_tcon);
+ enabled = 1;
+}
+
+u32 timer_us(void)
+{
+ uint64_t raw = timer_raw_value();
+ uint32_t ticks_per_microsecond = timer_hz()/1000000;
+ uint32_t usec = raw / ticks_per_microsecond;
+ return usec;
+}
+
diff --git a/src/include/time.h b/src/include/time.h
new file mode 100644
index 0000000..6bd9e08
--- /dev/null
+++ b/src/include/time.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, 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
+ */
+
+#ifndef TIME_H
+#define TIME_H
+
+#if !defined( __ROMCC__)
+
+void timer_start(void);
+u32 timer_us(void);
+#endif
+#endif /* TIME_H */
diff --git a/src/mainboard/google/snow/romstage.c b/src/mainboard/google/snow/romstage.c
index 7a26ed9..b1cc0fd 100644
--- a/src/mainboard/google/snow/romstage.c
+++ b/src/mainboard/google/snow/romstage.c
@@ -36,6 +36,7 @@
#include <cpu/samsung/exynos5250/clock_init.h>
#include <console/console.h>
#include <arch/stages.h>
+#include <time.h>
#include <drivers/maxim/max77686/max77686.h>
#include <device/i2c.h>
@@ -150,6 +151,10 @@ void main(void)
struct arm_clk_ratios *arm_ratios;
int ret;
void *entry;
+ /* kick off the microsecond timer. We want to do this as early
+ * as we can.
+ */
+ timer_start();
clock_set_rate(PERIPH_ID_SPI1, 50000000); /* set spi clock to 50Mhz */
Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3073
-gerrit
commit 68938fdaa0e8a97b392a71521c57c0c6c019d256
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Thu Apr 11 15:03:28 2013 -0700
Exynos5250: add a microsecond timer
Add a microsecond timer, its declaration, the function to start it,
and its usage. To start it, one calls microsecond() for any reason,
using the result or not. From that point on, it returns microseconds
from the first call.
We show its use in romstage. You want it started very early.
Finally, the delay.h changed having been (ironically) delayed,
we create time.h and have it hold one declaration, for the
microseconds prototype.
Change-Id: I19cbc2bb0089a3de88cfb94276266af38b9363c5
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
src/cpu/samsung/exynos5250/Kconfig | 8 +++
src/cpu/samsung/exynos5250/Makefile.inc | 2 +
src/cpu/samsung/exynos5250/mct.c | 122 ++++++++++++++++++++++++++++++++
src/include/time.h | 9 +++
src/mainboard/google/snow/romstage.c | 5 ++
5 files changed, 146 insertions(+)
diff --git a/src/cpu/samsung/exynos5250/Kconfig b/src/cpu/samsung/exynos5250/Kconfig
index cc67abd..a63ccd7 100644
--- a/src/cpu/samsung/exynos5250/Kconfig
+++ b/src/cpu/samsung/exynos5250/Kconfig
@@ -97,3 +97,11 @@ config SYS_TEXT_BASE
config COREBOOT_TABLES_SIZE
hex
default 0x4000000
+
+config MCT_ADDRESS
+ hex
+ default 0x101c0000
+
+config MCT_HZ
+ int
+ default 24000000
diff --git a/src/cpu/samsung/exynos5250/Makefile.inc b/src/cpu/samsung/exynos5250/Makefile.inc
index 74bc871..6652328 100644
--- a/src/cpu/samsung/exynos5250/Makefile.inc
+++ b/src/cpu/samsung/exynos5250/Makefile.inc
@@ -16,6 +16,7 @@ romstage-y += pinmux.c # required by s3c24x0_i2c (exynos5-common) and uart.
romstage-y += dmc_common.c
romstage-y += dmc_init_ddr3.c
romstage-y += power.c
+romstage-y += mct.c
romstage-$(CONFIG_EARLY_CONSOLE) += soc.c
romstage-$(CONFIG_EARLY_CONSOLE) += uart.c
@@ -27,6 +28,7 @@ ramstage-y += power.c
ramstage-y += soc.c
ramstage-$(CONFIG_CONSOLE_SERIAL_UART) += uart.c
ramstage-y += cpu.c
+ramstage-y += mct.c
#ramstage-$(CONFIG_SATA_AHCI) += sata.c
diff --git a/src/cpu/samsung/exynos5250/mct.c b/src/cpu/samsung/exynos5250/mct.c
new file mode 100644
index 0000000..98b8ca8
--- /dev/null
+++ b/src/cpu/samsung/exynos5250/mct.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <arch/io.h>
+#include <stdint.h>
+#include <time.h>
+
+typedef struct __attribute__((packed)) mct_regs
+{
+ uint32_t mct_cfg;
+ uint8_t reserved0[0xfc];
+ uint32_t g_cnt_l;
+ uint32_t g_cnt_u;
+ uint8_t reserved1[0x8];
+ uint32_t g_cnt_wstat;
+ uint8_t reserved2[0xec];
+ uint32_t g_comp0_l;
+ uint32_t g_comp0_u;
+ uint32_t g_comp0_addr_incr;
+ uint8_t reserved3[0x4];
+ uint32_t g_comp1_l;
+ uint32_t g_comp1_u;
+ uint32_t g_comp1_addr_incr;
+ uint8_t reserved4[0x4];
+ uint32_t g_comp2_l;
+ uint32_t g_comp2_u;
+ uint32_t g_comp2_addr_incr;
+ uint8_t reserved5[0x4];
+ uint32_t g_comp3_l;
+ uint32_t g_comp3_u;
+ uint32_t g_comp3_addr_incr;
+ uint8_t reserved6[0x4];
+ uint32_t g_tcon;
+ uint32_t g_int_cstat;
+ uint32_t g_int_enb;
+ uint32_t g_wstat;
+ uint8_t reserved7[0xb0];
+ uint32_t l0_tcntb;
+ uint32_t l0_tcnto;
+ uint32_t l0_icntb;
+ uint32_t l0_icnto;
+ uint32_t l0_frcntb;
+ uint32_t l0_frcnto;
+ uint8_t reserved8[0x8];
+ uint32_t l0_tcon;
+ uint8_t reserved9[0xc];
+ uint32_t l0_int_cstat;
+ uint32_t l0_int_enb;
+ uint8_t reserved10[0x8];
+ uint32_t l0_wstat;
+ uint8_t reserved11[0xbc];
+ uint32_t l1_tcntb;
+ uint32_t l1_tcnto;
+ uint32_t l1_icntb;
+ uint32_t l1_icnto;
+ uint32_t l1_frcntb;
+ uint32_t l1_frcnto;
+ uint8_t reserved12[0x8];
+ uint32_t l1_tcon;
+ uint8_t reserved13[0xc];
+ uint32_t l1_int_cstat;
+ uint32_t l1_int_enb;
+ uint8_t reserved14[0x8];
+ uint32_t l1_wstat;
+} mct_regs;
+
+/* I would prefer not to export these for now. */
+static uint64_t timer_hz(void)
+{
+ return CONFIG_MCT_HZ;
+}
+
+static int enabled = 0;
+static mct_regs *const mct =
+ (mct_regs *)CONFIG_MCT_ADDRESS;
+
+static uint64_t timer_raw_value(void)
+{
+ if (!enabled) {
+ writel(readl(&mct->g_tcon) | (0x1 << 8), &mct->g_tcon);
+ enabled = 1;
+ }
+
+ uint64_t upper = readl(&mct->g_cnt_u);
+ uint64_t lower = readl(&mct->g_cnt_l);
+
+ return (upper << 32) | lower;
+}
+
+void timer_start(void)
+{
+ writel(readl(&mct->g_tcon) | (0x1 << 8), &mct->g_tcon);
+ enabled = 1;
+}
+
+u32 timer_us(void)
+{
+ uint64_t raw = timer_raw_value();
+ uint32_t ticks_per_microsecond = timer_hz()/1000000;
+ uint32_t usec = raw / ticks_per_microsecond;
+ return usec;
+}
+
diff --git a/src/include/time.h b/src/include/time.h
new file mode 100644
index 0000000..da0f3c7
--- /dev/null
+++ b/src/include/time.h
@@ -0,0 +1,9 @@
+#ifndef TIME_H
+#define TIME_H
+
+#if !defined( __ROMCC__)
+
+void timer_start(void);
+u32 timer_us(void);
+#endif
+#endif /* TIME_H */
diff --git a/src/mainboard/google/snow/romstage.c b/src/mainboard/google/snow/romstage.c
index 7a26ed9..b1cc0fd 100644
--- a/src/mainboard/google/snow/romstage.c
+++ b/src/mainboard/google/snow/romstage.c
@@ -36,6 +36,7 @@
#include <cpu/samsung/exynos5250/clock_init.h>
#include <console/console.h>
#include <arch/stages.h>
+#include <time.h>
#include <drivers/maxim/max77686/max77686.h>
#include <device/i2c.h>
@@ -150,6 +151,10 @@ void main(void)
struct arm_clk_ratios *arm_ratios;
int ret;
void *entry;
+ /* kick off the microsecond timer. We want to do this as early
+ * as we can.
+ */
+ timer_start();
clock_set_rate(PERIPH_ID_SPI1, 50000000); /* set spi clock to 50Mhz */
Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3073
-gerrit
commit 06131f43f00a48be09867f4fd552369e5c172299
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Thu Apr 11 15:03:28 2013 -0700
Exynos5250: add a microsecond timer
Add a microsecond timer, its declaration, and its usage.
To start it, one calls microsecond() for any reason, using the
result or not. From that point on, it returns microseconds from the
first call.
We show its use in romstage. You want it started very early.
Finally, the delay.h changed having been (ironically) delayed,
we create time.h and have it hold one declaration, for the
microseconds prototype.
Change-Id: I19cbc2bb0089a3de88cfb94276266af38b9363c5
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
src/cpu/samsung/exynos5250/Kconfig | 8 +++
src/cpu/samsung/exynos5250/Makefile.inc | 2 +
src/cpu/samsung/exynos5250/mct.c | 119 ++++++++++++++++++++++++++++++++
src/include/time.h | 8 +++
src/mainboard/google/snow/romstage.c | 5 ++
5 files changed, 142 insertions(+)
diff --git a/src/cpu/samsung/exynos5250/Kconfig b/src/cpu/samsung/exynos5250/Kconfig
index cc67abd..a63ccd7 100644
--- a/src/cpu/samsung/exynos5250/Kconfig
+++ b/src/cpu/samsung/exynos5250/Kconfig
@@ -97,3 +97,11 @@ config SYS_TEXT_BASE
config COREBOOT_TABLES_SIZE
hex
default 0x4000000
+
+config MCT_ADDRESS
+ hex
+ default 0x101c0000
+
+config MCT_HZ
+ int
+ default 24000000
diff --git a/src/cpu/samsung/exynos5250/Makefile.inc b/src/cpu/samsung/exynos5250/Makefile.inc
index 74bc871..6652328 100644
--- a/src/cpu/samsung/exynos5250/Makefile.inc
+++ b/src/cpu/samsung/exynos5250/Makefile.inc
@@ -16,6 +16,7 @@ romstage-y += pinmux.c # required by s3c24x0_i2c (exynos5-common) and uart.
romstage-y += dmc_common.c
romstage-y += dmc_init_ddr3.c
romstage-y += power.c
+romstage-y += mct.c
romstage-$(CONFIG_EARLY_CONSOLE) += soc.c
romstage-$(CONFIG_EARLY_CONSOLE) += uart.c
@@ -27,6 +28,7 @@ ramstage-y += power.c
ramstage-y += soc.c
ramstage-$(CONFIG_CONSOLE_SERIAL_UART) += uart.c
ramstage-y += cpu.c
+ramstage-y += mct.c
#ramstage-$(CONFIG_SATA_AHCI) += sata.c
diff --git a/src/cpu/samsung/exynos5250/mct.c b/src/cpu/samsung/exynos5250/mct.c
new file mode 100644
index 0000000..5a50b27
--- /dev/null
+++ b/src/cpu/samsung/exynos5250/mct.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <arch/io.h>
+#include <stdint.h>
+#include <time.h>
+
+#include "config.h"
+
+typedef struct __attribute__((packed)) MctRegs
+{
+ uint32_t mct_cfg;
+ uint8_t reserved0[0xfc];
+ uint32_t g_cnt_l;
+ uint32_t g_cnt_u;
+ uint8_t reserved1[0x8];
+ uint32_t g_cnt_wstat;
+ uint8_t reserved2[0xec];
+ uint32_t g_comp0_l;
+ uint32_t g_comp0_u;
+ uint32_t g_comp0_addr_incr;
+ uint8_t reserved3[0x4];
+ uint32_t g_comp1_l;
+ uint32_t g_comp1_u;
+ uint32_t g_comp1_addr_incr;
+ uint8_t reserved4[0x4];
+ uint32_t g_comp2_l;
+ uint32_t g_comp2_u;
+ uint32_t g_comp2_addr_incr;
+ uint8_t reserved5[0x4];
+ uint32_t g_comp3_l;
+ uint32_t g_comp3_u;
+ uint32_t g_comp3_addr_incr;
+ uint8_t reserved6[0x4];
+ uint32_t g_tcon;
+ uint32_t g_int_cstat;
+ uint32_t g_int_enb;
+ uint32_t g_wstat;
+ uint8_t reserved7[0xb0];
+ uint32_t l0_tcntb;
+ uint32_t l0_tcnto;
+ uint32_t l0_icntb;
+ uint32_t l0_icnto;
+ uint32_t l0_frcntb;
+ uint32_t l0_frcnto;
+ uint8_t reserved8[0x8];
+ uint32_t l0_tcon;
+ uint8_t reserved9[0xc];
+ uint32_t l0_int_cstat;
+ uint32_t l0_int_enb;
+ uint8_t reserved10[0x8];
+ uint32_t l0_wstat;
+ uint8_t reserved11[0xbc];
+ uint32_t l1_tcntb;
+ uint32_t l1_tcnto;
+ uint32_t l1_icntb;
+ uint32_t l1_icnto;
+ uint32_t l1_frcntb;
+ uint32_t l1_frcnto;
+ uint8_t reserved12[0x8];
+ uint32_t l1_tcon;
+ uint8_t reserved13[0xc];
+ uint32_t l1_int_cstat;
+ uint32_t l1_int_enb;
+ uint8_t reserved14[0x8];
+ uint32_t l1_wstat;
+} MctRegs;
+
+/* I would prefer not to export these for now. */
+static uint64_t timer_hz(void)
+{
+ return CONFIG_MCT_HZ;
+}
+
+static uint64_t timer_raw_value(void)
+{
+ static int enabled = 0;
+
+ MctRegs * const mct =
+ (MctRegs *)CONFIG_MCT_ADDRESS;
+
+ if (!enabled) {
+ writel(readl(&mct->g_tcon) | (0x1 << 8), &mct->g_tcon);
+ enabled = 1;
+ }
+
+ uint64_t upper = readl(&mct->g_cnt_u);
+ uint64_t lower = readl(&mct->g_cnt_l);
+
+ return (upper << 32) | lower;
+}
+
+u32 microseconds(void)
+{
+ uint64_t raw = timer_raw_value();
+ uint32_t ticks_per_microsecond = timer_hz()/1000000;
+ uint32_t usec = raw / ticks_per_microsecond;
+ return usec;
+}
+
diff --git a/src/include/time.h b/src/include/time.h
new file mode 100644
index 0000000..a4794d0
--- /dev/null
+++ b/src/include/time.h
@@ -0,0 +1,8 @@
+#ifndef TIME_H
+#define TIME_H
+
+#if !defined( __ROMCC__)
+
+u32 microseconds(void);
+#endif
+#endif /* TIME_H */
diff --git a/src/mainboard/google/snow/romstage.c b/src/mainboard/google/snow/romstage.c
index 7a26ed9..a1a99c2 100644
--- a/src/mainboard/google/snow/romstage.c
+++ b/src/mainboard/google/snow/romstage.c
@@ -36,6 +36,7 @@
#include <cpu/samsung/exynos5250/clock_init.h>
#include <console/console.h>
#include <arch/stages.h>
+#include <time.h>
#include <drivers/maxim/max77686/max77686.h>
#include <device/i2c.h>
@@ -150,6 +151,10 @@ void main(void)
struct arm_clk_ratios *arm_ratios;
int ret;
void *entry;
+ /* kick off the microsecond timer. We want to do this as early
+ * as we can.
+ */
+ (void) microseconds();
clock_set_rate(PERIPH_ID_SPI1, 50000000); /* set spi clock to 50Mhz */
the following patch was just integrated into master:
commit 6a1210901dff47a65dac157445f0a76219be0d55
Author: Paul Menzel <paulepanter(a)users.sourceforge.net>
Date: Wed Apr 10 11:33:37 2013 +0200
AMD RS780, SR5650: PcieTrainPort: Fix typo *i*gnoring in comment
Reading the paste of code in a message to the mailing list [1],
a typo was spotted and found in one more place.
$ git grep egnoring
src/southbridge/amd/rs780/cmn.c: * egnoring the reversal case
src/southbridge/amd/sr5650/sr5650.c: * egnoring the reversal case
These typos are there since when the code was committed and are
now corrected.
[1] http://www.coreboot.org/pipermail/coreboot/2013-April/075644.html
Change-Id: I55c65f71e4834f209b60d678f0d44bc2f4217099
Signed-off-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
Reviewed-on: http://review.coreboot.org/3062
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martin.roth(a)se-eng.com>
Build-Tested: build bot (Jenkins) at Wed Apr 10 12:05:17 2013, giving +1
Reviewed-By: Martin Roth <martin.roth(a)se-eng.com> at Thu Apr 11 22:04:19 2013, giving +2
See http://review.coreboot.org/3062 for details.
-gerrit
the following patch was just integrated into master:
commit 573a1d6fa8d72e6d3f738bb889a34b405952046c
Author: Mike Loptien <mike.loptien(a)se-eng.com>
Date: Mon Mar 18 11:19:26 2013 -0600
Persimmon/Fam14/SB800 DSDT: Split into common areas
Split the Persimmon DSDT into common code areas.
For example, split the Southbridge specific code into
the Southbridge directory and CPU specific code into
the CPU directory. Also adding the superio.asl file
to the Persimmon DSDT tree. This file is empty for
the moment but will be necessary in the future. I have
also emptied the thermal.asl file in the mainboard
directory because it does not seem to perform as
intended (fan control does not change when it is
brought back into the code base) and it has been
inside a '#if 0' statement for a long time. Removing
it until it is decided that it is actually necessary.
This change was verified in three different ways:
1. Visual comparison of the compiled DSDT pulled from the
Persimmon after booting into Linux using the ACPI tools
acpidump, acpixtract, and iasl. The comparison was done
between the DSDT before and after doing the split work.
This test is somewhat difficult considering the expanse
of the changes. Blocks of code have been moved, and
others changed.
2. Linux logs were dumped before and after the DSDT split.
Logs dumped and compared include dmesg and lspci -tv.
Neither log changed significantly between the two compare
points.
3. The test suite FWTS was run on the Coreboot build both
before and after doing the DSDT split with the command
'sudo fwts -b -P -u'. The flag -b specifies all batch jobs,
-P specifies all power tests, and -u specifies utilities.
Interactive jobs were not run as most of them consist of
laptop checks. Again, there were no significant changes
between the two endpoints.
These tests lead me to believe that there was no change in
the functionality of the ACPI tables apart from what is
known and expected.
This patch is the first of a series of patches to split the DSDT.
The ASRock patch was merged before this one and breaks the ASROCK
E350M1 build (patch 8d80a3fb: http://review.coreboot.org/#/c/3050/).
Please be aware of this dependency when pulling these patches.
Other patches that depend on this patch are
'AMD Fam14: Split out the AMD Fam14 DSDT'
(http://review.coreboot.org/#/c/3051/)
and 'Fam14 DSDT: Also return for unrecognized UUID in _OSC'
(http://review.coreboot.org/#/c/3052/)
Change-Id: I53ff59909cceb30a08e8eab3d59b30b97c802726
Signed-off-by: Mike Loptien <mike.loptien(a)se-eng.com>
Reviewed-on: http://review.coreboot.org/3048
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martin.roth(a)se-eng.com>
Build-Tested: build bot (Jenkins) at Thu Apr 11 21:38:01 2013, giving +1
Reviewed-By: Martin Roth <martin.roth(a)se-eng.com> at Thu Apr 11 21:48:27 2013, giving +2
See http://review.coreboot.org/3048 for details.
-gerrit
the following patch was just integrated into master:
commit 109a7107436ec142b8028e2b8afc013af80107f1
Author: Paul Menzel <paulepanter(a)users.sourceforge.net>
Date: Thu Apr 11 15:19:04 2013 +0200
libpayload: storage.c: Fix typo in st*orage in comment
Reading commit »libpayload: New AHCI, ATA and ATAPI drivers«
(1f6bd94f) [1], the spelling error was found and is now fixed.
[1] http://review.coreboot.org/1622
Change-Id: Id418bcb99c1a9a400a49fc04078e465bd0908074
Signed-off-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
Reviewed-on: http://review.coreboot.org/3071
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
Build-Tested: build bot (Jenkins) at Thu Apr 11 15:48:47 2013, giving +1
Reviewed-By: Ronald G. Minnich <rminnich(a)gmail.com> at Thu Apr 11 18:09:19 2013, giving +2
See http://review.coreboot.org/3071 for details.
-gerrit
Steven Sherk (steven.sherk(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3072
-gerrit
commit c2339af72b4a8710098517ec1755ea3630822ef9
Author: Steven Sherk <steven.sherk(a)se-eng.com>
Date: Thu Apr 11 08:40:57 2013 -0600
Add new superio device
- Added in new support for Nuvoton NCT5104D LPC device.
Change-Id: I0af8c5e3e46fdd0a549475b30917897ae9e144a7
Signed-off-by: Steven Sherk <steven.sherk(a)se-eng.com>
---
src/superio/nuvoton/Kconfig | 4 +-
src/superio/nuvoton/Makefile.inc | 3 +-
src/superio/nuvoton/nct5104d/Makefile.inc | 23 ++++++++
src/superio/nuvoton/nct5104d/early_init.c | 47 ++++++++++++++++
src/superio/nuvoton/nct5104d/nct5104d.h | 40 ++++++++++++++
src/superio/nuvoton/nct5104d/superio.c | 89 +++++++++++++++++++++++++++++++
6 files changed, 204 insertions(+), 2 deletions(-)
diff --git a/src/superio/nuvoton/Kconfig b/src/superio/nuvoton/Kconfig
index 4865fd5..142738d 100644
--- a/src/superio/nuvoton/Kconfig
+++ b/src/superio/nuvoton/Kconfig
@@ -14,8 +14,10 @@
##
## 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
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
config SUPERIO_NUVOTON_WPCM450
bool
+config SUPERIO_NUVOTON_NCT5104D
+ bool
diff --git a/src/superio/nuvoton/Makefile.inc b/src/superio/nuvoton/Makefile.inc
index c052e91..18025c9 100644
--- a/src/superio/nuvoton/Makefile.inc
+++ b/src/superio/nuvoton/Makefile.inc
@@ -14,7 +14,8 @@
##
## 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
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
subdirs-$(CONFIG_SUPERIO_NUVOTON_WPCM450) += wpcm450
+subdirs-$(CONFIG_SUPERIO_NUVOTON_NCT5104D) += nct5104d
diff --git a/src/superio/nuvoton/nct5104d/Makefile.inc b/src/superio/nuvoton/nct5104d/Makefile.inc
new file mode 100755
index 0000000..b9345aa
--- /dev/null
+++ b/src/superio/nuvoton/nct5104d/Makefile.inc
@@ -0,0 +1,23 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2011 - 2012 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
+##
+
+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
new file mode 100755
index 0000000..9c0cf0f
--- /dev/null
+++ b/src/superio/nuvoton/nct5104d/early_init.c
@@ -0,0 +1,47 @@
+/*
+ * 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 <arch/romcc_io.h>
+#include <device/pnp_def.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);
+}
+
+static 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
new file mode 100755
index 0000000..2f833af
--- /dev/null
+++ b/src/superio/nuvoton/nct5104d/nct5104d.h
@@ -0,0 +1,40 @@
+/*
+ * 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
+ */
+
+#ifndef SUPERIO_NUVOTON_NCT5104D_NCT5104D_H
+#define SUPERIO_NUVOTON_NCT5104D_NCT5104D_H
+
+/* Logical Device Numbers (LDN). */
+#define NCT5104D_SP1 0x02 /* Com1 */
+#define NCT5104D_SP2 0x03 /* Com2 */
+#define NCT5104D_GPIO_WDT 0x08 /* GPIO WDT Interface */
+#define NCT5104D_GPIO_PP_OD 0xF /* GPIO Push-Pull / Open drain select */
+
+/* Virtual Logical Device Numbers (LDN) */
+#define NCT5104D_GPIO_V 0x07 /* GPIO - 0,1,6 Interface */
+
+/* Virtual devices sharing the enables are encoded as follows:
+ VLDN = baseLDN[7:0] | [10:8] bitpos of enable in 0x30 of baseLDN
+*/
+#define NCT5104D_GPIO0 ((0 << 8) | NCT5104D_GPIO_V)
+#define NCT5104D_GPIO1 ((1 << 8) | NCT5104D_GPIO_V)
+#define NCT5104D_GPIO6 ((6 << 8) | NCT5104D_GPIO_V)
+
+#endif
diff --git a/src/superio/nuvoton/nct5104d/superio.c b/src/superio/nuvoton/nct5104d/superio.c
new file mode 100755
index 0000000..3c78cbc
--- /dev/null
+++ b/src/superio/nuvoton/nct5104d/superio.c
@@ -0,0 +1,89 @@
+/*
+ * 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 <stdlib.h>
+#include "nct5104d.h"
+
+static void pnp_enter_exteded_mode(device_t dev)
+{
+ outb(0x87,dev->path.pnp.port);
+ outb(0x87,dev->path.pnp.port);
+}
+
+static void pnp_exit_extended_mode(device_t dev)
+{
+ outb(0xaa,dev->path.pnp.port);
+}
+
+static void nct5104d_init(device_t dev)
+{
+}
+
+static void nct5104d_pnp_set_resources(device_t dev)
+{
+ pnp_enter_exteded_mode(dev);
+ pnp_set_resources(dev);
+ pnp_exit_extended_mode(dev);
+}
+
+static void nct5104d_pnp_enable_resources(device_t dev)
+{
+ pnp_enter_exteded_mode(dev);
+ pnp_enable_resources(dev);
+ pnp_exit_extended_mode(dev);
+}
+
+static void nct5104d_pnp_enable(device_t dev)
+{
+ pnp_enter_exteded_mode(dev);
+ pnp_set_logical_device(dev);
+ (dev->enabled) ? pnp_set_enable(dev,1) : pnp_set_enable(dev,0);
+ pnp_exit_extended_mode(dev);
+}
+
+static struct device_operations ops = {
+ .read_resources = pnp_read_resources,
+ .set_resources = nct5104d_pnp_set_resources,
+ .enable_resources = nct5104d_pnp_enable_resources,
+ .enable = nct5104d_pnp_enable,
+ .init = nct5104d_init,
+};
+
+static struct pnp_info pnp_dev_info[] = {
+ { &ops, NCT5104D_SP2, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, NCT5104D_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
+ { &ops, NCT5104D_GPIO_WDT},
+ { &ops, NCT5104D_GPIO_PP_OD},
+ { &ops, NCT5104D_GPIO0},
+ { &ops, NCT5104D_GPIO1},
+ { &ops, NCT5104D_GPIO6},
+};
+
+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_nct5104d_ops = {
+ CHIP_NAME("NUVOTON NCT5104D Super I/O")
+ .enable_dev = enable_dev,
+};