| 1 |
|
| 2 |
|
| 3 |
#include <baseboard/variants.h> |
| 4 |
#include <ec/google/chromeec/ec.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <fw_config.h> |
| 7 |
#include <gpio.h> |
| 8 |
|
| 9 |
#define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a)) |
| 10 |
|
| 11 |
static const struct pad_config dmic_disable_pads[] = { |
| 12 |
PAD_NC(GPP_S02, NONE), |
| 13 |
PAD_NC(GPP_S03, NONE), |
| 14 |
PAD_NC(GPP_S06, NONE), |
| 15 |
PAD_NC(GPP_S07, NONE), |
| 16 |
}; |
| 17 |
|
| 18 |
static const struct pad_config i2s_disable_pads[] = { |
| 19 |
PAD_NC(GPP_D09, NONE), |
| 20 |
PAD_NC(GPP_D10, NONE), |
| 21 |
PAD_NC(GPP_D11, NONE), |
| 22 |
PAD_NC(GPP_D12, DN_20K), |
| 23 |
PAD_NC(GPP_D13, NONE), |
| 24 |
PAD_NC(GPP_D14, NONE), |
| 25 |
PAD_NC(GPP_D15, NONE), |
| 26 |
PAD_NC(GPP_D16, NONE), |
| 27 |
PAD_NC(GPP_D17, NONE), |
| 28 |
}; |
| 29 |
|
| 30 |
|
| 31 |
static const struct pad_config bt_i2s_enable_pads[] = { |
| 32 |
|
| 33 |
PAD_CFG_NF(GPP_VGPIO30, NONE, DEEP, NF2), |
| 34 |
|
| 35 |
PAD_CFG_NF(GPP_VGPIO31, NONE, DEEP, NF2), |
| 36 |
|
| 37 |
PAD_CFG_NF(GPP_VGPIO32, NONE, DEEP, NF2), |
| 38 |
|
| 39 |
PAD_CFG_NF(GPP_VGPIO33, NONE, DEEP, NF2), |
| 40 |
|
| 41 |
PAD_CFG_NF(GPP_VGPIO34, NONE, DEEP, NF1), |
| 42 |
|
| 43 |
PAD_CFG_NF(GPP_VGPIO35, NONE, DEEP, NF1), |
| 44 |
|
| 45 |
PAD_CFG_NF(GPP_VGPIO36, NONE, DEEP, NF1), |
| 46 |
|
| 47 |
PAD_CFG_NF(GPP_VGPIO37, NONE, DEEP, NF1), |
| 48 |
}; |
| 49 |
|
| 50 |
static const struct pad_config bt_i2s_disable_pads[] = { |
| 51 |
|
| 52 |
PAD_NC(GPP_VGPIO30, NONE), |
| 53 |
|
| 54 |
PAD_NC(GPP_VGPIO31, NONE), |
| 55 |
|
| 56 |
PAD_NC(GPP_VGPIO32, NONE), |
| 57 |
|
| 58 |
PAD_NC(GPP_VGPIO33, NONE), |
| 59 |
|
| 60 |
PAD_NC(GPP_VGPIO34, NONE), |
| 61 |
|
| 62 |
PAD_NC(GPP_VGPIO35, NONE), |
| 63 |
|
| 64 |
PAD_NC(GPP_VGPIO36, NONE), |
| 65 |
|
| 66 |
PAD_NC(GPP_VGPIO37, NONE), |
| 67 |
}; |
| 68 |
|
| 69 |
static const struct pad_config usb_oc2_gpio_pads[] = { |
| 70 |
PAD_CFG_NF_LOCK(GPP_B14, UP_20K, NF1, LOCK_CONFIG), |
| 71 |
}; |
| 72 |
|
| 73 |
void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
| 74 |
{ |
| 75 |
uint32_t id = 0; |
| 76 |
google_chromeec_get_board_version(&id); |
| 77 |
if (id == 2 || id == 1) { |
| 78 |
printk(BIOS_INFO, "Configure GPIOs for evt and dvt1.\n"); |
| 79 |
GPIO_PADBASED_OVERRIDE(padbased_table, usb_oc2_gpio_pads); |
| 80 |
} |
| 81 |
|
| 82 |
if (!fw_config_is_provisioned()) { |
| 83 |
GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 84 |
GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 85 |
GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
| 86 |
return; |
| 87 |
} |
| 88 |
|
| 89 |
if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { |
| 90 |
printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); |
| 91 |
GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); |
| 92 |
GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); |
| 93 |
GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads); |
| 94 |
} else if (fw_config_probe(FW_CONFIG(AUDIO, ALC1019_ALC5682I_I2S))) { |
| 95 |
printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); |
| 96 |
GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); |
| 97 |
} |
| 98 |
} |