xref: /openbmc/linux/arch/arm/mach-ux500/cpu-db8500.c (revision 18a99278)
1cb165c52SRabin Vincent /*
2c15def1cSLinus Walleij  * Copyright (C) 2008-2009 ST-Ericsson SA
3cb165c52SRabin Vincent  *
4cb165c52SRabin Vincent  * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
5cb165c52SRabin Vincent  *
6cb165c52SRabin Vincent  * This program is free software; you can redistribute it and/or modify
7cb165c52SRabin Vincent  * it under the terms of the GNU General Public License version 2, as
8cb165c52SRabin Vincent  * published by the Free Software Foundation.
9cb165c52SRabin Vincent  *
10cb165c52SRabin Vincent  */
11cb165c52SRabin Vincent #include <linux/types.h>
12cb165c52SRabin Vincent #include <linux/init.h>
13cb165c52SRabin Vincent #include <linux/device.h>
14cb165c52SRabin Vincent #include <linux/amba/bus.h>
15aa90eb9dSRabin Vincent #include <linux/interrupt.h>
16cb165c52SRabin Vincent #include <linux/irq.h>
17cb165c52SRabin Vincent #include <linux/platform_device.h>
18cb165c52SRabin Vincent #include <linux/io.h>
19fa86a764SLee Jones #include <linux/of.h>
20fa86a764SLee Jones #include <linux/of_platform.h>
21fa8ad788SMark Rutland #include <linux/perf/arm_pmu.h>
22fa86a764SLee Jones #include <linux/regulator/machine.h>
23cb165c52SRabin Vincent 
24cb165c52SRabin Vincent #include <asm/mach/map.h>
25b8edf848SLinus Torvalds 
26e657bcf6SArnd Bergmann #include "setup.h"
27cb165c52SRabin Vincent 
28fa86a764SLee Jones #include "board-mop500.h"
296f6d6433SLee Jones #include "db8500-regs.h"
30cb165c52SRabin Vincent 
31aa90eb9dSRabin Vincent /*
32aa90eb9dSRabin Vincent  * The PMU IRQ lines of two cores are wired together into a single interrupt.
33aa90eb9dSRabin Vincent  * Bounce the interrupt to the other core if it's not ours.
34aa90eb9dSRabin Vincent  */
35aa90eb9dSRabin Vincent static irqreturn_t db8500_pmu_handler(int irq, void *dev, irq_handler_t handler)
36aa90eb9dSRabin Vincent {
37aa90eb9dSRabin Vincent 	irqreturn_t ret = handler(irq, dev);
38aa90eb9dSRabin Vincent 	int other = !smp_processor_id();
39aa90eb9dSRabin Vincent 
40aa90eb9dSRabin Vincent 	if (ret == IRQ_NONE && cpu_online(other))
41aa90eb9dSRabin Vincent 		irq_set_affinity(irq, cpumask_of(other));
42aa90eb9dSRabin Vincent 
43aa90eb9dSRabin Vincent 	/*
44aa90eb9dSRabin Vincent 	 * We should be able to get away with the amount of IRQ_NONEs we give,
45aa90eb9dSRabin Vincent 	 * while still having the spurious IRQ detection code kick in if the
46aa90eb9dSRabin Vincent 	 * interrupt really starts hitting spuriously.
47aa90eb9dSRabin Vincent 	 */
48aa90eb9dSRabin Vincent 	return ret;
49aa90eb9dSRabin Vincent }
50aa90eb9dSRabin Vincent 
510d01ab3aSSachin Kamat static struct arm_pmu_platdata db8500_pmu_platdata = {
52aa90eb9dSRabin Vincent 	.handle_irq		= db8500_pmu_handler,
53aa90eb9dSRabin Vincent };
54aa90eb9dSRabin Vincent 
55fa86a764SLee Jones static struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
56fa86a764SLee Jones 	/* Requires call-back bindings. */
57fa86a764SLee Jones 	OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata),
58cece5c40SLee Jones 	/* Requires DMA bindings. */
59acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80123000,
60acab2f6fSLee Jones 		       "ux500-msp-i2s.0", &msp0_platform_data),
61acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80124000,
62acab2f6fSLee Jones 		       "ux500-msp-i2s.1", &msp1_platform_data),
63acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80117000,
64acab2f6fSLee Jones 		       "ux500-msp-i2s.2", &msp2_platform_data),
65acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80125000,
66acab2f6fSLee Jones 		       "ux500-msp-i2s.3", &msp3_platform_data),
671b1d2e83SLee Jones 	/* Requires non-DT:able platform data. */
684e657946SArnd Bergmann 	OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu", NULL),
69946cc7ddSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-cryp", 0xa03cb000, "cryp1", NULL),
70f016d440SLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-hash", 0xa03c2000, "hash1", NULL),
71ef95f7ffSFabio Baltieri 	OF_DEV_AUXDATA("stericsson,snd-soc-mop500", 0, "snd-soc-mop500.0",
72ef95f7ffSFabio Baltieri 			NULL),
73fa86a764SLee Jones 	{},
74fa86a764SLee Jones };
75fa86a764SLee Jones 
76c21a43b7SLee Jones static struct of_dev_auxdata u8540_auxdata_lookup[] __initdata = {
774e657946SArnd Bergmann 	OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu", NULL),
78c21a43b7SLee Jones 	{},
79c21a43b7SLee Jones };
80c21a43b7SLee Jones 
81fa86a764SLee Jones static const struct of_device_id u8500_local_bus_nodes[] = {
82fa86a764SLee Jones 	/* only create devices below soc node */
83fa86a764SLee Jones 	{ .compatible = "stericsson,db8500", },
84fa86a764SLee Jones 	{ .compatible = "stericsson,db8500-prcmu", },
85fa86a764SLee Jones 	{ .compatible = "simple-bus"},
86fa86a764SLee Jones 	{ },
87fa86a764SLee Jones };
88fa86a764SLee Jones 
89fa86a764SLee Jones static void __init u8500_init_machine(void)
90fa86a764SLee Jones {
91c21a43b7SLee Jones 	/* automatically probe child nodes of dbx5x0 devices */
92c21a43b7SLee Jones 	if (of_machine_is_compatible("st-ericsson,u8540"))
93c21a43b7SLee Jones 		of_platform_populate(NULL, u8500_local_bus_nodes,
9418a99278SArnd Bergmann 				     u8540_auxdata_lookup, NULL);
95c21a43b7SLee Jones 	else
96c21a43b7SLee Jones 		of_platform_populate(NULL, u8500_local_bus_nodes,
9718a99278SArnd Bergmann 				     u8500_auxdata_lookup, NULL);
98fa86a764SLee Jones }
99fa86a764SLee Jones 
10079b40753SLee Jones static const char * stericsson_dt_platform_compat[] = {
10179b40753SLee Jones 	"st-ericsson,u8500",
10279b40753SLee Jones 	"st-ericsson,u8540",
10379b40753SLee Jones 	"st-ericsson,u9500",
10479b40753SLee Jones 	"st-ericsson,u9540",
105fa86a764SLee Jones 	NULL,
106fa86a764SLee Jones };
107fa86a764SLee Jones 
10846c1bf81SLee Jones DT_MACHINE_START(U8500_DT, "ST-Ericsson Ux5x0 platform (Device Tree Support)")
1091e6cbc06SArnd Bergmann 	.l2c_aux_val    = 0,
1101e6cbc06SArnd Bergmann 	.l2c_aux_mask	= ~0,
111fa86a764SLee Jones 	.init_irq	= ux500_init_irq,
112fa86a764SLee Jones 	.init_machine	= u8500_init_machine,
11379b40753SLee Jones 	.dt_compat      = stericsson_dt_platform_compat,
114bd93ec50SFabio Baltieri 	.restart        = ux500_restart,
115fa86a764SLee Jones MACHINE_END
116