Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Deepa Dinamani | 1c2748d | 2015-01-12 11:57:09 -0800 | [diff] [blame] | 4 | * Copyright (c) 2015, The Linux Foundation. All rights reserved. |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 5 | * Copyright 2014 Google Inc. |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 6 | * |
| 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 Bendebury | 1de971d | 2014-08-07 15:20:21 -0700 | [diff] [blame] | 21 | #include <boardid.h> |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 22 | #include <boot/coreboot_tables.h> |
Vadim Bendebury | c6d3040 | 2014-08-01 17:36:45 -0700 | [diff] [blame] | 23 | #include <delay.h> |
Vadim Bendebury | 1de971d | 2014-08-07 15:20:21 -0700 | [diff] [blame] | 24 | #include <device/device.h> |
Julius Werner | eaa9c45 | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 25 | #include <gpio.h> |
Julius Werner | 73d1ed6 | 2014-10-20 13:20:49 -0700 | [diff] [blame] | 26 | #include <soc/clock.h> |
Vikas Das | 08f249e | 2014-09-22 17:49:56 -0700 | [diff] [blame] | 27 | #include <soc/soc_services.h> |
Julius Werner | 73d1ed6 | 2014-10-20 13:20:49 -0700 | [diff] [blame] | 28 | #include <soc/usb.h> |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 29 | #include <symbols.h> |
Vadim Bendebury | c6d3040 | 2014-08-01 17:36:45 -0700 | [diff] [blame] | 30 | |
Vadim Bendebury | 103a07f | 2014-10-23 16:03:29 -0700 | [diff] [blame] | 31 | #include <vendorcode/google/chromeos/chromeos.h> |
Deepa Dinamani | 1c2748d | 2015-01-12 11:57:09 -0800 | [diff] [blame] | 32 | #include "mmu.h" |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 33 | |
Vadim Bendebury | f6ad832 | 2014-06-24 07:26:03 -0700 | [diff] [blame] | 34 | #define USB_ENABLE_GPIO 51 |
| 35 | |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 36 | static void setup_usb(void) |
| 37 | { |
Vadim Bendebury | f752d01 | 2014-07-10 15:24:18 -0700 | [diff] [blame] | 38 | #if !CONFIG_BOARD_VARIANT_AP148 |
Vadim Bendebury | f6ad832 | 2014-06-24 07:26:03 -0700 | [diff] [blame] | 39 | gpio_tlmm_config_set(USB_ENABLE_GPIO, FUNC_SEL_GPIO, |
| 40 | GPIO_PULL_UP, GPIO_10MA, GPIO_ENABLE); |
Julius Werner | eaa9c45 | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 41 | gpio_set(USB_ENABLE_GPIO, 1); |
Vadim Bendebury | f752d01 | 2014-07-10 15:24:18 -0700 | [diff] [blame] | 42 | #endif |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 43 | usb_clock_config(); |
| 44 | |
| 45 | setup_usb_host1(); |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 46 | } |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 47 | |
Vadim Bendebury | 1de971d | 2014-08-07 15:20:21 -0700 | [diff] [blame] | 48 | #define TPM_RESET_GPIO 22 |
| 49 | static void setup_tpm(void) |
| 50 | { |
Dan Ehrenberg | 644afa7 | 2014-10-24 13:22:05 -0700 | [diff] [blame] | 51 | if (board_id() != BOARD_ID_PROTO_0) |
Vadim Bendebury | 1de971d | 2014-08-07 15:20:21 -0700 | [diff] [blame] | 52 | 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 Werner | eaa9c45 | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 61 | gpio_set(TPM_RESET_GPIO, 0); |
Vadim Bendebury | 1de971d | 2014-08-07 15:20:21 -0700 | [diff] [blame] | 62 | udelay(160); |
Julius Werner | eaa9c45 | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 63 | gpio_set(TPM_RESET_GPIO, 1); |
Vadim Bendebury | 1de971d | 2014-08-07 15:20:21 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Vadim Bendebury | c7bbc04 | 2014-09-08 14:34:09 -0700 | [diff] [blame] | 66 | #define SW_RESET_GPIO 26 |
Vadim Bendebury | a45d5d3 | 2014-10-22 12:14:29 -0700 | [diff] [blame] | 67 | static void assert_sw_reset(void) |
Vadim Bendebury | c7bbc04 | 2014-09-08 14:34:09 -0700 | [diff] [blame] | 68 | { |
Dan Ehrenberg | 644afa7 | 2014-10-24 13:22:05 -0700 | [diff] [blame] | 69 | if (board_id() == BOARD_ID_PROTO_0) |
Vadim Bendebury | c7bbc04 | 2014-09-08 14:34:09 -0700 | [diff] [blame] | 70 | return; |
| 71 | |
Vadim Bendebury | f32ef13 | 2014-09-09 20:41:33 -0700 | [diff] [blame] | 72 | /* |
Vadim Bendebury | a45d5d3 | 2014-10-22 12:14:29 -0700 | [diff] [blame] | 73 | * 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 Bendebury | f32ef13 | 2014-09-09 20:41:33 -0700 | [diff] [blame] | 76 | */ |
Vadim Bendebury | c7bbc04 | 2014-09-08 14:34:09 -0700 | [diff] [blame] | 77 | gpio_tlmm_config_set(SW_RESET_GPIO, FUNC_SEL_GPIO, |
| 78 | GPIO_PULL_UP, GPIO_4MA, GPIO_ENABLE); |
| 79 | |
Vadim Bendebury | a45d5d3 | 2014-10-22 12:14:29 -0700 | [diff] [blame] | 80 | gpio_set(SW_RESET_GPIO, 1); |
Vadim Bendebury | c7bbc04 | 2014-09-08 14:34:09 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 83 | static void mainboard_init(device_t dev) |
| 84 | { |
Deepa Dinamani | 1c2748d | 2015-01-12 11:57:09 -0800 | [diff] [blame] | 85 | /* disable mmu and d-cache before setting up secure world.*/ |
| 86 | dcache_mmu_disable(); |
Vikas Das | 08f249e | 2014-09-22 17:49:56 -0700 | [diff] [blame] | 87 | start_tzbsp(); |
Deepa Dinamani | 1c2748d | 2015-01-12 11:57:09 -0800 | [diff] [blame] | 88 | /* Setup mmu and d-cache again as non secure entries. */ |
| 89 | setup_mmu(DRAM_INITIALIZED); |
Vadim Bendebury | 6114c99 | 2014-12-16 14:34:28 -0800 | [diff] [blame] | 90 | start_rpm(); |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 91 | setup_usb(); |
Vadim Bendebury | a45d5d3 | 2014-10-22 12:14:29 -0700 | [diff] [blame] | 92 | assert_sw_reset(); |
Vadim Bendebury | 1de971d | 2014-08-07 15:20:21 -0700 | [diff] [blame] | 93 | setup_tpm(); |
Dan Ehrenberg | cb3b0c5a | 2014-10-23 17:46:39 -0700 | [diff] [blame] | 94 | /* Functionally a 0-cost no-op if NAND is not present */ |
| 95 | board_nand_init(); |
Vadim Bendebury | 103a07f | 2014-10-23 16:03:29 -0700 | [diff] [blame] | 96 | |
| 97 | #if IS_ENABLED(CONFIG_CHROMEOS) |
| 98 | /* Copy WIFI calibration data into CBMEM. */ |
| 99 | cbmem_add_vpd_calibration_data(); |
| 100 | #endif |
Vadim Bendebury | 3cfb6a0 | 2015-02-11 15:13:04 -0800 | [diff] [blame^] | 101 | |
| 102 | /* |
| 103 | * Make sure bootloader can issue sounds The frequency is calculated |
| 104 | * as "<frame_rate> * <bit_width> * <channels> * 4", i.e. |
| 105 | * |
| 106 | * 48000 * 2 * 16 * 4 = 6144000 |
| 107 | */ |
| 108 | audio_clock_config(6144000); |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | static void mainboard_enable(device_t dev) |
| 112 | { |
| 113 | dev->ops->init = &mainboard_init; |
| 114 | } |
| 115 | |
| 116 | struct chip_operations mainboard_ops = { |
| 117 | .name = "storm", |
| 118 | .enable_dev = mainboard_enable, |
| 119 | }; |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 120 | |
| 121 | void lb_board(struct lb_header *header) |
| 122 | { |
| 123 | struct lb_range *dma; |
| 124 | |
| 125 | dma = (struct lb_range *)lb_new_record(header); |
| 126 | dma->tag = LB_TAB_DMA; |
| 127 | dma->size = sizeof(*dma); |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 128 | dma->range_start = (uintptr_t)_dma_coherent; |
| 129 | dma->range_size = _dma_coherent_size; |
Vadim Bendebury | e9e0eec | 2014-10-16 13:26:59 -0700 | [diff] [blame] | 130 | |
| 131 | #if IS_ENABLED(CONFIG_CHROMEOS) |
| 132 | /* Retrieve the switch interface MAC addressses. */ |
| 133 | lb_table_add_macs_from_vpd(header); |
| 134 | #endif |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 135 | } |