the following patch was just integrated into master:
commit 8b38d485d3d996b2db5e7e2078625de34110ca8d
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Mar 13 03:33:35 2014 +1100
mainboard/jetway/nf81-t56n-lf: Fix HWM base addr.
The target board has a different base addr. for its hardware
monitor (fans, temp, etc) from the Fintek Super I/O datasheet.
Change-Id: Ifc025cb92d0fc4e8f813091d00a6c87deae05863
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
See http://review.coreboot.org/5383 for details.
-gerrit
the following patch was just integrated into master:
commit 40db3d0d04ef2f4d4dbbfe68acbe0dbc07fce58e
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Mar 13 01:08:31 2014 +1100
mainboard/jetway/nf81-t56n-lf: Remove hard-coded IMC fan craft.
Fan controls in 0x400-0x4ff are not programmed here. Thus fan
control from amd/persimmon in the devicetree.cb does not apply
to this board.
Change-Id: I9156143476df0a7b44c7af90fa2107e8a8ba851e
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
See http://review.coreboot.org/5381 for details.
-gerrit
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5385
-gerrit
commit 0c7361e6d2be744e9e45aee0e1e83f6fd02727f4
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Fri Mar 14 01:06:22 2014 +1100
drivers/hwm: Add a generic hwm driver.
Make generic, testing with Fintek Super I/O....
Change-Id: Ic7bdea55907e379aad9e74b87b514e8038ef9fd0
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/drivers/Kconfig | 1 +
src/drivers/hwm/Kconfig | 6 +++
src/drivers/hwm/Makefile.inc | 20 +++++++
src/drivers/hwm/superio_hwm.c | 122 ++++++++++++++++++++++++++++++++++++++++++
src/drivers/hwm/superio_hwm.h | 30 +++++++++++
5 files changed, 179 insertions(+)
diff --git a/src/drivers/Kconfig b/src/drivers/Kconfig
index 5267ff8..6b793d9 100644
--- a/src/drivers/Kconfig
+++ b/src/drivers/Kconfig
@@ -40,3 +40,4 @@ source src/drivers/trident/Kconfig
source src/drivers/uart/Kconfig
source src/drivers/usb/Kconfig
source src/drivers/xpowers/Kconfig
+source src/drivers/hwm/Kconfig
diff --git a/src/drivers/hwm/Kconfig b/src/drivers/hwm/Kconfig
new file mode 100644
index 0000000..72ae2bd
--- /dev/null
+++ b/src/drivers/hwm/Kconfig
@@ -0,0 +1,6 @@
+config SUPERIO_HWM
+ bool "Super I/O HWM"
+ default n
+ help
+ Just enough of a driver to make coreboot control system fans.
+ No configuration is necessary for the OS to pick up the device.
diff --git a/src/drivers/hwm/Makefile.inc b/src/drivers/hwm/Makefile.inc
new file mode 100644
index 0000000..9777667
--- /dev/null
+++ b/src/drivers/hwm/Makefile.inc
@@ -0,0 +1,20 @@
+##
+## This file is part of the coreboot project.
+##
+## 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
+##
+
+ramstage-$(CONFIG_SUPERIO_HWM) += superio_hwm.c
diff --git a/src/drivers/hwm/superio_hwm.c b/src/drivers/hwm/superio_hwm.c
new file mode 100644
index 0000000..b0b080b
--- /dev/null
+++ b/src/drivers/hwm/superio_hwm.c
@@ -0,0 +1,122 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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; 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
+ */
+
+/* This code should work for all Fintek Super I/O HWM's. */
+#include <arch/io.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <stdlib.h>
+#include "superio_hwm.h"
+
+/* Helper functions */
+static void pnp_write_index(u16 port, u8 reg, u8 value)
+{
+ outb(reg, port);
+ outb(value, port + 1);
+}
+
+static u8 pnp_read_index(u16 port, u8 reg)
+{
+ outb(reg, port);
+ return inb(port + 1);
+}
+/* .. */
+
+/* Initialize F71869AD hardware monitor registers, which are at 0x225. */
+/* XXX: make configurable.. */
+static void init_registers(u16 base)
+{
+ u8 reg, value;
+ int i;
+
+ /* XXX: work out correct values??? */
+ u8 hwm_reg_values[] = {
+ /* reg mask data */
+ 0x40, 0xff, 0x81, /* Start HWM. */
+ 0x48, 0xaa, 0x2a, /* Set SMBus base to 0x2a (0x54 >> 1). */
+ 0x4a, 0x21, 0x21, /* Set T2 SMBus base to 0x92>>1 and T3 SMBus base to 0x94>>1. */
+ 0x4e, 0x80, 0x00,
+ 0x43, 0x00, 0xff,
+ 0x44, 0x00, 0x3f,
+ 0x4c, 0xbf, 0x18,
+ 0x4d, 0xff, 0x80, /* Turn off beep */
+ };
+
+ for (i = 0; i < ARRAY_SIZE(hwm_reg_values); i += 3) {
+ reg = hwm_reg_values[i];
+ value = pnp_read_index(base, reg);
+ value &= 0xff & hwm_reg_values[i + 1];
+ value |= 0xff & hwm_reg_values[i + 2];
+ printk(BIOS_DEBUG, "base = 0x%04x, reg = 0x%02x, "
+ "value = 0x%02x\n", base, reg, value);
+ pnp_write_index(base, reg, value);
+ }
+}
+/* .. */
+
+/* Main driver */
+static void hwm_init(device_t dev)
+{
+ /* return if hwm is disabled in devicetree.cb */
+ struct drivers_superio_hwm_config *config = dev->chip_info;
+ if (!dev->enabled || !config)
+ return;
+
+ if (!dev->path.type == DEVICE_PATH_PNP)
+ return;
+
+ u32 hwm_base = config->base;
+
+ printk(BIOS_DEBUG, "Super I/O: Initializing Hardware Monitor at 0x%08x\n"
+ , hwm_base);
+
+ struct resource *res = find_resource(dev, PNP_IDX_IO0);
+ if (!res) {
+ printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n");
+ return;
+ }
+
+ printk(BIOS_DEBUG, "Super I/O HWM: HWM BAR: 0x%x\n", (u32)res->base);
+ printk(BIOS_WARNING, "Super I/O HWM: Configuring registers...\n");
+// XXX: be sure we are getting the right base addr passed (0x225) first!
+// init_registers(res->base);
+}
+
+static void hwm_noop(device_t dummy)
+{
+}
+
+static struct device_operations hwm_ops = {
+ .read_resources = hwm_noop,
+ .set_resources = hwm_noop,
+ .enable_resources = hwm_noop,
+ .init = hwm_init,
+};
+
+static void enable_dev(device_t dev)
+{
+ dev->ops = &hwm_ops;
+}
+
+struct chip_operations hwm_fintek_ops = {
+ CHIP_NAME("Super I/O Hardware Monitor.")
+ .enable_dev = enable_dev
+};
diff --git a/src/drivers/hwm/superio_hwm.h b/src/drivers/hwm/superio_hwm.h
new file mode 100644
index 0000000..34957be
--- /dev/null
+++ b/src/drivers/hwm/superio_hwm.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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
+ */
+
+#ifndef DRIVERS_SUPERIO_HWM_H
+#define DRIVERS_SUPERIO_HWM_H
+
+#include <device/device.h>
+
+/* Initialization parameters?? */
+typedef struct drivers_superio_hwm_config {
+ u32 base;
+} hwm_config_t;
+
+#endif /* DRIVERS_SUPERIO_HWM_H */
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5385
-gerrit
commit 9463a84c3c3003498c01ac2598e07aac06c3fcfd
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Fri Mar 14 01:06:22 2014 +1100
drivers/hwm: Add a generic hwm driver.
Make generic, testing with Fintek Super I/O....
Change-Id: Ic7bdea55907e379aad9e74b87b514e8038ef9fd0
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/drivers/Kconfig | 1 +
src/drivers/hwm/Kconfig | 6 +++
src/drivers/hwm/Makefile.inc | 20 ++++++++
src/drivers/hwm/superio_hwm.c | 114 ++++++++++++++++++++++++++++++++++++++++++
src/include/hwm/superio_hwm.h | 10 ++++
5 files changed, 151 insertions(+)
diff --git a/src/drivers/Kconfig b/src/drivers/Kconfig
index 5267ff8..6b793d9 100644
--- a/src/drivers/Kconfig
+++ b/src/drivers/Kconfig
@@ -40,3 +40,4 @@ source src/drivers/trident/Kconfig
source src/drivers/uart/Kconfig
source src/drivers/usb/Kconfig
source src/drivers/xpowers/Kconfig
+source src/drivers/hwm/Kconfig
diff --git a/src/drivers/hwm/Kconfig b/src/drivers/hwm/Kconfig
new file mode 100644
index 0000000..72ae2bd
--- /dev/null
+++ b/src/drivers/hwm/Kconfig
@@ -0,0 +1,6 @@
+config SUPERIO_HWM
+ bool "Super I/O HWM"
+ default n
+ help
+ Just enough of a driver to make coreboot control system fans.
+ No configuration is necessary for the OS to pick up the device.
diff --git a/src/drivers/hwm/Makefile.inc b/src/drivers/hwm/Makefile.inc
new file mode 100644
index 0000000..9777667
--- /dev/null
+++ b/src/drivers/hwm/Makefile.inc
@@ -0,0 +1,20 @@
+##
+## This file is part of the coreboot project.
+##
+## 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
+##
+
+ramstage-$(CONFIG_SUPERIO_HWM) += superio_hwm.c
diff --git a/src/drivers/hwm/superio_hwm.c b/src/drivers/hwm/superio_hwm.c
new file mode 100644
index 0000000..4f21f4d
--- /dev/null
+++ b/src/drivers/hwm/superio_hwm.c
@@ -0,0 +1,114 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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; 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
+ */
+
+/* This code should work for all Fintek Super I/O HWM's. */
+#include <arch/io.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <stdlib.h>
+#include <hwm/superio_hwm.h>
+
+/* Helper functions */
+static void pnp_write_index(u16 port, u8 reg, u8 value)
+{
+ outb(reg, port);
+ outb(value, port + 1);
+}
+
+static u8 pnp_read_index(u16 port, u8 reg)
+{
+ outb(reg, port);
+ return inb(port + 1);
+}
+/* .. */
+
+/* Initialize F71869AD hardware monitor registers, which are at 0x225. */
+/* XXX: make configurable.. */
+static void init_registers(u16 base)
+{
+ u8 reg, value;
+ int i;
+
+ /* XXX: work out correct values??? */
+ u8 hwm_reg_values[] = {
+ /* reg mask data */
+ 0x40, 0xff, 0x81, /* Start HWM. */
+ 0x48, 0xaa, 0x2a, /* Set SMBus base to 0x2a (0x54 >> 1). */
+ 0x4a, 0x21, 0x21, /* Set T2 SMBus base to 0x92>>1 and T3 SMBus base to 0x94>>1. */
+ 0x4e, 0x80, 0x00,
+ 0x43, 0x00, 0xff,
+ 0x44, 0x00, 0x3f,
+ 0x4c, 0xbf, 0x18,
+ 0x4d, 0xff, 0x80, /* Turn off beep */
+ };
+
+ for (i = 0; i < ARRAY_SIZE(hwm_reg_values); i += 3) {
+ reg = hwm_reg_values[i];
+ value = pnp_read_index(base, reg);
+ value &= 0xff & hwm_reg_values[i + 1];
+ value |= 0xff & hwm_reg_values[i + 2];
+ printk(BIOS_DEBUG, "base = 0x%04x, reg = 0x%02x, "
+ "value = 0x%02x\n", base, reg, value);
+ pnp_write_index(base, reg, value);
+ }
+}
+/* .. */
+
+/* Main driver */
+static void hwm_init(device_t dev)
+{
+ /* return if hwm is disabled in devicetree.cb */
+ if (!dev->enabled || !dev->path.type == DEVICE_PATH_PNP)
+ return;
+
+ printk(BIOS_DEBUG, "Initializing Super I/O Hardware Monitor..\n");
+
+ struct resource *res = find_resource(dev, PNP_IDX_IO0);
+ if (!res) {
+ printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n");
+ return;
+ }
+
+ printk(BIOS_DEBUG, "Super I/O HWM: HWM BAR: 0x%x\n", (u32)res->base);
+ printk(BIOS_WARNING, "Super I/O HWM: Configuring registers...\n");
+ init_registers(res->base);
+}
+
+static void hwm_noop(device_t dummy)
+{
+}
+
+static struct device_operations hwm_ops = {
+ .read_resources = hwm_noop,
+ .set_resources = hwm_noop,
+ .enable_resources = hwm_noop,
+ .init = hwm_init,
+};
+
+static void enable_dev(device_t dev)
+{
+ dev->ops = &hwm_ops;
+}
+
+struct chip_operations hwm_fintek_ops = {
+ CHIP_NAME("Super I/O Hardware Monitor.")
+ .enable_dev = enable_dev
+};
diff --git a/src/include/hwm/superio_hwm.h b/src/include/hwm/superio_hwm.h
new file mode 100644
index 0000000..c2cf731
--- /dev/null
+++ b/src/include/hwm/superio_hwm.h
@@ -0,0 +1,10 @@
+#ifndef SUPERIO_HWM_H
+#define SUPERIO_HWM_H
+
+#include <device/device.h>
+
+/* Initialization parameters struct?? */
+
+void hwm_init(device_t dev, u16 iobase);
+
+#endif /* SUPERIO_HWM_H */
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5383
-gerrit
commit 8b38d485d3d996b2db5e7e2078625de34110ca8d
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Thu Mar 13 03:33:35 2014 +1100
mainboard/jetway/nf81-t56n-lf: Fix HWM base addr.
The target board has a different base addr. for its hardware
monitor (fans, temp, etc) from the Fintek Super I/O datasheet.
Change-Id: Ifc025cb92d0fc4e8f813091d00a6c87deae05863
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/mainboard/jetway/nf81-t56n-lf/devicetree.cb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mainboard/jetway/nf81-t56n-lf/devicetree.cb b/src/mainboard/jetway/nf81-t56n-lf/devicetree.cb
index 99b2266..5f49b41 100644
--- a/src/mainboard/jetway/nf81-t56n-lf/devicetree.cb
+++ b/src/mainboard/jetway/nf81-t56n-lf/devicetree.cb
@@ -80,7 +80,7 @@ chip northbridge/amd/agesa/family14/root_complex
drq 0x74 = 3
end
device pnp 2e.04 on # Hardware Monitor
- io 0x60 = 0x295
+ io 0x60 = 0x225 # Fintek datasheet says 0x295.
irq 0x70 = 0
end
device pnp 2e.05 on # KBC
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5385
-gerrit
commit 9df2762597d6762093b5d8570d3de4df5d43ea0c
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Fri Mar 14 01:06:22 2014 +1100
drivers/hwm: Add a generic hwm driver.
Make generic, testing with Fintek Super I/O....
Change-Id: Ic7bdea55907e379aad9e74b87b514e8038ef9fd0
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/drivers/Kconfig | 1 +
src/drivers/hwm/Kconfig | 6 +++
src/drivers/hwm/Makefile.inc | 20 ++++++++
src/drivers/hwm/superio_hwm.c | 110 ++++++++++++++++++++++++++++++++++++++++++
src/include/hwm/superio_hwm.h | 10 ++++
5 files changed, 147 insertions(+)
diff --git a/src/drivers/Kconfig b/src/drivers/Kconfig
index 5267ff8..6b793d9 100644
--- a/src/drivers/Kconfig
+++ b/src/drivers/Kconfig
@@ -40,3 +40,4 @@ source src/drivers/trident/Kconfig
source src/drivers/uart/Kconfig
source src/drivers/usb/Kconfig
source src/drivers/xpowers/Kconfig
+source src/drivers/hwm/Kconfig
diff --git a/src/drivers/hwm/Kconfig b/src/drivers/hwm/Kconfig
new file mode 100644
index 0000000..72ae2bd
--- /dev/null
+++ b/src/drivers/hwm/Kconfig
@@ -0,0 +1,6 @@
+config SUPERIO_HWM
+ bool "Super I/O HWM"
+ default n
+ help
+ Just enough of a driver to make coreboot control system fans.
+ No configuration is necessary for the OS to pick up the device.
diff --git a/src/drivers/hwm/Makefile.inc b/src/drivers/hwm/Makefile.inc
new file mode 100644
index 0000000..9777667
--- /dev/null
+++ b/src/drivers/hwm/Makefile.inc
@@ -0,0 +1,20 @@
+##
+## This file is part of the coreboot project.
+##
+## 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
+##
+
+ramstage-$(CONFIG_SUPERIO_HWM) += superio_hwm.c
diff --git a/src/drivers/hwm/superio_hwm.c b/src/drivers/hwm/superio_hwm.c
new file mode 100644
index 0000000..392d4e6
--- /dev/null
+++ b/src/drivers/hwm/superio_hwm.c
@@ -0,0 +1,110 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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; 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
+ */
+
+/* This code should work for all Fintek Super I/O HWM's. */
+#include <arch/io.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <stdlib.h>
+#include <hwm/superio_hwm.h>
+
+/* Helper functions */
+static void pnp_write_index(u16 port, u8 reg, u8 value)
+{
+ outb(reg, port);
+ outb(value, port + 1);
+}
+
+static u8 pnp_read_index(u16 port, u8 reg)
+{
+ outb(reg, port);
+ return inb(port + 1);
+}
+/* .. */
+
+/* Initialize F71869AD hardware monitor registers, which are at 0x225. */
+/* XXX: make configurable.. */
+static void init_registers(u16 base)
+{
+ u8 reg, value;
+ int i;
+
+ /* XXX: work out correct values??? */
+ u8 hwm_reg_values[] = {
+ /* reg mask data */
+ 0x40, 0xff, 0x81, /* Start HWM. */
+ 0x48, 0xaa, 0x2a, /* Set SMBus base to 0x2a (0x54 >> 1). */
+ 0x4a, 0x21, 0x21, /* Set T2 SMBus base to 0x92>>1 and T3 SMBus base to 0x94>>1. */
+ 0x4e, 0x80, 0x00,
+ 0x43, 0x00, 0xff,
+ 0x44, 0x00, 0x3f,
+ 0x4c, 0xbf, 0x18,
+ 0x4d, 0xff, 0x80, /* Turn off beep */
+ };
+
+ for (i = 0; i < ARRAY_SIZE(hwm_reg_values); i += 3) {
+ reg = hwm_reg_values[i];
+ value = pnp_read_index(base, reg);
+ value &= 0xff & hwm_reg_values[i + 1];
+ value |= 0xff & hwm_reg_values[i + 2];
+ printk(BIOS_DEBUG, "base = 0x%04x, reg = 0x%02x, "
+ "value = 0x%02x\n", base, reg, value);
+ pnp_write_index(base, reg, value);
+ }
+}
+/* .. */
+
+/* Main driver */
+void hwm_init(device_t dev, u16 iobase)
+{
+// struct resource *res0;
+
+ if (!CONFIG_DRIVERS_SUPERIO_HWM)
+ return;
+
+ printk(BIOS_DEBUG, "Initializing Fintek Hardware Monitor..\n");
+// res0 = find_resource(dev, PNP_IDX_IO0);
+// init_registers(res0->base);
+ init_registers(iobase);
+}
+
+/*
+static void hwm_noop(device_t dummy)
+{
+}
+
+static struct device_operations hwm_ops = {
+ .read_resources = hwm_noop,
+ .set_resources = hwm_noop,
+ .enable_resources = hwm_noop,
+ .init = hwm_init,
+};
+
+static void enable_dev(struct device *dev)
+{
+ dev->ops = &hwm_ops;
+}
+
+struct chip_operations hwm_fintek_ops = {
+ CHIP_NAME("Fintek F71869AD Super I/O HWM")
+ .enable_dev = enable_dev
+};
+*/
diff --git a/src/include/hwm/superio_hwm.h b/src/include/hwm/superio_hwm.h
new file mode 100644
index 0000000..c2cf731
--- /dev/null
+++ b/src/include/hwm/superio_hwm.h
@@ -0,0 +1,10 @@
+#ifndef SUPERIO_HWM_H
+#define SUPERIO_HWM_H
+
+#include <device/device.h>
+
+/* Initialization parameters struct?? */
+
+void hwm_init(device_t dev, u16 iobase);
+
+#endif /* SUPERIO_HWM_H */
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5385
-gerrit
commit 0adce5edb8071c43ab34d6ace57e441ffd16822f
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Fri Mar 14 01:06:22 2014 +1100
drivers/hwm: Add a generic hwm driver.
Make generic, testing with Fintek Super I/O....
Change-Id: Ic7bdea55907e379aad9e74b87b514e8038ef9fd0
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/drivers/Kconfig | 1 +
src/drivers/hwm/Kconfig | 6 +++
src/drivers/hwm/Makefile.inc | 20 ++++++++
src/drivers/hwm/superio_hwm.c | 109 ++++++++++++++++++++++++++++++++++++++++++
src/include/hwm/superio_hwm.h | 8 ++++
5 files changed, 144 insertions(+)
diff --git a/src/drivers/Kconfig b/src/drivers/Kconfig
index 5267ff8..6b793d9 100644
--- a/src/drivers/Kconfig
+++ b/src/drivers/Kconfig
@@ -40,3 +40,4 @@ source src/drivers/trident/Kconfig
source src/drivers/uart/Kconfig
source src/drivers/usb/Kconfig
source src/drivers/xpowers/Kconfig
+source src/drivers/hwm/Kconfig
diff --git a/src/drivers/hwm/Kconfig b/src/drivers/hwm/Kconfig
new file mode 100644
index 0000000..72ae2bd
--- /dev/null
+++ b/src/drivers/hwm/Kconfig
@@ -0,0 +1,6 @@
+config SUPERIO_HWM
+ bool "Super I/O HWM"
+ default n
+ help
+ Just enough of a driver to make coreboot control system fans.
+ No configuration is necessary for the OS to pick up the device.
diff --git a/src/drivers/hwm/Makefile.inc b/src/drivers/hwm/Makefile.inc
new file mode 100644
index 0000000..9777667
--- /dev/null
+++ b/src/drivers/hwm/Makefile.inc
@@ -0,0 +1,20 @@
+##
+## This file is part of the coreboot project.
+##
+## 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
+##
+
+ramstage-$(CONFIG_SUPERIO_HWM) += superio_hwm.c
diff --git a/src/drivers/hwm/superio_hwm.c b/src/drivers/hwm/superio_hwm.c
new file mode 100644
index 0000000..8d7a69f
--- /dev/null
+++ b/src/drivers/hwm/superio_hwm.c
@@ -0,0 +1,109 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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; 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
+ */
+
+/* This code should work for all Fintek Super I/O HWM's. */
+#include <arch/io.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <stdlib.h>
+#include <hwm/superio_hwm.h>
+
+/* Helper functions */
+static void pnp_write_index(u16 port, u8 reg, u8 value)
+{
+ outb(reg, port);
+ outb(value, port + 1);
+}
+
+static u8 pnp_read_index(u16 port, u8 reg)
+{
+ outb(reg, port);
+ return inb(port + 1);
+}
+/* .. */
+
+/* Initialize F71869AD hardware monitor registers, which are at 0x225. */
+/* XXX: make configurable.. */
+static void init_registers(u16 base)
+{
+ u8 reg, value;
+ int i;
+
+ /* XXX: work out correct values??? */
+ u8 hwm_reg_values[] = {
+ /* reg mask data */
+ 0x40, 0xff, 0x81, /* Start HWM. */
+ 0x48, 0xaa, 0x2a, /* Set SMBus base to 0x2a (0x54 >> 1). */
+ 0x4a, 0x21, 0x21, /* Set T2 SMBus base to 0x92>>1 and T3 SMBus base to 0x94>>1. */
+ 0x4e, 0x80, 0x00,
+ 0x43, 0x00, 0xff,
+ 0x44, 0x00, 0x3f,
+ 0x4c, 0xbf, 0x18,
+ 0x4d, 0xff, 0x80, /* Turn off beep */
+ };
+
+ for (i = 0; i < ARRAY_SIZE(hwm_reg_values); i += 3) {
+ reg = hwm_reg_values[i];
+ value = pnp_read_index(base, reg);
+ value &= 0xff & hwm_reg_values[i + 1];
+ value |= 0xff & hwm_reg_values[i + 2];
+ printk(BIOS_DEBUG, "base = 0x%04x, reg = 0x%02x, "
+ "value = 0x%02x\n", base, reg, value);
+ pnp_write_index(base, reg, value);
+ }
+}
+/* .. */
+
+/* Main driver */
+static void hwm_init(struct device *dev)
+{
+ struct resource *res0;
+
+ if (!CONFIG_DRIVERS_FINTEK_HWM)
+ return;
+
+ printk(BIOS_DEBUG, "Initializing Fintek Hardware Monitor..\n");
+ res0 = find_resource(dev, PNP_IDX_IO0);
+ init_registers(res0->base);
+}
+
+/*
+static void hwm_noop(device_t dummy)
+{
+}
+
+static struct device_operations hwm_ops = {
+ .read_resources = hwm_noop,
+ .set_resources = hwm_noop,
+ .enable_resources = hwm_noop,
+ .init = hwm_init,
+};
+
+static void enable_dev(struct device *dev)
+{
+ dev->ops = &hwm_ops;
+}
+
+struct chip_operations hwm_fintek_ops = {
+ CHIP_NAME("Fintek F71869AD Super I/O HWM")
+ .enable_dev = enable_dev
+};
+*/
diff --git a/src/include/hwm/superio_hwm.h b/src/include/hwm/superio_hwm.h
new file mode 100644
index 0000000..5911093
--- /dev/null
+++ b/src/include/hwm/superio_hwm.h
@@ -0,0 +1,8 @@
+#ifndef SUPERIO_HWM_H
+#define SUPERIO_HWM_H
+
+/* Initialization parameters struct?? */
+
+void hwm_init(struct fintek_hwm *hwm);
+
+#endif /* SUPERIO_HWM_H */