coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <boardid.h>
4 #include <boot/coreboot_tables.h>
5 #include <delay.h>
6 #include <device/device.h>
7 #include <gpio.h>
8 #include <soc/clock.h>
9 #include <soc/soc_services.h>
10 #include <soc/usb.h>
11 #include <symbols.h>
12 
13 #include <vendorcode/google/chromeos/chromeos.h>
14 #include "mmu.h"
15 
16 #define USB_ENABLE_GPIO 51
17 
18 static void setup_usb(void)
19 {
20 #if !CONFIG(BOARD_VARIANT_AP148)
24 #endif
26 
28 }
29 
30 #define TPM_RESET_GPIO 22
31 static void setup_tpm(void)
32 {
33  if (board_id() != BOARD_ID_PROTO_0)
34  return; /* Only proto0 have TPM reset connected to GPIO22 */
35 
38  /*
39  * Generate a reset pulse. The spec calls for 80 us minimum, let's
40  * make it twice as long. If the output was driven low originally, the
41  * reset pulse will be even longer.
42  */
44  udelay(160);
46 }
47 
48 #define SW_RESET_GPIO 26
49 static void assert_sw_reset(void)
50 {
51  if (board_id() == BOARD_ID_PROTO_0)
52  return;
53 
54  /*
55  * only proto0.2 and later care about this. We want to keep the
56  * ethernet switch in reset, otherwise it comes up in default
57  * (bridging) mode.
58  */
61 
63 }
64 
65 static void mainboard_init(struct device *dev)
66 {
67  /* disable mmu and d-cache before setting up secure world.*/
69  start_tzbsp();
70  /* Setup mmu and d-cache again as non secure entries. */
72  start_rpm();
73  setup_usb();
75  setup_tpm();
76  /* Functionally a 0-cost no-op if NAND is not present */
78 
79  /* Copy WIFI calibration data into CBMEM. */
80  if (CONFIG(CHROMEOS))
81  cbmem_add_vpd_calibration_data();
82 
83  /*
84  * Make sure bootloader can issue sounds The frequency is calculated
85  * as "<frame_rate> * <bit_width> * <channels> * 4", i.e.
86  *
87  * 48000 * 2 * 16 * 4 = 6144000
88  */
89  audio_clock_config(6144000);
90 }
91 
92 static void mainboard_enable(struct device *dev)
93 {
94  dev->ops->init = &mainboard_init;
95 }
96 
99 };
100 
101 void lb_board(struct lb_header *header)
102 {
103  struct lb_range *dma;
104 
105  dma = (struct lb_range *)lb_new_record(header);
106  dma->tag = LB_TAG_DMA;
107  dma->size = sizeof(*dma);
108  dma->range_start = (uintptr_t)_dma_coherent;
109  dma->range_size = REGION_SIZE(dma_coherent);
110 
111  /* Retrieve the switch interface MAC addresses. */
112  if (CONFIG(CHROMEOS))
114 }
struct chip_operations mainboard_ops
Definition: mainboard.c:19
struct arm64_kernel_header header
Definition: fit_payload.c:30
void dcache_mmu_disable(void)
Definition: cache.c:49
@ LB_TAG_DMA
int dma_coherent(void *ptr)
@ CONFIG
Definition: dsi_common.h:201
uint32_t board_id(void)
board_id() - Get the board version
Definition: ec_boardid.c:6
void lb_board(struct lb_header *header)
Definition: mainboard.c:325
static void mainboard_init(struct device *dev)
Definition: mainboard.c:65
static void setup_tpm(void)
Definition: mainboard.c:31
#define TPM_RESET_GPIO
Definition: mainboard.c:30
#define SW_RESET_GPIO
Definition: mainboard.c:48
static void assert_sw_reset(void)
Definition: mainboard.c:49
static void setup_usb(void)
Definition: mainboard.c:18
static void mainboard_enable(struct device *dev)
Definition: mainboard.c:92
#define USB_ENABLE_GPIO
Definition: mainboard.c:16
struct lb_record * lb_new_record(struct lb_header *header)
void lb_table_add_macs_from_vpd(struct lb_header *header)
void gpio_set(gpio_t gpio, int value)
Definition: gpio.c:174
#define REGION_SIZE(name)
Definition: symbols.h:10
void start_tzbsp(void)
Definition: blobs_init.c:106
void start_rpm(void)
Definition: blobs_init.c:89
void setup_mmu(enum dram_state dram)
Definition: mmu.c:40
@ DRAM_INITIALIZED
Definition: mmu.h:13
@ BOARD_ID_PROTO_0
Definition: gpio.h:21
struct @1399 * dma
@ GPIO_4MA
Definition: gpio_common.h:71
@ GPIO_10MA
Definition: gpio_common.h:74
void usb_clock_config(void)
usb_clock_config - configure USB controller clocks and reset the controller
Definition: clock.c:68
void gpio_tlmm_config_set(gpio_t gpio, unsigned int func, unsigned int pull, unsigned int drvstr, unsigned int enable)
Definition: gpio.c:32
int audio_clock_config(unsigned int frequency)
Definition: lcc.c:260
#define GPIO_ENABLE
Definition: gpio.h:38
#define FUNC_SEL_GPIO
Definition: gpio.h:13
#define GPIO_PULL_UP
Definition: gpio.h:24
void setup_usb_host1(void)
Definition: usb.c:274
unsigned long uintptr_t
Definition: stdint.h:21
void board_nand_init(void)
Definition: cdp.c:45
void(* enable_dev)(struct device *dev)
Definition: device.h:24
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
struct device_operations * ops
Definition: device.h:143
void udelay(uint32_t us)
Definition: udelay.c:15