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