Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <baseboard/gpio.h> |
| 4 | #include <baseboard/variants.h> |
| 5 | #include <boardid.h> |
| 6 | #include <gpio.h> |
| 7 | #include <soc/gpio.h> |
| 8 | #include <ec/google/chromeec/ec.h> |
| 9 | |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 10 | static const struct soc_amd_gpio morphius_bid1_gpio_set_stage_ram[] = { |
| 11 | /* DMIC_SEL */ |
| 12 | PAD_GPO(GPIO_13, LOW), // Select Camera 1 Dmic |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 13 | /* USB_OC4_L - USB_A1 */ |
Furquan Shaikh | f6b2e6f | 2020-07-17 15:30:47 -0700 | [diff] [blame] | 14 | PAD_NF(GPIO_14, USB_OC4_L, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 15 | /* USB_OC2_L - USB A0 */ |
Furquan Shaikh | f6b2e6f | 2020-07-17 15:30:47 -0700 | [diff] [blame] | 16 | PAD_NF(GPIO_18, USB_OC2_L, PULL_NONE), |
Furquan Shaikh | 65e1117 | 2020-07-21 21:51:27 -0700 | [diff] [blame] | 17 | /* EN_PWR_WIFI */ |
| 18 | PAD_GPO(GPIO_29, HIGH), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 19 | /* EN_PWR_TOUCHPAD_PS2 */ |
| 20 | PAD_GPO(GPIO_67, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 21 | /* DMIC_AD_EN */ |
| 22 | PAD_GPO(GPIO_84, HIGH), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 23 | /* MST_GPIO_2 (Fw Update HDMI hub) */ |
| 24 | PAD_GPI(GPIO_86, PULL_NONE), |
Furquan Shaikh | 79dba4a | 2020-08-04 17:16:33 -0700 | [diff] [blame] | 25 | /* EN_DEV_BEEP_L */ |
| 26 | PAD_GPO(GPIO_89, HIGH), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 27 | /* MST_GPIO_3 (Fw Update HDMI hub) */ |
| 28 | PAD_GPI(GPIO_90, PULL_NONE), |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 29 | /* USI_RESET */ |
| 30 | PAD_GPO(GPIO_140, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 31 | }; |
| 32 | |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 33 | static const struct soc_amd_gpio morphius_bid2_gpio_set_stage_ram[] = { |
| 34 | /* DMIC_SEL */ |
| 35 | PAD_GPO(GPIO_13, LOW), // Select Camera 1 Dmic |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 36 | /* USB_OC4_L - USB_A1 */ |
Furquan Shaikh | f6b2e6f | 2020-07-17 15:30:47 -0700 | [diff] [blame] | 37 | PAD_NF(GPIO_14, USB_OC4_L, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 38 | /* USB_OC2_L - USB A0 */ |
Furquan Shaikh | f6b2e6f | 2020-07-17 15:30:47 -0700 | [diff] [blame] | 39 | PAD_NF(GPIO_18, USB_OC2_L, PULL_NONE), |
Furquan Shaikh | 65e1117 | 2020-07-21 21:51:27 -0700 | [diff] [blame] | 40 | /* EN_PWR_WIFI */ |
| 41 | PAD_GPO(GPIO_29, HIGH), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 42 | /* EN_PWR_TOUCHPAD_PS2 */ |
| 43 | PAD_GPO(GPIO_67, HIGH), |
| 44 | /* MST_GPIO_2 (Fw Update HDMI hub) */ |
| 45 | PAD_GPI(GPIO_86, PULL_NONE), |
Furquan Shaikh | 79dba4a | 2020-08-04 17:16:33 -0700 | [diff] [blame] | 46 | /* EN_DEV_BEEP_L */ |
| 47 | PAD_GPO(GPIO_89, HIGH), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 48 | /* MST_GPIO_3 (Fw Update HDMI hub) */ |
| 49 | PAD_GPI(GPIO_90, PULL_NONE), |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 50 | /* USI_RESET */ |
| 51 | PAD_GPO(GPIO_140, HIGH), |
| 52 | }; |
| 53 | |
| 54 | static const struct soc_amd_gpio morphius_bid3_gpio_set_stage_ram[] = { |
Furquan Shaikh | 79dba4a | 2020-08-04 17:16:33 -0700 | [diff] [blame] | 55 | /* EN_DEV_BEEP_L */ |
| 56 | PAD_GPO(GPIO_89, HIGH), |
Furquan Shaikh | 5474f8e | 2020-08-05 14:54:39 -0700 | [diff] [blame] | 57 | /* TP */ |
| 58 | PAD_NC(GPIO_90), |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 59 | /* USI_RESET */ |
| 60 | PAD_GPO(GPIO_140, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | const struct soc_amd_gpio *variant_override_gpio_table(size_t *size) |
| 64 | { |
| 65 | uint32_t board_version; |
| 66 | |
| 67 | /* |
| 68 | * If board version cannot be read, assume that this is an older revision of the board |
| 69 | * and so apply overrides. If board version is provided by the EC, then apply overrides |
| 70 | * if version < 2. |
| 71 | */ |
Eric Lai | f209b18 | 2020-10-20 02:44:53 +0800 | [diff] [blame^] | 72 | if (google_chromeec_cbi_get_board_version(&board_version) != 0) |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 73 | board_version = 1; |
| 74 | |
| 75 | if (board_version <= 1) { |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 76 | *size = ARRAY_SIZE(morphius_bid1_gpio_set_stage_ram); |
| 77 | return morphius_bid1_gpio_set_stage_ram; |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 78 | } else if (board_version <= 2) { |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 79 | *size = ARRAY_SIZE(morphius_bid2_gpio_set_stage_ram); |
| 80 | return morphius_bid2_gpio_set_stage_ram; |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 81 | } else if (board_version <= 3) { |
| 82 | *size = ARRAY_SIZE(morphius_bid3_gpio_set_stage_ram); |
| 83 | return morphius_bid3_gpio_set_stage_ram; |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | *size = 0; |
| 87 | return NULL; |
| 88 | } |