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> |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 9 | |
| 10 | static const struct soc_amd_gpio berknip_bid1_gpio_set_stage_ram[] = { |
Kevin Chiu | cf081ab | 2020-08-28 10:11:26 +0800 | [diff] [blame] | 11 | /* PEN_DETECT_ODL - no used */ |
| 12 | PAD_NC(GPIO_4), |
| 13 | /* PEN_POWER_EN - no used */ |
| 14 | PAD_NC(GPIO_5), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 15 | /* DMIC_SEL */ |
| 16 | PAD_GPO(GPIO_13, LOW), // Select Camera 1 Dmic |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 17 | /* USB_OC4_L - USB_A1 */ |
Furquan Shaikh | f6b2e6f | 2020-07-17 15:30:47 -0700 | [diff] [blame] | 18 | PAD_NF(GPIO_14, USB_OC4_L, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 19 | /* USB_OC2_L - USB A0 */ |
Furquan Shaikh | f6b2e6f | 2020-07-17 15:30:47 -0700 | [diff] [blame] | 20 | PAD_NF(GPIO_18, USB_OC2_L, PULL_NONE), |
Furquan Shaikh | 65e1117 | 2020-07-21 21:51:27 -0700 | [diff] [blame] | 21 | /* EN_PWR_WIFI */ |
| 22 | PAD_GPO(GPIO_29, HIGH), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 23 | /* EN_PWR_TOUCHPAD_PS2 */ |
| 24 | PAD_GPO(GPIO_67, HIGH), |
| 25 | /* MST_GPIO_2 (Fw Update HDMI hub) */ |
| 26 | PAD_GPI(GPIO_86, PULL_NONE), |
Furquan Shaikh | 79dba4a | 2020-08-04 17:16:33 -0700 | [diff] [blame] | 27 | /* EN_DEV_BEEP_L */ |
| 28 | PAD_GPO(GPIO_89, HIGH), |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 29 | /* MST_GPIO_3 (Fw Update HDMI hub) */ |
| 30 | PAD_GPI(GPIO_90, PULL_NONE), |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 31 | /* USI_RESET */ |
| 32 | PAD_GPO(GPIO_140, HIGH), |
| 33 | }; |
| 34 | |
| 35 | static const struct soc_amd_gpio berknip_bid2_gpio_set_stage_ram[] = { |
Kevin Chiu | cf081ab | 2020-08-28 10:11:26 +0800 | [diff] [blame] | 36 | /* PEN_DETECT_ODL - no used */ |
| 37 | PAD_NC(GPIO_4), |
| 38 | /* PEN_POWER_EN - no used */ |
| 39 | PAD_NC(GPIO_5), |
Furquan Shaikh | 79dba4a | 2020-08-04 17:16:33 -0700 | [diff] [blame] | 40 | /* EN_DEV_BEEP_L */ |
| 41 | PAD_GPO(GPIO_89, HIGH), |
Furquan Shaikh | 5474f8e | 2020-08-05 14:54:39 -0700 | [diff] [blame] | 42 | /* TP */ |
| 43 | PAD_NC(GPIO_90), |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 44 | /* USI_RESET */ |
| 45 | PAD_GPO(GPIO_140, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 46 | }; |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 47 | |
Kevin Chiu | cf081ab | 2020-08-28 10:11:26 +0800 | [diff] [blame] | 48 | static const struct soc_amd_gpio berknip_gpio_set_stage_ram[] = { |
| 49 | /* PEN_DETECT_ODL - no used */ |
| 50 | PAD_NC(GPIO_4), |
| 51 | /* PEN_POWER_EN - no used */ |
| 52 | PAD_NC(GPIO_5), |
| 53 | }; |
| 54 | |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 55 | const struct soc_amd_gpio *variant_override_gpio_table(size_t *size) |
| 56 | { |
| 57 | uint32_t board_version; |
| 58 | |
| 59 | /* |
| 60 | * If board version cannot be read, assume that this is an older revision of the board |
| 61 | * and so apply overrides. If board version is provided by the EC, then apply overrides |
| 62 | * if version < 2. |
| 63 | */ |
Eric Lai | f209b18 | 2020-10-20 02:44:53 +0800 | [diff] [blame^] | 64 | if (google_chromeec_cbi_get_board_version(&board_version) != 0) |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 65 | board_version = 1; |
| 66 | |
| 67 | if (board_version <= 1) { |
Furquan Shaikh | da459c4 | 2020-06-18 01:34:48 -0700 | [diff] [blame] | 68 | *size = ARRAY_SIZE(berknip_bid1_gpio_set_stage_ram); |
| 69 | return berknip_bid1_gpio_set_stage_ram; |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 70 | } else if (board_version <= 2) { |
| 71 | *size = ARRAY_SIZE(berknip_bid2_gpio_set_stage_ram); |
| 72 | return berknip_bid2_gpio_set_stage_ram; |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 73 | } |
| 74 | |
Kevin Chiu | cf081ab | 2020-08-28 10:11:26 +0800 | [diff] [blame] | 75 | *size = ARRAY_SIZE(berknip_gpio_set_stage_ram); |
| 76 | return berknip_gpio_set_stage_ram; |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 77 | } |