| 1 |
|
| 2 |
|
| 3 |
#include <baseboard/variants.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <fw_config.h> |
| 6 |
#include <gpio.h> |
| 7 |
#include <inttypes.h> |
| 8 |
|
| 9 |
|
| 10 |
#define GPIO_PADBASED_OVERRIDE(t, o) gpio_padbased_override(t, o, ARRAY_SIZE(o)) |
| 11 |
|
| 12 |
#define GPIO_CONFIGURE_PADS(t) gpio_configure_pads(t, ARRAY_SIZE(t)) |
| 13 |
|
| 14 |
static const struct pad_config hda_enable_pads[] = { |
| 15 |
|
| 16 |
PAD_CFG_NF(GPP_D10, NONE, DEEP, NF1), |
| 17 |
|
| 18 |
PAD_CFG_NF(GPP_D11, NATIVE, DEEP, NF1), |
| 19 |
|
| 20 |
PAD_CFG_NF(GPP_D12, NATIVE, DEEP, NF1), |
| 21 |
|
| 22 |
PAD_CFG_NF(GPP_D13, NATIVE, DEEP, NF1), |
| 23 |
|
| 24 |
PAD_CFG_NF(GPP_S06, NONE, DEEP, NF5), |
| 25 |
|
| 26 |
PAD_CFG_NF(GPP_S07, NONE, DEEP, NF5), |
| 27 |
}; |
| 28 |
|
| 29 |
static const struct pad_config sndw_alc721_enable_pads[] = { |
| 30 |
|
| 31 |
PAD_CFG_NF(GPP_S02, NONE, DEEP, NF3), |
| 32 |
|
| 33 |
PAD_CFG_NF(GPP_S03, NONE, DEEP, NF3), |
| 34 |
|
| 35 |
PAD_CFG_NF(GPP_S06, NONE, DEEP, NF5), |
| 36 |
|
| 37 |
PAD_CFG_NF(GPP_S07, NONE, DEEP, NF5), |
| 38 |
}; |
| 39 |
|
| 40 |
static const struct pad_config sndw_alc722_alc1320_enable_pads[] = { |
| 41 |
|
| 42 |
PAD_CFG_NF(GPP_S00, NONE, DEEP, NF1), |
| 43 |
|
| 44 |
PAD_CFG_NF(GPP_S01, NONE, DEEP, NF1), |
| 45 |
|
| 46 |
PAD_CFG_NF(GPP_S02, NONE, DEEP, NF3), |
| 47 |
|
| 48 |
PAD_CFG_NF(GPP_S03, NONE, DEEP, NF3), |
| 49 |
|
| 50 |
PAD_CFG_NF(GPP_S04, NONE, DEEP, NF2), |
| 51 |
|
| 52 |
PAD_CFG_NF(GPP_S05, NONE, DEEP, NF2), |
| 53 |
|
| 54 |
PAD_CFG_NF(GPP_S06, NONE, DEEP, NF5), |
| 55 |
|
| 56 |
PAD_CFG_NF(GPP_S07, NONE, DEEP, NF5), |
| 57 |
}; |
| 58 |
|
| 59 |
static const struct pad_config enable_dmic_0_pads[] = { |
| 60 |
|
| 61 |
PAD_CFG_NF(GPP_S02, NONE, DEEP, NF5), |
| 62 |
|
| 63 |
PAD_CFG_NF(GPP_S03, NONE, DEEP, NF5), |
| 64 |
}; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
static const struct pad_config pre_mem_wwan_pwr_seq1_pads[] = { |
| 75 |
|
| 76 |
PAD_CFG_GPO(GPP_A09, 0, PLTRST), |
| 77 |
|
| 78 |
PAD_CFG_GPO(GPP_B20, 0, PLTRST), |
| 79 |
|
| 80 |
PAD_CFG_GPO(GPP_D03, 0, PLTRST), |
| 81 |
}; |
| 82 |
|
| 83 |
static const struct pad_config pre_mem_wwan_pwr_seq2_pads[] = { |
| 84 |
|
| 85 |
PAD_CFG_GPO(GPP_A09, 1, PLTRST), |
| 86 |
}; |
| 87 |
|
| 88 |
static const struct pad_config wwan_pwr_seq3_pads[] = { |
| 89 |
|
| 90 |
PAD_CFG_GPO(GPP_D03, 1, PLTRST), |
| 91 |
|
| 92 |
PAD_CFG_GPO(GPP_B20, 1, PLTRST), |
| 93 |
|
| 94 |
PAD_CFG_GPI_SCI_LOW(GPP_E02, NONE, DEEP, LEVEL), |
| 95 |
}; |
| 96 |
|
| 97 |
static const struct pad_config wwan_disable_pads[] = { |
| 98 |
|
| 99 |
PAD_NC(GPP_A09, NONE), |
| 100 |
|
| 101 |
PAD_NC(GPP_D03, NONE), |
| 102 |
|
| 103 |
PAD_NC(GPP_B20, NONE), |
| 104 |
|
| 105 |
PAD_NC(GPP_A10, NONE), |
| 106 |
|
| 107 |
PAD_NC(GPP_E02, NONE), |
| 108 |
}; |
| 109 |
|
| 110 |
static const struct pad_config bridge_disable_pads[] = { |
| 111 |
|
| 112 |
PAD_NC(GPP_D18, NONE), |
| 113 |
}; |
| 114 |
|
| 115 |
void fw_config_configure_pre_mem_gpio(void) |
| 116 |
{ |
| 117 |
if (!fw_config_is_provisioned()) { |
| 118 |
printk(BIOS_WARNING, "FW_CONFIG is not provisioned, Exiting\n"); |
| 119 |
return; |
| 120 |
} |
| 121 |
|
| 122 |
if (!fw_config_probe(FW_CONFIG(WWAN, WWAN_ABSENT))) |
| 123 |
GPIO_CONFIGURE_PADS(pre_mem_wwan_pwr_seq1_pads); |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
if (!fw_config_probe(FW_CONFIG(WWAN, WWAN_ABSENT))) |
| 136 |
GPIO_CONFIGURE_PADS(pre_mem_wwan_pwr_seq2_pads); |
| 137 |
} |
| 138 |
|
| 139 |
void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
| 140 |
{ |
| 141 |
if (!fw_config_is_provisioned()) { |
| 142 |
printk(BIOS_WARNING, "FW_CONFIG is not provisioned, Exiting\n"); |
| 143 |
return; |
| 144 |
} |
| 145 |
|
| 146 |
if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC256M_CG_HDA))) { |
| 147 |
printk(BIOS_INFO, "Configure GPIOs for HDA ALC256 mode.\n"); |
| 148 |
GPIO_PADBASED_OVERRIDE(padbased_table, hda_enable_pads); |
| 149 |
GPIO_PADBASED_OVERRIDE(padbased_table, enable_dmic_0_pads); |
| 150 |
} else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC721_SNDW))) { |
| 151 |
printk(BIOS_INFO, "Configure GPIOs for Soundwire ALC721 mode.\n"); |
| 152 |
GPIO_PADBASED_OVERRIDE(padbased_table, sndw_alc721_enable_pads); |
| 153 |
} else if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_ALC722_ALC1320_SNDW))) { |
| 154 |
printk(BIOS_INFO, "Configure GPIOs for Soundwire ALC722 & ALC1320 mode.\n"); |
| 155 |
GPIO_PADBASED_OVERRIDE(padbased_table, sndw_alc722_alc1320_enable_pads); |
| 156 |
} |
| 157 |
|
| 158 |
if (fw_config_probe(FW_CONFIG(WWAN, WWAN_PRESENT))) { |
| 159 |
GPIO_PADBASED_OVERRIDE(padbased_table, wwan_pwr_seq3_pads); |
| 160 |
} else { |
| 161 |
GPIO_PADBASED_OVERRIDE(padbased_table, wwan_disable_pads); |
| 162 |
} |
| 163 |
|
| 164 |
if (fw_config_probe(FW_CONFIG(BRIDGE, BRIDGE_HAYDEN))) { |
| 165 |
GPIO_PADBASED_OVERRIDE(padbased_table, bridge_disable_pads); |
| 166 |
} |
| 167 |
|
| 168 |
} |