blob: 9580525102dab810e944a1af441209baa82e2653 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01002/*
Linus Walleijc15def12011-12-15 13:38:40 +01003 * Copyright (C) 2008-2009 ST-Ericsson SA
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01004 *
5 * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01006 */
7#include <linux/types.h>
8#include <linux/init.h>
9#include <linux/device.h>
10#include <linux/amba/bus.h>
Rabin Vincentaa90eb92011-02-08 09:24:37 +053011#include <linux/interrupt.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010012#include <linux/irq.h>
Arnd Bergmanna16729e2016-06-20 23:40:55 +020013#include <linux/irqchip.h>
14#include <linux/irqchip/arm-gic.h>
15#include <linux/mfd/dbx500-prcmu.h>
16#include <linux/platform_data/arm-ux500-pm.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010017#include <linux/platform_device.h>
Rabin Vincentcc2c1332010-03-01 05:03:31 +010018#include <linux/io.h>
Lee Jonesfa86a762012-09-27 10:17:36 +010019#include <linux/of.h>
Arnd Bergmanna16729e2016-06-20 23:40:55 +020020#include <linux/of_address.h>
Lee Jonesfa86a762012-09-27 10:17:36 +010021#include <linux/of_platform.h>
22#include <linux/regulator/machine.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010023
Arnd Bergmanna16729e2016-06-20 23:40:55 +020024#include <asm/outercache.h>
25#include <asm/hardware/cache-l2x0.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010026#include <asm/mach/map.h>
Arnd Bergmanna16729e2016-06-20 23:40:55 +020027#include <asm/mach/arch.h>
Linus Torvaldsb8edf842012-12-13 10:57:16 -080028
Lee Jones6f6d6432013-11-06 10:05:43 +000029#include "db8500-regs.h"
Ulf Hansson72ecd792017-10-06 06:20:25 +020030#include "pm_domains.h"
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010031
Arnd Bergmanna16729e2016-06-20 23:40:55 +020032static int __init ux500_l2x0_unlock(void)
33{
34 int i;
35 struct device_node *np;
36 void __iomem *l2x0_base;
37
38 np = of_find_compatible_node(NULL, NULL, "arm,pl310-cache");
39 l2x0_base = of_iomap(np, 0);
40 of_node_put(np);
41 if (!l2x0_base)
42 return -ENODEV;
43
44 /*
45 * Unlock Data and Instruction Lock if locked. Ux500 U-Boot versions
46 * apparently locks both caches before jumping to the kernel. The
47 * l2x0 core will not touch the unlock registers if the l2x0 is
48 * already enabled, so we do it right here instead. The PL310 has
49 * 8 sets of registers, one per possible CPU.
50 */
51 for (i = 0; i < 8; i++) {
52 writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE +
53 i * L2X0_LOCKDOWN_STRIDE);
54 writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE +
55 i * L2X0_LOCKDOWN_STRIDE);
56 }
57 iounmap(l2x0_base);
58 return 0;
59}
60
61static void ux500_l2c310_write_sec(unsigned long val, unsigned reg)
62{
63 /*
64 * We can't write to secure registers as we are in non-secure
65 * mode, until we have some SMI service available.
66 */
67}
68
69/*
70 * FIXME: Should we set up the GPIO domain here?
71 *
72 * The problem is that we cannot put the interrupt resources into the platform
73 * device until the irqdomain has been added. Right now, we set the GIC interrupt
74 * domain from init_irq(), then load the gpio driver from
75 * core_initcall(nmk_gpio_init) and add the platform devices from
76 * arch_initcall(customize_machine).
77 *
78 * This feels fragile because it depends on the gpio device getting probed
79 * _before_ any device uses the gpio interrupts.
80*/
81static void __init ux500_init_irq(void)
82{
83 struct device_node *np;
84 struct resource r;
85
86 irqchip_init();
87 np = of_find_compatible_node(NULL, NULL, "stericsson,db8500-prcmu");
88 of_address_to_resource(np, 0, &r);
89 of_node_put(np);
90 if (!r.start) {
91 pr_err("could not find PRCMU base resource\n");
92 return;
93 }
94 prcmu_early_init(r.start, r.end-r.start);
95 ux500_pm_init(r.start, r.end-r.start);
96
97 /* Unlock before init */
98 ux500_l2x0_unlock();
99 outer_cache.write_sec = ux500_l2c310_write_sec;
100}
101
102static void ux500_restart(enum reboot_mode mode, const char *cmd)
103{
104 local_irq_disable();
105 local_fiq_disable();
106
107 prcmu_system_reset(0);
108}
109
Lee Jonesfa86a762012-09-27 10:17:36 +0100110static const struct of_device_id u8500_local_bus_nodes[] = {
111 /* only create devices below soc node */
112 { .compatible = "stericsson,db8500", },
113 { .compatible = "stericsson,db8500-prcmu", },
114 { .compatible = "simple-bus"},
115 { },
116};
117
118static void __init u8500_init_machine(void)
119{
Ulf Hansson72ecd792017-10-06 06:20:25 +0200120 /* Initialize ux500 power domains */
121 ux500_pm_domains_init();
122
Linus Walleij40a6c002018-03-07 14:29:23 +0100123 of_platform_populate(NULL, u8500_local_bus_nodes,
124 NULL, NULL);
Lee Jonesfa86a762012-09-27 10:17:36 +0100125}
126
Lee Jones79b40752012-10-15 10:07:55 +0100127static const char * stericsson_dt_platform_compat[] = {
128 "st-ericsson,u8500",
Lee Jones79b40752012-10-15 10:07:55 +0100129 "st-ericsson,u9500",
Lee Jonesfa86a762012-09-27 10:17:36 +0100130 NULL,
131};
132
Lee Jones46c1bf82012-10-15 08:55:17 +0100133DT_MACHINE_START(U8500_DT, "ST-Ericsson Ux5x0 platform (Device Tree Support)")
Arnd Bergmann1e6cbc02016-06-20 22:27:23 +0200134 .l2c_aux_val = 0,
135 .l2c_aux_mask = ~0,
Lee Jonesfa86a762012-09-27 10:17:36 +0100136 .init_irq = ux500_init_irq,
Lee Jonesfa86a762012-09-27 10:17:36 +0100137 .init_machine = u8500_init_machine,
Lee Jones79b40752012-10-15 10:07:55 +0100138 .dt_compat = stericsson_dt_platform_compat,
Fabio Baltieribd93ec52013-06-14 15:22:40 +0200139 .restart = ux500_restart,
Lee Jonesfa86a762012-09-27 10:17:36 +0100140MACHINE_END