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 <acpi/acpi.h>
|
||||||
#include <cpu/x86/smm.h>
|
#include <cpu/x86/smm.h>
|
||||||
#include <superio/ite/common/ite.h>
|
#include <superio/ite/common/ite.h>
|
||||||
|
#include <superio/ite/common/ite_gpio.h>
|
||||||
#include <superio/ite/it8772f/it8772f.h>
|
#include <superio/ite/it8772f/it8772f.h>
|
||||||
|
|
||||||
#define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
|
#define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
|
||||||
@@ -14,16 +15,11 @@ void mainboard_smi_sleep(u8 slp_typ)
|
|||||||
case ACPI_S3:
|
case ACPI_S3:
|
||||||
ite_set_3vsbsw(GPIO_DEV, true);
|
ite_set_3vsbsw(GPIO_DEV, true);
|
||||||
ite_delay_pwrgd3(GPIO_DEV);
|
ite_delay_pwrgd3(GPIO_DEV);
|
||||||
it8772f_gpio_led(
|
ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(1), 0x02);
|
||||||
GPIO_DEV,
|
ite_gpio_setup(GPIO_DEV, 22, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE,
|
||||||
2 /* set */,
|
ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE);
|
||||||
0x02 /* select */,
|
ite_gpio_setup_led(GPIO_DEV, 22, ITE_GPIO_LED_1, ITE_LED_FREQ_1HZ,
|
||||||
0x01 /* polarity */,
|
ITE_LED_CONTROL_DEFAULT);
|
||||||
0x01 /* 1 = pullup */,
|
|
||||||
0x01 /* output */,
|
|
||||||
0x00 /* 1 = Simple IO function */,
|
|
||||||
SIO_GPIO_BLINK_GPIO22,
|
|
||||||
IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@@ -1,17 +1,18 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* 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 <superio/ite/it8772f/it8772f.h>
|
||||||
#include "../../onboard.h"
|
#include "../../onboard.h"
|
||||||
|
|
||||||
void set_power_led(int state)
|
void set_power_led(int state)
|
||||||
{
|
{
|
||||||
it8772f_gpio_led(IT8772F_GPIO_DEV,
|
/* Configure GPIO10 as power LED */
|
||||||
1, /* set */
|
ite_reg_write(IT8772F_GPIO_DEV, ITE_GPIO_REG_SELECT(0), 0x01);
|
||||||
0x01, /* select */
|
ite_gpio_setup(IT8772F_GPIO_DEV, 10, ITE_GPIO_OUTPUT,
|
||||||
state == LED_BLINK ? 0x01 : 0x00, /* polarity */
|
state == LED_BLINK ? ITE_GPIO_ALT_FN_MODE : ITE_GPIO_SIMPLE_IO_MODE,
|
||||||
state == LED_BLINK ? 0x01 : 0x00, /* pullup/pulldown */
|
state == LED_BLINK ? ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE
|
||||||
0x01, /* output */
|
: ITE_GPIO_CONTROL_DEFAULT);
|
||||||
state == LED_BLINK ? 0x00 : 0x01, /* I/O function */
|
ite_gpio_setup_led(IT8772F_GPIO_DEV, 10, ITE_GPIO_LED_1,
|
||||||
SIO_GPIO_BLINK_GPIO10,
|
ITE_LED_FREQ_1HZ, ITE_LED_CONTROL_DEFAULT);
|
||||||
IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,18 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* 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 <superio/ite/it8772f/it8772f.h>
|
||||||
#include "../../onboard.h"
|
#include "../../onboard.h"
|
||||||
|
|
||||||
void set_power_led(int state)
|
void set_power_led(int state)
|
||||||
{
|
{
|
||||||
it8772f_gpio_led(IT8772F_GPIO_DEV,
|
/* Configure GPIO22 as power LED */
|
||||||
2, /* set */
|
ite_reg_write(IT8772F_GPIO_DEV, ITE_GPIO_REG_SELECT(1), 0xf7);
|
||||||
0xF7, /* select */
|
ite_gpio_setup(IT8772F_GPIO_DEV, 22, ITE_GPIO_OUTPUT,
|
||||||
state == LED_OFF ? 0x00 : 0x04, /* polarity */
|
state == LED_BLINK ? ITE_GPIO_ALT_FN_MODE : ITE_GPIO_SIMPLE_IO_MODE,
|
||||||
state == LED_BLINK ? 0x04 : 0x00, /* pullup/pulldown */
|
(state != LED_OFF ? ITE_GPIO_POL_INVERT : 0) |
|
||||||
0x04, /* output */
|
(state == LED_BLINK ? ITE_GPIO_PULLUP_ENABLE : 0));
|
||||||
state == LED_BLINK ? 0x00 : 0x04, /* I/O function */
|
ite_gpio_setup_led(IT8772F_GPIO_DEV, 22, ITE_GPIO_LED_1,
|
||||||
SIO_GPIO_BLINK_GPIO22,
|
ITE_LED_FREQ_1HZ, ITE_LED_CONTROL_DEFAULT);
|
||||||
IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
|
||||||
}
|
}
|
||||||
|
@@ -1,25 +1,26 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* 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 <superio/ite/it8772f/it8772f.h>
|
||||||
#include "onboard.h"
|
#include "onboard.h"
|
||||||
|
|
||||||
void set_power_led(int state)
|
void set_power_led(int state)
|
||||||
{
|
{
|
||||||
int polarity;
|
u8 polarity;
|
||||||
|
|
||||||
if (CONFIG(BOARD_GOOGLE_TIDUS)) {
|
if (CONFIG(BOARD_GOOGLE_TIDUS)) {
|
||||||
polarity = state == LED_OFF ? 0x00 : 0x01;
|
polarity = state == LED_OFF ? ITE_GPIO_POL_INVERT : 0;
|
||||||
} else {
|
} else {
|
||||||
polarity = state == LED_BLINK ? 0x01 : 0x00;
|
polarity = state == LED_BLINK ? ITE_GPIO_POL_INVERT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
it8772f_gpio_led(IT8772F_GPIO_DEV,
|
/* Configure GPIO10 as power LED */
|
||||||
1, /* set */
|
ite_reg_write(IT8772F_GPIO_DEV, ITE_GPIO_REG_SELECT(0), 0x01);
|
||||||
0x01, /* select */
|
ite_gpio_setup(IT8772F_GPIO_DEV, 10, ITE_GPIO_OUTPUT,
|
||||||
polarity, /* polarity */
|
state == LED_BLINK ? ITE_GPIO_ALT_FN_MODE : ITE_GPIO_SIMPLE_IO_MODE,
|
||||||
state == LED_BLINK ? 0x01 : 0x00, /* pullup/pulldown */
|
(state == LED_BLINK ? ITE_GPIO_PULLUP_ENABLE : ITE_GPIO_CONTROL_DEFAULT) |
|
||||||
0x01, /* output */
|
polarity);
|
||||||
state == LED_BLINK ? 0x00 : 0x01, /* I/O function */
|
ite_gpio_setup_led(IT8772F_GPIO_DEV, 10, ITE_GPIO_LED_1, ITE_LED_FREQ_1HZ,
|
||||||
SIO_GPIO_BLINK_GPIO10,
|
ITE_LED_CONTROL_DEFAULT);
|
||||||
IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* 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 "common_defines.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
void set_power_led(int state)
|
void set_power_led(int state)
|
||||||
{
|
{
|
||||||
// Board has a dual color LED
|
// Board has a dual color LED: GPIO22 and GPIO23
|
||||||
it8772f_gpio_setup(
|
ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(1), 0xf3 | LED_BOTH);
|
||||||
GPIO_DEV,
|
ite_gpio_setup(GPIO_DEV, 22, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE,
|
||||||
2, /* set */
|
state & LED_WHITE ? ITE_GPIO_POL_INVERT : ITE_GPIO_CONTROL_DEFAULT);
|
||||||
0xf3 | LED_BOTH, /* select, 0xf3 is default */
|
ite_gpio_setup(GPIO_DEV, 23, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE,
|
||||||
state, /* polarity */
|
state & LED_YELLOW ? ITE_GPIO_POL_INVERT : ITE_GPIO_CONTROL_DEFAULT);
|
||||||
0x00, /* pullup */
|
|
||||||
LED_BOTH, /* output */
|
|
||||||
0x00); /* enable */
|
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include <pc80/mc146818rtc.h>
|
#include <pc80/mc146818rtc.h>
|
||||||
#include <bootmode.h>
|
#include <bootmode.h>
|
||||||
#include <superio/ite/common/ite.h>
|
#include <superio/ite/common/ite.h>
|
||||||
|
#include <superio/ite/common/ite_gpio.h>
|
||||||
#include <superio/ite/it8772f/it8772f.h>
|
#include <superio/ite/it8772f/it8772f.h>
|
||||||
#include <northbridge/intel/sandybridge/sandybridge.h>
|
#include <northbridge/intel/sandybridge/sandybridge.h>
|
||||||
#include <northbridge/intel/sandybridge/raminit.h>
|
#include <northbridge/intel/sandybridge/raminit.h>
|
||||||
@@ -58,32 +59,40 @@ static void setup_sio_gpios(void)
|
|||||||
* GPIO10 as USBPWRON12#
|
* GPIO10 as USBPWRON12#
|
||||||
* GPIO12 as USBPWRON13#
|
* 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#
|
* 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#
|
* 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#
|
* GPIO45 as LED_POWER#
|
||||||
*/
|
*/
|
||||||
it8772f_gpio_led(GPIO_DEV, 4 /* set */, (0x1 << 5) /* select */,
|
ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(3), 0x20);
|
||||||
(0x1 << 5) /* polarity */, (0x1 << 5) /* 1 = pullup */,
|
ite_gpio_setup(GPIO_DEV, 45, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE,
|
||||||
(0x1 << 5) /* output */, (0x1 << 5) /* 1 = Simple IO function */,
|
ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE);
|
||||||
SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
ite_gpio_setup_led(GPIO_DEV, 45, ITE_GPIO_LED_1, ITE_LED_FREQ_1HZ,
|
||||||
|
ITE_LED_CONTROL_DEFAULT);
|
||||||
/*
|
/*
|
||||||
* GPIO51 as USBPWRON8#
|
* GPIO51 as USBPWRON8#
|
||||||
* GPIO52 as USBPWRON1#
|
* GPIO52 as USBPWRON1#
|
||||||
*/
|
*/
|
||||||
it8772f_gpio_setup(GPIO_DEV, 5, 0x06, 0x06, 0x00, 0x06, 0x06);
|
ite_reg_write(GPIO_DEV, ITE_GPIO_REG_SELECT(4), 0x06);
|
||||||
it8772f_gpio_setup(GPIO_DEV, 6, 0x00, 0x00, 0x00, 0x00, 0x00);
|
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)
|
void mainboard_fill_pei_data(struct pei_data *pei_data)
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
#include <northbridge/intel/sandybridge/sandybridge.h>
|
#include <northbridge/intel/sandybridge/sandybridge.h>
|
||||||
|
|
||||||
/* Include for SIO helper functions */
|
/* Include for SIO helper functions */
|
||||||
|
#include <superio/ite/common/ite.h>
|
||||||
|
#include <superio/ite/common/ite_gpio.h>
|
||||||
#include <superio/ite/it8772f/it8772f.h>
|
#include <superio/ite/it8772f/it8772f.h>
|
||||||
#define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
|
#define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
|
||||||
|
|
||||||
@@ -20,17 +22,14 @@ void mainboard_smi_sleep(u8 slp_typ)
|
|||||||
switch (slp_typ) {
|
switch (slp_typ) {
|
||||||
case ACPI_S3:
|
case ACPI_S3:
|
||||||
case ACPI_S4:
|
case ACPI_S4:
|
||||||
it8772f_gpio_led(GPIO_DEV, 4 /* set */, (0x1 << 5) /* select */,
|
ite_gpio_setup(GPIO_DEV, 45, ITE_GPIO_OUTPUT, ITE_GPIO_ALT_FN_MODE,
|
||||||
(0x1 << 5) /* polarity */, (0x1 << 5) /* 1 = pullup */,
|
ITE_GPIO_POL_INVERT | ITE_GPIO_PULLUP_ENABLE);
|
||||||
(0x1 << 5) /* output */, 0x00, /* 0 = Alternate function */
|
ite_gpio_setup_led(GPIO_DEV, 45, ITE_GPIO_LED_1, ITE_LED_FREQ_1HZ,
|
||||||
SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
ITE_LED_CONTROL_DEFAULT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACPI_S5:
|
case ACPI_S5:
|
||||||
it8772f_gpio_led(GPIO_DEV, 4 /* set */, (0x1 << 5) /* select */,
|
ite_gpio_setup(GPIO_DEV, 45, ITE_GPIO_OUTPUT, ITE_GPIO_SIMPLE_IO_MODE,
|
||||||
0x00 /* polarity: non-inverting */, 0x00 /* 0 = pulldown */,
|
ITE_GPIO_CONTROL_DEFAULT);
|
||||||
(0x1 << 5) /* output */, (0x1 << 5) /* 1 = Simple IO function */,
|
|
||||||
SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user