Merge patch series "scsi: libsas: Some coding style fixes and cleanups"
[linux-2.6-block.git] / arch / arm / mach-keystone / keystone.c
CommitLineData
75a6faf6 1// SPDX-License-Identifier: GPL-2.0-only
828989ad
SS
2/*
3 * Keystone2 based boards and SOC related code.
4 *
5 * Copyright 2013 Texas Instruments, Inc.
6 * Cyril Chemparathy <cyril@ti.com>
7 * Santosh Shilimkar <santosh.shillimkar@ti.com>
828989ad
SS
8 */
9#include <linux/io.h>
10#include <linux/of.h>
16fee29b 11#include <linux/dma-map-ops.h>
828989ad
SS
12#include <linux/init.h>
13#include <linux/of_platform.h>
14#include <linux/of_address.h>
bbea06f3 15#include <linux/memblock.h>
828989ad
SS
16
17#include <asm/setup.h>
18#include <asm/mach/map.h>
19#include <asm/mach/arch.h>
20#include <asm/mach/time.h>
5eb3da72
SS
21#include <asm/memory.h>
22
23#include "memory.h"
f07cb6a0
SS
24
25#include "keystone.h"
828989ad 26
cf141ae9 27#ifdef CONFIG_ARM_LPAE
14f37914
SS
28static int keystone_platform_notifier(struct notifier_block *nb,
29 unsigned long event, void *data)
30{
31 struct device *dev = data;
32
33 if (event != BUS_NOTIFY_ADD_DEVICE)
34 return NOTIFY_DONE;
35
36 if (!dev)
37 return NOTIFY_BAD;
38
39 if (!dev->of_node) {
e0d07278
JQ
40 int ret = dma_direct_set_offset(dev, KEYSTONE_HIGH_PHYS_START,
41 KEYSTONE_LOW_PHYS_START,
42 KEYSTONE_HIGH_PHYS_SIZE);
43 dev_err(dev, "set dma_offset%08llx%s\n",
44 KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START,
45 ret ? " failed" : "");
14f37914
SS
46 }
47 return NOTIFY_OK;
48}
828989ad 49
30b5f4d6
RK
50static struct notifier_block platform_nb = {
51 .notifier_call = keystone_platform_notifier,
52};
cf141ae9 53#endif /* CONFIG_ARM_LPAE */
30b5f4d6 54
828989ad
SS
55static void __init keystone_init(void)
56{
cf141ae9 57#ifdef CONFIG_ARM_LPAE
e0d07278 58 if (PHYS_OFFSET >= KEYSTONE_HIGH_PHYS_START)
14f37914 59 bus_register_notifier(&platform_bus_type, &platform_nb);
cf141ae9 60#endif
30b5f4d6 61 keystone_pm_runtime_init();
828989ad
SS
62}
63
c0b759d8 64static long long __init keystone_pv_fixup(void)
5eb3da72 65{
c8ca2b4b 66 long long offset;
844b85dd 67 u64 mem_start, mem_end;
5eb3da72 68
bbea06f3
SS
69 mem_start = memblock_start_of_DRAM();
70 mem_end = memblock_end_of_DRAM();
5eb3da72
SS
71
72 /* nothing to do if we are running out of the <32-bit space */
73 if (mem_start >= KEYSTONE_LOW_PHYS_START &&
74 mem_end <= KEYSTONE_LOW_PHYS_END)
c8ca2b4b 75 return 0;
5eb3da72
SS
76
77 if (mem_start < KEYSTONE_HIGH_PHYS_START ||
78 mem_end > KEYSTONE_HIGH_PHYS_END) {
79 pr_crit("Invalid address space for memory (%08llx-%08llx)\n",
844b85dd 80 mem_start, mem_end);
c8ca2b4b 81 return 0;
5eb3da72
SS
82 }
83
c8ca2b4b 84 offset = KEYSTONE_HIGH_PHYS_START - KEYSTONE_LOW_PHYS_START;
5eb3da72
SS
85
86 /* Populate the arch idmap hook */
981b6714 87 arch_phys_to_idmap_offset = -offset;
5eb3da72 88
c8ca2b4b 89 return offset;
5eb3da72
SS
90}
91
543c5040 92static const char *const keystone_match[] __initconst = {
01cf228b
NM
93 "ti,k2hk",
94 "ti,k2e",
95 "ti,k2l",
3b2d3dc9 96 "ti,k2g",
3babe306 97 "ti,keystone",
828989ad
SS
98 NULL,
99};
100
828989ad 101DT_MACHINE_START(KEYSTONE, "Keystone")
df595a9d
SS
102#if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
103 .dma_zone_size = SZ_2G,
104#endif
828989ad
SS
105 .init_machine = keystone_init,
106 .dt_compat = keystone_match,
c0b759d8 107 .pv_fixup = keystone_pv_fixup,
828989ad 108MACHINE_END