Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <baseboard/gpio.h> |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 4 | #include <baseboard/variants.h> |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 5 | #include <boardid.h> |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 6 | #include <bootstate.h> |
| 7 | #include <console/console.h> |
| 8 | #include <fw_config.h> |
| 9 | |
Reka Norman | e46a977 | 2022-05-12 14:48:17 +1000 | [diff] [blame] | 10 | static const struct pad_config lte_enable_pads[] = { |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 11 | /* A8 : WWAN_RF_DISABLE_ODL */ |
Reka Norman | e46a977 | 2022-05-12 14:48:17 +1000 | [diff] [blame] | 12 | PAD_CFG_GPO(GPP_A8, 1, DEEP), |
| 13 | /* H19 : SOC_I2C_SUB_INT_ODL */ |
| 14 | PAD_CFG_GPI_APIC(GPP_H19, NONE, PLTRST, LEVEL, NONE), |
| 15 | /* H23 : WWAN_SAR_DETECT_ODL */ |
| 16 | PAD_CFG_GPO(GPP_H23, 1, DEEP), |
| 17 | }; |
| 18 | |
| 19 | static const struct pad_config lte_disable_pads_nivviks[] = { |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 20 | /* D6 : WWAN_EN */ |
| 21 | PAD_NC(GPP_D6, NONE), |
| 22 | /* F12 : WWAN_RST_L */ |
| 23 | PAD_NC(GPP_F12, NONE), |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 24 | }; |
| 25 | |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 26 | static const struct pad_config lte_disable_pads_nirwen[] = { |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 27 | /* E13 : WWAN_EN */ |
| 28 | PAD_NC(GPP_E13, NONE), |
| 29 | /* F12 : WWAN_RST_L */ |
| 30 | PAD_NC(GPP_F12, NONE), |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 31 | }; |
| 32 | |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 33 | static const struct pad_config sd_disable_pads[] = { |
| 34 | /* D8 : SD_CLKREQ_ODL */ |
| 35 | PAD_NC(GPP_D8, NONE), |
| 36 | /* H12 : SD_PERST_L */ |
| 37 | PAD_NC(GPP_H12, NONE), |
| 38 | /* H13 : EN_PP3300_SD_X */ |
| 39 | PAD_NC(GPP_H13, NONE), |
| 40 | }; |
| 41 | |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 42 | static const struct pad_config wfc_disable_pads[] = { |
| 43 | /* D3 : WCAM_RST_L */ |
| 44 | PAD_NC(GPP_D3, NONE), |
| 45 | /* D15 : EN_PP2800_WCAM_X */ |
| 46 | PAD_NC(GPP_D15, NONE), |
| 47 | /* D16 : EN_PP1800_PP1200_WCAM_X */ |
| 48 | PAD_NC(GPP_D16, NONE), |
| 49 | /* H22 : WCAM_MCLK_R */ |
| 50 | PAD_NC(GPP_H22, NONE), |
| 51 | /* R6 : DMIC_WCAM_CLK_R */ |
| 52 | PAD_NC(GPP_R6, NONE), |
| 53 | /* R7 : DMIC_WCAM_DATA */ |
| 54 | PAD_NC(GPP_R7, NONE), |
| 55 | }; |
| 56 | |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 57 | static const struct pad_config emmc_disable_pads[] = { |
| 58 | /* I7 : EMMC_CMD */ |
| 59 | PAD_NC(GPP_I7, NONE), |
| 60 | /* I8 : EMMC_D0 */ |
| 61 | PAD_NC(GPP_I8, NONE), |
| 62 | /* I9 : EMMC_D1 */ |
| 63 | PAD_NC(GPP_I9, NONE), |
| 64 | /* I10 : EMMC_D2 */ |
| 65 | PAD_NC(GPP_I10, NONE), |
| 66 | /* I11 : EMMC_D3 */ |
| 67 | PAD_NC(GPP_I11, NONE), |
| 68 | /* I12 : EMMC_D4 */ |
| 69 | PAD_NC(GPP_I12, NONE), |
| 70 | /* I13 : EMMC_D5 */ |
| 71 | PAD_NC(GPP_I13, NONE), |
| 72 | /* I14 : EMMC_D6 */ |
| 73 | PAD_NC(GPP_I14, NONE), |
| 74 | /* I15 : EMMC_D7 */ |
| 75 | PAD_NC(GPP_I15, NONE), |
| 76 | /* I16 : EMMC_RCLK */ |
| 77 | PAD_NC(GPP_I16, NONE), |
| 78 | /* I17 : EMMC_CLK */ |
| 79 | PAD_NC(GPP_I17, NONE), |
| 80 | /* I18 : EMMC_RST_L */ |
| 81 | PAD_NC(GPP_I18, NONE), |
| 82 | }; |
| 83 | |
| 84 | static const struct pad_config nvme_disable_pads[] = { |
| 85 | /* B4 : SSD_PERST_L */ |
| 86 | PAD_NC(GPP_B4, NONE), |
| 87 | /* D6 : SSD_CLKREQ_ODL */ |
| 88 | PAD_NC(GPP_D6, NONE), |
| 89 | /* D11 : EN_PP3300_SSD */ |
| 90 | PAD_NC(GPP_D11, NONE), |
| 91 | /* E17 : SSD_PLN_L */ |
| 92 | PAD_NC(GPP_E17, NONE), |
| 93 | }; |
| 94 | |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 95 | void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 96 | { |
Reka Norman | e46a977 | 2022-05-12 14:48:17 +1000 | [diff] [blame] | 97 | if (fw_config_probe(FW_CONFIG(DB_USB, DB_1C_LTE))) { |
| 98 | printk(BIOS_INFO, "Enable LTE-related GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 99 | gpio_padbased_override(padbased_table, lte_enable_pads, |
| 100 | ARRAY_SIZE(lte_enable_pads)); |
Reka Norman | e46a977 | 2022-05-12 14:48:17 +1000 | [diff] [blame] | 101 | } else { |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 102 | if (board_id() >= 2) { |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 103 | printk(BIOS_INFO, "Disable LTE-related GPIO pins on nirwen.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 104 | gpio_padbased_override(padbased_table, lte_disable_pads_nirwen, |
| 105 | ARRAY_SIZE(lte_disable_pads_nirwen) |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 106 | ); |
| 107 | } else { |
| 108 | printk(BIOS_INFO, "Disable LTE-related GPIO pins on nivviks.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 109 | gpio_padbased_override(padbased_table, lte_disable_pads_nivviks, |
| 110 | ARRAY_SIZE(lte_disable_pads_nivviks) |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 111 | ); |
| 112 | } |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 113 | } |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 114 | |
| 115 | if (fw_config_probe(FW_CONFIG(SD_CARD, SD_ABSENT))) { |
| 116 | printk(BIOS_INFO, "Disable SD card GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 117 | gpio_padbased_override(padbased_table, sd_disable_pads, |
| 118 | ARRAY_SIZE(sd_disable_pads)); |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 119 | } |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 120 | |
| 121 | if (fw_config_probe(FW_CONFIG(WFC, WFC_ABSENT))) { |
| 122 | printk(BIOS_INFO, "Disable MIPI WFC GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 123 | gpio_padbased_override(padbased_table, wfc_disable_pads, |
| 124 | ARRAY_SIZE(wfc_disable_pads)); |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 125 | } |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 126 | |
| 127 | if (!fw_config_probe(FW_CONFIG(STORAGE, STORAGE_EMMC))) { |
| 128 | printk(BIOS_INFO, "Disable eMMC SSD GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 129 | gpio_padbased_override(padbased_table, emmc_disable_pads, |
| 130 | ARRAY_SIZE(emmc_disable_pads)); |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | if (board_id() >= 2 && !fw_config_probe(FW_CONFIG(STORAGE, STORAGE_NVME))) { |
| 134 | printk(BIOS_INFO, "Disable NVMe SSD GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame^] | 135 | gpio_padbased_override(padbased_table, nvme_disable_pads, |
| 136 | ARRAY_SIZE(nvme_disable_pads)); |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 137 | } |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 138 | } |