Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [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 sndw_disable_pads[] = { |
| 19 | PAD_NC(GPP_S00, NONE), |
| 20 | PAD_NC(GPP_S01, NONE), |
| 21 | PAD_NC(GPP_S04, NONE), |
| 22 | PAD_NC(GPP_S05, NONE), |
| 23 | }; |
| 24 | |
| 25 | static const struct pad_config i2s_disable_pads[] = { |
| 26 | PAD_NC(GPP_D09, NONE), |
| 27 | PAD_NC(GPP_D10, NONE), |
| 28 | PAD_NC(GPP_D11, NONE), |
| 29 | PAD_NC(GPP_D12, DN_20K), |
| 30 | PAD_NC(GPP_D13, NONE), |
| 31 | PAD_NC(GPP_D14, NONE), |
| 32 | PAD_NC(GPP_D15, NONE), |
| 33 | PAD_NC(GPP_D16, NONE), |
| 34 | PAD_NC(GPP_D17, NONE), |
| 35 | }; |
| 36 | |
Ravi Sarawadi | 9afa18f | 2023-02-07 09:33:46 -0800 | [diff] [blame] | 37 | static const struct pad_config bt_i2s_enable_pads[] = { |
| 38 | /* GPP_V30 : [] ==> BT_I2S_BCLK */ |
| 39 | PAD_CFG_NF(GPP_VGPIO30, NONE, DEEP, NF2), |
| 40 | /* GPP_V31 : [] ==> BT_I2S_SYNC */ |
| 41 | PAD_CFG_NF(GPP_VGPIO31, NONE, DEEP, NF2), |
| 42 | /* GPP_V32 : [] ==> BT_I2S_SDO */ |
| 43 | PAD_CFG_NF(GPP_VGPIO32, NONE, DEEP, NF2), |
| 44 | /* GPP_V33 : [] ==> BT_I2S_SDI */ |
| 45 | PAD_CFG_NF(GPP_VGPIO33, NONE, DEEP, NF2), |
| 46 | /* GPP_V34 : [] ==> SSP2_SCLK */ |
| 47 | PAD_CFG_NF(GPP_VGPIO34, NONE, DEEP, NF1), |
| 48 | /* GPP_V35 : [] ==> SSP2_SFRM */ |
| 49 | PAD_CFG_NF(GPP_VGPIO35, NONE, DEEP, NF1), |
| 50 | /* GPP_V36 : [] ==> SSP_TXD */ |
| 51 | PAD_CFG_NF(GPP_VGPIO36, NONE, DEEP, NF1), |
| 52 | /* GPP_V37 : [] ==> SSP_RXD */ |
| 53 | PAD_CFG_NF(GPP_VGPIO37, NONE, DEEP, NF1), |
| 54 | }; |
| 55 | |
| 56 | static const struct pad_config bt_i2s_disable_pads[] = { |
| 57 | /* GPP_V30 : [] ==> BT_I2S_BCLK */ |
| 58 | PAD_NC(GPP_VGPIO30, NONE), |
| 59 | /* GPP_V31 : [] ==> BT_I2S_SYNC */ |
| 60 | PAD_NC(GPP_VGPIO31, NONE), |
| 61 | /* GPP_V32 : [] ==> BT_I2S_SDO */ |
| 62 | PAD_NC(GPP_VGPIO32, NONE), |
| 63 | /* GPP_V33 : [] ==> BT_I2S_SDI */ |
| 64 | PAD_NC(GPP_VGPIO33, NONE), |
| 65 | /* GPP_V34 : [] ==> SSP2_SCLK */ |
| 66 | PAD_NC(GPP_VGPIO34, NONE), |
| 67 | /* GPP_V35 : [] ==> SSP2_SFRM */ |
| 68 | PAD_NC(GPP_VGPIO35, NONE), |
| 69 | /* GPP_V36 : [] ==> SSP_TXD */ |
| 70 | PAD_NC(GPP_VGPIO36, NONE), |
| 71 | /* GPP_V37 : [] ==> SSP_RXD */ |
| 72 | PAD_NC(GPP_VGPIO37, NONE), |
| 73 | }; |
| 74 | |
Bernardo Perez Priego | 3dedfcb | 2023-05-30 13:48:59 -0700 | [diff] [blame] | 75 | static const struct pad_config ish_enable_pads[] = { |
| 76 | /* GPP_B02 : ISH I2C0_SDA */ |
| 77 | PAD_CFG_NF(GPP_B02, NONE, DEEP, NF3), |
| 78 | /* GPP_B03 : ISH_I2C0_SCL */ |
| 79 | PAD_CFG_NF(GPP_B03, NONE, DEEP, NF3), |
| 80 | /* GPP_D05 : ISH_UART_TX */ |
| 81 | PAD_CFG_NF(GPP_D05, NONE, DEEP, NF2), |
| 82 | /* GPP_D06 : ISH_UART_RX */ |
| 83 | PAD_CFG_NF(GPP_D06, NONE, DEEP, NF2), |
| 84 | /* GPP_B08 : ISH_GP3, SOC_ISH_ACCEL_INT_L */ |
| 85 | PAD_CFG_NF(GPP_B08, NONE, DEEP, NF4), |
| 86 | /* GPP_E15 : ISH_GP5A, SOC_ISH_IMU_INT_L */ |
| 87 | PAD_CFG_NF(GPP_E15, NONE, DEEP, NF8), |
| 88 | /* GPP_F22 : ISH_GP8A, SOC_ISH_ALS_INT_L */ |
| 89 | PAD_CFG_NF(GPP_F22, NONE, DEEP, NF8), |
| 90 | }; |
| 91 | |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 92 | void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
| 93 | { |
| 94 | if (!fw_config_is_provisioned()) { |
| 95 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 96 | GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 97 | GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
Ravi Sarawadi | 9afa18f | 2023-02-07 09:33:46 -0800 | [diff] [blame] | 98 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 99 | return; |
| 100 | } |
| 101 | |
| 102 | if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { |
| 103 | printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); |
| 104 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 105 | GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 106 | GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
Ravi Sarawadi | 9afa18f | 2023-02-07 09:33:46 -0800 | [diff] [blame] | 107 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 108 | } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98363_CS42L42_SNDW))) { |
| 109 | printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n"); |
| 110 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
Uday M Bhat | 68e3826 | 2023-06-22 21:25:55 +0530 | [diff] [blame^] | 111 | printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 112 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 113 | } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) { |
| 114 | printk(BIOS_INFO, "Configure GPIOs for I2S audio.\n"); |
| 115 | GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
Ravi Sarawadi | 9afa18f | 2023-02-07 09:33:46 -0800 | [diff] [blame] | 116 | printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 117 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 118 | } |
Bernardo Perez Priego | 3dedfcb | 2023-05-30 13:48:59 -0700 | [diff] [blame] | 119 | |
| 120 | if (fw_config_probe(FW_CONFIG(ISH, ISH_ENABLE))) { |
| 121 | printk(BIOS_INFO, "Configure GPIOs for ISH.\n"); |
| 122 | GPIO_PADBASED_OVERRIDE(padbased_table, ish_enable_pads); |
| 123 | } |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 124 | } |