Michał Żygowski has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83469?usp=email )
Change subject: superio/ite,mb: Switch the mainboards' code to the new ITE GPIO driver ......................................................................
superio/ite,mb: Switch the mainboards' code to the new ITE GPIO driver
Refactor mainboards' code to use the new GPIO and remove any custom driver in the respective ITE SIO chip directory.
Change-Id: I707ee090ee2551b4935847e12ade678d36ff9302 Signed-off-by: Michał Żygowski michal.zygowski@3mdeb.com --- M src/mainboard/google/beltino/variants/mccloud/led.c M src/mainboard/google/beltino/variants/tricky/led.c M src/mainboard/google/jecht/led.c M src/mainboard/hp/pro_3500_series/led.c M src/mainboard/samsung/stumpy/early_init.c M src/mainboard/samsung/stumpy/smihandler.c M src/superio/ite/it8659e/it8659e.h M src/superio/ite/it8772f/Makefile.mk D src/superio/ite/it8772f/early_init.c M src/superio/ite/it8772f/it8772f.h 10 files changed, 72 insertions(+), 185 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/83469/1
diff --git a/src/mainboard/google/beltino/variants/mccloud/led.c b/src/mainboard/google/beltino/variants/mccloud/led.c index da5002f..04e17ec 100644 --- a/src/mainboard/google/beltino/variants/mccloud/led.c +++ b/src/mainboard/google/beltino/variants/mccloud/led.c @@ -1,17 +1,18 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <superio/ite/common/ite.h> +#include <superio/ite/common/ite_gpio.h> #include <superio/ite/it8772f/it8772f.h> #include "../../onboard.h"
void set_power_led(int state) { - it8772f_gpio_led(IT8772F_GPIO_DEV, - 1, /* set */ - 0x01, /* select */ - state == LED_BLINK ? 0x01 : 0x00, /* polarity */ - state == LED_BLINK ? 0x01 : 0x00, /* pullup/pulldown */ - 0x01, /* output */ - state == LED_BLINK ? 0x00 : 0x01, /* I/O function */ - SIO_GPIO_BLINK_GPIO10, - IT8772F_GPIO_BLINK_FREQUENCY_1_HZ); + /* Configure GPIO10 as power LED */ + ite_reg_write(IT8772F_GPIO_DEV, ITE_GPIO_REG_SELECT(0), 0x01); + ite_gpio_setup(IT8772F_GPIO_DEV, 10, ITE_GPIO_OUTPUT, + state == LED_BLINK ? ITE_GPIO_ALT_FN_MODE : ITE_GPIO_SIMPLE_IO_MODE, + state == LED_BLINK ? ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE + : ITE_GPIO_CONTROL_DEFAULT); + ite_gpio_setup_led(IT8772F_GPIO_DEV, 10, ITE_GPIO_LED_1, + ITE_LED_FREQ_1HZ, ITE_LED_CONTROL_DEFAULT); } diff --git a/src/mainboard/google/beltino/variants/tricky/led.c b/src/mainboard/google/beltino/variants/tricky/led.c index 49d7918..b21e18e 100644 --- a/src/mainboard/google/beltino/variants/tricky/led.c +++ b/src/mainboard/google/beltino/variants/tricky/led.c @@ -1,17 +1,18 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <superio/ite/common/ite.h> +#include <superio/ite/common/ite_gpio.h> #include <superio/ite/it8772f/it8772f.h> #include "../../onboard.h"
void set_power_led(int state) { - it8772f_gpio_led(IT8772F_GPIO_DEV, - 2, /* set */ - 0xF7, /* select */ - state == LED_OFF ? 0x00 : 0x04, /* polarity */ - state == LED_BLINK ? 0x04 : 0x00, /* pullup/pulldown */ - 0x04, /* output */ - state == LED_BLINK ? 0x00 : 0x04, /* I/O function */ - SIO_GPIO_BLINK_GPIO22, - IT8772F_GPIO_BLINK_FREQUENCY_1_HZ); + /* Configure GPIO22 as power LED */ + ite_reg_write(IT8772F_GPIO_DEV, ITE_GPIO_REG_SELECT(1), 0xf7); + ite_gpio_setup(IT8772F_GPIO_DEV, 22, ITE_GPIO_OUTPUT, + state == LED_BLINK ? ITE_GPIO_ALT_FN_MODE : ITE_GPIO_SIMPLE_IO_MODE, + (state != LED_OFF ? ITE_GPIO_POL_INVERT : 0) | + (state == LED_BLINK ? ITE_GPIO_PULLUP_ENABLE : 0)); + ite_gpio_setup_led(IT8772F_GPIO_DEV, 22, ITE_GPIO_LED_1, + ITE_LED_FREQ_1HZ, ITE_LED_CONTROL_DEFAULT); } diff --git a/src/mainboard/google/jecht/led.c b/src/mainboard/google/jecht/led.c index 8a6a304..419ef44 100644 --- a/src/mainboard/google/jecht/led.c +++ b/src/mainboard/google/jecht/led.c @@ -1,25 +1,26 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <superio/ite/common/ite.h> +#include <superio/ite/common/ite_gpio.h> #include <superio/ite/it8772f/it8772f.h> #include "onboard.h"
void set_power_led(int state) { - int polarity; + u8 polarity;
if (CONFIG(BOARD_GOOGLE_TIDUS)) { - polarity = state == LED_OFF ? 0x00 : 0x01; + polarity = state == LED_OFF ? ITE_GPIO_POL_INVERT : 0; } else { - polarity = state == LED_BLINK ? 0x01 : 0x00; + polarity = state == LED_BLINK ? ITE_GPIO_POL_INVERT : 0; }
- it8772f_gpio_led(IT8772F_GPIO_DEV, - 1, /* set */ - 0x01, /* select */ - polarity, /* polarity */ - state == LED_BLINK ? 0x01 : 0x00, /* pullup/pulldown */ - 0x01, /* output */ - state == LED_BLINK ? 0x00 : 0x01, /* I/O function */ - SIO_GPIO_BLINK_GPIO10, - IT8772F_GPIO_BLINK_FREQUENCY_1_HZ); + /* Configure GPIO10 as power LED */ + ite_reg_write(IT8772F_GPIO_DEV, ITE_GPIO_REG_SELECT(0), 0x01); + ite_gpio_setup(IT8772F_GPIO_DEV, 10, ITE_GPIO_OUTPUT, + state == LED_BLINK ? ITE_GPIO_ALT_FN_MODE : ITE_GPIO_SIMPLE_IO_MODE, + (state == LED_BLINK ? ITE_GPIO_PULLUP_ENABLE : ITE_GPIO_CONTROL_DEFAULT) | + polarity); + ite_gpio_setup_led(IT8772F_GPIO_DEV, 10, ITE_GPIO_LED_1, + ITE_LED_CONTROL_DEFAULT, ITE_LED_FREQ_1HZ); } diff --git a/src/mainboard/hp/pro_3500_series/led.c b/src/mainboard/hp/pro_3500_series/led.c index 073f5f5..103763f 100644 --- a/src/mainboard/hp/pro_3500_series/led.c +++ b/src/mainboard/hp/pro_3500_series/led.c @@ -1,17 +1,17 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <superio/ite/common/ite.h> +#include <superio/ite/common/ite_gpio.h> + #include "common_defines.h" #include "led.h"
void set_power_led(int state) { - // Board has a dual color LED - it8772f_gpio_setup( - GPIO_DEV, - 2, /* set */ - 0xf3 | LED_BOTH, /* select, 0xf3 is default */ - state, /* polarity */ - 0x00, /* pullup */ - LED_BOTH, /* output */ - 0x00); /* enable */ + // Board has a dual color LED: GPIO22 and GPIO23 + ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(1), 0xf3 | LED_BOTH); + ite_gpio_setup(GPIO_DEV, 22, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE, + state & LED_WHITE ? ITE_GPIO_POL_INVERT : ITE_GPIO_CONTROL_DEFAULT); + ite_gpio_setup(GPIO_DEV, 23, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE, + state & LED_YELLOW ? ITE_GPIO_POL_INVERT : ITE_GPIO_CONTROL_DEFAULT); } diff --git a/src/mainboard/samsung/stumpy/early_init.c b/src/mainboard/samsung/stumpy/early_init.c index 852759e..e4b4020 100644 --- a/src/mainboard/samsung/stumpy/early_init.c +++ b/src/mainboard/samsung/stumpy/early_init.c @@ -5,6 +5,7 @@ #include <pc80/mc146818rtc.h> #include <bootmode.h> #include <superio/ite/common/ite.h> +#include <superio/ite/common/ite_gpio.h> #include <superio/ite/it8772f/it8772f.h> #include <northbridge/intel/sandybridge/sandybridge.h> #include <northbridge/intel/sandybridge/raminit.h> @@ -58,32 +59,40 @@ * GPIO10 as USBPWRON12# * GPIO12 as USBPWRON13# */ - it8772f_gpio_setup(GPIO_DEV, 1, 0x05, 0x05, 0x00, 0x05, 0x05); - + ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(0), 0x05); + ite_gpio_setup(GPIO_DEV, 10, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_POL_INVERT); + ite_gpio_setup(GPIO_DEV, 12, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_POL_INVERT); /* * GPIO22 as wake SCI# */ - it8772f_gpio_setup(GPIO_DEV, 2, 0x04, 0x04, 0x00, 0x04, 0x04); - + ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(1), 0x04); + ite_gpio_setup(GPIO_DEV, 22, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_POL_INVERT); /* * GPIO32 as EXTSMI# */ - it8772f_gpio_setup(GPIO_DEV, 3, 0x04, 0x04, 0x00, 0x04, 0x04); - + ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(2), 0x04); + ite_gpio_setup(GPIO_DEV, 32, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_POL_INVERT); /* * GPIO45 as LED_POWER# */ - it8772f_gpio_led(GPIO_DEV, 4 /* set */, (0x1 << 5) /* select */, - (0x1 << 5) /* polarity */, (0x1 << 5) /* 1 = pullup */, - (0x1 << 5) /* output */, (0x1 << 5) /* 1 = Simple IO function */, - SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ); - + ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(3), 0x20); + ite_gpio_setup(GPIO_DEV, 45, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE); + ite_gpio_setup_led(GPIO_DEV, 45, ITE_GPIO_LED_1, ITE_LED_FREQ_1HZ, + ITE_LED_CONTROL_DEFAULT); /* * GPIO51 as USBPWRON8# * GPIO52 as USBPWRON1# */ - it8772f_gpio_setup(GPIO_DEV, 5, 0x06, 0x06, 0x00, 0x06, 0x06); - it8772f_gpio_setup(GPIO_DEV, 6, 0x00, 0x00, 0x00, 0x00, 0x00); + ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(4), 0x06); + ite_gpio_setup(GPIO_DEV, 51, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_POL_INVERT); + ite_gpio_setup(GPIO_DEV, 52, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_POL_INVERT); }
void mainboard_fill_pei_data(struct pei_data *pei_data) diff --git a/src/mainboard/samsung/stumpy/smihandler.c b/src/mainboard/samsung/stumpy/smihandler.c index f9b9d3b..0b6e133 100644 --- a/src/mainboard/samsung/stumpy/smihandler.c +++ b/src/mainboard/samsung/stumpy/smihandler.c @@ -8,6 +8,8 @@ #include <northbridge/intel/sandybridge/sandybridge.h>
/* Include for SIO helper functions */ +#include <superio/ite/common/ite.h> +#include <superio/ite/common/ite_gpio.h> #include <superio/ite/it8772f/it8772f.h> #define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
@@ -20,17 +22,14 @@ switch (slp_typ) { case ACPI_S3: case ACPI_S4: - it8772f_gpio_led(GPIO_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); + ite_gpio_setup(GPIO_DEV, 45, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE, + ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE); + ite_gpio_setup_led(GPIO_DEV, 45, ITE_GPIO_LED_1, ITE_LED_FREQ_1HZ, + ITE_LED_CONTROL_DEFAULT); break; - case ACPI_S5: - it8772f_gpio_led(GPIO_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); + ite_gpio_setup(GPIO_DEV, 45, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE, + ITE_GPIO_CONTROL_DEFAULT); break; default: break; diff --git a/src/superio/ite/it8659e/it8659e.h b/src/superio/ite/it8659e/it8659e.h index 4fa91e9..f6eda07 100644 --- a/src/superio/ite/it8659e/it8659e.h +++ b/src/superio/ite/it8659e/it8659e.h @@ -11,24 +11,4 @@ #define IT8659E_GPIO 0x07 /* GPIO */ #define IT8659E_CIR 0x0A /* CIR */
-/* GPIO Polarity Select: 1: Inverting, 0: Non-inverting */ -#define GPIO_REG_POLARITY(x) (0xb0 + (x)) -#define GPIO_POL_NO_INVERT 0 -#define GPIO_POL_INVERT 1 - -/* GPIO Internal Pull-up: 1: Enable, 0: Disable */ -#define GPIO_REG_PULLUP(x) (0xb8 + (x)) -#define GPIO_PULLUP_DIS 0 -#define GPIO_PULLUP_EN 1 - -/* GPIO Function Select: 1: Simple I/O, 0: Alternate function */ -#define GPIO_REG_ENABLE(x) (0xc0 + (x)) -#define GPIO_ALT_FN 0 -#define GPIO_SIMPLE_IO 1 - -/* GPIO Mode: 0: input mode, 1: output mode */ -#define GPIO_REG_OUTPUT(x) (0xc8 + (x)) -#define GPIO_INPUT_MODE 0 -#define GPIO_OUTPUT_MODE 1 - #endif /* SUPERIO_ITE_IT8659E_H */ diff --git a/src/superio/ite/it8772f/Makefile.mk b/src/superio/ite/it8772f/Makefile.mk index a96a862..93ea16d 100644 --- a/src/superio/ite/it8772f/Makefile.mk +++ b/src/superio/ite/it8772f/Makefile.mk @@ -1,6 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-or-later
-bootblock-$(CONFIG_SUPERIO_ITE_IT8772F) += early_init.c -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 deleted file mode 100644 index efbb035..0000000 --- a/src/superio/ite/it8772f/early_init.c +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -#include <arch/io.h> -#include <device/pnp_def.h> -#include <device/pnp_ops.h> - -#include "it8772f.h" -#include "../common/ite.h" - -#define IT8772F_CONFIG_REG_CC 0x02 /* Configure Control (write-only). */ - -/* NOTICE: This file is deprecated, use ite/common instead */ - -static void it8772f_enter_conf(pnp_devfn_t dev) -{ - u16 port = dev >> 8; - - outb(0x87, port); - outb(0x01, port); - outb(0x55, port); - outb((port == 0x4e) ? 0xaa : 0x55, port); -} - -static void it8772f_exit_conf(pnp_devfn_t dev) -{ - pnp_write_config(dev, IT8772F_CONFIG_REG_CC, 0x02); -} - -/* Configure a set of GPIOs */ -void it8772f_gpio_setup(pnp_devfn_t dev, int set, u8 select, u8 polarity, - u8 pullup, u8 output, u8 enable) -{ - set--; /* Set 1 is offset 0 */ - it8772f_enter_conf(dev); - pnp_set_logical_device(dev); - if (set < 5) { - pnp_write_config(dev, GPIO_REG_SELECT(set), select); - pnp_write_config(dev, GPIO_REG_ENABLE(set), enable); - pnp_write_config(dev, GPIO_REG_POLARITY(set), polarity); - } - pnp_write_config(dev, GPIO_REG_OUTPUT(set), output); - pnp_write_config(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); - pnp_set_logical_device(dev); - if (set < 5) { - pnp_write_config(dev, IT8772F_GPIO_LED_BLINK1_PINMAP, led_pin_map); - pnp_write_config(dev, IT8772F_GPIO_LED_BLINK1_CONTROL, led_freq); - pnp_write_config(dev, GPIO_REG_SELECT(set), select); - pnp_write_config(dev, GPIO_REG_ENABLE(set), enable); - pnp_write_config(dev, GPIO_REG_POLARITY(set), polarity); - } - pnp_write_config(dev, GPIO_REG_OUTPUT(set), output); - pnp_write_config(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 4df21c5..f286923 100644 --- a/src/superio/ite/it8772f/it8772f.h +++ b/src/superio/ite/it8772f/it8772f.h @@ -11,42 +11,4 @@ #define IT8772F_GPIO 0x07 /* GPIO */ #define IT8772F_IR 0x0a /* Consumer IR */
- -/* GPIO interface */ -#define IT8772F_GPIO_LED_BLINK1_PINMAP 0xf8 - -#define SIO_GPIO_BLINK_GPIO10 0x08 -#define SIO_GPIO_BLINK_GPIO22 0x12 -#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 Internal Pull-up: 1: Enable, 0: Disable */ -#define GPIO_REG_PULLUP(x) (0xb8 + (x)) - -/* GPIO Function 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 <device/pnp_type.h> -#include <stdint.h> - -void it8772f_gpio_setup(pnp_devfn_t dev, int set, u8 select, u8 polarity, - u8 pullup, u8 output, u8 enable); - -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 */