[coreboot-gerrit] New patch to review for coreboot: IT8772F: Clean up it8772f includes and add a LED API

Matt DeVillier (matt.devillier@gmail.com) gerrit at coreboot.org
Thu Dec 24 21:29:10 CET 2015


Matt DeVillier (matt.devillier at gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12797

-gerrit

commit 19c91c12724c9781d7f8f49cd9197ee55b02b10b
Author: david <david_wu at quantatw.com>
Date:   Mon Jan 19 17:11:36 2015 +0800

    IT8772F: Clean up it8772f includes and add a LED API
    
    - Remove it8772f c includes
    - Add a new LED API, it8772f_gpio_led
    - Stumpy: using it8772f_gpio_led
    
    BUG=chrome-os-partner:28232
    BRANCH=Guado
    TEST=emerge-guado coreboot chromeos-bootimage
    
    Change-Id: I08de52515d3c1e7e85d1761c09a0cebffda7dda3
    Signed-off-by: David Wu <David_Wu at quantatw.com>
    Reviewed-on: https://chromium-review.googlesource.com/241813
    Tested-by: David Wu <david_wu at quantatw.com>
    Reviewed-by: Shawn N <shawnn at chromium.org>
    Commit-Queue: David Wu <david_wu at quantatw.com>
    Signed-off-by: Matt DeVillier <matt.devillier at gmail.com>
---
 src/mainboard/samsung/stumpy/romstage.c   |  5 +++-
 src/mainboard/samsung/stumpy/smihandler.c | 40 +++++++++++--------------------
 src/superio/ite/it8772f/Makefile.inc      |  1 +
 src/superio/ite/it8772f/early_init.c      | 19 +++++++++++++++
 src/superio/ite/it8772f/it8772f.h         | 22 +++++++++++++++++
 5 files changed, 60 insertions(+), 27 deletions(-)

diff --git a/src/mainboard/samsung/stumpy/romstage.c b/src/mainboard/samsung/stumpy/romstage.c
index f76de7a..bf1ddb3 100644
--- a/src/mainboard/samsung/stumpy/romstage.c
+++ b/src/mainboard/samsung/stumpy/romstage.c
@@ -155,7 +155,10 @@ static void setup_sio_gpios(void)
 	/*
 	 * GPIO45 as LED_POWER#
 	 */
-	it8772f_gpio_setup(DUMMY_DEV, 4, 0x20, 0x20, 0x20, 0x20, 0x20);
+	it8772f_gpio_led(DUMMY_DEV, 4 /* set */, (0x1<<5) /* select */,
+		0x00 /* polarity: non-inverting */, 0x00 /* 0=pulldown */,
+		(0x1<<5) /* output */, (0x1<<5) /* 1=Simple IO function */,
+		SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
 
 	/*
 	 * GPIO51 as USBPWRON8#
diff --git a/src/mainboard/samsung/stumpy/smihandler.c b/src/mainboard/samsung/stumpy/smihandler.c
index 39df8a4..2e0f0dd 100644
--- a/src/mainboard/samsung/stumpy/smihandler.c
+++ b/src/mainboard/samsung/stumpy/smihandler.c
@@ -22,44 +22,32 @@
 #include <northbridge/intel/sandybridge/sandybridge.h>
 #include <cpu/intel/model_206ax/model_206ax.h>
 
-/* FIXME: Include romstage serial for SIO helper functions */
-#include <superio/ite/it8772f/early_init.c>
-//#include <superio/ite/it8772f/it8772f.h>
+/* Include for SIO helper functions */
+#include <superio/ite/it8772f/it8772f.h>
 #define DUMMY_DEV PNP_DEV(0x2e, 0)
 
 /*
  * Change LED_POWER# (SIO GPIO 45) state based on sleep type.
- * The IO address is hardcoded as we don't have device path in SMM.
- */
-#define SIO_GPIO_BASE_SET4	(0x730 + 3)
-#define SIO_GPIO_BLINK_GPIO45	0x25
+*/
 void mainboard_smi_sleep(u8 slp_typ)
 {
-	u8 reg8;
-
+	printk(BIOS_DEBUG, "SMI: sleep S%d\n", slp_typ);
 	switch (slp_typ) {
 	case 3:
 	case 4:
-		/* Blink LED */
-		it8772f_enter_conf(DUMMY_DEV);
-		it8772f_sio_write(DUMMY_DEV, IT8772F_CONFIG_REG_LDN, IT8772F_GPIO);
-		/* Enable blink pin map */
-		it8772f_sio_write(DUMMY_DEV, IT8772F_GPIO_LED_BLINK1_PINMAP,
-				  SIO_GPIO_BLINK_GPIO45);
-		/* Enable 4HZ blink */
-		it8772f_sio_write(DUMMY_DEV, IT8772F_GPIO_LED_BLINK1_CONTROL, 0x02);
-		/* Set GPIO to alternate function */
-		reg8 = it8772f_sio_read(DUMMY_DEV, GPIO_REG_ENABLE(3));
-		reg8 &= ~(1 << 5);
-		it8772f_sio_write(DUMMY_DEV, GPIO_REG_ENABLE(3), reg8);
-		it8772f_exit_conf(DUMMY_DEV);
+		it8772f_gpio_led(DUMMY_DEV, 4 /* set */, (0x1<<5) /* select */,
+			(0x1<<5) /* polarity */, (0x1<<5) /* 1=pullup */,
+			(0x1<<5) /* output */, 0x00, /* 0=Alternate function */
+			SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
 		break;
 
 	case 5:
-		/* Turn off LED */
-		reg8 = inb(SIO_GPIO_BASE_SET4);
-		reg8 |= (1 << 5);
-		outb(reg8, SIO_GPIO_BASE_SET4);
+		it8772f_gpio_led(DUMMY_DEV, 4 /* set */, (0x1<<5) /* select */,
+			0x00 /* polarity: non-inverting */, 0x00 /* 0=pulldown */,
+			(0x1<<5) /* output */, (0x1<<5) /* 1=Simple IO function */,
+			SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
+		break;
+	default:
 		break;
 	}
 }
diff --git a/src/superio/ite/it8772f/Makefile.inc b/src/superio/ite/it8772f/Makefile.inc
index f39e2ba..a0bf94d 100644
--- a/src/superio/ite/it8772f/Makefile.inc
+++ b/src/superio/ite/it8772f/Makefile.inc
@@ -16,3 +16,4 @@
 
 romstage-$(CONFIG_SUPERIO_ITE_IT8772F) += early_init.c
 ramstage-$(CONFIG_SUPERIO_ITE_IT8772F) += superio.c
+smm-$(CONFIG_SUPERIO_ITE_IT8772F) += early_init.c
diff --git a/src/superio/ite/it8772f/early_init.c b/src/superio/ite/it8772f/early_init.c
index 893e69b..eed1e9c 100644
--- a/src/superio/ite/it8772f/early_init.c
+++ b/src/superio/ite/it8772f/early_init.c
@@ -81,3 +81,22 @@ void it8772f_gpio_setup(pnp_devfn_t dev, int set, u8 select, u8 polarity,
 	it8772f_sio_write(dev, GPIO_REG_PULLUP(set), pullup);
 	it8772f_exit_conf(dev);
 }
+
+/* Configure LED GPIOs */
+void it8772f_gpio_led(pnp_devfn_t dev,int set, u8 select, u8 polarity, u8 pullup,
+			u8 output, u8 enable, u8 led_pin_map, u8 led_freq)
+{
+	set--; /* Set 1 is offset 0 */
+	it8772f_enter_conf(dev);
+	it8772f_sio_write(dev, IT8772F_CONFIG_REG_LDN, IT8772F_GPIO);
+	if (set < 5) {
+		it8772f_sio_write(dev, IT8772F_GPIO_LED_BLINK1_PINMAP, led_pin_map);
+		it8772f_sio_write(dev, IT8772F_GPIO_LED_BLINK1_CONTROL, led_freq);
+		it8772f_sio_write(dev, GPIO_REG_SELECT(set), select);
+		it8772f_sio_write(dev, GPIO_REG_ENABLE(set), enable);
+		it8772f_sio_write(dev, GPIO_REG_POLARITY(set), polarity);
+	}
+	it8772f_sio_write(dev, GPIO_REG_OUTPUT(set), output);
+	it8772f_sio_write(dev, GPIO_REG_PULLUP(set), pullup);
+	it8772f_exit_conf(dev);
+}
diff --git a/src/superio/ite/it8772f/it8772f.h b/src/superio/ite/it8772f/it8772f.h
index a113bc7..2c6c44b 100644
--- a/src/superio/ite/it8772f/it8772f.h
+++ b/src/superio/ite/it8772f/it8772f.h
@@ -17,6 +17,8 @@
 #ifndef SUPERIO_ITE_IT8772F_H
 #define SUPERIO_ITE_IT8772F_H
 
+#define IT8772F_BASE 0x2e
+
 #define IT8772F_FDC  0x00 /* Floppy disk controller */
 #define IT8772F_SP1  0x01 /* Com1 */
 #define IT8772F_EC   0x04 /* Environment controller */
@@ -92,12 +94,29 @@
 
 /* GPIO interface */
 #define IT8772F_GPIO_LED_BLINK1_PINMAP		0xf8
+
+#define SIO_GPIO_BLINK_GPIO10 0x08
+#define SIO_GPIO_BLINK_GPIO45 0x25
+
 #define IT8772F_GPIO_LED_BLINK1_CONTROL		0xf9
 
+#define IT8772F_GPIO_BLINK_FREQUENCY_4_HZ   (0<<1)
+#define IT8772F_GPIO_BLINK_FREQUENCY_1_HZ   (1<<1)
+#define IT8772F_GPIO_BLINK_FREQUENCY_1_4_HZ (2<<1)
+#define IT8772F_GPIO_BLINK_FREQUENCY_1_8_HZ (3<<1)
+
 #define GPIO_REG_SELECT(x)   (0x25 + (x))
+
+/* GPIO Polarity Select: 1: Inverting, 0: Non-inverting */
 #define GPIO_REG_POLARITY(x) (0xb0 + (x))
+
+/* GPIO Inernal Pull-up: 1: Enable, 0: Disable */
 #define GPIO_REG_PULLUP(x)   (0xb8 + (x))
+
+/* GPIO Fucntion Select: 1: Simple I/O, 0: Alternate function */
 #define GPIO_REG_ENABLE(x)   (0xc0 + (x))
+
+/* GPIO Mode: 0: input mode, 1: output mode */
 #define GPIO_REG_OUTPUT(x)   (0xc8 + (x))
 
 #include <arch/io.h>
@@ -116,5 +135,8 @@ void it8772f_gpio_setup(pnp_devfn_t dev, int set, u8 select, u8 polarity,
 
 void it8772f_enter_conf(pnp_devfn_t dev);
 void it8772f_exit_conf(pnp_devfn_t dev);
+void it8772f_gpio_led(pnp_devfn_t dev, int set, u8 select, u8 polarity, u8 pullup,
+			u8 output, u8 enable, u8 led_pin_map, u8 led_freq);
+
 
 #endif /* SUPERIO_ITE_IT8772F_H */



More information about the coreboot-gerrit mailing list