blob: bb4cff8ff027166337f86193fe0401cffb904f9c [file] [log] [blame]
Furquan Shaikhda01d942014-03-19 14:31:23 -07001/*
2 * This file is part of the coreboot project.
3 *
Deepa Dinamani2c041172014-05-15 17:14:12 -07004 * Copyright 2014 Google Inc.
Furquan Shaikhda01d942014-03-19 14:31:23 -07005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
Deepa Dinamani2c041172014-05-15 17:14:12 -070020#include <arch/cache.h>
Furquan Shaikhda01d942014-03-19 14:31:23 -070021#include <boot/coreboot_tables.h>
Deepa Dinamani2c041172014-05-15 17:14:12 -070022#include <device/device.h>
Julius Werner028cba92014-05-30 18:01:44 -070023#include <soc/qualcomm/ipq806x/include/clock.h>
Vadim Bendeburyf6ad8322014-06-24 07:26:03 -070024#include <soc/qualcomm/ipq806x/include/gpio.h>
Julius Werner028cba92014-05-30 18:01:44 -070025#include <soc/qualcomm/ipq806x/include/usb.h>
Deepa Dinamani2c041172014-05-15 17:14:12 -070026
27/* convenient shorthand (in MB) */
Julius Werner028cba92014-05-30 18:01:44 -070028#define DRAM_START (CONFIG_SYS_SDRAM_BASE / MiB)
Deepa Dinamani2c041172014-05-15 17:14:12 -070029#define DRAM_SIZE (CONFIG_DRAM_SIZE_MB)
30#define DRAM_END (DRAM_START + DRAM_SIZE)
31
32/* DMA memory for drivers */
Julius Werner028cba92014-05-30 18:01:44 -070033#define DMA_START (CONFIG_DRAM_DMA_START / MiB)
34#define DMA_SIZE (CONFIG_DRAM_DMA_SIZE / MiB)
35
Vadim Bendeburyf6ad8322014-06-24 07:26:03 -070036#define USB_ENABLE_GPIO 51
37
Julius Werner028cba92014-05-30 18:01:44 -070038static void setup_usb(void)
39{
Vadim Bendeburyf752d012014-07-10 15:24:18 -070040#if !CONFIG_BOARD_VARIANT_AP148
Vadim Bendeburyf6ad8322014-06-24 07:26:03 -070041 gpio_tlmm_config_set(USB_ENABLE_GPIO, FUNC_SEL_GPIO,
42 GPIO_PULL_UP, GPIO_10MA, GPIO_ENABLE);
Vadim Bendeburyf752d012014-07-10 15:24:18 -070043#endif
Julius Werner028cba92014-05-30 18:01:44 -070044 usb_clock_config();
45
46 setup_usb_host1();
Julius Werner028cba92014-05-30 18:01:44 -070047}
Deepa Dinamani2c041172014-05-15 17:14:12 -070048
49static void setup_mmu(void)
50{
51 dcache_mmu_disable();
52
53 /* Map Device memory. */
54 mmu_config_range(0, DRAM_START, DCACHE_OFF);
55 /* Disable Page 0 for trapping NULL pointer references. */
56 mmu_disable_range(0, 1);
57 /* Map DRAM memory */
58 mmu_config_range(DRAM_START, DRAM_SIZE, DCACHE_WRITEBACK);
59 /* Map DMA memory */
Julius Werner028cba92014-05-30 18:01:44 -070060 mmu_config_range(DMA_START, DMA_SIZE, DCACHE_OFF);
Deepa Dinamani2c041172014-05-15 17:14:12 -070061
62 mmu_disable_range(DRAM_END, 4096 - DRAM_END);
63
64 mmu_init();
65
66 dcache_mmu_enable();
67}
Furquan Shaikhda01d942014-03-19 14:31:23 -070068
69static void mainboard_init(device_t dev)
70{
Deepa Dinamani2c041172014-05-15 17:14:12 -070071 setup_mmu();
Julius Werner028cba92014-05-30 18:01:44 -070072 setup_usb();
Furquan Shaikhda01d942014-03-19 14:31:23 -070073}
74
75static void mainboard_enable(device_t dev)
76{
77 dev->ops->init = &mainboard_init;
78}
79
80struct chip_operations mainboard_ops = {
81 .name = "storm",
82 .enable_dev = mainboard_enable,
83};
Julius Werner028cba92014-05-30 18:01:44 -070084
85void lb_board(struct lb_header *header)
86{
87 struct lb_range *dma;
88
89 dma = (struct lb_range *)lb_new_record(header);
90 dma->tag = LB_TAB_DMA;
91 dma->size = sizeof(*dma);
92 dma->range_start = CONFIG_DRAM_DMA_START;
93 dma->range_size = CONFIG_DRAM_DMA_SIZE;
94}