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), |
Bernardo Perez Priego | 5f15e37 | 2023-08-15 17:45:50 -0700 | [diff] [blame^] | 88 | /* GPP_E16 : ISH_GP10, SOC_EC_ISH_NB_MODE */ |
| 89 | PAD_CFG_NF(GPP_E16, NONE, DEEP, NF8), |
Bernardo Perez Priego | 3dedfcb | 2023-05-30 13:48:59 -0700 | [diff] [blame] | 90 | /* GPP_F22 : ISH_GP8A, SOC_ISH_ALS_INT_L */ |
| 91 | PAD_CFG_NF(GPP_F22, NONE, DEEP, NF8), |
Bernardo Perez Priego | 5f15e37 | 2023-08-15 17:45:50 -0700 | [diff] [blame^] | 92 | /* GPP_F23 : ISH_GP9A, LID_OPEN_1V8 */ |
| 93 | PAD_CFG_NF(GPP_F23, NONE, DEEP, NF8), |
| 94 | /* GPP_H11 : ISH_GP11A, SOC_ISH_IMU_INT_L */ |
| 95 | PAD_CFG_NF(GPP_H11, NONE, DEEP, NF8), |
Bernardo Perez Priego | 3dedfcb | 2023-05-30 13:48:59 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
Eran Mitrani | 95a5e72 | 2023-06-26 13:27:42 -0700 | [diff] [blame] | 98 | static const struct pad_config touchscreen_i2c_int_pads[] = { |
| 99 | /* GPP_C07 : [] ==> SOC_TCHSCR_INT */ |
| 100 | PAD_CFG_GPI_APIC(GPP_C07, NONE, PLTRST, LEVEL, NONE), |
| 101 | }; |
| 102 | |
| 103 | static const struct pad_config touchscreen_spi_int_pads[] = { |
| 104 | /* GPP_C07 : [] ==> SOC_TCHSCR_INT */ |
| 105 | PAD_CFG_GPI_APIC(GPP_C07, NONE, PLTRST, EDGE_SINGLE, INVERT), |
| 106 | }; |
| 107 | |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 108 | void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
| 109 | { |
| 110 | if (!fw_config_is_provisioned()) { |
| 111 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 112 | GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 113 | GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
Ravi Sarawadi | 9afa18f | 2023-02-07 09:33:46 -0800 | [diff] [blame] | 114 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 115 | return; |
| 116 | } |
| 117 | |
| 118 | if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { |
| 119 | printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); |
| 120 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 121 | GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 122 | GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
Ravi Sarawadi | 9afa18f | 2023-02-07 09:33:46 -0800 | [diff] [blame] | 123 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 124 | } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98363_CS42L42_SNDW))) { |
| 125 | printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n"); |
| 126 | GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
Uday M Bhat | 68e3826 | 2023-06-22 21:25:55 +0530 | [diff] [blame] | 127 | printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 128 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 129 | } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) { |
| 130 | printk(BIOS_INFO, "Configure GPIOs for I2S audio.\n"); |
| 131 | GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
Ravi Sarawadi | 9afa18f | 2023-02-07 09:33:46 -0800 | [diff] [blame] | 132 | printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 133 | GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 134 | } |
Bernardo Perez Priego | 3dedfcb | 2023-05-30 13:48:59 -0700 | [diff] [blame] | 135 | |
| 136 | if (fw_config_probe(FW_CONFIG(ISH, ISH_ENABLE))) { |
| 137 | printk(BIOS_INFO, "Configure GPIOs for ISH.\n"); |
| 138 | GPIO_PADBASED_OVERRIDE(padbased_table, ish_enable_pads); |
| 139 | } |
Eran Mitrani | 95a5e72 | 2023-06-26 13:27:42 -0700 | [diff] [blame] | 140 | |
| 141 | if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_I2C))) { |
| 142 | printk(BIOS_INFO, "Configure Touchscreen Interrupt for I2C.\n"); |
| 143 | GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_i2c_int_pads); |
| 144 | } else { /* SPI */ |
| 145 | printk(BIOS_INFO, "Configure Touchscreen Interrupt for SPI.\n"); |
| 146 | GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_spi_int_pads); |
| 147 | } |
Kapil Porwal | 8618bc6 | 2023-02-19 22:07:55 +0530 | [diff] [blame] | 148 | } |