mb/google/brya: Create rull variant
[coreboot2.git] / src / mainboard / google / reef / variants / snappy / mainboard.c
blob0b155054bbe8c23ea6374a77d5260a78e83e5a78
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <string.h>
4 #include <baseboard/variants.h>
5 #include <ec/google/chromeec/ec.h>
6 #include <drivers/vpd/vpd.h>
7 #include <soc/cpu.h>
8 #include <soc/intel/apollolake/chip.h>
10 /* SKU ID enumeration */
11 enum snappy_sku {
12 SKU_UNKNOWN = -1,
13 SKU_RESERVED0,
14 SKU_RESERVED1,
15 SKU_BIGDADDY_KBDBKLIGHT,
16 SKU_RESERVED3,
17 SKU_RESERVED4,
18 SKU_BIGDADDY,
19 SKU_RESERVED6,
20 SKU_ALAN,
21 SKU_SNAPPY,
24 void variant_board_ec_set_skuid(void)
26 google_chromeec_set_sku_id(variant_board_sku());
30 * override SKU ID by VPD definition
32 uint8_t variant_board_sku(void)
34 static int board_sku_num = -1;
35 int vpd_sku_num;
36 char vpd_skuid[] = "skuid";
37 char vpd_buffer[4];
38 int vpd_len;
39 int i;
41 if (board_sku_num != -1)
42 return board_sku_num;
44 board_sku_num = sku_strapping_value();
46 if (!CONFIG(VPD))
47 return board_sku_num;
49 if (!vpd_gets(vpd_skuid, vpd_buffer, ARRAY_SIZE(vpd_buffer), VPD_RO_THEN_RW))
50 return board_sku_num;
52 vpd_len = strlen(vpd_buffer);
54 vpd_sku_num = 0;
55 for (i = 0; i < vpd_len; i++) {
56 char ch = vpd_buffer[i];
57 if ((ch < '0') || (ch > '9')) {
58 vpd_sku_num = -1;
59 break;
61 vpd_sku_num = vpd_sku_num * 10 + (ch - '0');
64 if (vpd_sku_num != -1)
65 board_sku_num = vpd_sku_num;
67 return board_sku_num;
70 void mainboard_devtree_update(struct device *dev)
72 /* Override dev tree settings per board */
73 struct soc_intel_apollolake_config *cfg = dev->chip_info;
74 uint8_t sku_id;
76 sku_id = variant_board_sku();
78 switch (sku_id) {
79 case SKU_ALAN:
80 cfg->usb2eye[2].Usb20PerPortPeTxiSet = 4;
81 cfg->usb2eye[2].Usb20PerPortTxiSet = 4;
82 cfg->usb2eye[2].Usb20IUsbTxEmphasisEn = 1;
83 cfg->usb2eye[2].Usb20PerPortTxPeHalf = 0;
85 cfg->usb2eye[4].Usb20PerPortPeTxiSet = 7;
86 cfg->usb2eye[4].Usb20PerPortTxiSet = 7;
87 cfg->usb2eye[4].Usb20IUsbTxEmphasisEn = 1;
88 cfg->usb2eye[4].Usb20PerPortTxPeHalf = 0;
89 break;
90 case SKU_BIGDADDY_KBDBKLIGHT:
91 case SKU_BIGDADDY:
92 cfg->usb2eye[1].Usb20PerPortPeTxiSet = 7;
93 cfg->usb2eye[1].Usb20PerPortTxiSet = 1;
94 cfg->usb2eye[1].Usb20IUsbTxEmphasisEn = 3;
95 cfg->usb2eye[1].Usb20PerPortTxPeHalf = 0;
97 cfg->usb2eye[2].Usb20PerPortPeTxiSet = 4;
98 cfg->usb2eye[2].Usb20PerPortTxiSet = 4;
99 cfg->usb2eye[2].Usb20IUsbTxEmphasisEn = 1;
100 cfg->usb2eye[2].Usb20PerPortTxPeHalf = 0;
102 cfg->usb2eye[4].Usb20PerPortPeTxiSet = 7;
103 cfg->usb2eye[4].Usb20PerPortTxiSet = 7;
104 cfg->usb2eye[4].Usb20IUsbTxEmphasisEn = 1;
105 cfg->usb2eye[4].Usb20PerPortTxPeHalf = 0;
106 break;
107 default:
108 break;