blob: f83cfe99ad51bf71e6c7a629f01495c70b1c05e0 [file] [log] [blame]
Furquan Shaikhda01d942014-03-19 14:31:23 -07001/*
2 * This file is part of the coreboot project.
3 *
Deepa Dinamani1c2748d2015-01-12 11:57:09 -08004 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
Deepa Dinamani2c041172014-05-15 17:14:12 -07005 * Copyright 2014 Google Inc.
Furquan Shaikhda01d942014-03-19 14:31:23 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
Vadim Bendebury1de971d2014-08-07 15:20:21 -070021#include <boardid.h>
Furquan Shaikhda01d942014-03-19 14:31:23 -070022#include <boot/coreboot_tables.h>
Vadim Bendeburyc6d30402014-08-01 17:36:45 -070023#include <delay.h>
Vadim Bendebury1de971d2014-08-07 15:20:21 -070024#include <device/device.h>
Julius Wernereaa9c452014-09-24 15:40:49 -070025#include <gpio.h>
Julius Werner73d1ed62014-10-20 13:20:49 -070026#include <soc/clock.h>
Vikas Das08f249e2014-09-22 17:49:56 -070027#include <soc/soc_services.h>
Julius Werner73d1ed62014-10-20 13:20:49 -070028#include <soc/usb.h>
Julius Wernerec5e5e02014-08-20 15:29:56 -070029#include <symbols.h>
Vadim Bendeburyc6d30402014-08-01 17:36:45 -070030
Vadim Bendebury103a07f2014-10-23 16:03:29 -070031#include <vendorcode/google/chromeos/chromeos.h>
Deepa Dinamani1c2748d2015-01-12 11:57:09 -080032#include "mmu.h"
Julius Werner028cba92014-05-30 18:01:44 -070033
Vadim Bendeburyf6ad8322014-06-24 07:26:03 -070034#define USB_ENABLE_GPIO 51
35
Julius Werner028cba92014-05-30 18:01:44 -070036static void setup_usb(void)
37{
Vadim Bendeburyf752d012014-07-10 15:24:18 -070038#if !CONFIG_BOARD_VARIANT_AP148
Vadim Bendeburyf6ad8322014-06-24 07:26:03 -070039 gpio_tlmm_config_set(USB_ENABLE_GPIO, FUNC_SEL_GPIO,
40 GPIO_PULL_UP, GPIO_10MA, GPIO_ENABLE);
Julius Wernereaa9c452014-09-24 15:40:49 -070041 gpio_set(USB_ENABLE_GPIO, 1);
Vadim Bendeburyf752d012014-07-10 15:24:18 -070042#endif
Julius Werner028cba92014-05-30 18:01:44 -070043 usb_clock_config();
44
45 setup_usb_host1();
Julius Werner028cba92014-05-30 18:01:44 -070046}
Deepa Dinamani2c041172014-05-15 17:14:12 -070047
Vadim Bendebury1de971d2014-08-07 15:20:21 -070048#define TPM_RESET_GPIO 22
49static void setup_tpm(void)
50{
Dan Ehrenberg644afa72014-10-24 13:22:05 -070051 if (board_id() != BOARD_ID_PROTO_0)
Vadim Bendebury1de971d2014-08-07 15:20:21 -070052 return; /* Only proto0 have TPM reset connected to GPIO22 */
53
54 gpio_tlmm_config_set(TPM_RESET_GPIO, FUNC_SEL_GPIO, GPIO_PULL_UP,
55 GPIO_4MA, GPIO_ENABLE);
56 /*
57 * Generate a reset pulse. The spec calls for 80 us minimum, let's
58 * make it twice as long. If the output was driven low originally, the
59 * reset pulse will be even longer.
60 */
Julius Wernereaa9c452014-09-24 15:40:49 -070061 gpio_set(TPM_RESET_GPIO, 0);
Vadim Bendebury1de971d2014-08-07 15:20:21 -070062 udelay(160);
Julius Wernereaa9c452014-09-24 15:40:49 -070063 gpio_set(TPM_RESET_GPIO, 1);
Vadim Bendebury1de971d2014-08-07 15:20:21 -070064}
65
Vadim Bendeburyc7bbc042014-09-08 14:34:09 -070066#define SW_RESET_GPIO 26
Vadim Bendeburya45d5d32014-10-22 12:14:29 -070067static void assert_sw_reset(void)
Vadim Bendeburyc7bbc042014-09-08 14:34:09 -070068{
Dan Ehrenberg644afa72014-10-24 13:22:05 -070069 if (board_id() == BOARD_ID_PROTO_0)
Vadim Bendeburyc7bbc042014-09-08 14:34:09 -070070 return;
71
Vadim Bendeburyf32ef132014-09-09 20:41:33 -070072 /*
Vadim Bendeburya45d5d32014-10-22 12:14:29 -070073 * only proto0.2 and later care about this. We want to keep the
74 * ethernet switch in reset, otherwise it comes up in default
75 * (bridging) mode.
Vadim Bendeburyf32ef132014-09-09 20:41:33 -070076 */
Vadim Bendeburyc7bbc042014-09-08 14:34:09 -070077 gpio_tlmm_config_set(SW_RESET_GPIO, FUNC_SEL_GPIO,
78 GPIO_PULL_UP, GPIO_4MA, GPIO_ENABLE);
79
Vadim Bendeburya45d5d32014-10-22 12:14:29 -070080 gpio_set(SW_RESET_GPIO, 1);
Vadim Bendeburyc7bbc042014-09-08 14:34:09 -070081}
82
Furquan Shaikhda01d942014-03-19 14:31:23 -070083static void mainboard_init(device_t dev)
84{
Deepa Dinamani1c2748d2015-01-12 11:57:09 -080085 /* disable mmu and d-cache before setting up secure world.*/
86 dcache_mmu_disable();
Vikas Das08f249e2014-09-22 17:49:56 -070087 start_tzbsp();
Deepa Dinamani1c2748d2015-01-12 11:57:09 -080088 /* Setup mmu and d-cache again as non secure entries. */
89 setup_mmu(DRAM_INITIALIZED);
Vadim Bendebury6114c992014-12-16 14:34:28 -080090 start_rpm();
Julius Werner028cba92014-05-30 18:01:44 -070091 setup_usb();
Vadim Bendeburya45d5d32014-10-22 12:14:29 -070092 assert_sw_reset();
Vadim Bendebury1de971d2014-08-07 15:20:21 -070093 setup_tpm();
Dan Ehrenbergcb3b0c5a2014-10-23 17:46:39 -070094 /* Functionally a 0-cost no-op if NAND is not present */
95 board_nand_init();
Vadim Bendebury103a07f2014-10-23 16:03:29 -070096
97#if IS_ENABLED(CONFIG_CHROMEOS)
98 /* Copy WIFI calibration data into CBMEM. */
99 cbmem_add_vpd_calibration_data();
100#endif
Furquan Shaikhda01d942014-03-19 14:31:23 -0700101}
102
103static void mainboard_enable(device_t dev)
104{
105 dev->ops->init = &mainboard_init;
106}
107
108struct chip_operations mainboard_ops = {
109 .name = "storm",
110 .enable_dev = mainboard_enable,
111};
Julius Werner028cba92014-05-30 18:01:44 -0700112
113void lb_board(struct lb_header *header)
114{
115 struct lb_range *dma;
116
117 dma = (struct lb_range *)lb_new_record(header);
118 dma->tag = LB_TAB_DMA;
119 dma->size = sizeof(*dma);
Julius Wernerec5e5e02014-08-20 15:29:56 -0700120 dma->range_start = (uintptr_t)_dma_coherent;
121 dma->range_size = _dma_coherent_size;
Vadim Bendeburye9e0eec2014-10-16 13:26:59 -0700122
123#if IS_ENABLED(CONFIG_CHROMEOS)
124 /* Retrieve the switch interface MAC addressses. */
125 lb_table_add_macs_from_vpd(header);
126#endif
Julius Werner028cba92014-05-30 18:01:44 -0700127}