2 * Copyright 2016 Rockchip Inc.
4 * See file CREDITS for list of people who contributed to this
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.
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.
19 #include <libpayload.h>
21 #include "base/init_funcs.h"
24 #include "drivers/bus/spi/rockchip.h"
25 #include "drivers/ec/cros/spi.h"
26 #include "drivers/flash/spi.h"
27 #include "drivers/flash/spi.h"
28 #include "drivers/gpio/rockchip.h"
29 #include "drivers/gpio/sysinfo.h"
30 #include "drivers/storage/dw_mmc.h"
31 #include "drivers/storage/rk_dwmmc.h"
32 #include "drivers/storage/sdhci.h"
33 #include "vboot/util/flag.h"
35 static const int emmc_sd_clock_min = 400 * 1000;
36 static const int emmc_clock_max = 200 * 1000 * 1000;
38 static int board_setup(void)
40 // Claim that we have an open lid to satisfy vboot.
41 flag_replace(FLAG_LIDSW, new_gpio_high());
43 // Claim that we have an power key to satisfy vboot.
44 flag_replace(FLAG_PWRSW, new_gpio_low());
46 RkSpi *spi1 = new_rockchip_spi(0xff1d0000);
48 flash_set_ops(&new_spi_flash(&spi1->ops)->ops);
50 // EC on Kevin is connected to SPI bus #5
51 RkSpi *spi5 = new_rockchip_spi(0xff200000);
52 CrosEcSpiBus *cros_ec_spi_bus = new_cros_ec_spi_bus(&spi5->ops);
53 GpioOps *ec_int = sysinfo_lookup_gpio("EC interrupt", 1,
54 new_rk_gpio_input_from_coreboot);
55 CrosEc *cros_ec = new_cros_ec(&cros_ec_spi_bus->ops, 0, ec_int);
56 register_vboot_ec(&cros_ec->vboot, 0);
59 SdhciHost *emmc = new_mem_sdhci_host((void *)0xfe330000,
60 SDHCI_PLATFORM_NO_EMMC_HS200 |
61 SDHCI_PLATFORM_NO_CLK_BASE,
65 list_insert_after(&emmc->mmc_ctrlr.ctrlr.list_node,
66 &fixed_block_dev_controllers);
70 /* SDMMC_DET_L is different on different board revisions. */
71 switch (lib_sysinfo.board_id) {
72 case 0: /* This is for Kevin rev1. */
73 card_detect = new_rk_gpio_input(GPIO(4, D, 2));
76 card_detect = new_rk_gpio_input(GPIO(4, D, 0));
80 GpioOps *card_detect_ops = &card_detect->ops;
82 card_detect_ops = new_gpio_not(card_detect_ops);
84 DwmciHost *sd_card = new_rkdwmci_host(0xfe320000, 594000000, 4, 1,
87 list_insert_after(&sd_card->mmc.ctrlr.list_node,
88 &removable_block_dev_controllers);
93 INIT_FUNC(board_setup);