2 * Keystone2 based boards and SOC related code.
4 * Copyright 2013 Texas Instruments, Inc.
5 * Cyril Chemparathy <cyril@ti.com>
6 * Santosh Shilimkar <santosh.shillimkar@ti.com>
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.
14 #include <linux/init.h>
15 #include <linux/of_platform.h>
16 #include <linux/of_address.h>
18 #include <asm/setup.h>
19 #include <asm/mach/map.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach/time.h>
22 #include <asm/smp_plat.h>
23 #include <asm/memory.h>
29 #define PLL_RESET_WRITE_KEY_MASK 0xffff0000
30 #define PLL_RESET_WRITE_KEY 0x5a69
31 #define PLL_RESET BIT(16)
33 static void __iomem
*keystone_rstctrl
;
35 static void __init
keystone_init(void)
37 struct device_node
*node
;
39 node
= of_find_compatible_node(NULL
, NULL
, "ti,keystone-reset");
41 pr_warn("ti,keystone-reset node undefined\n");
43 keystone_rstctrl
= of_iomap(node
, 0);
44 if (WARN_ON(!keystone_rstctrl
))
45 pr_warn("ti,keystone-reset iomap error\n");
47 keystone_pm_runtime_init();
48 of_platform_populate(NULL
, of_default_bus_match_table
, NULL
, NULL
);
51 static phys_addr_t
keystone_virt_to_idmap(unsigned long x
)
53 return (phys_addr_t
)(x
) - CONFIG_PAGE_OFFSET
+ KEYSTONE_LOW_PHYS_START
;
56 static void __init
keystone_init_meminfo(void)
58 bool lpae
= IS_ENABLED(CONFIG_ARM_LPAE
);
59 bool pvpatch
= IS_ENABLED(CONFIG_ARM_PATCH_PHYS_VIRT
);
60 phys_addr_t offset
= PHYS_OFFSET
- KEYSTONE_LOW_PHYS_START
;
61 phys_addr_t mem_start
, mem_end
;
63 BUG_ON(meminfo
.nr_banks
< 1);
64 mem_start
= meminfo
.bank
[0].start
;
65 mem_end
= mem_start
+ meminfo
.bank
[0].size
- 1;
67 /* nothing to do if we are running out of the <32-bit space */
68 if (mem_start
>= KEYSTONE_LOW_PHYS_START
&&
69 mem_end
<= KEYSTONE_LOW_PHYS_END
)
72 if (!lpae
|| !pvpatch
) {
73 pr_crit("Enable %s%s%s to run outside 32-bit space\n",
74 !lpae
? __stringify(CONFIG_ARM_LPAE
) : "",
75 (!lpae
&& !pvpatch
) ? " and " : "",
76 !pvpatch
? __stringify(CONFIG_ARM_PATCH_PHYS_VIRT
) : "");
79 if (mem_start
< KEYSTONE_HIGH_PHYS_START
||
80 mem_end
> KEYSTONE_HIGH_PHYS_END
) {
81 pr_crit("Invalid address space for memory (%08llx-%08llx)\n",
82 (u64
)mem_start
, (u64
)mem_end
);
85 offset
+= KEYSTONE_HIGH_PHYS_START
;
86 __pv_phys_pfn_offset
= PFN_DOWN(offset
);
87 __pv_offset
= (offset
- PAGE_OFFSET
);
89 /* Populate the arch idmap hook */
90 arch_virt_to_idmap
= keystone_virt_to_idmap
;
92 pr_info("Switching to high address space at 0x%llx\n", (u64
)offset
);
95 static const char *keystone_match
[] __initconst
= {
100 void keystone_restart(enum reboot_mode mode
, const char *cmd
)
104 BUG_ON(!keystone_rstctrl
);
106 /* Enable write access to RSTCTRL */
107 val
= readl(keystone_rstctrl
);
108 val
&= PLL_RESET_WRITE_KEY_MASK
;
109 val
|= PLL_RESET_WRITE_KEY
;
110 writel(val
, keystone_rstctrl
);
113 val
= readl(keystone_rstctrl
);
115 writel(val
, keystone_rstctrl
);
118 DT_MACHINE_START(KEYSTONE
, "Keystone")
119 #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
120 .dma_zone_size
= SZ_2G
,
122 .smp
= smp_ops(keystone_smp_ops
),
123 .init_machine
= keystone_init
,
124 .dt_compat
= keystone_match
,
125 .restart
= keystone_restart
,
126 .init_meminfo
= keystone_init_meminfo
,