Commit | Line | Data |
---|---|---|
828989ad SS |
1 | /* |
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> | |
bbea06f3 | 17 | #include <linux/memblock.h> |
828989ad SS |
18 | |
19 | #include <asm/setup.h> | |
20 | #include <asm/mach/map.h> | |
21 | #include <asm/mach/arch.h> | |
22 | #include <asm/mach/time.h> | |
f07cb6a0 | 23 | #include <asm/smp_plat.h> |
5eb3da72 SS |
24 | #include <asm/memory.h> |
25 | ||
26 | #include "memory.h" | |
f07cb6a0 SS |
27 | |
28 | #include "keystone.h" | |
828989ad | 29 | |
14f37914 SS |
30 | static unsigned long keystone_dma_pfn_offset __read_mostly; |
31 | ||
32 | static 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 | } | |
828989ad | 50 | |
30b5f4d6 RK |
51 | static struct notifier_block platform_nb = { |
52 | .notifier_call = keystone_platform_notifier, | |
53 | }; | |
54 | ||
828989ad SS |
55 | static void __init keystone_init(void) |
56 | { | |
30b5f4d6 RK |
57 | if (PHYS_OFFSET >= KEYSTONE_HIGH_PHYS_START) { |
58 | keystone_dma_pfn_offset = PFN_DOWN(KEYSTONE_HIGH_PHYS_START - | |
59 | KEYSTONE_LOW_PHYS_START); | |
14f37914 | 60 | bus_register_notifier(&platform_bus_type, &platform_nb); |
30b5f4d6 RK |
61 | } |
62 | keystone_pm_runtime_init(); | |
828989ad SS |
63 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
64 | } | |
65 | ||
c0b759d8 | 66 | static long long __init keystone_pv_fixup(void) |
5eb3da72 | 67 | { |
c8ca2b4b | 68 | long long offset; |
5eb3da72 SS |
69 | phys_addr_t mem_start, mem_end; |
70 | ||
bbea06f3 SS |
71 | mem_start = memblock_start_of_DRAM(); |
72 | mem_end = memblock_end_of_DRAM(); | |
5eb3da72 SS |
73 | |
74 | /* nothing to do if we are running out of the <32-bit space */ | |
75 | if (mem_start >= KEYSTONE_LOW_PHYS_START && | |
76 | mem_end <= KEYSTONE_LOW_PHYS_END) | |
c8ca2b4b | 77 | return 0; |
5eb3da72 SS |
78 | |
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", | |
c8ca2b4b RK |
82 | (u64)mem_start, (u64)mem_end); |
83 | return 0; | |
5eb3da72 SS |
84 | } |
85 | ||
c8ca2b4b | 86 | offset = KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START; |
5eb3da72 SS |
87 | |
88 | /* Populate the arch idmap hook */ | |
981b6714 | 89 | arch_phys_to_idmap_offset = -offset; |
5eb3da72 | 90 | |
c8ca2b4b | 91 | return offset; |
5eb3da72 SS |
92 | } |
93 | ||
543c5040 | 94 | static const char *const keystone_match[] __initconst = { |
01cf228b NM |
95 | "ti,k2hk", |
96 | "ti,k2e", | |
97 | "ti,k2l", | |
3b2d3dc9 | 98 | "ti,k2g", |
3babe306 | 99 | "ti,keystone", |
828989ad SS |
100 | NULL, |
101 | }; | |
102 | ||
828989ad | 103 | DT_MACHINE_START(KEYSTONE, "Keystone") |
df595a9d SS |
104 | #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE) |
105 | .dma_zone_size = SZ_2G, | |
106 | #endif | |
f07cb6a0 | 107 | .smp = smp_ops(keystone_smp_ops), |
828989ad SS |
108 | .init_machine = keystone_init, |
109 | .dt_compat = keystone_match, | |
c0b759d8 | 110 | .pv_fixup = keystone_pv_fixup, |
828989ad | 111 | MACHINE_END |