msm: mdm: Remove peripheral callbacks.
Removing and adding mdm peripheral devices are now done within the
the mdm driver. The peripheral device structure must be passed
in via platform data.
Change-Id: I1ed8290392ebda61df49d2bff9e31e488aa4b6b4
Signed-off-by: Joel King <joelking@codeaurora.org>
diff --git a/arch/arm/mach-msm/include/mach/mdm2.h b/arch/arm/mach-msm/include/mach/mdm2.h
index 43ec544..78ca88f 100644
--- a/arch/arm/mach-msm/include/mach/mdm2.h
+++ b/arch/arm/mach-msm/include/mach/mdm2.h
@@ -16,6 +16,7 @@
struct mdm_platform_data {
char *mdm_version;
int ramdump_delay_ms;
+ struct platform_device *peripheral_platform_device;
};
#endif
diff --git a/arch/arm/mach-msm/mdm2.c b/arch/arm/mach-msm/mdm2.c
index 2f2be31..75ea0eb 100644
--- a/arch/arm/mach-msm/mdm2.c
+++ b/arch/arm/mach-msm/mdm2.c
@@ -33,7 +33,6 @@
#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>
@@ -48,10 +47,36 @@
#define MDM_MODEM_DELTA 100
static int mdm_debug_on;
+static int hsic_peripheral_status = 1;
+static DEFINE_MUTEX(hsic_status_lock);
+
+static void mdm_peripheral_connect(struct mdm_modem_drv *mdm_drv)
+{
+ mutex_lock(&hsic_status_lock);
+ if (hsic_peripheral_status)
+ goto out;
+ if (mdm_drv->pdata->peripheral_platform_device)
+ platform_device_add(mdm_drv->pdata->peripheral_platform_device);
+ hsic_peripheral_status = 1;
+out:
+ mutex_unlock(&hsic_status_lock);
+}
+
+static void mdm_peripheral_disconnect(struct mdm_modem_drv *mdm_drv)
+{
+ mutex_lock(&hsic_status_lock);
+ if (!hsic_peripheral_status)
+ goto out;
+ if (mdm_drv->pdata->peripheral_platform_device)
+ platform_device_del(mdm_drv->pdata->peripheral_platform_device);
+ hsic_peripheral_status = 0;
+out:
+ mutex_unlock(&hsic_status_lock);
+}
static void power_on_mdm(struct mdm_modem_drv *mdm_drv)
{
- peripheral_disconnect();
+ mdm_peripheral_disconnect(mdm_drv);
/* Pull both ERR_FATAL and RESET low */
pr_debug("Pulling PWR and RESET gpio's low\n");
@@ -70,7 +95,7 @@
gpio_direction_output(mdm_drv->ap2mdm_kpdpwr_n_gpio, 1);
usleep(1000);
- peripheral_connect();
+ mdm_peripheral_connect(mdm_drv);
msleep(200);
}
@@ -97,7 +122,7 @@
}
}
- peripheral_disconnect();
+ mdm_peripheral_disconnect(mdm_drv);
}
static void debug_state_changed(int value)
@@ -105,13 +130,13 @@
mdm_debug_on = value;
}
-static void mdm_status_changed(int value)
+static void mdm_status_changed(struct mdm_modem_drv *mdm_drv, int value)
{
pr_debug("%s: value:%d\n", __func__, value);
if (value) {
- peripheral_disconnect();
- peripheral_connect();
+ mdm_peripheral_disconnect(mdm_drv);
+ mdm_peripheral_connect(mdm_drv);
}
}
diff --git a/arch/arm/mach-msm/mdm_common.c b/arch/arm/mach-msm/mdm_common.c
index 28159fa..b672957 100644
--- a/arch/arm/mach-msm/mdm_common.c
+++ b/arch/arm/mach-msm/mdm_common.c
@@ -139,7 +139,7 @@
{
int value = gpio_get_value(mdm_drv->mdm2ap_status_gpio);
- mdm_drv->ops->status_cb(value);
+ mdm_drv->ops->status_cb(mdm_drv, value);
pr_debug("%s: status:%d\n", __func__, value);
diff --git a/arch/arm/mach-msm/mdm_private.h b/arch/arm/mach-msm/mdm_private.h
index f0c53a5..206bd8b 100644
--- a/arch/arm/mach-msm/mdm_private.h
+++ b/arch/arm/mach-msm/mdm_private.h
@@ -20,7 +20,7 @@
void (*normal_boot_done_cb)(struct mdm_modem_drv *mdm_drv);
void (*power_down_mdm_cb)(struct mdm_modem_drv *mdm_drv);
void (*debug_state_changed_cb)(int value);
- void (*status_cb)(int value);
+ void (*status_cb)(struct mdm_modem_drv *mdm_drv, int value);
};
/* Private mdm2 data structure */