Skip to content

Commit 7aa3d7c

Browse files
author
Samuel Ortiz
committed
Merge tag 'ux500-multiplatform-mfd' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson
MFD portions of the ux500 multiplatform branch. A second tag for the ARM SoC tree will build upon this one. This mainly removes the header file dependencies from the PRCMU driver in the MFD subsystem, and moves the PM functions to the machine. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2 parents 8059c1c + 55b175d commit 7aa3d7c

14 files changed

Lines changed: 454 additions & 417 deletions

File tree

‎arch/arm/mach-ux500/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
obj-y := cpu.o devices.o devices-common.o \
6-
id.o usb.o timer.o
6+
id.o usb.o timer.o pm.o
77
obj-$(CONFIG_CPU_IDLE) += cpuidle.o
88
obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o
99
obj-$(CONFIG_UX500_SOC_DB8500) += cpu-db8500.o devices-db8500.o

‎arch/arm/mach-ux500/board-mop500.c‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -206,63 +206,6 @@ struct ab8500_platform_data ab8500_platdata = {
206206
.codec = &ab8500_codec_pdata,
207207
};
208208

209-
/*
210-
* Thermal Sensor
211-
*/
212-
213-
static struct resource db8500_thsens_resources[] = {
214-
{
215-
.name = "IRQ_HOTMON_LOW",
216-
.start = IRQ_PRCMU_HOTMON_LOW,
217-
.end = IRQ_PRCMU_HOTMON_LOW,
218-
.flags = IORESOURCE_IRQ,
219-
},
220-
{
221-
.name = "IRQ_HOTMON_HIGH",
222-
.start = IRQ_PRCMU_HOTMON_HIGH,
223-
.end = IRQ_PRCMU_HOTMON_HIGH,
224-
.flags = IORESOURCE_IRQ,
225-
},
226-
};
227-
228-
static struct db8500_thsens_platform_data db8500_thsens_data = {
229-
.trip_points[0] = {
230-
.temp = 70000,
231-
.type = THERMAL_TRIP_ACTIVE,
232-
.cdev_name = {
233-
[0] = "thermal-cpufreq-0",
234-
},
235-
},
236-
.trip_points[1] = {
237-
.temp = 75000,
238-
.type = THERMAL_TRIP_ACTIVE,
239-
.cdev_name = {
240-
[0] = "thermal-cpufreq-0",
241-
},
242-
},
243-
.trip_points[2] = {
244-
.temp = 80000,
245-
.type = THERMAL_TRIP_ACTIVE,
246-
.cdev_name = {
247-
[0] = "thermal-cpufreq-0",
248-
},
249-
},
250-
.trip_points[3] = {
251-
.temp = 85000,
252-
.type = THERMAL_TRIP_CRITICAL,
253-
},
254-
.num_trips = 4,
255-
};
256-
257-
static struct platform_device u8500_thsens_device = {
258-
.name = "db8500-thermal",
259-
.resource = db8500_thsens_resources,
260-
.num_resources = ARRAY_SIZE(db8500_thsens_resources),
261-
.dev = {
262-
.platform_data = &db8500_thsens_data,
263-
},
264-
};
265-
266209
static struct platform_device u8500_cpufreq_cooling_device = {
267210
.name = "db8500-cpufreq-cooling",
268211
};
@@ -622,7 +565,6 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
622565
&snowball_key_dev,
623566
&snowball_sbnet_dev,
624567
&snowball_gpio_en_3v3_regulator_dev,
625-
&u8500_thsens_device,
626568
&u8500_cpufreq_cooling_device,
627569
};
628570

‎arch/arm/mach-ux500/cpu-db8500.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ void __init u8500_map_io(void)
9494
iotable_init(u9540_io_desc, ARRAY_SIZE(u9540_io_desc));
9595
else
9696
iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
97-
98-
_PRCMU_BASE = __io_address(U8500_PRCMU_BASE);
9997
}
10098

