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 | 04ccd5f | 2018-03-16 13:43:52 +0800 | [diff] [blame^] | 25 | #include <variant/sku.h> |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 26 | |
amanda_hwang | 04ccd5f | 2018-03-16 13:43:52 +0800 | [diff] [blame^] | 27 | uint16_t variant_board_sku(void) |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 28 | { |
| 29 | static int sku_id = -1; |
| 30 | uint32_t id; |
| 31 | if (sku_id >= 0) |
| 32 | return sku_id; |
| 33 | if (google_chromeec_cbi_get_sku_id(&id)) |
| 34 | return SKU_UNKNOWN; |
| 35 | sku_id = id; |
| 36 | return sku_id; |
| 37 | } |
| 38 | |
| 39 | void variant_devtree_update(void) |
| 40 | { |
| 41 | /* Override dev tree settings per board */ |
amanda_hwang | 04ccd5f | 2018-03-16 13:43:52 +0800 | [diff] [blame^] | 42 | uint16_t sku_id = variant_board_sku(); |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 43 | device_t root = SA_DEV_ROOT; |
| 44 | config_t *cfg = root->chip_info; |
| 45 | switch (sku_id) { |
| 46 | case SKU_1_VAYNE: |
| 47 | cfg->usb2_ports[5].enable = 0;//rear camera |
| 48 | break; |
| 49 | default: |
| 50 | break; |
| 51 | } |
| 52 | } |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame] | 53 | |
| 54 | const char *smbios_mainboard_sku(void) |
| 55 | { |
| 56 | static char sku_str[9]; /* sku{0..65535} (basically up to FFFF) */ |
| 57 | |
amanda_hwang | 04ccd5f | 2018-03-16 13:43:52 +0800 | [diff] [blame^] | 58 | snprintf(sku_str, sizeof(sku_str), "sku%d", variant_board_sku()); |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame] | 59 | |
| 60 | return sku_str; |
| 61 | } |