msm: pm2: Call appropriate irq functions for 7k and 8625 targets
There is a difference between the 7k & 8625 targets interrupt
controllers. 7k & 8625 targets uses the VIC & QGIC controllers
respectively. Power driver uses these conrtoller API's to take
a decision while entering into low power modes. This change
provides a generic implementation wihtout worrying about the
interrupt controller being used on the target.
Change-Id: Ib50cb19dc84333a969fc5287381f7703b64042ed
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-msm7x27a.c b/arch/arm/mach-msm/board-msm7x27a.c
index 28d1cf0..e75a963 100644
--- a/arch/arm/mach-msm/board-msm7x27a.c
+++ b/arch/arm/mach-msm/board-msm7x27a.c
@@ -1375,6 +1375,8 @@
ARRAY_SIZE(msm7x27a_pm_data));
BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
}
+
+ msm_pm_register_irqs();
}
static void __init msm7x2x_init(void)
diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
index 1e4ebdcd..cd1e5b8 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -6820,6 +6820,7 @@
msm_fb_add_devices();
msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
+ msm_pm_register_irqs();
msm_device_i2c_init();
msm_device_i2c_2_init();
qup_device_i2c_init();
diff --git a/arch/arm/mach-msm/board-qrd7627a.c b/arch/arm/mach-msm/board-qrd7627a.c
index 3c01115..ad4114d 100644
--- a/arch/arm/mach-msm/board-qrd7627a.c
+++ b/arch/arm/mach-msm/board-qrd7627a.c
@@ -1323,6 +1323,7 @@
#endif
msm_pm_init();
+ msm_pm_register_irqs();
msm_fb_add_devices();
#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c
index 5a77333..239896a 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -55,6 +55,7 @@
#include "msm-keypad-devices.h"
#include "acpuclock.h"
#include "pm.h"
+#include "irq.h"
#include "pm-boot.h"
#include "proc_comm.h"
#ifdef CONFIG_USB_ANDROID
@@ -2442,6 +2443,7 @@
ARRAY_SIZE(msm_spi_board_info));
msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
+ msm_pm_register_irqs();
#ifdef CONFIG_SURF_FFA_GPIO_KEYPAD
if (machine_is_qsd8x50_ffa())
diff --git a/arch/arm/mach-msm/devices-msm7x27.c b/arch/arm/mach-msm/devices-msm7x27.c
index 26f246d..3008fe9 100644
--- a/arch/arm/mach-msm/devices-msm7x27.c
+++ b/arch/arm/mach-msm/devices-msm7x27.c
@@ -35,6 +35,8 @@
#include <mach/msm_hsusb.h>
#include <mach/usbdiag.h>
#include <mach/rpc_hsusb.h>
+#include "irq.h"
+#include "pm.h"
static struct resource resources_uart1[] = {
{
@@ -415,6 +417,21 @@
},
};
+static struct msm_pm_irq_calls msm7x27_pm_irq_calls = {
+ .irq_pending = msm_irq_pending,
+ .idle_sleep_allowed = msm_irq_idle_sleep_allowed,
+ .enter_sleep1 = msm_irq_enter_sleep1,
+ .enter_sleep2 = msm_irq_enter_sleep2,
+ .exit_sleep1 = msm_irq_exit_sleep1,
+ .exit_sleep2 = msm_irq_exit_sleep2,
+ .exit_sleep3 = msm_irq_exit_sleep3,
+};
+
+void msm_pm_register_irqs(void)
+{
+ msm_pm_set_irq_extns(&msm7x27_pm_irq_calls);
+}
+
#define MSM_SDC1_BASE 0xA0400000
#define MSM_SDC2_BASE 0xA0500000
#define MSM_SDC3_BASE 0xA0600000
diff --git a/arch/arm/mach-msm/devices-msm7x27a.c b/arch/arm/mach-msm/devices-msm7x27a.c
index b879d8b..8236e1e 100644
--- a/arch/arm/mach-msm/devices-msm7x27a.c
+++ b/arch/arm/mach-msm/devices-msm7x27a.c
@@ -35,6 +35,8 @@
#include "acpuclock.h"
#include "spm.h"
#include "mpm-8625.h"
+#include "irq.h"
+#include "pm.h"
/* Address of GSBI blocks */
#define MSM_GSBI0_PHYS 0xA1200000
@@ -425,6 +427,35 @@
},
};
+static struct msm_pm_irq_calls msm7x27a_pm_irq_calls = {
+ .irq_pending = msm_irq_pending,
+ .idle_sleep_allowed = msm_irq_idle_sleep_allowed,
+ .enter_sleep1 = msm_irq_enter_sleep1,
+ .enter_sleep2 = msm_irq_enter_sleep2,
+ .exit_sleep1 = msm_irq_exit_sleep1,
+ .exit_sleep2 = msm_irq_exit_sleep2,
+ .exit_sleep3 = msm_irq_exit_sleep3,
+};
+
+static struct msm_pm_irq_calls msm8625_pm_irq_calls = {
+ .irq_pending = msm_gic_spi_ppi_pending,
+ .idle_sleep_allowed = msm_gic_irq_idle_sleep_allowed,
+ .enter_sleep1 = msm_gic_irq_enter_sleep1,
+ .enter_sleep2 = msm_gic_irq_enter_sleep2,
+ .exit_sleep1 = msm_gic_irq_exit_sleep1,
+ .exit_sleep2 = msm_gic_irq_exit_sleep2,
+ .exit_sleep3 = msm_gic_irq_exit_sleep3,
+};
+
+void msm_pm_register_irqs(void)
+{
+ if (cpu_is_msm8625())
+ msm_pm_set_irq_extns(&msm8625_pm_irq_calls);
+ else
+ msm_pm_set_irq_extns(&msm7x27a_pm_irq_calls);
+
+}
+
#define MSM_SDC1_BASE 0xA0400000
#define MSM_SDC2_BASE 0xA0500000
#define MSM_SDC3_BASE 0xA0600000
diff --git a/arch/arm/mach-msm/devices-msm7x30.c b/arch/arm/mach-msm/devices-msm7x30.c
index e0c23fa..17e7364 100644
--- a/arch/arm/mach-msm/devices-msm7x30.c
+++ b/arch/arm/mach-msm/devices-msm7x30.c
@@ -40,6 +40,8 @@
#endif
#include <mach/dal_axi.h>
#include <mach/msm_memtypes.h>
+#include "pm.h"
+#include "irq.h"
/* EBI THERMAL DRIVER */
static struct resource msm_ebi0_thermal_resources[] = {
@@ -595,6 +597,21 @@
},
};
+static struct msm_pm_irq_calls msm7x30_pm_irq_calls = {
+ .irq_pending = msm_irq_pending,
+ .idle_sleep_allowed = msm_irq_idle_sleep_allowed,
+ .enter_sleep1 = msm_irq_enter_sleep1,
+ .enter_sleep2 = msm_irq_enter_sleep2,
+ .exit_sleep1 = msm_irq_exit_sleep1,
+ .exit_sleep2 = msm_irq_exit_sleep2,
+ .exit_sleep3 = msm_irq_exit_sleep3,
+};
+
+void msm_pm_register_irqs(void)
+{
+ msm_pm_set_irq_extns(&msm7x30_pm_irq_calls);
+}
+
static struct resource smd_resource[] = {
{
.name = "a9_m2a_0",
diff --git a/arch/arm/mach-msm/devices-qsd8x50.c b/arch/arm/mach-msm/devices-qsd8x50.c
index 05efcdf..a32079b 100644
--- a/arch/arm/mach-msm/devices-qsd8x50.c
+++ b/arch/arm/mach-msm/devices-qsd8x50.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2008-2012, Code Aurora Forum. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -33,6 +33,7 @@
#include <mach/msm_hsusb.h>
#include <mach/usbdiag.h>
#include <mach/rpc_hsusb.h>
+#include "pm.h"
static struct resource resources_uart1[] = {
{
@@ -432,6 +433,21 @@
},
};
+static struct msm_pm_irq_calls qsd8x50_pm_irq_calls = {
+ .irq_pending = msm_irq_pending,
+ .idle_sleep_allowed = msm_irq_idle_sleep_allowed,
+ .enter_sleep1 = msm_irq_enter_sleep1,
+ .enter_sleep2 = msm_irq_enter_sleep2,
+ .exit_sleep1 = msm_irq_exit_sleep1,
+ .exit_sleep2 = msm_irq_exit_sleep2,
+ .exit_sleep3 = msm_irq_exit_sleep3,
+};
+
+void msm_pm_register_irqs(void)
+{
+ msm_pm_set_irq_extns(&qsd8x50_pm_irq_calls);
+}
+
struct platform_device msm_device_smd = {
.name = "msm_smd",
.id = -1,
diff --git a/arch/arm/mach-msm/include/mach/board.h b/arch/arm/mach-msm/include/mach/board.h
index 66299a4..ae4d632 100644
--- a/arch/arm/mach-msm/include/mach/board.h
+++ b/arch/arm/mach-msm/include/mach/board.h
@@ -513,6 +513,7 @@
int msm_add_sdcc(unsigned int controller,
struct mmc_platform_data *plat);
+void msm_pm_register_irqs(void);
struct msm_usb_host_platform_data;
int msm_add_host(unsigned int host,
struct msm_usb_host_platform_data *plat);
diff --git a/arch/arm/mach-msm/pm.h b/arch/arm/mach-msm/pm.h
index 4e9cc3c..caafbdd 100644
--- a/arch/arm/mach-msm/pm.h
+++ b/arch/arm/mach-msm/pm.h
@@ -29,6 +29,20 @@
extern int power_collapsed;
+struct msm_pm_irq_calls {
+ unsigned int (*irq_pending)(void);
+ int (*idle_sleep_allowed)(void);
+ void (*enter_sleep1)(bool modem_wake, int from_idle, uint32_t
+ *irq_mask);
+ int (*enter_sleep2)(bool modem_wake, int from_idle);
+ void (*exit_sleep1)(uint32_t irq_mask, uint32_t wakeup_reason,
+ uint32_t pending_irqs);
+ void (*exit_sleep2)(uint32_t irq_mask, uint32_t wakeup_reason,
+ uint32_t pending_irqs);
+ void (*exit_sleep3)(uint32_t irq_mask, uint32_t wakeup_reason,
+ uint32_t pending_irqs);
+};
+
enum msm_pm_sleep_mode {
MSM_PM_SLEEP_MODE_POWER_COLLAPSE_SUSPEND,
MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
@@ -60,6 +74,7 @@
};
void msm_pm_set_platform_data(struct msm_pm_platform_data *data, int count);
+void msm_pm_set_irq_extns(struct msm_pm_irq_calls *irq_calls);
int msm_pm_idle_prepare(struct cpuidle_device *dev);
int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode);
void msm_pm_cpu_enter_lowpower(unsigned int cpu);
diff --git a/arch/arm/mach-msm/pm2.c b/arch/arm/mach-msm/pm2.c
index 94bc98f..6dc1859 100644
--- a/arch/arm/mach-msm/pm2.c
+++ b/arch/arm/mach-msm/pm2.c
@@ -155,6 +155,7 @@
};
static struct msm_pm_platform_data *msm_pm_modes;
+static struct msm_pm_irq_calls *msm_pm_irq_extns;
struct msm_pm_kobj_attribute {
unsigned int cpu;
@@ -398,6 +399,19 @@
msm_pm_modes = data;
}
+void __init msm_pm_set_irq_extns(struct msm_pm_irq_calls *irq_calls)
+{
+ /* sanity check */
+ BUG_ON(irq_calls == NULL || irq_calls->irq_pending == NULL ||
+ irq_calls->idle_sleep_allowed == NULL ||
+ irq_calls->enter_sleep1 == NULL ||
+ irq_calls->enter_sleep2 == NULL ||
+ irq_calls->exit_sleep1 == NULL ||
+ irq_calls->exit_sleep2 == NULL ||
+ irq_calls->exit_sleep3 == NULL);
+
+ msm_pm_irq_extns = irq_calls;
+}
/******************************************************************************
* Sleep Limitations
@@ -1015,7 +1029,8 @@
WARN_ON(ret);
}
- msm_irq_enter_sleep1(true, from_idle, &msm_pm_smem_data->irq_mask);
+ msm_pm_irq_extns->enter_sleep1(true, from_idle,
+ &msm_pm_smem_data->irq_mask);
msm_sirc_enter_sleep();
msm_gpio_enter_sleep(from_idle);
@@ -1061,7 +1076,7 @@
MSM_PM_DEBUG_PRINT_STATE("msm_pm_power_collapse(): PWRC RSA");
- ret = msm_irq_enter_sleep2(true, from_idle);
+ ret = msm_pm_irq_extns->enter_sleep2(true, from_idle);
if (ret < 0) {
MSM_PM_DPRINTK(
MSM_PM_DEBUG_SUSPEND|MSM_PM_DEBUG_POWER_COLLAPSE,
@@ -1125,7 +1140,7 @@
printk(KERN_ERR "%s(): failed to restore clock rate(%lu)\n",
__func__, saved_acpuclk_rate);
- msm_irq_exit_sleep1(msm_pm_smem_data->irq_mask,
+ msm_pm_irq_extns->exit_sleep1(msm_pm_smem_data->irq_mask,
msm_pm_smem_data->wakeup_reason,
msm_pm_smem_data->pending_irqs);
@@ -1202,10 +1217,10 @@
MSM_PM_DEBUG_PRINT_STATE("msm_pm_power_collapse(): WFPI RUN");
MSM_PM_DEBUG_PRINT_SLEEP_INFO();
- msm_irq_exit_sleep2(msm_pm_smem_data->irq_mask,
+ msm_pm_irq_extns->exit_sleep2(msm_pm_smem_data->irq_mask,
msm_pm_smem_data->wakeup_reason,
msm_pm_smem_data->pending_irqs);
- msm_irq_exit_sleep3(msm_pm_smem_data->irq_mask,
+ msm_pm_irq_extns->exit_sleep3(msm_pm_smem_data->irq_mask,
msm_pm_smem_data->wakeup_reason,
msm_pm_smem_data->pending_irqs);
msm_gpio_exit_sleep();
@@ -1438,7 +1453,7 @@
#ifdef CONFIG_HAS_WAKELOCK
has_wake_lock(WAKE_LOCK_IDLE) ||
#endif
- !msm_irq_idle_sleep_allowed()) {
+ !msm_pm_irq_extns->idle_sleep_allowed()) {
allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = false;
allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = false;
}
@@ -1521,7 +1536,7 @@
} else if (allow[MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT]) {
ret = msm_pm_swfi(true);
if (ret)
- while (!msm_irq_pending())
+ while (!msm_pm_irq_extns->irq_pending())
udelay(1);
low_power = 0;
#ifdef CONFIG_MSM_IDLE_STATS
@@ -1534,7 +1549,7 @@
exit_stat = MSM_PM_STAT_IDLE_WFI;
#endif
} else {
- while (!msm_irq_pending())
+ while (!msm_pm_irq_extns->irq_pending())
udelay(1);
low_power = 0;
#ifdef CONFIG_MSM_IDLE_STATS
@@ -1656,7 +1671,7 @@
} else if (allow[MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT]) {
ret = msm_pm_swfi(true);
if (ret)
- while (!msm_irq_pending())
+ while (!msm_pm_irq_extns->irq_pending())
udelay(1);
} else if (allow[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT]) {
msm_pm_swfi(false);