10199
static struct resource db8500_pmu_resources[] = {

‎arch/arm/mach-ux500/cpu.c‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <linux/platform_device.h>
1010
#include <linux/io.h>
11-
#include <linux/mfd/db8500-prcmu.h>
11+
#include <linux/mfd/dbx500-prcmu.h>
1212
#include <linux/clksrc-dbx500-prcmu.h>
1313
#include <linux/sys_soc.h>
1414
#include <linux/err.h>
@@ -20,6 +20,7 @@
2020
#include <linux/irqchip.h>
2121
#include <linux/irqchip/arm-gic.h>
2222
#include <linux/platform_data/clk-ux500.h>
23+
#include <linux/platform_data/arm-ux500-pm.h>
2324

2425
#include <asm/mach/map.h>
2526

@@ -30,8 +31,6 @@
3031
#include "board-mop500.h"
3132
#include "id.h"
3233

33-
void __iomem *_PRCMU_BASE;
34-
3534
/*
3635
* FIXME: Should we set up the GPIO domain here?
3736
*
@@ -68,13 +67,19 @@ void __init ux500_init_irq(void)
6867
* Init clocks here so that they are available for system timer
6968
* initialization.
7069
*/
71-
if (cpu_is_u8500_family() || cpu_is_u9540())
72-
db8500_prcmu_early_init();
73-
74-
if (cpu_is_u8500_family() || cpu_is_u9540())
70+
if (cpu_is_u8500_family()) {
71+
prcmu_early_init(U8500_PRCMU_BASE, SZ_8K - 1);
72+
ux500_pm_init(U8500_PRCMU_BASE, SZ_8K - 1);
7573
u8500_clk_init();
76-
else if (cpu_is_u8540())
74+
} else if (cpu_is_u9540()) {
75+
prcmu_early_init(U8500_PRCMU_BASE, SZ_8K - 1);
76+
ux500_pm_init(U8500_PRCMU_BASE, SZ_8K - 1);
77+
u8500_clk_init();
78+
} else if (cpu_is_u8540()) {
79+
prcmu_early_init(U8500_PRCMU_BASE, SZ_8K + SZ_4K - 1);
80+
ux500_pm_init(U8500_PRCMU_BASE, SZ_8K + SZ_4K - 1);
7781
u8540_clk_init();
82+
}
7883
}
7984

8085
void __init ux500_init_late(void)

‎arch/arm/mach-ux500/cpuidle.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/atomic.h>
1717
#include <linux/smp.h>
1818
#include <linux/mfd/dbx500-prcmu.h>
19+
#include <linux/platform_data/arm-ux500-pm.h>
1920

2021
#include <asm/cpuidle.h>
2122
#include <asm/proc-fns.h>
@@ -130,7 +131,7 @@ int __init ux500_idle_init(void)
130131
int ret, cpu;
131132
struct cpuidle_device *device;
132133

133-
/* Configure wake up reasons */
134+
/* Configure wake up reasons */
134135
prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
135136
PRCMU_WAKEUP(ABB));
136137

