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 <console/console.h> |
| 7 | #include <fw_config.h> |
| 8 | |
Reka Norman | e46a977 | 2022-05-12 14:48:17 +1000 | [diff] [blame] | 9 | static const struct pad_config lte_disable_pads_nivviks[] = { |
Reka Norman | 054620d | 2022-08-16 10:48:51 +1000 | [diff] [blame] | 10 | /* A8 : WWAN_RF_DISABLE_ODL */ |
| 11 | PAD_NC(GPP_A8, NONE), |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 12 | /* D6 : WWAN_EN */ |
| 13 | PAD_NC(GPP_D6, NONE), |
| 14 | /* F12 : WWAN_RST_L */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 15 | PAD_NC_LOCK(GPP_F12, NONE, LOCK_CONFIG), |
Reka Norman | 054620d | 2022-08-16 10:48:51 +1000 | [diff] [blame] | 16 | /* H19 : SOC_I2C_SUB_INT_ODL */ |
| 17 | PAD_NC(GPP_H19, NONE), |
| 18 | /* H23 : WWAN_SAR_DETECT_ODL */ |
| 19 | PAD_NC(GPP_H23, NONE), |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 20 | }; |
| 21 | |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 22 | static const struct pad_config lte_disable_pads_nirwen[] = { |
Reka Norman | 054620d | 2022-08-16 10:48:51 +1000 | [diff] [blame] | 23 | /* A8 : WWAN_RF_DISABLE_ODL */ |
| 24 | PAD_NC(GPP_A8, NONE), |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 25 | /* E13 : WWAN_EN */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 26 | PAD_NC_LOCK(GPP_E13, NONE, LOCK_CONFIG), |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 27 | /* F12 : WWAN_RST_L */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 28 | PAD_NC_LOCK(GPP_F12, NONE, LOCK_CONFIG), |
Reka Norman | 054620d | 2022-08-16 10:48:51 +1000 | [diff] [blame] | 29 | /* H19 : SOC_I2C_SUB_INT_ODL */ |
| 30 | PAD_NC(GPP_H19, NONE), |
| 31 | /* H23 : WWAN_SAR_DETECT_ODL */ |
| 32 | PAD_NC(GPP_H23, NONE), |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 33 | }; |
| 34 | |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 35 | static const struct pad_config sd_disable_pads[] = { |
| 36 | /* D8 : SD_CLKREQ_ODL */ |
| 37 | PAD_NC(GPP_D8, NONE), |
| 38 | /* H12 : SD_PERST_L */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 39 | PAD_NC_LOCK(GPP_H12, NONE, LOCK_CONFIG), |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 40 | /* H13 : EN_PP3300_SD_X */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 41 | PAD_NC_LOCK(GPP_H13, NONE, LOCK_CONFIG), |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 42 | }; |
| 43 | |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 44 | static const struct pad_config wfc_disable_pads[] = { |
| 45 | /* D3 : WCAM_RST_L */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 46 | PAD_NC_LOCK(GPP_D3, NONE, LOCK_CONFIG), |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 47 | /* D15 : EN_PP2800_WCAM_X */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 48 | PAD_NC_LOCK(GPP_D15, NONE, LOCK_CONFIG), |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 49 | /* D16 : EN_PP1800_PP1200_WCAM_X */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 50 | PAD_NC_LOCK(GPP_D16, NONE, LOCK_CONFIG), |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 51 | /* H22 : WCAM_MCLK_R */ |
| 52 | PAD_NC(GPP_H22, NONE), |
| 53 | /* R6 : DMIC_WCAM_CLK_R */ |
| 54 | PAD_NC(GPP_R6, NONE), |
| 55 | /* R7 : DMIC_WCAM_DATA */ |
| 56 | PAD_NC(GPP_R7, NONE), |
| 57 | }; |
| 58 | |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 59 | static const struct pad_config emmc_disable_pads[] = { |
| 60 | /* I7 : EMMC_CMD */ |
| 61 | PAD_NC(GPP_I7, NONE), |
| 62 | /* I8 : EMMC_D0 */ |
| 63 | PAD_NC(GPP_I8, NONE), |
| 64 | /* I9 : EMMC_D1 */ |
| 65 | PAD_NC(GPP_I9, NONE), |
| 66 | /* I10 : EMMC_D2 */ |
| 67 | PAD_NC(GPP_I10, NONE), |
| 68 | /* I11 : EMMC_D3 */ |
| 69 | PAD_NC(GPP_I11, NONE), |
| 70 | /* I12 : EMMC_D4 */ |
| 71 | PAD_NC(GPP_I12, NONE), |
| 72 | /* I13 : EMMC_D5 */ |
| 73 | PAD_NC(GPP_I13, NONE), |
| 74 | /* I14 : EMMC_D6 */ |
| 75 | PAD_NC(GPP_I14, NONE), |
| 76 | /* I15 : EMMC_D7 */ |
| 77 | PAD_NC(GPP_I15, NONE), |
| 78 | /* I16 : EMMC_RCLK */ |
| 79 | PAD_NC(GPP_I16, NONE), |
| 80 | /* I17 : EMMC_CLK */ |
| 81 | PAD_NC(GPP_I17, NONE), |
| 82 | /* I18 : EMMC_RST_L */ |
| 83 | PAD_NC(GPP_I18, NONE), |
| 84 | }; |
| 85 | |
| 86 | static const struct pad_config nvme_disable_pads[] = { |
| 87 | /* B4 : SSD_PERST_L */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 88 | PAD_NC_LOCK(GPP_B4, NONE, LOCK_CONFIG), |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 89 | /* D6 : SSD_CLKREQ_ODL */ |
| 90 | PAD_NC(GPP_D6, NONE), |
| 91 | /* D11 : EN_PP3300_SSD */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 92 | PAD_NC_LOCK(GPP_D11, NONE, LOCK_CONFIG), |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 93 | /* E17 : SSD_PLN_L */ |
Eric Lai | f777cad | 2022-07-01 14:03:24 +0800 | [diff] [blame] | 94 | PAD_NC_LOCK(GPP_E17, NONE, LOCK_CONFIG), |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 95 | }; |
| 96 | |
Poornima Tom | b80a691 | 2024-06-14 04:24:34 +0530 | [diff] [blame^] | 97 | static const struct pad_config wifi_pcie_enable_pad[] = { |
| 98 | /* H3 : SX_EXIT_HOLDOFF => WLAN_PCIE_WAKE_ODL */ |
| 99 | PAD_CFG_GPI_IRQ_WAKE(GPP_H3, NONE, PLTRST, LEVEL, INVERT), |
| 100 | /* D7 : SRCCLKREQ2# ==> WLAN_CLKREQ_ODL */ |
| 101 | PAD_CFG_NF(GPP_D7, NONE, DEEP, NF1), |
| 102 | /* H20 : IMGCLKOUT1 ==> WLAN_PERST_L */ |
| 103 | PAD_CFG_GPO_LOCK(GPP_H20, 1, LOCK_CONFIG), |
| 104 | }; |
| 105 | |
V Sowmya | ad0288a | 2022-08-22 13:02:09 +0530 | [diff] [blame] | 106 | static const struct pad_config stylus_disable_pads[] = { |
| 107 | /* F13 : SOC_PEN_DETECT_R_ODL */ |
| 108 | PAD_NC_LOCK(GPP_F13, NONE, LOCK_CONFIG), |
| 109 | /* F15 : SOC_PEN_DETECT_ODL */ |
| 110 | PAD_NC_LOCK(GPP_F15, NONE, LOCK_CONFIG), |
| 111 | }; |
| 112 | |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame] | 113 | void fw_config_gpio_padbased_override(struct pad_config *padbased_table) |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 114 | { |
Reka Norman | 054620d | 2022-08-16 10:48:51 +1000 | [diff] [blame] | 115 | if (!fw_config_probe(FW_CONFIG(DB_USB, DB_1C_LTE))) { |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 116 | if (board_id() >= 2) { |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 117 | printk(BIOS_INFO, "Disable LTE-related GPIO pins on nirwen.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame] | 118 | gpio_padbased_override(padbased_table, lte_disable_pads_nirwen, |
| 119 | ARRAY_SIZE(lte_disable_pads_nirwen) |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 120 | ); |
| 121 | } else { |
| 122 | printk(BIOS_INFO, "Disable LTE-related GPIO pins on nivviks.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame] | 123 | gpio_padbased_override(padbased_table, lte_disable_pads_nivviks, |
| 124 | ARRAY_SIZE(lte_disable_pads_nivviks) |
Reka Norman | e4ebc86 | 2022-05-09 16:08:01 +1000 | [diff] [blame] | 125 | ); |
| 126 | } |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 127 | } |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 128 | |
Poornima Tom | b80a691 | 2024-06-14 04:24:34 +0530 | [diff] [blame^] | 129 | if (fw_config_probe(FW_CONFIG(WIFI_CATEGORY, WIFI_7))) { |
| 130 | printk(BIOS_INFO, "Enable PCie based Wifi GPIO pins.\n"); |
| 131 | gpio_padbased_override(padbased_table, wifi_pcie_enable_pad, |
| 132 | ARRAY_SIZE(wifi_pcie_enable_pad)); |
| 133 | } |
| 134 | |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 135 | if (fw_config_probe(FW_CONFIG(SD_CARD, SD_ABSENT))) { |
| 136 | printk(BIOS_INFO, "Disable SD card GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame] | 137 | gpio_padbased_override(padbased_table, sd_disable_pads, |
| 138 | ARRAY_SIZE(sd_disable_pads)); |
Reka Norman | baf2246 | 2022-05-06 19:55:11 +1000 | [diff] [blame] | 139 | } |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 140 | |
| 141 | if (fw_config_probe(FW_CONFIG(WFC, WFC_ABSENT))) { |
| 142 | printk(BIOS_INFO, "Disable MIPI WFC GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame] | 143 | gpio_padbased_override(padbased_table, wfc_disable_pads, |
| 144 | ARRAY_SIZE(wfc_disable_pads)); |
Reka Norman | f1b8cee | 2022-05-06 20:04:54 +1000 | [diff] [blame] | 145 | } |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 146 | |
| 147 | if (!fw_config_probe(FW_CONFIG(STORAGE, STORAGE_EMMC))) { |
| 148 | printk(BIOS_INFO, "Disable eMMC SSD GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame] | 149 | gpio_padbased_override(padbased_table, emmc_disable_pads, |
| 150 | ARRAY_SIZE(emmc_disable_pads)); |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | if (board_id() >= 2 && !fw_config_probe(FW_CONFIG(STORAGE, STORAGE_NVME))) { |
| 154 | printk(BIOS_INFO, "Disable NVMe SSD GPIO pins.\n"); |
Eric Lai | a8d2cb8 | 2022-05-27 09:43:43 +0800 | [diff] [blame] | 155 | gpio_padbased_override(padbased_table, nvme_disable_pads, |
| 156 | ARRAY_SIZE(nvme_disable_pads)); |
Reka Norman | f2f785d | 2022-05-06 20:22:21 +1000 | [diff] [blame] | 157 | } |
V Sowmya | ad0288a | 2022-08-22 13:02:09 +0530 | [diff] [blame] | 158 | |
| 159 | if (fw_config_probe(FW_CONFIG(STYLUS, STYLUS_ABSENT))) { |
| 160 | printk(BIOS_INFO, "Disable Stylus GPIO pins.\n"); |
| 161 | gpio_padbased_override(padbased_table, stylus_disable_pads, |
| 162 | ARRAY_SIZE(stylus_disable_pads)); |
| 163 | } |
Reka Norman | 457d98d | 2022-02-04 11:17:32 +1100 | [diff] [blame] | 164 | } |