| 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 sndw_disable_pads[] = { |
| 43 |
PAD_NC(GPP_S0, NONE), |
| 44 |
PAD_NC(GPP_S1, NONE), |
| 45 |
PAD_NC(GPP_S4, NONE), |
| 46 |
PAD_NC(GPP_S5, NONE), |
| 47 |
}; |
| 48 |
|
| 49 |
static const struct pad_config i2s0_enable_pads[] = { |
| 50 |
PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), |
| 51 |
PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), |
| 52 |
PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), |
| 53 |
PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), |
| 54 |
}; |
| 55 |
|
| 56 |
static const struct pad_config i2s2_enable_pads[] = { |
| 57 |
PAD_CFG_NF(GPP_R4, NONE, DEEP, NF2), |
| 58 |
PAD_CFG_NF(GPP_R5, NONE, DEEP, NF2), |
| 59 |
PAD_CFG_NF(GPP_R6, NONE, DEEP, NF2), |
| 60 |
PAD_CFG_NF(GPP_R7, NONE, DEEP, NF2), |
| 61 |
}; |
| 62 |
|
| 63 |
static const struct pad_config i2s0_disable_pads[] = { |
| 64 |
PAD_NC(GPP_R0, NONE), |
| 65 |
PAD_NC(GPP_R1, NONE), |
| 66 |
PAD_NC(GPP_R2, NONE), |
| 67 |
PAD_NC(GPP_R3, NONE), |
| 68 |
}; |
| 69 |
|
| 70 |
static const struct pad_config i2s2_disable_pads[] = { |
| 71 |
PAD_NC(GPP_R4, NONE), |
| 72 |
PAD_NC(GPP_R5, NONE), |
| 73 |
PAD_NC(GPP_R6, NONE), |
| 74 |
PAD_NC(GPP_R7, NONE), |
| 75 |
}; |
| 76 |
|
| 77 |
static const struct pad_config bt_i2s_enable_pads[] = { |
| 78 |
PAD_CFG_NF(GPP_VGPIO_30, NONE, DEEP, NF3), |
| 79 |
PAD_CFG_NF(GPP_VGPIO_31, NONE, DEEP, NF3), |
| 80 |
PAD_CFG_NF(GPP_VGPIO_32, NONE, DEEP, NF3), |
| 81 |
PAD_CFG_NF(GPP_VGPIO_33, NONE, DEEP, NF3), |
| 82 |
PAD_CFG_NF(GPP_VGPIO_34, NONE, DEEP, NF1), |
| 83 |
PAD_CFG_NF(GPP_VGPIO_35, NONE, DEEP, NF1), |
| 84 |
PAD_CFG_NF(GPP_VGPIO_36, NONE, DEEP, NF1), |
| 85 |
PAD_CFG_NF(GPP_VGPIO_37, NONE, DEEP, NF1), |
| 86 |
}; |
| 87 |
|
| 88 |
static const struct pad_config bt_i2s_disable_pads[] = { |
| 89 |
PAD_NC(GPP_VGPIO_30, NONE), |
| 90 |
PAD_NC(GPP_VGPIO_31, NONE), |
| 91 |
PAD_NC(GPP_VGPIO_32, NONE), |
| 92 |
PAD_NC(GPP_VGPIO_33, NONE), |
| 93 |
PAD_NC(GPP_VGPIO_34, NONE), |
| 94 |
PAD_NC(GPP_VGPIO_35, NONE), |
| 95 |
PAD_NC(GPP_VGPIO_36, NONE), |
| 96 |
PAD_NC(GPP_VGPIO_37, NONE), |
| 97 |
}; |
| 98 |
|
| 99 |
static void enable_i2s(void) |
| 100 |
{ |
| 101 |
gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 102 |
gpio_configure_pads(i2s0_enable_pads, ARRAY_SIZE(i2s0_enable_pads)); |
| 103 |
gpio_configure_pads(i2s2_enable_pads, ARRAY_SIZE(i2s2_enable_pads)); |
| 104 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 105 |
} |
| 106 |
|
| 107 |
static void fw_config_handle(void *unused) |
| 108 |
{ |
| 109 |
if (!fw_config_is_provisioned() || fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { |
| 110 |
printk(BIOS_INFO, "Disable audio related GPIO pins.\n"); |
| 111 |
gpio_configure_pads(i2s0_disable_pads, ARRAY_SIZE(i2s0_disable_pads)); |
| 112 |
gpio_configure_pads(i2s2_disable_pads, ARRAY_SIZE(i2s2_disable_pads)); |
| 113 |
gpio_configure_pads(dmic_disable_pads, ARRAY_SIZE(dmic_disable_pads)); |
| 114 |
gpio_configure_pads(sndw_disable_pads, ARRAY_SIZE(sndw_disable_pads)); |
| 115 |
return; |
| 116 |
} |
| 117 |
|
| 118 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682_SNDW))) { |
| 119 |
printk(BIOS_INFO, "Configure audio over SoundWire with MAX98373 ALC5682.\n"); |
| 120 |
gpio_configure_pads(dmic_enable_pads, ARRAY_SIZE(dmic_enable_pads)); |
| 121 |
gpio_configure_pads(sndw_enable_pads, ARRAY_SIZE(sndw_enable_pads)); |
| 122 |
printk(BIOS_INFO, "BT offload enabled\n"); |
| 123 |
gpio_configure_pads(i2s0_enable_pads, ARRAY_SIZE(i2s0_enable_pads)); |
| 124 |
gpio_configure_pads(i2s2_disable_pads, ARRAY_SIZE(i2s2_disable_pads)); |
| 125 |
gpio_configure_pads(bt_i2s_enable_pads, ARRAY_SIZE(bt_i2s_enable_pads)); |
| 126 |
} else if (!fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) { |
| 127 |
printk(BIOS_INFO, "BT offload disabled\n"); |
| 128 |
gpio_configure_pads(i2s0_disable_pads, ARRAY_SIZE(i2s0_disable_pads)); |
| 129 |
gpio_configure_pads(i2s2_disable_pads, ARRAY_SIZE(i2s2_disable_pads)); |
| 130 |
gpio_configure_pads(bt_i2s_disable_pads, ARRAY_SIZE(bt_i2s_disable_pads)); |
| 131 |
} |
| 132 |
|
| 133 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98357_ALC5682I_I2S))) { |
| 134 |
printk(BIOS_INFO, "Configure audio over I2S with MAX98357 ALC5682I.\n"); |
| 135 |
enable_i2s(); |
| 136 |
} |
| 137 |
|
| 138 |
if (fw_config_probe(FW_CONFIG(AUDIO, ALC1019_NAU88L25B_I2S))) { |
| 139 |
printk(BIOS_INFO, "Configure audio over I2S with ALC1019 NAU88L25B.\n"); |
| 140 |
enable_i2s(); |
| 141 |
} |
| 142 |
|
| 143 |
if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) { |
| 144 |
printk(BIOS_INFO, "Configure audio over I2S with MAX98360 ALC5682I.\n"); |
| 145 |
gpio_configure_pads(max98360_enable_pads, ARRAY_SIZE(max98360_enable_pads)); |
| 146 |
printk(BIOS_INFO, "BT offload enabled\n"); |
| 147 |
gpio_configure_pads(i2s0_enable_pads, ARRAY_SIZE(i2s0_enable_pads)); |
| 148 |
gpio_configure_pads(bt_i2s_enable_pads, ARRAY_SIZE(bt_i2s_enable_pads)); |
| 149 |
} |
| 150 |
} |
| 151 |
BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fw_config_handle, NULL); |