From abe3c16df2e110d4934ffdb2671243fc9e34c210 Mon Sep 17 00:00:00 2001 From: Trevor Wu Date: Mon, 20 Feb 2023 17:47:56 +0800 Subject: mb/google/geralt: Add MAX98390 support for Geralt Add a config "USE_MAX98390" to enable MAX98390 support. MAX98390 is an I2S smart amplifier used in Geralt. It is also the default speaker for Geralt reference board. BUG=b:250459803 BRANCH=none TEST=Verify beep function through CLI in depthcharge successfully. Change-Id: I814f440cc5ac2a13404d01fb3baafeec092b1e74 Signed-off-by: Trevor Wu Signed-off-by: jason-ch chen Reviewed-on: https://review.coreboot.org/c/coreboot/+/73412 Reviewed-by: Yidi Lin Reviewed-by: Rex-BC Chen Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu --- src/mainboard/google/geralt/Kconfig | 10 ++++++++++ src/mainboard/google/geralt/chromeos.c | 8 ++++++++ src/mainboard/google/geralt/gpio.h | 5 +++++ src/mainboard/google/geralt/mainboard.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+) (limited to 'src/mainboard') diff --git a/src/mainboard/google/geralt/Kconfig b/src/mainboard/google/geralt/Kconfig index 8de4fea931..af4d7e0d80 100644 --- a/src/mainboard/google/geralt/Kconfig +++ b/src/mainboard/google/geralt/Kconfig @@ -60,4 +60,14 @@ config DRIVER_TPM_I2C_ADDR config SDCARD_INIT bool default y + +choice + prompt "Speaker AMP for Geralt" + default USE_MAX98390 if BOARD_GOOGLE_GERALT + +config USE_MAX98390 + bool "MAX98390" + +endchoice + endif diff --git a/src/mainboard/google/geralt/chromeos.c b/src/mainboard/google/geralt/chromeos.c index 266fc78db1..10fc9d314f 100644 --- a/src/mainboard/google/geralt/chromeos.c +++ b/src/mainboard/google/geralt/chromeos.c @@ -18,6 +18,7 @@ void setup_chromeos_gpios(void) /* Set up GPOs */ gpio_output(GPIO_AP_EC_WARM_RST_REQ, 0); gpio_output(GPIO_EN_SPKR, 0); + gpio_output(GPIO_RST_SPKR_L, 0); gpio_output(GPIO_XHCI_INIT_DONE, 0); } @@ -39,6 +40,13 @@ void fill_lb_gpios(struct lb_gpios *gpios) }; lb_add_gpios(gpios, sd_card_gpios, ARRAY_SIZE(sd_card_gpios)); } + + if (CONFIG(USE_MAX98390)) { + struct lb_gpio max98390_gpios[] = { + {GPIO_RST_SPKR_L.id, ACTIVE_LOW, -1, "speaker reset"}, + }; + lb_add_gpios(gpios, max98390_gpios, ARRAY_SIZE(max98390_gpios)); + } } int tis_plat_irq_status(void) diff --git a/src/mainboard/google/geralt/gpio.h b/src/mainboard/google/geralt/gpio.h index 36f488e7b8..126cfe8f3f 100644 --- a/src/mainboard/google/geralt/gpio.h +++ b/src/mainboard/google/geralt/gpio.h @@ -12,8 +12,13 @@ #define GPIO_EC_AP_INT_ODL GPIO(DPI_DE) #define GPIO_EN_SPKR GPIO(I2SIN_D2) #define GPIO_GSC_AP_INT_ODL GPIO(GPIO00) +#define GPIO_RST_SPKR_L GPIO(I2SO2_D1) #define GPIO_XHCI_INIT_DONE GPIO(DPI_CK) +#define GPIO_I2SI1_LRCK GPIO(I2SO2_D2) +#define GPIO_I2SI1_BCK GPIO(I2SIN_D3) +#define GPIO_I2SO1_D0 GPIO(GPIO11) + #define GPIO_EDP_BL_PWM_1V8 GPIO(DISP_PWM1) #define GPIO_EDP_HPD_1V8 GPIO(GPIO17) #define GPIO_EN_PP3300_EDP_DISP_X GPIO(DSI1_LCM_RST) diff --git a/src/mainboard/google/geralt/mainboard.c b/src/mainboard/google/geralt/mainboard.c index ee8b005d3e..1422398342 100644 --- a/src/mainboard/google/geralt/mainboard.c +++ b/src/mainboard/google/geralt/mainboard.c @@ -3,13 +3,42 @@ #include #include #include +#include #include #include +#include #include #include "display.h" #include "gpio.h" +#define AFE_SE_SECURE_CON (AUDIO_BASE + 0x17a8) + +static void configure_i2s(void) +{ + /* Audio PWR */ + mtcmos_audio_power_on(); + mtcmos_protect_audio_bus(); + + /* Switch to normal mode */ + write32p(AFE_SE_SECURE_CON, 0x0); + + /* SoC I2S */ + gpio_set_mode(GPIO_I2SI1_LRCK, PAD_I2SO2_D2_FUNC_TDMIN_LRCK); + gpio_set_mode(GPIO_I2SI1_BCK, PAD_I2SIN_D3_FUNC_TDMIN_BCK); + gpio_set_mode(GPIO_I2SO1_D0, PAD_GPIO11_FUNC_I2SO1_D0); +} + +static void configure_audio(void) +{ + if (CONFIG(USE_MAX98390)) { + printk(BIOS_DEBUG, "Configure MAX98390 audio\n"); + + mtk_i2c_bus_init(I2C0, I2C_SPEED_FAST); + configure_i2s(); + } +} + static void mainboard_init(struct device *dev) { mt6359p_init_pmif_arb(); @@ -23,6 +52,8 @@ static void mainboard_init(struct device *dev) mtk_msdc_configure_emmc(true); + configure_audio(); + if (CONFIG(SDCARD_INIT)) mtk_msdc_configure_sdcard(); -- cgit v1.2.3