From 1d19432e1e50dc507af2759bf83c74d5c32c6e4c Mon Sep 17 00:00:00 2001 From: Trevor Wu Date: Tue, 17 Aug 2021 15:58:11 +0800 Subject: mb/google/cherry: Support audio codec RT1011 Add GPIO "rt1011 reset" and i2c2 initialization for RT1011. Add CHERRY_USE_RT1011 and CHERRY_USE_RT1019 to Kconfig, so we can spearate code for the specific codec by config. Signed-off-by: Trevor Wu Change-Id: I18939a2a2caae0444ce17f4712764647975121ad Reviewed-on: https://review.coreboot.org/c/coreboot/+/57157 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/mainboard/google/cherry/Kconfig | 9 +++++++++ src/mainboard/google/cherry/chromeos.c | 22 ++++++++++++++++++++-- src/mainboard/google/cherry/gpio.h | 1 + src/mainboard/google/cherry/mainboard.c | 4 ++++ 4 files changed, 34 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mainboard/google/cherry/Kconfig b/src/mainboard/google/cherry/Kconfig index 07a5781105..09d820c2b7 100644 --- a/src/mainboard/google/cherry/Kconfig +++ b/src/mainboard/google/cherry/Kconfig @@ -54,4 +54,13 @@ config BOOT_DEVICE_SPI_FLASH_BUS config EC_GOOGLE_CHROMEEC_SPI_BUS hex default 0x0 + +config CHERRY_USE_RT1011 + bool + default n + +config CHERRY_USE_RT1019 + bool + default y if BOARD_GOOGLE_CHERRY || BOARD_GOOGLE_TOMATO + default n endif diff --git a/src/mainboard/google/cherry/chromeos.c b/src/mainboard/google/cherry/chromeos.c index db7db782a8..748e06e28d 100644 --- a/src/mainboard/google/cherry/chromeos.c +++ b/src/mainboard/google/cherry/chromeos.c @@ -12,12 +12,16 @@ void setup_chromeos_gpios(void) gpio_input(GPIO_WP); gpio_input_pullup(GPIO_EC_AP_INT); gpio_input_pullup(GPIO_SD_CD); - gpio_output(GPIO_BEEP_ON, 0); gpio_input_pullup(GPIO_EC_IN_RW); gpio_input_pullup(GPIO_GSC_AP_INT); gpio_output(GPIO_EN_SPK, 0); gpio_output(GPIO_RESET, 0); gpio_output(GPIO_XHCI_DONE, 0); + if (CONFIG(CHERRY_USE_RT1019)) + gpio_output(GPIO_BEEP_ON, 0); + else if (CONFIG(CHERRY_USE_RT1011)) + gpio_output(GPIO_RST_RT1011, 0); + } void fill_lb_gpios(struct lb_gpios *gpios) @@ -25,16 +29,30 @@ void fill_lb_gpios(struct lb_gpios *gpios) struct lb_gpio chromeos_gpios[] = { {GPIO_EC_AP_INT.id, ACTIVE_LOW, -1, "EC interrupt"}, {GPIO_SD_CD.id, ACTIVE_LOW, -1, "SD card detect"}, - {GPIO_BEEP_ON.id, ACTIVE_HIGH, -1, "beep enable"}, {GPIO_EC_IN_RW.id, ACTIVE_LOW, -1, "EC in RW"}, /* * The GPIO_GSC_AP_INT itself is active low, but the payloads will * create the IRQ using its eint driver, which is active high. */ {GPIO_GSC_AP_INT.id, ACTIVE_HIGH, -1, "TPM interrupt"}, + }; + + struct lb_gpio rt1019_gpios[] = { + {GPIO_BEEP_ON.id, ACTIVE_HIGH, -1, "beep enable"}, {GPIO_EN_SPK.id, ACTIVE_HIGH, -1, "speaker enable"}, }; + + struct lb_gpio rt1011_gpios[] = { + {GPIO_RST_RT1011.id, ACTIVE_HIGH, -1, "rt1011 reset"}, + {GPIO_EN_SPK.id, ACTIVE_HIGH, -1, "speaker enable"}, + }; + lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); + + if (CONFIG(CHERRY_USE_RT1019)) + lb_add_gpios(gpios, rt1019_gpios, ARRAY_SIZE(rt1019_gpios)); + else if (CONFIG(CHERRY_USE_RT1011)) + lb_add_gpios(gpios, rt1011_gpios, ARRAY_SIZE(rt1011_gpios)); } int tis_plat_irq_status(void) diff --git a/src/mainboard/google/cherry/gpio.h b/src/mainboard/google/cherry/gpio.h index e5465ac147..2c9c8e3bf8 100644 --- a/src/mainboard/google/cherry/gpio.h +++ b/src/mainboard/google/cherry/gpio.h @@ -12,6 +12,7 @@ #define GPIO_XHCI_DONE GPIO(DGI_D4) #define GPIO_EC_IN_RW GPIO(DGI_D10) #define GPIO_GSC_AP_INT GPIO(DGI_D11) +#define GPIO_RST_RT1011 GPIO(DGI_VSYNC) #define GPIO_EN_SPK GPIO(UART1_RTS) #define GPIO_RESET GPIO(UART1_CTS) diff --git a/src/mainboard/google/cherry/mainboard.c b/src/mainboard/google/cherry/mainboard.c index bb6dbac8ab..7b9ba658d1 100644 --- a/src/mainboard/google/cherry/mainboard.c +++ b/src/mainboard/google/cherry/mainboard.c @@ -203,6 +203,10 @@ static void mainboard_init(struct device *dev) configure_sdcard(); setup_usb_host(); + /* for audio usage */ + if (CONFIG(CHERRY_USE_RT1011)) + mtk_i2c_bus_init(I2C2); + if (dpm_init()) printk(BIOS_ERR, "dpm init failed, DVFS may not work\n"); -- cgit v1.2.3