2 * Copyright (C) 2016 Intel Corporation.
3 * Copyright 2016 Google Inc.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but without any warranty; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #include <libpayload.h>
23 #include "base/init_funcs.h"
24 #include "drivers/gpio/sysinfo.h"
25 #include "drivers/flash/memmapped.h"
26 #include "drivers/tpm/tpm.h"
27 #include "drivers/power/pch.h"
28 #include "drivers/tpm/lpc.h"
29 #include "drivers/storage/sdhci.h"
31 #define EMMC_SD_CLOCK_MIN 400000
32 #define EMMC_CLOCK_MAX 200000000
35 * FIXME: this needs to be derived differently. The coreboot code actually
36 * handles the situation better than assuming a specific descriptor layout
37 * and re-calculating the same information. Nevertheless in order to
38 * utilize the exist set of flash ops one needs to assume the following layout:
40 * 0 +----------------------+
42 * 4K +----------------------+
44 * X +----------------------+
45 * | CSE device extension |
46 * rom size +----------------------+
48 * The BIOS region is the only thing memory-mapped. And one needs to include
49 * the size of the descriptor in order for the math to work out within the
50 * memory-mapped flash implementation. In short, the 'X' above is the size
51 * used for FLASH_MEM_MAP_SIZE.
54 #define FLASH_MEM_MAP_SIZE 0x6FF000
55 #define FLASH_MEM_MAP_BASE ((uintptr_t)(0x100000000ULL - FLASH_MEM_MAP_SIZE))
57 static int board_setup(void)
59 sysinfo_install_flags(NULL);
61 /* W25Q128FV SPI Flash */
62 flash_set_ops(&new_mem_mapped_flash(FLASH_MEM_MAP_BASE,
63 FLASH_MEM_MAP_SIZE)->ops);
65 /* FIXME: not stuffed but need MOCK_TPM to work. */
66 tpm_set_ops(&new_lpc_tpm((void *)(uintptr_t)0xfed40000)->ops);
69 emmc = new_pci_sdhci_host(PCI_DEV(0, 0x1c, 0), 0,
70 EMMC_SD_CLOCK_MIN, EMMC_CLOCK_MAX);
71 list_insert_after(&emmc->mmc_ctrlr.ctrlr.list_node,
72 &fixed_block_dev_controllers);
75 power_set_ops(&apollolake_power_ops);
80 INIT_FUNC(board_setup);