xref: /openbmc/linux/arch/arm/mach-ux500/cpu-db8500.c (revision fa8ad788)
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>
193a8e39c9SLee Jones #include <linux/mfd/abx500/ab8500.h>
20661c6af0SLee Jones #include <linux/mfd/dbx500-prcmu.h>
21fa86a764SLee Jones #include <linux/of.h>
22fa86a764SLee Jones #include <linux/of_platform.h>
23fa8ad788SMark Rutland #include <linux/perf/arm_pmu.h>
24fa86a764SLee Jones #include <linux/regulator/machine.h>
254040d10aSLinus Walleij #include <linux/random.h>
26cb165c52SRabin Vincent 
27cb165c52SRabin Vincent #include <asm/mach/map.h>
28b8edf848SLinus Torvalds 
29e657bcf6SArnd Bergmann #include "setup.h"
30cb165c52SRabin Vincent 
316f6d6433SLee Jones #include "board-mop500-regulators.h"
32fa86a764SLee Jones #include "board-mop500.h"
336f6d6433SLee Jones #include "db8500-regs.h"
347a4f2609SLinus Walleij #include "id.h"
35fbf1eadfSRabin Vincent 
360d01ab3aSSachin Kamat static struct ab8500_platform_data ab8500_platdata = {
376f6d6433SLee Jones 	.regulator	= &ab8500_regulator_plat_data,
386f6d6433SLee Jones };
396f6d6433SLee Jones 
400d01ab3aSSachin Kamat static struct prcmu_pdata db8500_prcmu_pdata = {
416f6d6433SLee Jones 	.ab_platdata	= &ab8500_platdata,
426f6d6433SLee Jones 	.version_offset	= DB8500_PRCMU_FW_VERSION_OFFSET,
436f6d6433SLee Jones 	.legacy_offset	= DB8500_PRCMU_LEGACY_OFFSET,
446f6d6433SLee Jones };
456f6d6433SLee Jones 
460d01ab3aSSachin Kamat static void __init u8500_map_io(void)
47cb165c52SRabin Vincent {
48951b833eSLinus Walleij 	debug_ll_io_init();
499bac89e0SLinus Walleij 	ux500_setup_id();
50cb165c52SRabin Vincent }
51cb165c52SRabin Vincent 
52aa90eb9dSRabin Vincent /*
53aa90eb9dSRabin Vincent  * The PMU IRQ lines of two cores are wired together into a single interrupt.
54aa90eb9dSRabin Vincent  * Bounce the interrupt to the other core if it's not ours.
55aa90eb9dSRabin Vincent  */
56aa90eb9dSRabin Vincent static irqreturn_t db8500_pmu_handler(int irq, void *dev, irq_handler_t handler)
57aa90eb9dSRabin Vincent {
58aa90eb9dSRabin Vincent 	irqreturn_t ret = handler(irq, dev);
59aa90eb9dSRabin Vincent 	int other = !smp_processor_id();
60aa90eb9dSRabin Vincent 
61aa90eb9dSRabin Vincent 	if (ret == IRQ_NONE && cpu_online(other))
62aa90eb9dSRabin Vincent 		irq_set_affinity(irq, cpumask_of(other));
63aa90eb9dSRabin Vincent 
64aa90eb9dSRabin Vincent 	/*
65aa90eb9dSRabin Vincent 	 * We should be able to get away with the amount of IRQ_NONEs we give,
66aa90eb9dSRabin Vincent 	 * while still having the spurious IRQ detection code kick in if the
67aa90eb9dSRabin Vincent 	 * interrupt really starts hitting spuriously.
68aa90eb9dSRabin Vincent 	 */
69aa90eb9dSRabin Vincent 	return ret;
70aa90eb9dSRabin Vincent }
71aa90eb9dSRabin Vincent 
720d01ab3aSSachin Kamat static struct arm_pmu_platdata db8500_pmu_platdata = {
73aa90eb9dSRabin Vincent 	.handle_irq		= db8500_pmu_handler,
74aa90eb9dSRabin Vincent };
75aa90eb9dSRabin Vincent 
76eda413c2SLee Jones static const char *db8500_read_soc_id(void)
77eda413c2SLee Jones {
7880757f23SLinus Walleij 	void __iomem *uid;
79eda413c2SLee Jones 
8080757f23SLinus Walleij 	uid = ioremap(U8500_BB_UID_BASE, 0x20);
8180757f23SLinus Walleij 	if (!uid)
8280757f23SLinus Walleij 		return NULL;
834040d10aSLinus Walleij 	/* Throw these device-specific numbers into the entropy pool */
844040d10aSLinus Walleij 	add_device_randomness(uid, 0x14);
85eda413c2SLee Jones 	return kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x",
8633c8abceSFabio Baltieri 			 readl((u32 *)uid+0),
87eda413c2SLee Jones 			 readl((u32 *)uid+1), readl((u32 *)uid+2),
88eda413c2SLee Jones 			 readl((u32 *)uid+3), readl((u32 *)uid+4));
8980757f23SLinus Walleij 	iounmap(uid);
90eda413c2SLee Jones }
91eda413c2SLee Jones 
92eda413c2SLee Jones static struct device * __init db8500_soc_device_init(void)
93eda413c2SLee Jones {
94eda413c2SLee Jones 	const char *soc_id = db8500_read_soc_id();
95eda413c2SLee Jones 
96eda413c2SLee Jones 	return ux500_soc_device_init(soc_id);
97eda413c2SLee Jones }
98eda413c2SLee Jones 
99fa86a764SLee Jones static struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
100fa86a764SLee Jones 	/* Requires call-back bindings. */
101fa86a764SLee Jones 	OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata),
102cece5c40SLee Jones 	/* Requires DMA bindings. */
103acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80123000,
104acab2f6fSLee Jones 		       "ux500-msp-i2s.0", &msp0_platform_data),
105acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80124000,
106acab2f6fSLee Jones 		       "ux500-msp-i2s.1", &msp1_platform_data),
107acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80117000,
108acab2f6fSLee Jones 		       "ux500-msp-i2s.2", &msp2_platform_data),
109acab2f6fSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-msp-i2s", 0x80125000,
110acab2f6fSLee Jones 		       "ux500-msp-i2s.3", &msp3_platform_data),
1111b1d2e83SLee Jones 	/* Requires non-DT:able platform data. */
11205ec260eSLinus Walleij 	OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu",
11305ec260eSLinus Walleij 			&db8500_prcmu_pdata),
114946cc7ddSLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-cryp", 0xa03cb000, "cryp1", NULL),
115f016d440SLee Jones 	OF_DEV_AUXDATA("stericsson,ux500-hash", 0xa03c2000, "hash1", NULL),
116ef95f7ffSFabio Baltieri 	OF_DEV_AUXDATA("stericsson,snd-soc-mop500", 0, "snd-soc-mop500.0",
117ef95f7ffSFabio Baltieri 			NULL),
118fa86a764SLee Jones 	{},
119fa86a764SLee Jones };
120fa86a764SLee Jones 
121c21a43b7SLee Jones static struct of_dev_auxdata u8540_auxdata_lookup[] __initdata = {
122c21a43b7SLee Jones 	OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu",
123c21a43b7SLee Jones 			&db8500_prcmu_pdata),
124c21a43b7SLee Jones 	{},
125c21a43b7SLee Jones };
126c21a43b7SLee Jones 
127fa86a764SLee Jones static const struct of_device_id u8500_local_bus_nodes[] = {
128fa86a764SLee Jones 	/* only create devices below soc node */
129fa86a764SLee Jones 	{ .compatible = "stericsson,db8500", },
130fa86a764SLee Jones 	{ .compatible = "stericsson,db8500-prcmu", },
131fa86a764SLee Jones 	{ .compatible = "simple-bus"},
132fa86a764SLee Jones 	{ },
133fa86a764SLee Jones };
134fa86a764SLee Jones 
135fa86a764SLee Jones static void __init u8500_init_machine(void)
136fa86a764SLee Jones {
1371e74043aSLee Jones 	struct device *parent = db8500_soc_device_init();
138fa86a764SLee Jones 
139c21a43b7SLee Jones 	/* automatically probe child nodes of dbx5x0 devices */
140c21a43b7SLee Jones 	if (of_machine_is_compatible("st-ericsson,u8540"))
141c21a43b7SLee Jones 		of_platform_populate(NULL, u8500_local_bus_nodes,
142c21a43b7SLee Jones 				     u8540_auxdata_lookup, parent);
143c21a43b7SLee Jones 	else
144c21a43b7SLee Jones 		of_platform_populate(NULL, u8500_local_bus_nodes,
145c21a43b7SLee Jones 				     u8500_auxdata_lookup, parent);
146fa86a764SLee Jones }
147fa86a764SLee Jones 
14879b40753SLee Jones static const char * stericsson_dt_platform_compat[] = {
14979b40753SLee Jones 	"st-ericsson,u8500",
15079b40753SLee Jones 	"st-ericsson,u8540",
15179b40753SLee Jones 	"st-ericsson,u9500",
15279b40753SLee Jones 	"st-ericsson,u9540",
153fa86a764SLee Jones 	NULL,
154fa86a764SLee Jones };
155fa86a764SLee Jones 
15646c1bf81SLee Jones DT_MACHINE_START(U8500_DT, "ST-Ericsson Ux5x0 platform (Device Tree Support)")
157f44c5fd1SLee Jones 	.smp            = smp_ops(ux500_smp_ops),
158fa86a764SLee Jones 	.map_io		= u8500_map_io,
159fa86a764SLee Jones 	.init_irq	= ux500_init_irq,
160fa86a764SLee Jones 	/* we re-use nomadik timer here */
1616bb27d73SStephen Warren 	.init_time	= ux500_timer_init,
162fa86a764SLee Jones 	.init_machine	= u8500_init_machine,
16374a1c9abSLee Jones 	.init_late	= NULL,
16479b40753SLee Jones 	.dt_compat      = stericsson_dt_platform_compat,
165bd93ec50SFabio Baltieri 	.restart        = ux500_restart,
166fa86a764SLee Jones MACHINE_END
167