blob: 4fc3d885cfa5a4df66fb41787b5fba9220d6af77 [file] [log] [blame]
amanda_hwangb3b47e12018-03-08 11:04:40 +08001/*
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 Chen467cce42018-03-07 14:22:28 -080016#include <arch/cpu.h>
17#include <assert.h>
18#include <baseboard/variants.h>
amanda_hwangb3b47e12018-03-08 11:04:40 +080019#include <chip.h>
20#include <device/device.h>
21#include <ec/google/chromeec/ec.h>
Shelley Chen467cce42018-03-07 14:22:28 -080022#include <smbios.h>
23#include <soc/ramstage.h>
24#include <string.h>
amanda_hwang04ccd5f2018-03-16 13:43:52 +080025#include <variant/sku.h>
amanda_hwangb3b47e12018-03-08 11:04:40 +080026
Zhuohao Leef7b59552018-03-17 05:00:49 +080027uint32_t variant_board_sku(void)
amanda_hwangb3b47e12018-03-08 11:04:40 +080028{
Zhuohao Leef7b59552018-03-17 05:00:49 +080029 static uint32_t sku_id = SKU_UNKNOWN;
amanda_hwangb3b47e12018-03-08 11:04:40 +080030 uint32_t id;
Zhuohao Leef7b59552018-03-17 05:00:49 +080031
32 if (sku_id != SKU_UNKNOWN)
amanda_hwangb3b47e12018-03-08 11:04:40 +080033 return sku_id;
34 if (google_chromeec_cbi_get_sku_id(&id))
35 return SKU_UNKNOWN;
36 sku_id = id;
Zhuohao Leef7b59552018-03-17 05:00:49 +080037
amanda_hwangb3b47e12018-03-08 11:04:40 +080038 return sku_id;
39}
40
41void variant_devtree_update(void)
42{
43 /* Override dev tree settings per board */
Zhuohao Leef7b59552018-03-17 05:00:49 +080044 uint32_t sku_id = variant_board_sku();
amanda_hwangb3b47e12018-03-08 11:04:40 +080045 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 Chen467cce42018-03-07 14:22:28 -080055
56const char *smbios_mainboard_sku(void)
57{
Zhuohao Leef7b59552018-03-17 05:00:49 +080058 static char sku_str[14]; /* sku{0..4294967295} */
Shelley Chen467cce42018-03-07 14:22:28 -080059
Zhuohao Leef7b59552018-03-17 05:00:49 +080060 snprintf(sku_str, sizeof(sku_str), "sku%u", variant_board_sku());
Shelley Chen467cce42018-03-07 14:22:28 -080061
62 return sku_str;
63}