blob: 84613abf35a3371b988655ce3aea6f0457b95598 [file] [log] [blame]
Santosh Shilimkar828989a2013-06-10 11:27:13 -04001/*
2 * Keystone2 based boards and SOC related code.
3 *
4 * Copyright 2013 Texas Instruments, Inc.
5 * Cyril Chemparathy <cyril@ti.com>
6 * Santosh Shilimkar <santosh.shillimkar@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 */
12#include <linux/io.h>
13#include <linux/of.h>
14#include <linux/init.h>
15#include <linux/of_platform.h>
16#include <linux/of_address.h>
Santosh Shilimkarbbea06f2014-06-05 15:22:52 -040017#include <linux/memblock.h>
Santosh Shilimkar828989a2013-06-10 11:27:13 -040018
19#include <asm/setup.h>
20#include <asm/mach/map.h>
21#include <asm/mach/arch.h>
22#include <asm/mach/time.h>
Santosh Shilimkarf07cb6a2013-06-10 12:20:17 -040023#include <asm/smp_plat.h>
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040024#include <asm/memory.h>
25
26#include "memory.h"
Santosh Shilimkarf07cb6a2013-06-10 12:20:17 -040027
28#include "keystone.h"
Santosh Shilimkar828989a2013-06-10 11:27:13 -040029
Santosh Shilimkar14f37912014-02-24 17:32:59 +020030static unsigned long keystone_dma_pfn_offset __read_mostly;
31
32static int keystone_platform_notifier(struct notifier_block *nb,
33 unsigned long event, void *data)
34{
35 struct device *dev = data;
36
37 if (event != BUS_NOTIFY_ADD_DEVICE)
38 return NOTIFY_DONE;
39
40 if (!dev)
41 return NOTIFY_BAD;
42
43 if (!dev->of_node) {
44 dev->dma_pfn_offset = keystone_dma_pfn_offset;
45 dev_err(dev, "set dma_pfn_offset%08lx\n",
46 dev->dma_pfn_offset);
47 }
48 return NOTIFY_OK;
49}
Santosh Shilimkar828989a2013-06-10 11:27:13 -040050
Russell King30b5f4d2015-04-04 11:30:04 +010051static struct notifier_block platform_nb = {
52 .notifier_call = keystone_platform_notifier,
53};
54
Santosh Shilimkar828989a2013-06-10 11:27:13 -040055static void __init keystone_init(void)
56{
Russell King30b5f4d2015-04-04 11:30:04 +010057 if (PHYS_OFFSET >= KEYSTONE_HIGH_PHYS_START) {
58 keystone_dma_pfn_offset = PFN_DOWN(KEYSTONE_HIGH_PHYS_START -
59 KEYSTONE_LOW_PHYS_START);
Santosh Shilimkar14f37912014-02-24 17:32:59 +020060 bus_register_notifier(&platform_bus_type, &platform_nb);
Russell King30b5f4d2015-04-04 11:30:04 +010061 }
62 keystone_pm_runtime_init();
Santosh Shilimkar828989a2013-06-10 11:27:13 -040063}
64
Russell Kingc0b759d2015-04-04 10:01:10 +010065static long long __init keystone_pv_fixup(void)
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040066{
Russell Kingc8ca2b42015-04-04 09:53:38 +010067 long long offset;
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040068 phys_addr_t mem_start, mem_end;
69
Santosh Shilimkarbbea06f2014-06-05 15:22:52 -040070 mem_start = memblock_start_of_DRAM();
71 mem_end = memblock_end_of_DRAM();
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040072
73 /* nothing to do if we are running out of the <32-bit space */
74 if (mem_start >= KEYSTONE_LOW_PHYS_START &&
75 mem_end <= KEYSTONE_LOW_PHYS_END)
Russell Kingc8ca2b42015-04-04 09:53:38 +010076 return 0;
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040077
78 if (mem_start < KEYSTONE_HIGH_PHYS_START ||
79 mem_end > KEYSTONE_HIGH_PHYS_END) {
80 pr_crit("Invalid address space for memory (%08llx-%08llx)\n",
Russell Kingc8ca2b42015-04-04 09:53:38 +010081 (u64)mem_start, (u64)mem_end);
82 return 0;
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040083 }
84
Russell Kingc8ca2b42015-04-04 09:53:38 +010085 offset = KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START;
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040086
87 /* Populate the arch idmap hook */
Russell King981b6712016-03-15 14:55:03 +000088 arch_phys_to_idmap_offset = -offset;
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040089
Russell Kingc8ca2b42015-04-04 09:53:38 +010090 return offset;
Santosh Shilimkar5eb3da72013-06-13 19:24:39 -040091}
92
Uwe Kleine-König543c5042015-02-18 21:01:45 +010093static const char *const keystone_match[] __initconst = {
Nishanth Menon01cf2282015-10-03 17:02:56 -070094 "ti,k2hk",
95 "ti,k2e",
96 "ti,k2l",
Nishanth Menon3b2d3dc2016-02-05 10:37:17 -080097 "ti,k2g",
Ivan Khoronzhuk3babe302014-03-20 17:00:27 -040098 "ti,keystone",
Santosh Shilimkar828989a2013-06-10 11:27:13 -040099 NULL,
100};
101
Santosh Shilimkar828989a2013-06-10 11:27:13 -0400102DT_MACHINE_START(KEYSTONE, "Keystone")
Santosh Shilimkardf595a92013-11-23 16:58:03 -0500103#if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
104 .dma_zone_size = SZ_2G,
105#endif
Santosh Shilimkarf07cb6a2013-06-10 12:20:17 -0400106 .smp = smp_ops(keystone_smp_ops),
Santosh Shilimkar828989a2013-06-10 11:27:13 -0400107 .init_machine = keystone_init,
108 .dt_compat = keystone_match,
Russell Kingc0b759d2015-04-04 10:01:10 +0100109 .pv_fixup = keystone_pv_fixup,
Santosh Shilimkar828989a2013-06-10 11:27:13 -0400110MACHINE_END