summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorRaj Jayaraman <rjayaraman@nvidia.com>2011-10-14 13:32:31 -0700
committerVarun Wadekar <vwadekar@nvidia.com>2011-12-15 11:50:01 +0530
commit95c407fe0fc62de80cf15d7a68112ded47593a13 (patch)
tree9e68850d421d3e7c4c94a106d4fd5411966c069c /drivers/misc
parent07b1a0d342f49215f5e6ce72fe6142b0bc026ff9 (diff)
misc: tegra-baseband: Add support for M7400 modem.
Bug 878736 Bug 886459 (cherry picked from commit 6f6a3b6759f95b833a3c98ee45015592f388b161) Signed-off-by: Raj Jayaraman <rjayaraman@nvidia.com> Change-Id: Ieb5e9313ad9d6a32a813dadd911f448d8b334b42 Reviewed-on: http://git-master/r/68289 Reviewed-by: Rajkumar Jayaraman <rjayaraman@nvidia.com> Tested-by: Rajkumar Jayaraman <rjayaraman@nvidia.com> Reviewed-by: Steve Lin <stlin@nvidia.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/tegra-baseband/Kconfig7
-rw-r--r--drivers/misc/tegra-baseband/Makefile1
-rw-r--r--drivers/misc/tegra-baseband/bb-m7400.c145
-rw-r--r--drivers/misc/tegra-baseband/bb-power.c10
-rw-r--r--drivers/misc/tegra-baseband/bb-power.h10
5 files changed, 169 insertions, 4 deletions
diff --git a/drivers/misc/tegra-baseband/Kconfig b/drivers/misc/tegra-baseband/Kconfig
index 53147ec3c9fe..1f116918296f 100644
--- a/drivers/misc/tegra-baseband/Kconfig
+++ b/drivers/misc/tegra-baseband/Kconfig
@@ -22,4 +22,11 @@ config TEGRA_BB_POWER
Disabled by default. Choose Y here if you want to build the driver.
+config TEGRA_BB_M7400
+ bool "Enable driver for M7400 modem"
+ ---help---
+ Enables driver for M7400 modem.
+
+ Disabled by default. Choose Y here if you want to build the driver.
+
endif # TEGRA_BB_SUPPORT
diff --git a/drivers/misc/tegra-baseband/Makefile b/drivers/misc/tegra-baseband/Makefile
index 54414d6b2016..a95d84dbf117 100644
--- a/drivers/misc/tegra-baseband/Makefile
+++ b/drivers/misc/tegra-baseband/Makefile
@@ -3,3 +3,4 @@
#
obj-$(CONFIG_TEGRA_BB_POWER) += bb-power.o
+obj-$(CONFIG_TEGRA_BB_M7400) += bb-m7400.o
diff --git a/drivers/misc/tegra-baseband/bb-m7400.c b/drivers/misc/tegra-baseband/bb-m7400.c
new file mode 100644
index 000000000000..4ab705732b27
--- /dev/null
+++ b/drivers/misc/tegra-baseband/bb-m7400.c
@@ -0,0 +1,145 @@
+/*
+ * drivers/misc/tegra-baseband/bb-m7400.c
+ *
+ * Copyright (c) 2011, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/resource.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <linux/usb.h>
+#include <linux/wakelock.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <mach/tegra-bb-power.h>
+#include "bb-power.h"
+
+static struct tegra_bb_gpio_data m7400_gpios[] = {
+ { { GPIO_INVALID, GPIOF_OUT_INIT_LOW, "MDM_PWR_ON" }, true },
+ { { GPIO_INVALID, GPIOF_IN, "MDM_PWRSTATUS" }, true },
+ { { GPIO_INVALID, GPIOF_IN, "MDM_SERVICE" }, true },
+ { { GPIO_INVALID, GPIOF_OUT_INIT_HIGH, "MDM_USB_AWR" }, false },
+ { { GPIO_INVALID, GPIOF_IN, "MDM_USB_CWR" }, false },
+ { { GPIO_INVALID, GPIOF_IN, "MDM_RESOUT2" }, true },
+ { { GPIO_INVALID, 0, NULL }, false }, /* End of table */
+};
+
+static int gpio_wait_timeout(int gpio, int value, int timeout_msec)
+{
+ int count;
+ for (count = 0; count < timeout_msec; ++count) {
+ if (gpio_get_value(gpio) == value)
+ return 0;
+ mdelay(1);
+ }
+ return -1;
+}
+
+static int baseband_l3_suspend(void)
+{
+ int gpio_awr = m7400_gpios[3].data.gpio;
+
+ /* Signal L3 to modem - Drive USB_AWR low. */
+ gpio_set_value(gpio_awr, 0);
+
+ return 0;
+}
+
+static int baseband_l3_resume(void)
+{
+ int gpio_awr = m7400_gpios[3].data.gpio;
+ int gpio_cwr = m7400_gpios[4].data.gpio;
+
+ /* Signal L0 to modem - Drive USB_AWR high. */
+ gpio_set_value(gpio_awr, 1);
+
+ /* If this is a AP driven wakeup, wait for CP
+ to ack by driving USB_CWR high.
+ If this is a CP driven wakeup, USB_CWR will
+ be high already. AP has already driven it's
+ response as above.
+ */
+ if (gpio_wait_timeout(gpio_cwr, 1, 10) != 0)
+ pr_info("%s: timeout waiting for modem ack.\n", __func__);
+
+ return 0;
+}
+
+static irqreturn_t baseband_wake_irq(int irq, void *dev_id)
+{
+ pr_info("%s {\n", __func__);
+
+ /* Resume usb host activity. */
+ /* TBD */
+
+ return IRQ_HANDLED;
+}
+
+int m7400_power_callback(int code)
+{
+ switch (code) {
+ case CB_CODE_L0L2:
+ break;
+ case CB_CODE_L2L0:
+ break;
+ case CB_CODE_L2L3:
+ baseband_l3_suspend();
+ break;
+ case CB_CODE_L3L0:
+ baseband_l3_resume();
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+
+static struct tegra_bb_gpio_irqdata m7400_gpioirqs[] = {
+ { GPIO_INVALID, "tegra_bb_wake", baseband_wake_irq,
+ IRQF_TRIGGER_RISING, NULL },
+ { GPIO_INVALID, NULL, NULL, 0, NULL }, /* End of table */
+};
+
+static struct tegra_bb_power_gdata m7400_gdata = {
+ .gpio = m7400_gpios,
+ .gpioirq = m7400_gpioirqs,
+};
+
+void *m7400_init(void *pdata, int code)
+{
+ struct tegra_bb_pdata *platdata = (struct tegra_bb_pdata *) pdata;
+ union tegra_bb_gpio_id *id = platdata->id;
+
+ if (code == CB_CODE_INIT) {
+ /* Fill the gpio ids allocated by hardware */
+ m7400_gpios[0].data.gpio = id->m7400.pwr_on;
+ m7400_gpios[1].data.gpio = id->m7400.pwr_status;
+ m7400_gpios[2].data.gpio = id->m7400.service;
+ m7400_gpios[3].data.gpio = id->m7400.usb_awr;
+ m7400_gpios[4].data.gpio = id->m7400.usb_cwr;
+ m7400_gpios[5].data.gpio = id->m7400.resout2;
+ m7400_gpioirqs[0].id = id->m7400.usb_cwr;
+ }
+
+ return (void *) &m7400_gdata;
+}
diff --git a/drivers/misc/tegra-baseband/bb-power.c b/drivers/misc/tegra-baseband/bb-power.c
index cc1d0de7ebcf..f0d40964cdbb 100644
--- a/drivers/misc/tegra-baseband/bb-power.c
+++ b/drivers/misc/tegra-baseband/bb-power.c
@@ -37,14 +37,14 @@ static bb_init_cb init_cb_list[] = {
NULL,
NULL,
NULL,
- NULL,
+ M7400_INIT_CB,
};
static bb_power_cb power_cb_list[] = {
NULL,
NULL,
NULL,
- NULL,
+ M7400_PWR_CB,
};
static int tegra_bb_power_gpio_init(struct tegra_bb_power_gdata *gdata)
@@ -205,7 +205,8 @@ static int tegra_bb_power_probe(struct platform_device *device)
/* BB specific callback */
bb_id = pdata->bb_id;
if (init_cb_list[bb_id] != NULL) {
- gdata = init_cb_list[pdata->bb_id](pdata, CB_CODE_INIT);
+ gdata = (struct tegra_bb_power_gdata *)
+ init_cb_list[pdata->bb_id]((void *)pdata, CB_CODE_INIT);
if (!gdata) {
pr_err("%s - Error: Gpio data is empty.\n", __func__);
@@ -237,7 +238,8 @@ static int tegra_bb_power_remove(struct platform_device *device)
/* BB specific callback */
if (init_cb_list[bb_id] != NULL) {
pdata = (struct tegra_bb_pdata *) dev->platform_data;
- gdata = init_cb_list[bb_id](pdata, CB_CODE_DEINIT);
+ gdata = (struct tegra_bb_power_gdata *)
+ init_cb_list[bb_id]((void *)pdata, CB_CODE_DEINIT);
/* Deinitialize gpios */
if (gdata)
diff --git a/drivers/misc/tegra-baseband/bb-power.h b/drivers/misc/tegra-baseband/bb-power.h
index dfa7496219de..54cf1addf237 100644
--- a/drivers/misc/tegra-baseband/bb-power.h
+++ b/drivers/misc/tegra-baseband/bb-power.h
@@ -44,3 +44,13 @@ struct tegra_bb_power_gdata {
typedef void* (*bb_init_cb)(void *pdata, int code);
typedef int (*bb_power_cb)(int code);
+
+#ifdef CONFIG_TEGRA_BB_M7400
+extern void *m7400_init(void *pdata, int code);
+#define M7400_INIT_CB m7400_init
+extern int m7400_power_callback(int code);
+#define M7400_PWR_CB m7400_power_callback
+#else
+#define M7400_INIT_CB NULL
+#define M7400_PWR_CB NULL
+#endif