blob: 1e622f490456d0c5748255c04a0bd386fe2953c9 [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>
23
24#define TO_MB(x) ((x)>>20)
25
26/* convenient shorthand (in MB) */
27#define DRAM_START TO_MB(CONFIG_SYS_SDRAM_BASE)
28#define DRAM_SIZE (CONFIG_DRAM_SIZE_MB)
29#define DRAM_END (DRAM_START + DRAM_SIZE)
30
31/* DMA memory for drivers */
32#define DMA_START TO_MB(CONFIG_DRAM_DMA_START)
33#define DMA_SIZE TO_MB(CONFIG_DRAM_DMA_SIZE)
34
35static void setup_mmu(void)
36{
37 dcache_mmu_disable();
38
39 /* Map Device memory. */
40 mmu_config_range(0, DRAM_START, DCACHE_OFF);
41 /* Disable Page 0 for trapping NULL pointer references. */
42 mmu_disable_range(0, 1);
43 /* Map DRAM memory */
44 mmu_config_range(DRAM_START, DRAM_SIZE, DCACHE_WRITEBACK);
45 /* Map DMA memory */
46 if (DMA_SIZE)
47 mmu_config_range(DMA_START, DMA_SIZE, DCACHE_OFF);
48
49 mmu_disable_range(DRAM_END, 4096 - DRAM_END);
50
51 mmu_init();
52
53 dcache_mmu_enable();
54}
Furquan Shaikhda01d942014-03-19 14:31:23 -070055
56static void mainboard_init(device_t dev)
57{
Deepa Dinamani2c041172014-05-15 17:14:12 -070058 setup_mmu();
Furquan Shaikhda01d942014-03-19 14:31:23 -070059}
60
61static void mainboard_enable(device_t dev)
62{
63 dev->ops->init = &mainboard_init;
64}
65
66struct chip_operations mainboard_ops = {
67 .name = "storm",
68 .enable_dev = mainboard_enable,
69};