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 | |
Zhuohao Lee | f7b5955 | 2018-03-17 05:00:49 +0800 | [diff] [blame^] | 27 | uint32_t variant_board_sku(void) |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 28 | { |
Zhuohao Lee | f7b5955 | 2018-03-17 05:00:49 +0800 | [diff] [blame^] | 29 | static uint32_t sku_id = SKU_UNKNOWN; |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 30 | uint32_t id; |
Zhuohao Lee | f7b5955 | 2018-03-17 05:00:49 +0800 | [diff] [blame^] | 31 | |
| 32 | if (sku_id != SKU_UNKNOWN) |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 33 | return sku_id; |
| 34 | if (google_chromeec_cbi_get_sku_id(&id)) |
| 35 | return SKU_UNKNOWN; |
| 36 | sku_id = id; |
Zhuohao Lee | f7b5955 | 2018-03-17 05:00:49 +0800 | [diff] [blame^] | 37 | |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 38 | return sku_id; |
| 39 | } |
| 40 | |
| 41 | void variant_devtree_update(void) |
| 42 | { |
| 43 | /* Override dev tree settings per board */ |
Zhuohao Lee | f7b5955 | 2018-03-17 05:00:49 +0800 | [diff] [blame^] | 44 | uint32_t sku_id = variant_board_sku(); |
amanda_hwang | b3b47e1 | 2018-03-08 11:04:40 +0800 | [diff] [blame] | 45 | device_t root = SA_DEV_ROOT; |
| 46 | config_t *cfg = root->chip_info; |
| 47 | switch (sku_id) { |
| 48 | case SKU_1_VAYNE: |
| 49 | cfg->usb2_ports[5].enable = 0;//rear camera |
| 50 | break; |
| 51 | default: |
| 52 | break; |
| 53 | } |
| 54 | } |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame] | 55 | |
| 56 | const char *smbios_mainboard_sku(void) |
| 57 | { |
Zhuohao Lee | f7b5955 | 2018-03-17 05:00:49 +0800 | [diff] [blame^] | 58 | static char sku_str[14]; /* sku{0..4294967295} */ |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame] | 59 | |
Zhuohao Lee | f7b5955 | 2018-03-17 05:00:49 +0800 | [diff] [blame^] | 60 | snprintf(sku_str, sizeof(sku_str), "sku%u", variant_board_sku()); |
Shelley Chen | 467cce4 | 2018-03-07 14:22:28 -0800 | [diff] [blame] | 61 | |
| 62 | return sku_str; |
| 63 | } |