Martin Roth | ecb4491 | 2018-05-24 16:55:10 -0600 | [diff] [blame] | 1 | /* |
| 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 Roth | 4ae44fc | 2018-09-17 13:30:51 -0600 | [diff] [blame] | 18 | #include <cbfs.h> |
Marc Jones | 290c445 | 2018-07-14 17:37:30 -0600 | [diff] [blame] | 19 | #include <gpio.h> |
Martin Roth | 4ae44fc | 2018-09-17 13:30:51 -0600 | [diff] [blame] | 20 | #include <smbios.h> |
Marc Jones | 290c445 | 2018-07-14 17:37:30 -0600 | [diff] [blame] | 21 | #include <variant/gpio.h> |
Kevin Chiu | 328ff7d | 2018-08-27 11:44:46 +0800 | [diff] [blame] | 22 | #include <device/pci.h> |
| 23 | #include <drivers/generic/bayhub/bh720.h> |
Martin Roth | ecb4491 | 2018-05-24 16:55:10 -0600 | [diff] [blame] | 24 | |
| 25 | uint8_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 Jones | 290c445 | 2018-07-14 17:37:30 -0600 | [diff] [blame] | 34 | |
Marc Jones | 290c445 | 2018-07-14 17:37:30 -0600 | [diff] [blame] | 35 | void variant_mainboard_suspend_resume(void) |
| 36 | { |
| 37 | /* Enable backlight - GPIO 133 active low */ |
| 38 | gpio_set(GPIO_133, 0); |
| 39 | } |
Kevin Chiu | 328ff7d | 2018-08-27 11:44:46 +0800 | [diff] [blame] | 40 | |
| 41 | void 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 Roth | 4ae44fc | 2018-09-17 13:30:51 -0600 | [diff] [blame] | 76 | |
Martin Roth | 4ae44fc | 2018-09-17 13:30:51 -0600 | [diff] [blame] | 77 | |
| 78 | const char *smbios_mainboard_manufacturer(void) |
| 79 | { |
Kevin Chiu | 0fa007b | 2018-10-03 10:12:44 +0800 | [diff] [blame] | 80 | static char oem_bin_data[11]; |
Martin Roth | 4ae44fc | 2018-09-17 13:30:51 -0600 | [diff] [blame] | 81 | 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 Roth | 1f42a38 | 2018-09-24 15:39:12 -0600 | [diff] [blame] | 89 | 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 Roth | 4ae44fc | 2018-09-17 13:30:51 -0600 | [diff] [blame] | 94 | manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; |
| 95 | |
| 96 | return manuf; |
| 97 | } |