msm: subsystem_fatal_8x60: Separate out the modem and lpass drivers.
Change-Id: Ia50596cb4ffbc0b8f3d09ca3ee8914d7504e7f61
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 025f1c7..b7357cd 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -167,7 +167,7 @@
obj-y += subsystem_notif.o
obj-y += subsystem_restart.o
obj-y += ramdump.o
- obj-$(CONFIG_ARCH_MSM8X60) += subsystem-fatal-8x60.o
+ obj-$(CONFIG_ARCH_MSM8X60) += modem-8660.o lpass-8660.o
endif
obj-$(CONFIG_MSM_SYSMON_COMM) += sysmon.o
obj-$(CONFIG_MSM_MODEM_8960) += modem-8960.o
diff --git a/arch/arm/mach-msm/lpass-8660.c b/arch/arm/mach-msm/lpass-8660.c
new file mode 100644
index 0000000..36b8dcc
--- /dev/null
+++ b/arch/arm/mach-msm/lpass-8660.c
@@ -0,0 +1,166 @@
+/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/reboot.h>
+#include <linux/workqueue.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/stringify.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+
+#include <mach/irqs.h>
+#include <mach/scm.h>
+#include <mach/peripheral-loader.h>
+#include <mach/subsystem_restart.h>
+#include <mach/subsystem_notif.h>
+
+#include "smd_private.h"
+#include "modem_notifier.h"
+#include "ramdump.h"
+
+#define Q6SS_WDOG_ENABLE 0x28882024
+#define Q6SS_SOFT_INTR_WAKEUP 0x288A001C
+#define MODULE_NAME "lpass_8x60"
+#define SCM_Q6_NMI_CMD 0x1
+
+/* Subsystem restart: QDSP6 data, functions */
+static void *q6_ramdump_dev;
+static void q6_fatal_fn(struct work_struct *);
+static DECLARE_WORK(q6_fatal_work, q6_fatal_fn);
+
+static void q6_fatal_fn(struct work_struct *work)
+{
+ pr_err("%s: Watchdog bite received from Q6!\n", MODULE_NAME);
+ subsystem_restart("lpass");
+ enable_irq(LPASS_Q6SS_WDOG_EXPIRED);
+}
+
+static void send_q6_nmi(void)
+{
+ /* Send NMI to QDSP6 via an SCM call. */
+ uint32_t cmd = 0x1;
+ void __iomem *q6_wakeup_intr;
+
+ scm_call(SCM_SVC_UTIL, SCM_Q6_NMI_CMD,
+ &cmd, sizeof(cmd), NULL, 0);
+
+ /* Wakeup the Q6 */
+ q6_wakeup_intr = ioremap_nocache(Q6SS_SOFT_INTR_WAKEUP, 8);
+ writel_relaxed(0x2000, q6_wakeup_intr);
+ iounmap(q6_wakeup_intr);
+ mb();
+
+ /* Q6 requires atleast 100ms to dump caches etc.*/
+ msleep(100);
+
+ pr_info("subsystem-fatal-8x60: Q6 NMI was sent.\n");
+}
+
+int subsys_q6_shutdown(const struct subsys_data *crashed_subsys)
+{
+ void __iomem *q6_wdog_addr =
+ ioremap_nocache(Q6SS_WDOG_ENABLE, 8);
+
+ send_q6_nmi();
+ writel_relaxed(0x0, q6_wdog_addr);
+ /* The write needs to go through before the q6 is shutdown. */
+ mb();
+ iounmap(q6_wdog_addr);
+
+ pil_force_shutdown("q6");
+ disable_irq_nosync(LPASS_Q6SS_WDOG_EXPIRED);
+
+ if (get_restart_level() == RESET_SUBSYS_MIXED)
+ smsm_reset_modem(SMSM_RESET);
+
+ return 0;
+}
+
+int subsys_q6_powerup(const struct subsys_data *crashed_subsys)
+{
+ int ret = pil_force_boot("q6");
+ enable_irq(LPASS_Q6SS_WDOG_EXPIRED);
+ return ret;
+}
+
+/* FIXME: Get address, size from PIL */
+static struct ramdump_segment q6_segments[] = { {0x46700000, 0x47F00000 -
+ 0x46700000}, {0x28400000, 0x12800} };
+static int subsys_q6_ramdump(int enable,
+ const struct subsys_data *crashed_subsys)
+{
+ if (enable)
+ return do_ramdump(q6_ramdump_dev, q6_segments,
+ ARRAY_SIZE(q6_segments));
+ else
+ return 0;
+}
+
+void subsys_q6_crash_shutdown(const struct subsys_data *crashed_subsys)
+{
+ send_q6_nmi();
+}
+
+static irqreturn_t lpass_wdog_bite_irq(int irq, void *dev_id)
+{
+ int ret;
+
+ ret = schedule_work(&q6_fatal_work);
+ disable_irq_nosync(LPASS_Q6SS_WDOG_EXPIRED);
+
+ return IRQ_HANDLED;
+}
+
+static struct subsys_data subsys_8x60_q6 = {
+ .name = "lpass",
+ .shutdown = subsys_q6_shutdown,
+ .powerup = subsys_q6_powerup,
+ .ramdump = subsys_q6_ramdump,
+ .crash_shutdown = subsys_q6_crash_shutdown
+};
+
+static void __exit lpass_fatal_exit(void)
+{
+ free_irq(LPASS_Q6SS_WDOG_EXPIRED, NULL);
+}
+
+static int __init lpass_fatal_init(void)
+{
+ int ret;
+
+ ret = request_irq(LPASS_Q6SS_WDOG_EXPIRED, lpass_wdog_bite_irq,
+ IRQF_TRIGGER_RISING, "q6_wdog", NULL);
+
+ if (ret < 0) {
+ pr_err("%s: Unable to request LPASS_Q6SS_WDOG_EXPIRED irq.",
+ __func__);
+ goto out;
+ }
+
+ q6_ramdump_dev = create_ramdump_device("lpass");
+
+ if (!q6_ramdump_dev) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ ret = ssr_register_subsystem(&subsys_8x60_q6);
+out:
+ return ret;
+}
+
+module_init(lpass_fatal_init);
+module_exit(lpass_fatal_exit);
+
diff --git a/arch/arm/mach-msm/subsystem-fatal-8x60.c b/arch/arm/mach-msm/modem-8660.c
similarity index 60%
rename from arch/arm/mach-msm/subsystem-fatal-8x60.c
rename to arch/arm/mach-msm/modem-8660.c
index a061aa0..19711a2 100644
--- a/arch/arm/mach-msm/subsystem-fatal-8x60.c
+++ b/arch/arm/mach-msm/modem-8660.c
@@ -31,11 +31,8 @@
#include "ramdump.h"
#define MODEM_HWIO_MSS_RESET_ADDR 0x00902C48
-#define SCM_Q6_NMI_CMD 0x1
-#define MODULE_NAME "subsystem_fatal_8x60"
-#define Q6SS_SOFT_INTR_WAKEUP 0x288A001C
+#define MODULE_NAME "modem_8660"
#define MODEM_WDOG_ENABLE 0x10020008
-#define Q6SS_WDOG_ENABLE 0x28882024
#define MODEM_CLEANUP_DELAY_MS 20
#define SUBSYS_FATAL_DEBUG
@@ -50,86 +47,8 @@
module_param(reset_modem, int, 0644);
#endif
-static void do_soc_restart(void);
-
-/* Subsystem restart: QDSP6 data, functions */
-static void q6_fatal_fn(struct work_struct *);
-static DECLARE_WORK(q6_fatal_work, q6_fatal_fn);
-static void *q6_ramdump_dev, *modem_ramdump_dev;
-static void __iomem *q6_wakeup_intr;
-
-static void q6_fatal_fn(struct work_struct *work)
-{
- pr_err("%s: Watchdog bite received from Q6!\n", MODULE_NAME);
- subsystem_restart("lpass");
- enable_irq(LPASS_Q6SS_WDOG_EXPIRED);
-}
-
-static void send_q6_nmi(void)
-{
- /* Send NMI to QDSP6 via an SCM call. */
- uint32_t cmd = 0x1;
-
- scm_call(SCM_SVC_UTIL, SCM_Q6_NMI_CMD,
- &cmd, sizeof(cmd), NULL, 0);
-
- /* Wakeup the Q6 */
- if (q6_wakeup_intr)
- writel_relaxed(0x2000, q6_wakeup_intr);
- mb();
-
- /* Q6 requires atleast 100ms to dump caches etc.*/
- mdelay(100);
-
- pr_info("subsystem-fatal-8x60: Q6 NMI was sent.\n");
-}
-
-int subsys_q6_shutdown(const struct subsys_data *crashed_subsys)
-{
- void __iomem *q6_wdog_addr =
- ioremap_nocache(Q6SS_WDOG_ENABLE, 8);
-
- send_q6_nmi();
- writel_relaxed(0x0, q6_wdog_addr);
- /* The write needs to go through before the q6 is shutdown. */
- mb();
- iounmap(q6_wdog_addr);
-
- pil_force_shutdown("q6");
- disable_irq_nosync(LPASS_Q6SS_WDOG_EXPIRED);
-
- if (get_restart_level() == RESET_SUBSYS_MIXED)
- smsm_reset_modem(SMSM_RESET);
-
- return 0;
-}
-
-int subsys_q6_powerup(const struct subsys_data *crashed_subsys)
-{
- int ret = pil_force_boot("q6");
- enable_irq(LPASS_Q6SS_WDOG_EXPIRED);
- return ret;
-}
-
-/* FIXME: Get address, size from PIL */
-static struct ramdump_segment q6_segments[] = { {0x46700000, 0x47F00000 -
- 0x46700000}, {0x28400000, 0x12800} };
-static int subsys_q6_ramdump(int enable,
- const struct subsys_data *crashed_subsys)
-{
- if (enable)
- return do_ramdump(q6_ramdump_dev, q6_segments,
- ARRAY_SIZE(q6_segments));
- else
- return 0;
-}
-
-void subsys_q6_crash_shutdown(const struct subsys_data *crashed_subsys)
-{
- send_q6_nmi();
-}
-
/* Subsystem restart: Modem data, functions */
+static void *modem_ramdump_dev;
static void modem_fatal_fn(struct work_struct *);
static void modem_unlock_timeout(struct work_struct *work);
static int modem_notif_handler(struct notifier_block *this,
@@ -180,7 +99,7 @@
pr_err("%s: User-invoked system reset/powerdown.",
MODULE_NAME);
- do_soc_restart();
+ kernel_restart(NULL);
} else {
@@ -191,7 +110,7 @@
pr_err("%s: Modem AHB locked up.\n", MODULE_NAME);
pr_err("%s: Trying to free up modem!\n", MODULE_NAME);
- writel(0x3, hwio_modem_reset_addr);
+ writel_relaxed(0x3, hwio_modem_reset_addr);
/* If we are still alive after 6 seconds (allowing for
* the 5-second-delayed-panic-reboot), modem is either
@@ -217,7 +136,7 @@
return NOTIFY_DONE;
}
-static int subsys_modem_shutdown(const struct subsys_data *crashed_subsys)
+static int modem_shutdown(const struct subsys_data *crashed_subsys)
{
void __iomem *modem_wdog_addr;
int smsm_notif_unregistered = 0;
@@ -257,7 +176,7 @@
return 0;
}
-static int subsys_modem_powerup(const struct subsys_data *crashed_subsys)
+static int modem_powerup(const struct subsys_data *crashed_subsys)
{
int ret;
@@ -271,7 +190,7 @@
static struct ramdump_segment modem_segments[] = {
{0x42F00000, 0x46000000 - 0x42F00000} };
-static int subsys_modem_ramdump(int enable,
+static int modem_ramdump(int enable,
const struct subsys_data *crashed_subsys)
{
if (enable)
@@ -281,7 +200,7 @@
return 0;
}
-static void subsys_modem_crash_shutdown(
+static void modem_crash_shutdown(
const struct subsys_data *crashed_subsys)
{
/* If modem hasn't already crashed, send SMSM_RESET. */
@@ -294,61 +213,25 @@
mdelay(5);
}
-/* Non-subsystem-specific functions */
-static void do_soc_restart(void)
-{
- pr_err("%s: Rebooting SoC..\n", MODULE_NAME);
- kernel_restart(NULL);
-}
-
-static irqreturn_t subsys_wdog_bite_irq(int irq, void *dev_id)
+static irqreturn_t modem_wdog_bite_irq(int irq, void *dev_id)
{
int ret;
- switch (irq) {
-
- case MARM_WDOG_EXPIRED:
- ret = schedule_work(&modem_fatal_work);
- disable_irq_nosync(MARM_WDOG_EXPIRED);
- break;
-
- case LPASS_Q6SS_WDOG_EXPIRED:
- ret = schedule_work(&q6_fatal_work);
- disable_irq_nosync(LPASS_Q6SS_WDOG_EXPIRED);
- break;
-
- default:
- pr_err("%s: %s: Unknown IRQ!\n", MODULE_NAME, __func__);
- }
+ ret = schedule_work(&modem_fatal_work);
+ disable_irq_nosync(MARM_WDOG_EXPIRED);
return IRQ_HANDLED;
}
-static struct subsys_data subsys_8x60_q6 = {
- .name = "lpass",
- .shutdown = subsys_q6_shutdown,
- .powerup = subsys_q6_powerup,
- .ramdump = subsys_q6_ramdump,
- .crash_shutdown = subsys_q6_crash_shutdown
-};
-
-static struct subsys_data subsys_8x60_modem = {
+static struct subsys_data subsys_8660_modem = {
.name = "modem",
- .shutdown = subsys_modem_shutdown,
- .powerup = subsys_modem_powerup,
- .ramdump = subsys_modem_ramdump,
- .crash_shutdown = subsys_modem_crash_shutdown
+ .shutdown = modem_shutdown,
+ .powerup = modem_powerup,
+ .ramdump = modem_ramdump,
+ .crash_shutdown = modem_crash_shutdown
};
-static int __init subsystem_restart_8x60_init(void)
-{
- ssr_register_subsystem(&subsys_8x60_modem);
- ssr_register_subsystem(&subsys_8x60_q6);
-
- return 0;
-}
-
-static int __init subsystem_fatal_init(void)
+static int __init modem_8660_init(void)
{
int ret;
@@ -359,7 +242,7 @@
schedule_delayed_work(&debug_crash_modem_work, msecs_to_jiffies(5000));
#endif
- ret = request_irq(MARM_WDOG_EXPIRED, subsys_wdog_bite_irq,
+ ret = request_irq(MARM_WDOG_EXPIRED, modem_wdog_bite_irq,
IRQF_TRIGGER_RISING, "modem_wdog", NULL);
if (ret < 0) {
@@ -368,27 +251,6 @@
goto out;
}
- ret = request_irq(LPASS_Q6SS_WDOG_EXPIRED, subsys_wdog_bite_irq,
- IRQF_TRIGGER_RISING, "q6_wdog", NULL);
-
- if (ret < 0) {
- pr_err("%s: Unable to request LPASS_Q6SS_WDOG_EXPIRED irq.",
- __func__);
- goto out;
- }
-
- q6_wakeup_intr = ioremap_nocache(Q6SS_SOFT_INTR_WAKEUP, 8);
-
- if (!q6_wakeup_intr)
- pr_err("%s: Unable to request q6 wakeup interrupt.", __func__);
-
- q6_ramdump_dev = create_ramdump_device("lpass");
-
- if (!q6_ramdump_dev) {
- ret = -ENOMEM;
- goto out;
- }
-
modem_ramdump_dev = create_ramdump_device("modem");
if (!modem_ramdump_dev) {
@@ -396,15 +258,14 @@
goto out;
}
- ret = subsystem_restart_8x60_init();
+ ret = ssr_register_subsystem(&subsys_8660_modem);
out:
return ret;
}
-static void __exit subsystem_fatal_exit(void)
+static void __exit modem_8660_exit(void)
{
free_irq(MARM_WDOG_EXPIRED, NULL);
- free_irq(LPASS_Q6SS_WDOG_EXPIRED, NULL);
}
#ifdef SUBSYS_FATAL_DEBUG
@@ -420,5 +281,6 @@
}
#endif
-module_init(subsystem_fatal_init);
-module_exit(subsystem_fatal_exit);
+module_init(modem_8660_init);
+module_exit(modem_8660_exit);
+