mdm2: Replace hsic platform_add/remove with connect/disconnect
mdm2 driver calls platform add/remove apis to notify hsic about
peripheral(9x15) connection/disconnection. Instead include hsic
connect/disconnect apis to keep mdm driver unaware of hsic
disconnection and discovery logic
Change-Id: I3bbb0d652d60de4bc5941e31eebbd75bb10b69b7
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8960.c b/arch/arm/mach-msm/board-8960.c
index e6ca8e0c..26dd04b 100644
--- a/arch/arm/mach-msm/board-8960.c
+++ b/arch/arm/mach-msm/board-8960.c
@@ -78,6 +78,7 @@
#include <linux/ion.h>
#include <mach/ion.h>
#include <mach/mdm2.h>
+#include <mach/mdm-peripheral.h>
#include <linux/fmem.h>
@@ -2059,6 +2060,33 @@
#endif /* CONFIG_MSM_DSPS */
}
+static int hsic_peripheral_status = 1;
+static DEFINE_MUTEX(hsic_status_lock);
+
+void peripheral_connect()
+{
+ mutex_lock(&hsic_status_lock);
+ if (hsic_peripheral_status)
+ goto out;
+ platform_device_add(&msm_device_hsic_host);
+ hsic_peripheral_status = 1;
+out:
+ mutex_unlock(&hsic_status_lock);
+}
+EXPORT_SYMBOL(peripheral_connect);
+
+void peripheral_disconnect()
+{
+ mutex_lock(&hsic_status_lock);
+ if (!hsic_peripheral_status)
+ goto out;
+ platform_device_del(&msm_device_hsic_host);
+ hsic_peripheral_status = 0;
+out:
+ mutex_unlock(&hsic_status_lock);
+}
+EXPORT_SYMBOL(peripheral_disconnect);
+
static void __init msm8960_init_hsic(void)
{
#ifdef CONFIG_USB_EHCI_MSM_HSIC
diff --git a/arch/arm/mach-msm/include/mach/mdm-peripheral.h b/arch/arm/mach-msm/include/mach/mdm-peripheral.h
new file mode 100644
index 0000000..0f3bd33
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/mdm-peripheral.h
@@ -0,0 +1,19 @@
+/* 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.
+ */
+
+#ifndef _ARCH_ARM_MACH_MSM_MDM_PERIPHERAL_H
+#define _ARCH_ARM_MACH_MSM_MDM_PERIPHERAL_H_
+
+extern void peripheral_connect(void);
+extern void peripheral_disconnect(void);
+
+#endif
diff --git a/arch/arm/mach-msm/mdm2.c b/arch/arm/mach-msm/mdm2.c
index 0737a81..91f8fc2 100644
--- a/arch/arm/mach-msm/mdm2.c
+++ b/arch/arm/mach-msm/mdm2.c
@@ -33,6 +33,7 @@
#include <asm/mach-types.h>
#include <asm/uaccess.h>
#include <mach/mdm2.h>
+#include <mach/mdm-peripheral.h>
#include <mach/restart.h>
#include <mach/subsystem_notif.h>
#include <mach/subsystem_restart.h>
@@ -49,7 +50,6 @@
#define IFLINE_DOWN 0
static int mdm_debug_on;
-static int ifline_status = IFLINE_UP;
static struct mdm_callbacks mdm_cb;
#define MDM_DBG(...) do { if (mdm_debug_on) \
@@ -58,12 +58,7 @@
static void power_on_mdm(struct mdm_modem_drv *mdm_drv)
{
- /* Remove hsic driver before powering on the modem. */
- if (ifline_status == IFLINE_UP) {
- MDM_DBG("%s: Removing hsic device\n", __func__);
- platform_device_del(&msm_device_hsic_host);
- ifline_status = IFLINE_DOWN;
- }
+ peripheral_disconnect();
/* Pull both ERR_FATAL and RESET low */
MDM_DBG("Pulling PWR and RESET gpio's low\n");
@@ -82,10 +77,7 @@
gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1);
usleep(1000);
- /* Add back hsic device after modem power up */
- MDM_DBG("%s: Adding hsic device\n", __func__);
- platform_device_add(&msm_device_hsic_host);
- ifline_status = IFLINE_UP;
+ peripheral_connect();
msleep(200);
}
@@ -111,12 +103,8 @@
msleep(MDM_MODEM_DELTA);
}
}
- /* Also remove the hsic device on 9k power down. */
- MDM_DBG("%s: Removing hsic device\n", __func__);
- if (ifline_status == IFLINE_UP) {
- platform_device_del(&msm_device_hsic_host);
- ifline_status = IFLINE_DOWN;
- }
+
+ peripheral_disconnect();
}
static void normal_boot_done(struct mdm_modem_drv *mdm_drv)