SIO: Winbond w83627dhg update
authorKerry Sheh <shekairui@gmail.com>
Tue, 7 Feb 2012 12:32:37 +0000 (20:32 +0800)
committerMarc Jones <marcj303@gmail.com>
Thu, 16 Feb 2012 20:08:50 +0000 (21:08 +0100)
1. Stop include c file.
2. W83627dhg Pin 89, Pin 90 are multi function pins,
   add support to select them to I2C function.

Change-Id: I42eaaf7d70aa48d7edf2710349b51e401526c1a6
Signed-off-by: Kerry Sheh <kerry.she@amd.com>
Signed-off-by: Kerry Sheh <shekairui@gmail.com>
Reviewed-on: http://review.coreboot.org/565
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marcj303@gmail.com>
src/mainboard/asrock/939a785gmh/romstage.c
src/mainboard/kontron/kt690/romstage.c
src/superio/winbond/w83627dhg/Makefile.inc
src/superio/winbond/w83627dhg/early_serial.c
src/superio/winbond/w83627dhg/superio.c
src/superio/winbond/w83627dhg/w83627dhg.h

index 3183c1c1f203bb565153d04e4736955d5b9b1dd2..4a1b1c30ab13fbbd13a29dfb6f39266c0ff055c2 100644 (file)
@@ -39,7 +39,7 @@
 #include <spd.h>
 #include "cpu/x86/lapic/boot_cpu.c"
 #include "northbridge/amd/amdk8/reset_test.c"
-#include "superio/winbond/w83627dhg/early_serial.c"
+#include "superio/winbond/w83627dhg/w83627dhg.h"
 #include "cpu/x86/mtrr/earlymtrr.c"
 #include "cpu/x86/bist.h"
 #include "northbridge/amd/amdk8/setup_resource_map.c"
index f2525e31d0aebabe812d747daee9798a2f35a496..621c27f6b6d1c10b5b2c0be0eaa1684ab5e7d898 100644 (file)
@@ -40,7 +40,7 @@
 #include "cpu/x86/lapic/boot_cpu.c"
 #include "northbridge/amd/amdk8/reset_test.c"
 #include "northbridge/amd/amdk8/debug.c"
-#include "superio/winbond/w83627dhg/early_serial.c"
+#include "superio/winbond/w83627dhg/w83627dhg.h"
 #include <cpu/amd/mtrr.h>
 #include "cpu/x86/bist.h"
 #include "northbridge/amd/amdk8/setup_resource_map.c"
index 0b0bb8b40cd4972faba2870d382c2170cf0e662d..09df47e523fc7dad37b7f3b7926c50397917b487 100644 (file)
@@ -2,6 +2,7 @@
 ## This file is part of the coreboot project.
 ##
 ## Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 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
@@ -18,5 +19,6 @@
 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 ##
 
+romstage-$(CONFIG_SUPERIO_WINBOND_W83627DHG) += early_serial.c
 ramstage-$(CONFIG_SUPERIO_WINBOND_W83627DHG) += superio.c
 
index f530dc679777106e9b81cbfc08da7e36fa39148b..e0be8dee756add56efc2ba7a3e609129a3ae0395 100644 (file)
@@ -2,6 +2,7 @@
  * This file is part of the coreboot project.
  *
  * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 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
  * 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 <stdint.h>
 #include "w83627dhg.h"
 
-static void pnp_enter_ext_func_mode(device_t dev)
+void pnp_enter_ext_func_mode(device_t dev)
 {
        u16 port = dev >> 8;
        outb(0x87, port);
        outb(0x87, port);
 }
 
-static void pnp_exit_ext_func_mode(device_t dev)
+void pnp_exit_ext_func_mode(device_t dev)
 {
        u16 port = dev >> 8;
        outb(0xaa, port);
 }
 
-static void w83627dhg_enable_serial(device_t dev, u16 iobase)
+void w83627dhg_enable_serial(device_t dev, u16 iobase)
 {
        pnp_enter_ext_func_mode(dev);
        pnp_set_logical_device(dev);
@@ -44,3 +47,23 @@ static void w83627dhg_enable_serial(device_t dev, u16 iobase)
        pnp_set_enable(dev, 1);
        pnp_exit_ext_func_mode(dev);
 }
+
+/**
+ * Select Pin 89, Pin 90 function as I2C interface SDA, SCL.
+ *  {Pin 89, Pin 90} function can be selected as {GP33, GP32}, or
+ *  {RSTOUT3#, RSTOUT2#} or {SDA, SCL}
+ */
+void w83627dhg_enable_i2c(device_t dev)
+{
+       u8 val;
+
+       pnp_enter_ext_func_mode(dev);
+       pnp_set_logical_device(dev);
+
+       val = pnp_read_config(dev, 0x2A);
+       val |= 1 << 1;
+       pnp_write_config(dev, 0x2A, val);
+
+       pnp_exit_ext_func_mode(dev);
+}
+
index 1771c269e2d23f40dacce6943da5fe5c0f860bb6..a936ce1e6c3adaa392503efffc472fdafc995d0c 100644 (file)
 #include "chip.h"
 #include "w83627dhg.h"
 
-static void pnp_enter_ext_func_mode(device_t dev)
+void pnp_enter_ext_func_mode(device_t dev)
 {
        outb(0x87, dev->path.pnp.port);
        outb(0x87, dev->path.pnp.port);
 }
 
-static void pnp_exit_ext_func_mode(device_t dev)
+void pnp_exit_ext_func_mode(device_t dev)
 {
        outb(0xaa, dev->path.pnp.port);
 }
index 74761e988445fd427e86b644978968027434fad4..158e60b1446a46fc0defe2953b05dcbc5845320c 100644 (file)
@@ -2,6 +2,7 @@
  * This file is part of the coreboot project.
  *
  * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 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
@@ -51,4 +52,9 @@
 
 /* Note: There is no GPIO1 on the W83627DHG as per datasheet. */
 
+void pnp_enter_ext_func_mode(device_t dev);
+void pnp_exit_ext_func_mode(device_t dev);
+void w83627dhg_enable_serial(device_t dev, u16 iobase);
+void w83627dhg_enable_i2c(device_t dev);
+
 #endif