| 1 |
|
| 2 |
|
| 3 |
#include <bootstate.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <fw_config.h> |
| 6 |
#include <gpio.h> |
| 7 |
|
| 8 |
static const struct pad_config dmic_enable_pads[] = { |
| 9 |
PAD_CFG_NF(GPP_S2, NONE, DEEP, NF2), |
| 10 |
PAD_CFG_NF(GPP_S3, NONE, DEEP, NF2), |
| 11 |
PAD_CFG_NF(GPP_S6, NONE, DEEP, NF2), |
| 12 |
PAD_CFG_NF(GPP_S7, NONE, DEEP, NF2), |
| 13 |
}; |
| 14 |
|
| 15 |
static const struct pad_config dmic_disable_pads[] = { |
| 16 |
PAD_NC(GPP_S2, NONE), |
| 17 |
PAD_NC(GPP_S3, NONE), |
| 18 |
PAD_NC(GPP_S6, NONE), |
| 19 |
PAD_NC(GPP_S7, NONE), |
| 20 |
}; |
| 21 |
|
| 22 |
static const struct pad_config sndw_enable_pads[] = { |
| 23 |
PAD_CFG_NF(GPP_S0, NONE, DEEP, NF1), |
| 24 |
PAD_CFG_NF(GPP_S1, NONE, DEEP, NF1), |
| 25 |
PAD_CFG_NF(GPP_S4, NONE, DEEP, NF1), |
| 26 |
PAD_CFG_NF(GPP_S5, NONE, DEEP, NF1), |
| 27 |
}; |
| 28 |
|
| 29 |
static const struct pad_config max98360_enable_pads[] = { |
| 30 |
PAD_CFG_NF(GPP_S0, NONE, DEEP, NF4), |
| 31 |
PAD_CFG_NF(GPP_S1, NONE, DEEP, NF4), |
| 32 |
PAD_CFG_NF(GPP_S2, NONE, DEEP, NF4), |
| 33 |
PAD_CFG_NF(GPP_S3, NONE, DEEP, NF4), |
| 34 |
PAD_CFG_NF(GPP_S6, NONE, DEEP, NF2), |
| 35 |
PAD_CFG_NF(GPP_S7, NONE, DEEP, NF2), |
| 36 |
PAD_CFG_NF(GPP_R4, NONE, DEEP, NF3), |
| 37 |
PAD_CFG_NF(GPP_R5, NONE, DEEP, NF3), |
| 38 |
PAD_NC(GPP_R6, NONE), |
| 39 |
PAD_NC(GPP_R7, NONE), |
| 40 |
}; |
| 41 |
|
| 42 |
static const struct pad_config nau8318_enable_pads[] = { |
| 43 |
PAD_CFG_GPO(GPP_R7, 0, DEEP), |
| 44 |
}; |
| 45 |
|
| 46 |
static const struct pad_config sndw_disable_pads[] = { |
| 47 |
PAD_NC(GPP_S0, NONE), |
| 48 |
PAD_NC(GPP_S1, NONE), |
| 49 |
PAD_NC(GPP_S4, NONE), |
| 50 |
PAD_NC(GPP_S5, NONE), |
| 51 |
}; |
| 52 |
|
| 53 |
static const struct pad_config i2s0_enable_pads[] = { |
| 54 |
PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), |
| 55 |
PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), |
| 56 |
PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), |
| 57 |
PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), |
| 58 |
}; |
| 59 |
|
| 60 |
static const struct pad_config i2s2_enable_pads[] = { |
| 61 |
PAD_CFG_NF(GPP_R4, NONE, DEEP, NF2), |
| 62 |
PAD_CFG_NF(GPP_R5, NONE, DEEP, NF2), |
| 63 |
PAD_CFG_NF(GPP_R6, NONE, DEEP, NF2), |
| 64 |
PAD_CFG_NF(GPP_R7, NONE, DEEP, NF2), |
| 65 |
}; |
| 66 |
|
| 67 |
static const struct pad_config i2s0_disable_pads[] = { |
| 68 |
PAD_NC(GPP_R0, NONE), |
| 69 |
PAD_NC(GPP_R1, NONE), |
| 70 |
PAD_NC(GPP_R2, NONE), |
| 71 |
PAD_NC(GPP_R3, NONE), |
| 72 |
}; |
| 73 |
|
| 74 |
static const struct pad_config i2s2_disable_pads[] = { |
| 75 |
PAD_NC(GPP_R4, NONE), |
| 76 |
PAD_NC(GPP_R5, NONE), |
| 77 |
PAD_NC(GPP_R6, NONE), |
| 78 |
PAD_NC(GPP_R7, NONE), |
| 79 |
}; |
| 80 |
|
| 81 |
static const struct pad_config bt_i2s_enable_pads[] = { |
| 82 |
PAD_CFG_NF(GPP_VGPIO_30, NONE, DEEP, NF3), |
| 83 |
PAD_CFG_NF(GPP_VGPIO_31, NONE, DEEP, NF3), |
| 84 |
PAD_CFG_NF(GPP_VGPIO_32, NONE, DEEP, NF3), |
| 85 |
PAD_CFG_NF(GPP_VGPIO_33, NONE, DEEP, NF3), |
| 86 |
PAD_CFG_NF(GPP_VGPIO_34, NONE, DEEP, NF1), |
| 87 |
PAD_CFG_NF(GPP_VGPIO_35, NONE, DEEP, NF1), |
| 88 |
PAD_CFG_NF(GPP_VGPIO_36, NONE, DEEP, NF1), |
| 89 |
PAD_CFG_NF(GPP_VGPIO_37, NONE, DEEP, NF1), |
| 90 |
}; |
| 91 |
|
| 92 |
static const struct pad_config bt_i2s_disable_pads[] = { |
| 93 |
PAD_NC(GPP_VGPIO_30, NONE), |
| 94 |
PAD_NC(GPP_VGPIO_31, NONE), |
| 95 |
PAD_NC(GPP_VGPIO_32, NONE), |
| 96 |
PAD_NC(GPP_VGPIO_33, NONE), |
| 97 |
PAD_NC(GPP_VGPIO_34, NONE), |
| 98 |
PAD_NC(GPP_VGPIO_35, NONE), |
| 99 |
PAD_NC(GPP_VGPIO_36, NONE), |
| 100 |
PAD_NC(GPP_VGPIO_37, NONE), |
| 101 |
}; |
| 102 |
|
| 103 |
static const struct pad_config hps_disable_pads[] = { |
| 104 |
|
| 105 |
PAD_NC(GPP_E3, NONE), |
| 106 |
|
| 107 |
PAD_NC(GPP_E7, NONE), |
| 108 |
|
| 109 |
PAD_NC(GPP_F20, NONE), |
| 110 |
}; |
| 111 |
|
| 112 |
static const struct pad_config lte_disable_pads[] = { |
| 113 |
|
| 114 |
PAD_NC(GPP_A7, NONE), |
| 115 |
|
| 116 |
PAD_NC(GPP_A8, NONE), |
| 117 |
|
| 118 |
PAD_NC(GPP_D5, NONE), |
| 119 |
|
| 120 |
PAD_NC(GPP_E0, NONE), |
| 121 |
|
| 122 |
PAD_NC_LOCK(GPP_E10, NONE, LOCK_CONFIG), |
| 123 |
|
| 124 |
PAD_NC(GPP_E16, NONE), |
| 125 |
|
| 126 |
PAD_NC_LOCK(GPP_E17, NONE, LOCK_CONFIG), |
| 127 |
|
| 128 |
PAD_NC(GPP_F21, NONE), |
| 129 |
|
| 130 |
PAD_NC(GPP_H23, NONE), |
| 131 |
|
| 132 |
PAD_NC(GPD11, NONE), |
| 133 |
}; |
| 134 |
|
| 135 |
static void enable_i2s(void) |
| 136 |
{ |
| 137 |
gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 138 |
gpio_configure_pads(i2s0_enable_pads, ARRAY_SIZE(i2s0_enable_pads)); |
| 139 |
gpio_configure_pads(i2s2_enable_pads, ARRAY_SIZE(i2s2_enable_pads)); |
| 140 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 141 |
} |
| 142 |
|
| 143 |
static void fw_config_handle(void *unused) |
| 144 |
{ |
| 145 |
if (!fw_config_is_provisioned() || fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { |
| 146 |
printk(BIOS_INFO, "Disable audio related GPIO pins.\n"); |
| 147 |
gpio_configure_pads(i2s0_disable_pads, ARRAY_SIZE(i2s0_disable_pads)); |
| 148 |
gpio_configure_pads(i2s2_disable_pads, ARRAY_SIZE(i2s2_disable_pads)); |
| 149 |
gpio_configure_pads(dmic_disable_pads, ARRAY_SIZE(dmic_disable_pads)); |
| 150 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 151 |
return; |
| 152 |
} |
| 153 |
|
| 154 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682_SNDW))) { |
| 155 |
printk(BIOS_INFO, "Configure audio over SoundWire with MAX98373 ALC5682.\n"); |
| 156 |
gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 157 |
gpio_configure_pads(sndw_enable_pads, ARRAY_SIZE(sndw_enable_pads)); |
| 158 |
printk(BIOS_INFO, "BT offload enabled\n"); |
| 159 |
gpio_configure_pads(i2s0_enable_pads, ARRAY_SIZE(i2s0_enable_pads)); |
| 160 |
gpio_configure_pads(i2s2_disable_pads, ARRAY_SIZE(i2s2_disable_pads)); |
| 161 |
gpio_configure_pads(bt_i2s_enable_pads, ARRAY_SIZE(bt_i2s_enable_pads)); |
| 162 |
} else if (!fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) { |
| 163 |
printk(BIOS_INFO, "BT offload disabled\n"); |
| 164 |
gpio_configure_pads(i2s0_disable_pads, ARRAY_SIZE(i2s0_disable_pads)); |
| 165 |
gpio_configure_pads(i2s2_disable_pads, ARRAY_SIZE(i2s2_disable_pads)); |
| 166 |
gpio_configure_pads(bt_i2s_disable_pads, ARRAY_SIZE(bt_i2s_disable_pads)); |
| 167 |
} |
| 168 |
|
| 169 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98357_ALC5682I_I2S))) { |
| 170 |
printk(BIOS_INFO, "Configure audio over I2S with MAX98357 ALC5682I.\n"); |
| 171 |
enable_i2s(); |
| 172 |
} |
| 173 |
|
| 174 |
if (fw_config_probe(FW_CONFIG(AUDIO, ALC1019_NAU88L25B_I2S))) { |
| 175 |
printk(BIOS_INFO, "Configure audio over I2S with ALC1019 NAU88L25B.\n"); |
| 176 |
enable_i2s(); |
| 177 |
} |
| 178 |
|
| 179 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S)) || |
| 180 |
fw_config_probe(FW_CONFIG(AUDIO, NAU8318_NAU88L25B_I2S))) { |
| 181 |
printk(BIOS_INFO, "Configure audio over I2S with MAX98360 ALC5682I.\n"); |
| 182 |
gpio_configure_pads(max98360_enable_pads, ARRAY_SIZE(max98360_enable_pads)); |
| 183 |
printk(BIOS_INFO, "BT offload enabled\n"); |
| 184 |
gpio_configure_pads(i2s0_enable_pads, ARRAY_SIZE(i2s0_enable_pads)); |
| 185 |
gpio_configure_pads(bt_i2s_enable_pads, ARRAY_SIZE(bt_i2s_enable_pads)); |
| 186 |
|
| 187 |
if (fw_config_probe(FW_CONFIG(AUDIO, NAU8318_NAU88L25B_I2S))) |
| 188 |
gpio_configure_pads(nau8318_enable_pads, ARRAY_SIZE(nau8318_enable_pads)); |
| 189 |
} |
| 190 |
|
| 191 |
if (fw_config_probe(FW_CONFIG(DB_LTE, LTE_ABSENT))) { |
| 192 |
printk(BIOS_INFO, "Disable LTE related GPIO pins.\n"); |
| 193 |
gpio_configure_pads(lte_disable_pads, ARRAY_SIZE(lte_disable_pads)); |
| 194 |
} |
| 195 |
|
| 196 |
if (fw_config_probe(FW_CONFIG(HPS, HPS_ABSENT))) { |
| 197 |
printk(BIOS_INFO, "Disable HPS related GPIO pins.\n"); |
| 198 |
gpio_configure_pads(hps_disable_pads, ARRAY_SIZE(hps_disable_pads)); |
| 199 |
} |
| 200 |
} |
| 201 |
BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fw_config_handle, NULL); |