‎arch/arm/mach-ux500/devices-db8500.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ struct platform_device u8500_ske_keypad_device = {
199199

200200
struct prcmu_pdata db8500_prcmu_pdata = {
201201
.ab_platdata = &ab8500_platdata,
202+
.ab_irq = IRQ_DB8500_AB8500,
203+
.irq_base = IRQ_PRCMU_BASE,
202204
.version_offset = DB8500_PRCMU_FW_VERSION_OFFSET,
203205
.legacy_offset = DB8500_PRCMU_LEGACY_OFFSET,
204206
};

‎arch/arm/mach-ux500/include/mach/hardware.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939

4040
#ifndef __ASSEMBLY__
4141

42-
extern void __iomem *_PRCMU_BASE;
43-
4442
#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
4543

4644
#endif /* __ASSEMBLY__ */

‎arch/arm/mach-ux500/include/mach/irqs-db8500.h‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,31 +109,6 @@
109109

110110
/* Virtual interrupts corresponding to the PRCMU wakeups. */
111111
#define IRQ_PRCMU_BASE IRQ_SOC_START
112-
#define NUM_PRCMU_WAKEUPS (IRQ_PRCMU_END - IRQ_PRCMU_BASE)
113-
114-
#define IRQ_PRCMU_RTC (IRQ_PRCMU_BASE)
115-
#define IRQ_PRCMU_RTT0 (IRQ_PRCMU_BASE + 1)
116-
#define IRQ_PRCMU_RTT1 (IRQ_PRCMU_BASE + 2)
117-
#define IRQ_PRCMU_HSI0 (IRQ_PRCMU_BASE + 3)
118-
#define IRQ_PRCMU_HSI1 (IRQ_PRCMU_BASE + 4)
119-
#define IRQ_PRCMU_CA_WAKE (IRQ_PRCMU_BASE + 5)
120-
#define IRQ_PRCMU_USB (IRQ_PRCMU_BASE + 6)
121-
#define IRQ_PRCMU_ABB (IRQ_PRCMU_BASE + 7)
122-
#define IRQ_PRCMU_ABB_FIFO (IRQ_PRCMU_BASE + 8)
123-
#define IRQ_PRCMU_ARM (IRQ_PRCMU_BASE + 9)
124-
#define IRQ_PRCMU_MODEM_SW_RESET_REQ (IRQ_PRCMU_BASE + 10)
125-
#define IRQ_PRCMU_GPIO0 (IRQ_PRCMU_BASE + 11)
126-
#define IRQ_PRCMU_GPIO1 (IRQ_PRCMU_BASE + 12)
127-
#define IRQ_PRCMU_GPIO2 (IRQ_PRCMU_BASE + 13)
128-
#define IRQ_PRCMU_GPIO3 (IRQ_PRCMU_BASE + 14)
129-
#define IRQ_PRCMU_GPIO4 (IRQ_PRCMU_BASE + 15)
130-
#define IRQ_PRCMU_GPIO5 (IRQ_PRCMU_BASE + 16)
131-
#define IRQ_PRCMU_GPIO6 (IRQ_PRCMU_BASE + 17)
132-
#define IRQ_PRCMU_GPIO7 (IRQ_PRCMU_BASE + 18)
133-
#define IRQ_PRCMU_GPIO8 (IRQ_PRCMU_BASE + 19)
134-
#define IRQ_PRCMU_CA_SLEEP (IRQ_PRCMU_BASE + 20)
135-
#define IRQ_PRCMU_HOTMON_LOW (IRQ_PRCMU_BASE + 21)
136-
#define IRQ_PRCMU_HOTMON_HIGH (IRQ_PRCMU_BASE + 22)
137112
#define IRQ_PRCMU_END (IRQ_PRCMU_BASE + 23)
138113

139114
/*

‎arch/arm/mach-ux500/pm.c‎

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
* Copyright (C) ST-Ericsson SA 2010-2013
3+
* Author: Rickard Andersson <rickard.andersson@stericsson.com> for
4+
* ST-Ericsson.
5+
* Author: Daniel Lezcano <daniel.lezcano@linaro.org> for Linaro.
6+
* License terms: GNU General Public License (GPL) version 2
7+
*
8+
*/
9+
10+
#include <linux/kernel.h>
11+
#include <linux/irqchip/arm-gic.h>
12+
#include <linux/delay.h>
13+
#include <linux/io.h>
14+
#include <linux/platform_data/arm-ux500-pm.h>
15+
16+
#include <mach/hardware.h>
17+
18+
/* ARM WFI Standby signal register */
19+
#define PRCM_ARM_WFI_STANDBY (prcmu_base + 0x130)
20+
#define PRCM_ARM_WFI_STANDBY_WFI0 0x08
21+
#define PRCM_ARM_WFI_STANDBY_WFI1 0x10
22+
#define PRCM_IOCR (prcmu_base + 0x310)
23+
#define PRCM_IOCR_IOFORCE 0x1
24+
25+
/* Dual A9 core interrupt management unit registers */
26+
#define PRCM_A9_MASK_REQ (prcmu_base + 0x328)
27+
#define PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ 0x1
28+
29+
#define PRCM_A9_MASK_ACK (prcmu_base + 0x32c)
30+
#define PRCM_ARMITMSK31TO0 (prcmu_base + 0x11c)
31+
#define PRCM_ARMITMSK63TO32 (prcmu_base + 0x120)
32+
#define PRCM_ARMITMSK95TO64 (prcmu_base + 0x124)
33+
#define PRCM_ARMITMSK127TO96 (prcmu_base + 0x128)
34+
#define PRCM_POWER_STATE_VAL (prcmu_base + 0x25C)
35+
#define PRCM_ARMITVAL31TO0 (prcmu_base + 0x260)
36+
#define PRCM_ARMITVAL63TO32 (prcmu_base + 0x264)
37+
#define PRCM_ARMITVAL95TO64 (prcmu_base + 0x268)
38+
#define PRCM_ARMITVAL127TO96 (prcmu_base + 0x26C)
39+
40+
static void __iomem *prcmu_base;
41+
42+
/* This function decouple the gic from the prcmu */
43+
int prcmu_gic_decouple(void)
44+
{
45+
u32 val = readl(PRCM_A9_MASK_REQ);
46+
47+
/* Set bit 0 register value to 1 */
48+
writel(val | PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ,
49+
PRCM_A9_MASK_REQ);
50+
51+
/* Make sure the register is updated */
52+
readl(PRCM_A9_MASK_REQ);
53+
54+
/* Wait a few cycles for the gic mask completion */
55+
udelay(1);
56+
57+
return 0;
58+
}
59+
60+
/* This function recouple the gic with the prcmu */
61+
int prcmu_gic_recouple(void)
62+
{
63+
u32 val = readl(PRCM_A9_MASK_REQ);
64+
65+
/* Set bit 0 register value to 0 */
66+
writel(val & ~PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ, PRCM_A9_MASK_REQ);
67+
68+
return 0;
69+
}
70+
71+
#define PRCMU_GIC_NUMBER_REGS 5
72+
73+
/*
74+
* This function checks if there are pending irq on the gic. It only
75+
* makes sense if the gic has been decoupled before with the
76+
* db8500_prcmu_gic_decouple function. Disabling an interrupt only
77+
* disables the forwarding of the interrupt to any CPU interface. It
78+
* does not prevent the interrupt from changing state, for example
79+
* becoming pending, or active and pending if it is already
80+
* active. Hence, we have to check the interrupt is pending *and* is
81+
* active.
82+
*/
83+
bool prcmu_gic_pending_irq(void)
84+
{
85+
u32 pr; /* Pending register */
86+
u32 er; /* Enable register */
87+
void __iomem *dist_base = __io_address(U8500_GIC_DIST_BASE);
88+
int i;
89+
90+
/* 5 registers. STI & PPI not skipped */
91+
for (i = 0; i < PRCMU_GIC_NUMBER_REGS; i++) {
92+
93+
pr = readl_relaxed(dist_base + GIC_DIST_PENDING_SET + i * 4);
94+
er = readl_relaxed(dist_base + GIC_DIST_ENABLE_SET + i * 4);
95+
96+
if (pr & er)
97+
return true; /* There is a pending interrupt */
98+
}
99+
100+
return false;
101+
}
102+
103+
/*
104+
* This function checks if there are pending interrupt on the
105+
* prcmu which has been delegated to monitor the irqs with the
106+
* db8500_prcmu_copy_gic_settings function.
107+
*/
108+
bool prcmu_pending_irq(void)
109+
{
110+
u32 it, im;
111+
int i;
112+
113+
for (i = 0; i < PRCMU_GIC_NUMBER_REGS - 1; i++) {
114+
it = readl(PRCM_ARMITVAL31TO0 + i * 4);
115+
im = readl(PRCM_ARMITMSK31TO0 + i * 4);
116+
if (it & im)
117+
return true; /* There is a pending interrupt */
118+
}
119+
120+
return false;
121+
}
122+
123+
/*
124+
* This function checks if the specified cpu is in in WFI. It's usage
125+
* makes sense only if the gic is decoupled with the db8500_prcmu_gic_decouple
126+
* function. Of course passing smp_processor_id() to this function will
127+
* always return false...
128+
*/
129+
bool prcmu_is_cpu_in_wfi(int cpu)
130+
{
131+
return readl(PRCM_ARM_WFI_STANDBY) & cpu ? PRCM_ARM_WFI_STANDBY_WFI1 :
132+
PRCM_ARM_WFI_STANDBY_WFI0;
133+
}
134+
135+
/*
136+
* This function copies the gic SPI settings to the prcmu in order to
137+
* monitor them and abort/finish the retention/off sequence or state.
138+
*/
139+
int prcmu_copy_gic_settings(void)
140+
{
141+
u32 er; /* Enable register */
142+
void __iomem *dist_base = __io_address(U8500_GIC_DIST_BASE);
143+
int i;
144+
145+
/* We skip the STI and PPI */
146+
for (i = 0; i < PRCMU_GIC_NUMBER_REGS - 1; i++) {
147+
er = readl_relaxed(dist_base +
148+
GIC_DIST_ENABLE_SET + (i + 1) * 4);
149+
writel(er, PRCM_ARMITMSK31TO0 + i * 4);
150+
}
151+
152+
return 0;
153+
}
154+
155+
void __init ux500_pm_init(u32 phy_base, u32 size)
156+
{
157+
prcmu_base = ioremap(phy_base, size);
158+
if (!prcmu_base) {
159+
pr_err("could not remap PRCMU for PM functions\n");
160+
return;
161+
}
162+
/*
163+
* On watchdog reboot the GIC is in some cases decoupled.
164+
* This will make sure that the GIC is correctly configured.
165+
*/
166+
prcmu_gic_recouple();
167+
}

0 commit comments

Comments
 (0)