Terry Cheong | 03807ac | 2023-12-07 19:39:41 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <baseboard/variants.h> |
| 4 | #include <bootstate.h> |
| 5 | #include <console/console.h> |
| 6 | #include <fw_config.h> |
| 7 | #include <gpio.h> |
| 8 | |
| 9 | #define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a)) |
| 10 | |
| 11 | static const struct pad_config dmic_disable_pads[] = { |
| 12 | PAD_NC(GPP_S02, NONE), |
| 13 | PAD_NC(GPP_S03, NONE), |
| 14 | PAD_NC(GPP_S06, NONE), |
| 15 | PAD_NC(GPP_S07, NONE), |
| 16 | }; |
| 17 | |
| 18 | static const struct pad_config i2s_disable_pads[] = { |
| 19 | PAD_NC(GPP_D09, NONE), |
| 20 | PAD_NC(GPP_D10, NONE), |
| 21 | PAD_NC(GPP_D11, NONE), |
| 22 | PAD_NC(GPP_D12, DN_20K), |
| 23 | PAD_NC(GPP_D13, NONE), |
| 24 | PAD_NC(GPP_D14, NONE), |
| 25 | PAD_NC(GPP_D15, NONE), |
| 26 | PAD_NC(GPP_D16, NONE), |
| 27 | PAD_NC(GPP_D17, NONE), |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | static const struct pad_config bt_i2s_enable_pads[] = { |
| 32 | /* GPP_V30 : [] ==> BT_I2S_BCLK */ |
| 33 | PAD_CFG_NF(GPP_VGPIO30, NONE, DEEP, NF2), |
| 34 | /* GPP_V31 : [] ==> BT_I2S_SYNC */ |
| 35 | PAD_CFG_NF(GPP_VGPIO31, NONE, DEEP, NF2), |
| 36 | /* GPP_V32 : [] ==> BT_I2S_SDO */ |
| 37 | PAD_CFG_NF(GPP_VGPIO32, NONE, DEEP, NF2), |
| 38 | /* GPP_V33 : [] ==> BT_I2S_SDI */ |
| 39 | PAD_CFG_NF(GPP_VGPIO33, NONE, DEEP, NF2), |
| 40 | /* GPP_V34 : [] ==> SSP2_SCLK */ |
| 41 | PAD_CFG_NF(GPP_VGPIO34, NONE, DEEP, NF1), |
| 42 | /* GPP_V35 : [] ==> SSP2_SFRM */ |
| 43 | PAD_CFG_NF(GPP_VGPIO35, NONE, DEEP, NF1), |
| 44 | /* GPP_V36 : [] ==> SSP_TXD */ |
| 45 | PAD_CFG_NF(GPP_VGPIO36, NONE, DEEP, NF1), |
| 46 | /* GPP_V37 : [] ==> SSP_RXD */ |
| 47 | PAD_CFG_NF(GPP_VGPIO37, NONE, DEEP, NF1), |
| 48 | }; |
| 49 | |
| 50 | static const struct pad_config bt_i2s_disable_pads[] = { |
| 51 | /* GPP_V30 : [] ==> BT_I2S_BCLK */ |
| 52 | PAD_NC(GPP_VGPIO30, NONE), |
| 53 | /* GPP_V31 : [] ==> BT_I2S_SYNC */ |
| 54 | PAD_NC(GPP_VGPIO31, NONE), |
| 55 | /* GPP_V32 : [] ==> BT_I2S_SDO */ |
| 56 | PAD_NC(GPP_VGPIO32, NONE), |
| 57 | /* GPP_V33 : [] ==> BT_I2S_SDI */ |
| 58 | PAD_NC(GPP_VGPIO33, NONE), |
| 59 | /* GPP_V34 : [] ==> SSP2_SCLK */ |
| 60 | PAD_NC(GPP_VGPIO34, NONE), |
| 61 | /* GPP_V35 : [] ==> SSP2_SFRM */ |
| 62 | PAD_NC(GPP_VGPIO35, NONE), |
| 63 | /* GPP_V36 : [] ==> SSP_TXD */ |
| 64 | PAD_NC(GPP_VGPIO36, NONE), |
| 65 | /* GPP_V37 : [] ==> SSP_RXD */ |
| 66 | PAD_NC(GPP_VGPIO37, NONE), |
| 67 | }; |
| 68 | |
| 69 | void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
| 70 | { |
| 71 | if (!fw_config_is_provisioned()) { |
| 72 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 73 | GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 74 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { |
| 79 | printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); |
| 80 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 81 | GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 82 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
| 83 | } else if (fw_config_probe(FW_CONFIG(AUDIO, ALC1019_ALC5682I_I2S))) { |
| 84 | printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 85 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
| 86 | } |
| 87 | } |