| 1 |
|
| 2 |
|
| 3 |
#include <baseboard/variants.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <fw_config.h> |
| 6 |
#include <gpio.h> |
| 7 |
|
| 8 |
#define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a)) |
| 9 |
|
| 10 |
static const struct pad_config dmic_disable_pads[] = { |
| 11 |
PAD_NC(GPP_S02, NONE), |
| 12 |
PAD_NC(GPP_S03, NONE), |
| 13 |
PAD_NC(GPP_S06, NONE), |
| 14 |
PAD_NC(GPP_S07, NONE), |
| 15 |
}; |
| 16 |
|
| 17 |
static const struct pad_config sndw_disable_pads[] = { |
| 18 |
PAD_NC(GPP_S00, NONE), |
| 19 |
PAD_NC(GPP_S01, NONE), |
| 20 |
PAD_NC(GPP_S04, NONE), |
| 21 |
PAD_NC(GPP_S05, NONE), |
| 22 |
}; |
| 23 |
|
| 24 |
static const struct pad_config i2s_disable_pads[] = { |
| 25 |
PAD_NC(GPP_D09, NONE), |
| 26 |
PAD_NC(GPP_D10, NONE), |
| 27 |
PAD_NC(GPP_D11, NONE), |
| 28 |
PAD_NC(GPP_D12, DN_20K), |
| 29 |
PAD_NC(GPP_D13, NONE), |
| 30 |
PAD_NC(GPP_D14, NONE), |
| 31 |
PAD_NC(GPP_D15, NONE), |
| 32 |
PAD_NC(GPP_D16, NONE), |
| 33 |
PAD_NC(GPP_D17, NONE), |
| 34 |
}; |
| 35 |
|
| 36 |
static const struct pad_config bt_i2s_enable_pads[] = { |
| 37 |
|
| 38 |
PAD_CFG_NF(GPP_VGPIO30, NONE, DEEP, NF2), |
| 39 |
|
| 40 |
PAD_CFG_NF(GPP_VGPIO31, NONE, DEEP, NF2), |
| 41 |
|
| 42 |
PAD_CFG_NF(GPP_VGPIO32, NONE, DEEP, NF2), |
| 43 |
|
| 44 |
PAD_CFG_NF(GPP_VGPIO33, NONE, DEEP, NF2), |
| 45 |
|
| 46 |
PAD_CFG_NF(GPP_VGPIO34, NONE, DEEP, NF1), |
| 47 |
|
| 48 |
PAD_CFG_NF(GPP_VGPIO35, NONE, DEEP, NF1), |
| 49 |
|
| 50 |
PAD_CFG_NF(GPP_VGPIO36, NONE, DEEP, NF1), |
| 51 |
|
| 52 |
PAD_CFG_NF(GPP_VGPIO37, NONE, DEEP, NF1), |
| 53 |
}; |
| 54 |
|
| 55 |
static const struct pad_config discrete_bt_i2s_enable_pads[] = { |
| 56 |
|
| 57 |
PAD_CFG_NF(GPP_S00, NONE, DEEP, NF6), |
| 58 |
|
| 59 |
PAD_CFG_NF(GPP_S01, NONE, DEEP, NF6), |
| 60 |
|
| 61 |
PAD_CFG_NF(GPP_S02, NONE, DEEP, NF6), |
| 62 |
|
| 63 |
PAD_CFG_NF(GPP_S03, NONE, DEEP, NF6), |
| 64 |
}; |
| 65 |
|
| 66 |
static const struct pad_config bt_i2s_disable_pads[] = { |
| 67 |
|
| 68 |
PAD_NC(GPP_VGPIO30, NONE), |
| 69 |
|
| 70 |
PAD_NC(GPP_VGPIO31, NONE), |
| 71 |
|
| 72 |
PAD_NC(GPP_VGPIO32, NONE), |
| 73 |
|
| 74 |
PAD_NC(GPP_VGPIO33, NONE), |
| 75 |
|
| 76 |
PAD_NC(GPP_VGPIO34, NONE), |
| 77 |
|
| 78 |
PAD_NC(GPP_VGPIO35, NONE), |
| 79 |
|
| 80 |
PAD_NC(GPP_VGPIO36, NONE), |
| 81 |
|
| 82 |
PAD_NC(GPP_VGPIO37, NONE), |
| 83 |
}; |
| 84 |
|
| 85 |
static const struct pad_config ish_enable_pads[] = { |
| 86 |
|
| 87 |
PAD_CFG_NF_IOSTANDBY_IGNORE(GPP_B02, NONE, DEEP, NF3), |
| 88 |
|
| 89 |
PAD_CFG_NF_IOSTANDBY_IGNORE(GPP_B03, NONE, DEEP, NF3), |
| 90 |
|
| 91 |
PAD_CFG_NF(GPP_B08, NONE, DEEP, NF4), |
| 92 |
|
| 93 |
PAD_CFG_NF(GPP_E15, NONE, DEEP, NF8), |
| 94 |
|
| 95 |
PAD_CFG_NF(GPP_E16, NONE, DEEP, NF8), |
| 96 |
|
| 97 |
PAD_CFG_NF(GPP_F22, NONE, DEEP, NF8), |
| 98 |
|
| 99 |
PAD_CFG_NF(GPP_F23, NONE, DEEP, NF8), |
| 100 |
|
| 101 |
PAD_CFG_NF(GPP_H11, NONE, DEEP, NF8), |
| 102 |
}; |
| 103 |
|
| 104 |
static const struct pad_config touchscreen_i2c_int_pads[] = { |
| 105 |
|
| 106 |
PAD_CFG_GPI_APIC(GPP_C07, NONE, PLTRST, LEVEL, NONE), |
| 107 |
}; |
| 108 |
|
| 109 |
static const struct pad_config touchscreen_spi_int_pads[] = { |
| 110 |
|
| 111 |
PAD_CFG_GPI_APIC(GPP_C07, NONE, PLTRST, EDGE_SINGLE, INVERT), |
| 112 |
}; |
| 113 |
|
| 114 |
static const struct pad_config uwb_gspi1_enable_pads[] = { |
| 115 |
PAD_CFG_GPO_LOCK(GPP_D07, 0, LOCK_CONFIG), |
| 116 |
PAD_CFG_GPO(GPP_E06, 0, DEEP), |
| 117 |
PAD_CFG_GPO(GPP_F19, 0, DEEP), |
| 118 |
PAD_CFG_GPI_INT(GPP_F20, NONE, PLTRST, LEVEL), |
| 119 |
}; |
| 120 |
|
| 121 |
static const struct pad_config uwb_gspi1_disable_pads[] = { |
| 122 |
PAD_CFG_GPO_LOCK(GPP_D07, 1, LOCK_CONFIG), |
| 123 |
PAD_NC(GPP_E06, NONE), |
| 124 |
PAD_NC(GPP_F19, NONE), |
| 125 |
PAD_NC(GPP_F20, NONE), |
| 126 |
}; |
| 127 |
|
| 128 |
static const struct pad_config wwan_disable_pads[] = { |
| 129 |
PAD_CFG_GPO(GPP_B17, 0, DEEP) |
| 130 |
}; |
| 131 |
|
| 132 |
void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
| 133 |
{ |
| 134 |
if (!fw_config_is_provisioned()) { |
| 135 |
GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 136 |
GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 137 |
GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
| 138 |
GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
| 139 |
return; |
| 140 |
} |
| 141 |
|
| 142 |
if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { |
| 143 |
printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); |
| 144 |
GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 145 |
GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 146 |
GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
| 147 |
GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
| 148 |
} else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98363_CS42L42_SNDW))) { |
| 149 |
printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n"); |
| 150 |
GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 151 |
printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 152 |
GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
| 153 |
} else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) { |
| 154 |
printk(BIOS_INFO, "Configure GPIOs for I2S audio.\n"); |
| 155 |
GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
| 156 |
printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 157 |
GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
| 158 |
} else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_DISCRETE_I2S_BT))) { |
| 159 |
printk(BIOS_INFO, "Configure GPIOs for I2S audio.\n"); |
| 160 |
GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); |
| 161 |
printk(BIOS_INFO, "Configure GPIOs for BT offload mode(discrete).\n"); |
| 162 |
GPIO_PADBASED_OVERRIDE(padbased_table, discrete_bt_i2s_enable_pads); |
| 163 |
} |
| 164 |
|
| 165 |
if (fw_config_probe(FW_CONFIG(ISH, ISH_ENABLE))) { |
| 166 |
printk(BIOS_INFO, "Configure GPIOs for ISH.\n"); |
| 167 |
GPIO_PADBASED_OVERRIDE(padbased_table, ish_enable_pads); |
| 168 |
} |
| 169 |
|
| 170 |
if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_I2C))) { |
| 171 |
printk(BIOS_INFO, "Configure Touchscreen Interrupt for I2C.\n"); |
| 172 |
GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_i2c_int_pads); |
| 173 |
} else { |
| 174 |
printk(BIOS_INFO, "Configure Touchscreen Interrupt for SPI.\n"); |
| 175 |
GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_spi_int_pads); |
| 176 |
} |
| 177 |
|
| 178 |
if (fw_config_probe(FW_CONFIG(UWB, UWB_GSPI1)) && |
| 179 |
fw_config_probe(FW_CONFIG(FP, FP_ABSENT))) { |
| 180 |
printk(BIOS_INFO, "Configure GPIOs for UWB over GSPI1.\n"); |
| 181 |
GPIO_PADBASED_OVERRIDE(padbased_table, uwb_gspi1_enable_pads); |
| 182 |
} else { |
| 183 |
printk(BIOS_INFO, "Disabling UWB (absent or misconfigured)\n"); |
| 184 |
GPIO_PADBASED_OVERRIDE(padbased_table, uwb_gspi1_disable_pads); |
| 185 |
} |
| 186 |
|
| 187 |
if (fw_config_probe(FW_CONFIG(CELLULAR, CELLULAR_ABSENT))) { |
| 188 |
printk(BIOS_INFO, "Configure GPIOs for no cellular.\n"); |
| 189 |
GPIO_PADBASED_OVERRIDE(padbased_table, wwan_disable_pads); |
| 190 |
} |
| 191 |
} |