amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2018 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame^] | 16 | #include <arch/cpu.h> |
| 17 | #include <assert.h> |
| 18 | #include <baseboard/variants.h> |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 19 | #include <chip.h> |
| 20 | #include <device/device.h> |
| 21 | #include <ec/google/chromeec/ec.h> |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame^] | 22 | #include <smbios.h> |
| 23 | #include <soc/ramstage.h> |
| 24 | #include <string.h> |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 25 | |
| 26 | #define SKU_UNKNOWN 0xFFFF |
| 27 | #define SKU_0_NAMI 0x3A7B |
| 28 | #define SKU_1_VAYNE 0x3A63 |
| 29 | #define SKU_2_VAYNE 0x3A7F |
| 30 | |
| 31 | static uint16_t board_sku_id(void) |
| 32 | { |
| 33 | static int sku_id = -1; |
| 34 | uint32_t id; |
| 35 | if (sku_id >= 0) |
| 36 | return sku_id; |
| 37 | if (google_chromeec_cbi_get_sku_id(&id)) |
| 38 | return SKU_UNKNOWN; |
| 39 | sku_id = id; |
| 40 | return sku_id; |
| 41 | } |
| 42 | |
| 43 | void variant_devtree_update(void) |
| 44 | { |
| 45 | /* Override dev tree settings per board */ |
| 46 | uint16_t sku_id = board_sku_id(); |
| 47 | device_t root = SA_DEV_ROOT; |
| 48 | config_t *cfg = root->chip_info; |
| 49 | switch (sku_id) { |
| 50 | case SKU_1_VAYNE: |
| 51 | cfg->usb2_ports[5].enable = 0;//rear camera |
| 52 | break; |
| 53 | default: |
| 54 | break; |
| 55 | } |
| 56 | } |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame^] | 57 | |
| 58 | const char *smbios_mainboard_sku(void) |
| 59 | { |
| 60 | static char sku_str[9]; /* sku{0..65535} (basically up to FFFF) */ |
| 61 | |
| 62 | snprintf(sku_str, sizeof(sku_str), "sku%d", board_sku_id()); |
| 63 | |
| 64 | return sku_str; |
| 65 | } |