| 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_S4, NONE, DEEP, NF2), |
| 10 |
PAD_CFG_NF(GPP_S5, 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_S4, NONE), |
| 17 |
PAD_NC(GPP_S5, 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_S2, NONE, DEEP, NF1), |
| 26 |
PAD_CFG_NF(GPP_S3, NONE, DEEP, NF1), |
| 27 |
}; |
| 28 |
|
| 29 |
static const struct pad_config sndw_disable_pads[] = { |
| 30 |
PAD_NC(GPP_S0, NONE), |
| 31 |
PAD_NC(GPP_S1, NONE), |
| 32 |
PAD_NC(GPP_S2, NONE), |
| 33 |
PAD_NC(GPP_S3, NONE), |
| 34 |
}; |
| 35 |
|
| 36 |
static const struct pad_config i2s_up3_enable_pads[] = { |
| 37 |
PAD_CFG_NF(GPP_A23, NONE, DEEP, NF1), |
| 38 |
PAD_CFG_NF(GPP_D19, NONE, DEEP, NF1), |
| 39 |
PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), |
| 40 |
PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), |
| 41 |
PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), |
| 42 |
PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), |
| 43 |
PAD_CFG_NF(GPP_R5, NONE, DEEP, NF2), |
| 44 |
PAD_CFG_NF(GPP_R6, NONE, DEEP, NF2), |
| 45 |
PAD_CFG_NF(GPP_R7, NONE, DEEP, NF2), |
| 46 |
}; |
| 47 |
|
| 48 |
static const struct pad_config i2s_up4_enable_pads[] = { |
| 49 |
PAD_CFG_NF(GPP_A7, NONE, DEEP, NF1), |
| 50 |
PAD_CFG_NF(GPP_D19, NONE, DEEP, NF1), |
| 51 |
PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), |
| 52 |
PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), |
| 53 |
PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), |
| 54 |
PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), |
| 55 |
}; |
| 56 |
|
| 57 |
static const struct pad_config i2s_disable_pads[] = { |
| 58 |
PAD_NC(GPP_A23, NONE), |
| 59 |
PAD_NC(GPP_D19, NONE), |
| 60 |
PAD_NC(GPP_R0, NONE), |
| 61 |
PAD_NC(GPP_R1, NONE), |
| 62 |
PAD_NC(GPP_R2, DN_20K), |
| 63 |
PAD_NC(GPP_R3, NONE), |
| 64 |
PAD_NC(GPP_R5, NONE), |
| 65 |
PAD_NC(GPP_R6, NONE), |
| 66 |
PAD_NC(GPP_R7, NONE), |
| 67 |
}; |
| 68 |
|
| 69 |
static const struct pad_config sd_power_enable_pads[] = { |
| 70 |
PAD_CFG_GPO(GPP_D16, 1, DEEP), |
| 71 |
}; |
| 72 |
|
| 73 |
static void fw_config_handle(void *unused) |
| 74 |
{ |
| 75 |
if (!fw_config_is_provisioned()) { |
| 76 |
gpio_configure_pads(i2s_disable_pads, ARRAY_SIZE(i2s_disable_pads)); |
| 77 |
gpio_configure_pads(dmic_disable_pads, ARRAY_SIZE(dmic_disable_pads)); |
| 78 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 79 |
return; |
| 80 |
} |
| 81 |
|
| 82 |
if (fw_config_probe(FW_CONFIG(AUDIO, NONE))) { |
| 83 |
printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); |
| 84 |
gpio_configure_pads(i2s_disable_pads, ARRAY_SIZE(i2s_disable_pads)); |
| 85 |
gpio_configure_pads(dmic_disable_pads, ARRAY_SIZE(dmic_disable_pads)); |
| 86 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 87 |
} |
| 88 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682_SNDW))) { |
| 89 |
printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n"); |
| 90 |
gpio_configure_pads(sndw_enable_pads, ARRAY_SIZE(sndw_enable_pads)); |
| 91 |
gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 92 |
gpio_configure_pads(i2s_disable_pads, ARRAY_SIZE(i2s_disable_pads)); |
| 93 |
} |
| 94 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98357_ALC5682I_I2S)) || |
| 95 |
fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682I_I2S)) || |
| 96 |
fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S)) || |
| 97 |
fw_config_probe(FW_CONFIG(AUDIO, RT1011_ALC5682I_I2S))) { |
| 98 |
printk(BIOS_INFO, "Configure GPIOs for I2S audio on UP3.\n"); |
| 99 |
gpio_configure_pads(i2s_up3_enable_pads, ARRAY_SIZE(i2s_up3_enable_pads)); |
| 100 |
gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 101 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 102 |
} |
| 103 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682I_I2S_UP4))) { |
| 104 |
printk(BIOS_INFO, "Configure GPIOs for I2S audio on UP4.\n"); |
| 105 |
gpio_configure_pads(i2s_up4_enable_pads, ARRAY_SIZE(i2s_up4_enable_pads)); |
| 106 |
gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 107 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 108 |
} |
| 109 |
if (fw_config_probe(FW_CONFIG(DB_SD, SD_GL9755S)) || |
| 110 |
fw_config_probe(FW_CONFIG(DB_SD, SD_RTS5227S)) || |
| 111 |
fw_config_probe(FW_CONFIG(DB_SD, SD_GL9750)) || |
| 112 |
fw_config_probe(FW_CONFIG(DB_SD, SD_OZ711LV2LN))) { |
| 113 |
printk(BIOS_INFO, "Configure GPIOs for SD power enable.\n"); |
| 114 |
gpio_configure_pads(sd_power_enable_pads, ARRAY_SIZE(sd_power_enable_pads)); |
| 115 |
} |
| 116 |
} |
| 117 |
BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fw_config_handle, NULL); |