blob: 71aca7381b2ea9742d565e64a72e93c164794dc8 [file] [log] [blame]
Martin Rothecb44912018-05-24 16:55:10 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2018 Google LLC
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
16#include <ec/google/chromeec/ec.h>
17#include <baseboard/variants.h>
Martin Roth4ae44fc2018-09-17 13:30:51 -060018#include <cbfs.h>
Marc Jones290c4452018-07-14 17:37:30 -060019#include <gpio.h>
Martin Roth4ae44fc2018-09-17 13:30:51 -060020#include <smbios.h>
Marc Jones290c4452018-07-14 17:37:30 -060021#include <variant/gpio.h>
Kevin Chiu328ff7d2018-08-27 11:44:46 +080022#include <device/pci.h>
23#include <drivers/generic/bayhub/bh720.h>
Martin Rothecb44912018-05-24 16:55:10 -060024
25uint8_t variant_board_sku(void)
26{
27 static int sku = -1;
28
29 if (sku == -1)
30 sku = google_chromeec_get_sku_id();
31
32 return sku;
33}
Marc Jones290c4452018-07-14 17:37:30 -060034
Marc Jones290c4452018-07-14 17:37:30 -060035void variant_mainboard_suspend_resume(void)
36{
37 /* Enable backlight - GPIO 133 active low */
38 gpio_set(GPIO_133, 0);
39}
Kevin Chiu328ff7d2018-08-27 11:44:46 +080040
41void board_bh720(struct device *dev)
42{
43 u32 sdbar;
44 u32 bh720_pcr_data;
45
46 sdbar = pci_read_config32(dev, PCI_BASE_ADDRESS_1);
47
48 /* Enable Memory Access Function */
49 write32((void *)(sdbar + BH720_MEM_ACCESS_EN), 0x40000000);
50 write32((void *)(sdbar + BH720_MEM_RW_DATA), 0x80000000);
51 write32((void *)(sdbar + BH720_MEM_RW_ADR), 0x800000D0);
52
53 /* Set EMMC VCCQ 1.8V PCR 0x308[4] */
54 write32((void *)(sdbar + BH720_MEM_RW_ADR),
55 BH720_MEM_RW_READ | BH720_PCR_EMMC_SETTING);
56 bh720_pcr_data = read32((void *)(sdbar + BH720_MEM_RW_DATA));
57 write32((void *)(sdbar + BH720_MEM_RW_DATA),
58 bh720_pcr_data | BH720_PCR_EMMC_SETTING_1_8V);
59 write32((void *)(sdbar + BH720_MEM_RW_ADR),
60 BH720_MEM_RW_WRITE | BH720_PCR_EMMC_SETTING);
61
62 /* Set Bayhub SD base CLK 50MHz: case#1 PCR 0x3E4[22] = 0 */
63 write32((void *)(sdbar + BH720_MEM_RW_ADR),
64 BH720_MEM_RW_READ | BH720_PCR_CSR);
65 bh720_pcr_data = read32((void *)(sdbar + BH720_MEM_RW_DATA));
66 write32((void *)(sdbar + BH720_MEM_RW_DATA),
67 bh720_pcr_data & ~BH720_PCR_CSR_EMMC_MODE_SEL);
68 write32((void *)(sdbar + BH720_MEM_RW_ADR),
69 BH720_MEM_RW_WRITE | BH720_PCR_CSR);
70
71 /* Disable Memory Access */
72 write32((void *)(sdbar + BH720_MEM_RW_DATA), 0x80000001);
73 write32((void *)(sdbar + BH720_MEM_RW_ADR), 0x800000D0);
74 write32((void *)(sdbar + BH720_MEM_ACCESS_EN), 0x80000000);
75}
Martin Roth4ae44fc2018-09-17 13:30:51 -060076
Martin Roth4ae44fc2018-09-17 13:30:51 -060077
78const char *smbios_mainboard_manufacturer(void)
79{
Kevin Chiu0fa007b2018-10-03 10:12:44 +080080 static char oem_bin_data[11];
Martin Roth4ae44fc2018-09-17 13:30:51 -060081 static const char *manuf;
82
83 if (!IS_ENABLED(CONFIG_USE_OEM_BIN))
84 return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
85
86 if (manuf)
87 return manuf;
88
Martin Roth1f42a382018-09-24 15:39:12 -060089 if (cbfs_boot_load_file("oem.bin", oem_bin_data,
90 sizeof(oem_bin_data) - 1,
91 CBFS_TYPE_RAW))
92 manuf = &oem_bin_data[0];
93 else
Martin Roth4ae44fc2018-09-17 13:30:51 -060094 manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
95
96 return manuf;
97}