Duncan Laurie | 9db8c25 | 2020-05-10 11:16:45 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <bootstate.h> |
| 4 | #include <console/console.h> |
| 5 | #include <fw_config.h> |
| 6 | #include <gpio.h> |
| 7 | |
| 8 | static const struct pad_config dmic_enable_pads[] = { |
| 9 | PAD_CFG_NF(GPP_S4, NONE, DEEP, NF2), /* DMIC_CLK1 */ |
| 10 | PAD_CFG_NF(GPP_S5, NONE, DEEP, NF2), /* DMIC_DATA1 */ |
| 11 | PAD_CFG_NF(GPP_S6, NONE, DEEP, NF2), /* DMIC_CLK0 */ |
| 12 | PAD_CFG_NF(GPP_S7, NONE, DEEP, NF2), /* DMIC_DATA0 */ |
| 13 | }; |
| 14 | |
| 15 | static const struct pad_config dmic_disable_pads[] = { |
| 16 | PAD_NC(GPP_S4, NONE), |
| 17 | PAD_NC(GPP_S5, NONE), |
| 18 | PAD_NC(GPP_S6, NONE), |
| 19 | PAD_NC(GPP_S7, NONE), |
| 20 | }; |
| 21 | |
| 22 | static const struct pad_config sndw_enable_pads[] = { |
| 23 | PAD_CFG_NF(GPP_S0, NONE, DEEP, NF1), /* SNDW0_CLK */ |
| 24 | PAD_CFG_NF(GPP_S1, NONE, DEEP, NF1), /* SNDW0_DATA */ |
| 25 | PAD_CFG_NF(GPP_S2, NONE, DEEP, NF1), /* SNDW1_CLK */ |
| 26 | PAD_CFG_NF(GPP_S3, NONE, DEEP, NF1), /* SNDW1_DATA */ |
| 27 | }; |
| 28 | |
| 29 | static const struct pad_config sndw_disable_pads[] = { |
| 30 | PAD_NC(GPP_S0, NONE), |
| 31 | PAD_NC(GPP_S1, NONE), |
| 32 | PAD_NC(GPP_S2, NONE), |
| 33 | PAD_NC(GPP_S3, NONE), |
| 34 | }; |
| 35 | |
Frank Wu | 362bcee | 2020-08-19 09:56:43 +0800 | [diff] [blame] | 36 | static const struct pad_config i2s_up3_enable_pads[] = { |
Duncan Laurie | 9db8c25 | 2020-05-10 11:16:45 -0700 | [diff] [blame] | 37 | PAD_CFG_NF(GPP_A23, NONE, DEEP, NF1), /* I2S1_SCLK */ |
| 38 | PAD_CFG_NF(GPP_D19, NONE, DEEP, NF1), /* I2S_MCLK1 */ |
| 39 | PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), /* I2S0_SCLK */ |
| 40 | PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), /* I2S0_SFRM */ |
| 41 | PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), /* I2S0_TXD */ |
| 42 | PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), /* I2S0_RXD */ |
| 43 | PAD_CFG_NF(GPP_R5, NONE, DEEP, NF2), /* I2S1_RXD */ |
| 44 | PAD_CFG_NF(GPP_R6, NONE, DEEP, NF2), /* I2S1_TXD */ |
| 45 | PAD_CFG_NF(GPP_R7, NONE, DEEP, NF2), /* I2S1_SFRM */ |
| 46 | }; |
| 47 | |
Frank Wu | 362bcee | 2020-08-19 09:56:43 +0800 | [diff] [blame] | 48 | static const struct pad_config i2s_up4_enable_pads[] = { |
| 49 | PAD_CFG_NF(GPP_A7, NONE, DEEP, NF1), /* I2S2_SCLK */ |
| 50 | PAD_CFG_NF(GPP_D19, NONE, DEEP, NF1), /* I2S_MCLK1 */ |
| 51 | PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), /* I2S0_SCLK */ |
| 52 | PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), /* I2S0_SFRM */ |
| 53 | PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), /* I2S0_TXD */ |
| 54 | PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), /* I2S0_RXD */ |
| 55 | }; |
| 56 | |
Duncan Laurie | 9db8c25 | 2020-05-10 11:16:45 -0700 | [diff] [blame] | 57 | static const struct pad_config i2s_disable_pads[] = { |
| 58 | PAD_NC(GPP_A23, NONE), |
| 59 | PAD_NC(GPP_D19, NONE), |
| 60 | PAD_NC(GPP_R0, NONE), |
| 61 | PAD_NC(GPP_R1, NONE), |
| 62 | PAD_NC(GPP_R2, DN_20K), |
| 63 | PAD_NC(GPP_R3, NONE), |
| 64 | PAD_NC(GPP_R5, NONE), |
| 65 | PAD_NC(GPP_R6, NONE), |
| 66 | PAD_NC(GPP_R7, NONE), |
| 67 | }; |
| 68 | |
Duncan Laurie | 912d9ec | 2020-11-30 10:09:42 -0800 | [diff] [blame^] | 69 | static const struct pad_config sd_power_enable_pads[] = { |
Duncan Laurie | 9d0fde3 | 2020-11-09 09:36:31 -0800 | [diff] [blame] | 70 | PAD_CFG_GPO(GPP_D16, 1, DEEP), |
| 71 | }; |
| 72 | |
Duncan Laurie | 9db8c25 | 2020-05-10 11:16:45 -0700 | [diff] [blame] | 73 | static void fw_config_handle(void *unused) |
| 74 | { |
| 75 | if (fw_config_probe(FW_CONFIG(AUDIO, NONE))) { |
| 76 | printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); |
| 77 | gpio_configure_pads(i2s_disable_pads, ARRAY_SIZE(i2s_disable_pads)); |
| 78 | gpio_configure_pads(dmic_disable_pads, ARRAY_SIZE(dmic_disable_pads)); |
| 79 | gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 80 | } |
| 81 | if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682_SNDW))) { |
| 82 | printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n"); |
| 83 | gpio_configure_pads(sndw_enable_pads, ARRAY_SIZE(sndw_enable_pads)); |
| 84 | gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 85 | gpio_configure_pads(i2s_disable_pads, ARRAY_SIZE(i2s_disable_pads)); |
| 86 | } |
| 87 | if (fw_config_probe(FW_CONFIG(AUDIO, MAX98357_ALC5682I_I2S)) || |
Wisley Chen | 35010ef | 2020-11-06 17:16:59 +0800 | [diff] [blame] | 88 | fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682I_I2S)) || |
Stanley Wu | 64f7bdf | 2020-10-30 12:01:20 +0800 | [diff] [blame] | 89 | fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S)) || |
| 90 | fw_config_probe(FW_CONFIG(AUDIO, RT1011_ALC5682I_I2S))) { |
Frank Wu | 362bcee | 2020-08-19 09:56:43 +0800 | [diff] [blame] | 91 | printk(BIOS_INFO, "Configure GPIOs for I2S audio on UP3.\n"); |
| 92 | gpio_configure_pads(i2s_up3_enable_pads, ARRAY_SIZE(i2s_up3_enable_pads)); |
| 93 | gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 94 | gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 95 | } |
| 96 | if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682I_I2S_UP4))) { |
| 97 | printk(BIOS_INFO, "Configure GPIOs for I2S audio on UP4.\n"); |
| 98 | gpio_configure_pads(i2s_up4_enable_pads, ARRAY_SIZE(i2s_up4_enable_pads)); |
Duncan Laurie | 9db8c25 | 2020-05-10 11:16:45 -0700 | [diff] [blame] | 99 | gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 100 | gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 101 | } |
Duncan Laurie | 912d9ec | 2020-11-30 10:09:42 -0800 | [diff] [blame^] | 102 | if (fw_config_probe(FW_CONFIG(DB_SD, SD_GL9755S)) || |
| 103 | fw_config_probe(FW_CONFIG(DB_SD, SD_RTS5227S)) || |
| 104 | fw_config_probe(FW_CONFIG(DB_SD, SD_GL9750)) || |
| 105 | fw_config_probe(FW_CONFIG(DB_SD, SD_OZ711LV2LN))) { |
| 106 | printk(BIOS_INFO, "Configure GPIOs for SD power enable.\n"); |
| 107 | gpio_configure_pads(sd_power_enable_pads, ARRAY_SIZE(sd_power_enable_pads)); |
Duncan Laurie | 9d0fde3 | 2020-11-09 09:36:31 -0800 | [diff] [blame] | 108 | } |
Duncan Laurie | 9db8c25 | 2020-05-10 11:16:45 -0700 | [diff] [blame] | 109 | } |
| 110 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fw_config_handle, NULL); |