58b0366e0e89e3b6486d91539577117daeef1781
[depthcharge.git] / src / board / amenia / board.c
1 /*
2  * Copyright (C) 2016 Intel Corporation.
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but without any warranty; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20  * MA 02111-1307 USA
21  */
22
23 #include <libpayload.h>
24 #include <sysinfo.h>
25
26 #include "base/init_funcs.h"
27 #include "drivers/gpio/sysinfo.h"
28 #include "drivers/flash/memmapped.h"
29 #include "drivers/tpm/tpm.h"
30 #include "drivers/bus/usb/usb.h"
31 #include "drivers/power/pch.h"
32 #include "drivers/tpm/lpc.h"
33 #include "drivers/storage/sdhci.h"
34
35 #define EMMC_SD_CLOCK_MIN       400000
36 #define EMMC_CLOCK_MAX          200000000
37
38 /* Flash memory map size includes the 4K descriptor which is not accessible */
39 #define FLASH_MEM_MAP_SIZE      0x6FF000
40 #define FLASH_MEM_MAP_BASE      ((uintptr_t)(0x100000000ULL - FLASH_MEM_MAP_SIZE))
41
42
43 static int board_setup(void)
44 {
45         sysinfo_install_flags(NULL);
46
47         /* W25Q128FV SPI Flash */
48         flash_set_ops(&new_mem_mapped_flash(FLASH_MEM_MAP_BASE, FLASH_MEM_MAP_SIZE)->ops);
49
50         /* SLB9670 SPI TPM */
51         tpm_set_ops(&new_lpc_tpm((void *)(uintptr_t)0xfed40000)->ops);
52
53         SdhciHost *emmc;
54         emmc = new_pci_sdhci_host(PCI_DEV(0, 0x1c, 0), 0,
55                         EMMC_SD_CLOCK_MIN, EMMC_CLOCK_MAX);
56         list_insert_after(&emmc->mmc_ctrlr.ctrlr.list_node,
57                         &fixed_block_dev_controllers);
58
59         /* PCH Power */
60         power_set_ops(&apollolake_power_ops);
61
62         return 0;
63 }
64
65 INIT_FUNC(board_setup);