superio/ite,mb: Switch to new ITE GPIO driver
Refactor mainboards' code to use the new GPIO driver. TEST=Put Google Jecht to S3 sleep and check if the LED blinks. Change-Id: I707ee090ee2551b4935847e12ade678d36ff9302 Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com> Tested-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/83469 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
committed by
Nico Huber
parent
ec049cb29d
commit
001f33cc03
@@ -4,6 +4,7 @@
|
||||
#include <acpi/acpi.h>
|
||||
#include <cpu/x86/smm.h>
|
||||
#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)
|
||||
@@ -14,16 +15,11 @@ void mainboard_smi_sleep(u8 slp_typ)
|
||||
case ACPI_S3:
|
||||
ite_set_3vsbsw(GPIO_DEV, true);
|
||||
ite_delay_pwrgd3(GPIO_DEV);
|
||||
it8772f_gpio_led(
|
||||
GPIO_DEV,
|
||||
2 /* set */,
|
||||
0x02 /* select */,
|
||||
0x01 /* polarity */,
|
||||
0x01 /* 1 = pullup */,
|
||||
0x01 /* output */,
|
||||
0x00 /* 1 = Simple IO function */,
|
||||
SIO_GPIO_BLINK_GPIO22,
|
||||
IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
||||
ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(1), 0x02);
|
||||
ite_gpio_setup(GPIO_DEV, 22, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE,
|
||||
ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE);
|
||||
ite_gpio_setup_led(GPIO_DEV, 22, ITE_GPIO_LED_1, ITE_LED_FREQ_1HZ,
|
||||
ITE_LED_CONTROL_DEFAULT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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_FREQ_1HZ,
|
||||
ITE_LED_CONTROL_DEFAULT);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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 @@ static void setup_sio_gpios(void)
|
||||
* 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)
|
||||
|
@@ -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 @@ void mainboard_smi_sleep(u8 slp_typ)
|
||||
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;
|
||||
|
Reference in New Issue
Block a user