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 | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 4 | * Copyright 2014 Google Inc. |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 5 | * |
| 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 Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 20 | #include <arch/cache.h> |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 21 | #include <boot/coreboot_tables.h> |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 22 | #include <device/device.h> |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 23 | #include <soc/qualcomm/ipq806x/include/clock.h> |
Vadim Bendebury | f6ad832 | 2014-06-24 07:26:03 -0700 | [diff] [blame^] | 24 | #include <soc/qualcomm/ipq806x/include/gpio.h> |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 25 | #include <soc/qualcomm/ipq806x/include/usb.h> |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 26 | |
| 27 | /* convenient shorthand (in MB) */ |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 28 | #define DRAM_START (CONFIG_SYS_SDRAM_BASE / MiB) |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 29 | #define DRAM_SIZE (CONFIG_DRAM_SIZE_MB) |
| 30 | #define DRAM_END (DRAM_START + DRAM_SIZE) |
| 31 | |
| 32 | /* DMA memory for drivers */ |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 33 | #define DMA_START (CONFIG_DRAM_DMA_START / MiB) |
| 34 | #define DMA_SIZE (CONFIG_DRAM_DMA_SIZE / MiB) |
| 35 | |
Vadim Bendebury | f6ad832 | 2014-06-24 07:26:03 -0700 | [diff] [blame^] | 36 | #define USB_ENABLE_GPIO 51 |
| 37 | |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 38 | static void setup_usb(void) |
| 39 | { |
Vadim Bendebury | f6ad832 | 2014-06-24 07:26:03 -0700 | [diff] [blame^] | 40 | gpio_tlmm_config_set(USB_ENABLE_GPIO, FUNC_SEL_GPIO, |
| 41 | GPIO_PULL_UP, GPIO_10MA, GPIO_ENABLE); |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 42 | usb_clock_config(); |
| 43 | |
| 44 | setup_usb_host1(); |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 45 | } |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 46 | |
| 47 | static void setup_mmu(void) |
| 48 | { |
| 49 | dcache_mmu_disable(); |
| 50 | |
| 51 | /* Map Device memory. */ |
| 52 | mmu_config_range(0, DRAM_START, DCACHE_OFF); |
| 53 | /* Disable Page 0 for trapping NULL pointer references. */ |
| 54 | mmu_disable_range(0, 1); |
| 55 | /* Map DRAM memory */ |
| 56 | mmu_config_range(DRAM_START, DRAM_SIZE, DCACHE_WRITEBACK); |
| 57 | /* Map DMA memory */ |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 58 | mmu_config_range(DMA_START, DMA_SIZE, DCACHE_OFF); |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 59 | |
| 60 | mmu_disable_range(DRAM_END, 4096 - DRAM_END); |
| 61 | |
| 62 | mmu_init(); |
| 63 | |
| 64 | dcache_mmu_enable(); |
| 65 | } |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 66 | |
| 67 | static void mainboard_init(device_t dev) |
| 68 | { |
Deepa Dinamani | 2c04117 | 2014-05-15 17:14:12 -0700 | [diff] [blame] | 69 | setup_mmu(); |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 70 | setup_usb(); |
Furquan Shaikh | da01d94 | 2014-03-19 14:31:23 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static void mainboard_enable(device_t dev) |
| 74 | { |
| 75 | dev->ops->init = &mainboard_init; |
| 76 | } |
| 77 | |
| 78 | struct chip_operations mainboard_ops = { |
| 79 | .name = "storm", |
| 80 | .enable_dev = mainboard_enable, |
| 81 | }; |
Julius Werner | 028cba9 | 2014-05-30 18:01:44 -0700 | [diff] [blame] | 82 | |
| 83 | void lb_board(struct lb_header *header) |
| 84 | { |
| 85 | struct lb_range *dma; |
| 86 | |
| 87 | dma = (struct lb_range *)lb_new_record(header); |
| 88 | dma->tag = LB_TAB_DMA; |
| 89 | dma->size = sizeof(*dma); |
| 90 | dma->range_start = CONFIG_DRAM_DMA_START; |
| 91 | dma->range_size = CONFIG_DRAM_DMA_SIZE; |
| 92 | } |