summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary King <gking@nvidia.com>2010-05-25 16:49:08 -0700
committerGary King <gking@nvidia.com>2010-05-25 16:52:14 -0700
commit00d122d6d2a7cac085554c5655933c1c0e122e88 (patch)
tree952c1879956212642f2fefc79f224df8cf546014
parent61ad8dcf738d41a0b2d5a0a3dc71e3a01b212b32 (diff)
misc: rfkill: add rfkill driver for Murata LBEE9QMBC module
Change-Id: Ib2d277392f9c2e2aa0c3ecb3e3c1f936cd5150b0
-rw-r--r--drivers/misc/Kconfig8
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/lbee9qmb-rfkill.c140
-rw-r--r--include/linux/lbee9qmb-rfkill.h29
4 files changed, 178 insertions, 0 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index c00355bcd097..d6e8760e136b 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -261,6 +261,14 @@ config UID_STAT
bool "UID based statistics tracking exported to /proc/uid_stat"
default n
+config LBEE9QMB_RFKILL
+ tristate "Bluetooth power control driver for Murata lbee9qmbc"
+ depends on RFKILL
+ default n
+ ---help---
+ Creates an rfkill entry in sysfs for power control of
+ Murata lbee9qmbc Bluetooth+WiFi chips.
+
config WL127X_RFKILL
tristate "Bluetooth power control driver for TI wl127x"
depends on RFKILL
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b24537deeef2..a5bb197669df 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -26,5 +26,6 @@ obj-$(CONFIG_UID_STAT) += uid_stat.o
obj-$(CONFIG_C2PORT) += c2port/
obj-y += eeprom/
obj-y += cb710/
+obj-$(CONFIG_LBEE9QMB_RFKILL) += lbee9qmb-rfkill.o
obj-$(CONFIG_WL127X_RFKILL) += wl127x-rfkill.o
obj-$(CONFIG_APANIC) += apanic.o
diff --git a/drivers/misc/lbee9qmb-rfkill.c b/drivers/misc/lbee9qmb-rfkill.c
new file mode 100644
index 000000000000..0042157c7cf2
--- /dev/null
+++ b/drivers/misc/lbee9qmb-rfkill.c
@@ -0,0 +1,140 @@
+/*
+ * Bluetooth+WiFi Murata LBEE19QMBC rfkill power control via GPIO
+ *
+ * Copyright (C) 2010 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/gpio.h>
+#include <linux/rfkill.h>
+#include <linux/delay.h>
+#include <linux/regulator/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/lbee9qmb-rfkill.h>
+
+static int lbee9qmb_rfkill_set_power(void *data, bool blocked)
+{
+ struct platform_device *pdev = data;
+ struct lbee9qmb_platform_data *plat = pdev->dev.platform_data;
+ struct regulator *regulator;
+
+ regulator = regulator_get(&pdev->dev, "Vdd");
+
+ if (IS_ERR(regulator)) {
+ dev_err(&pdev->dev, "Unable to get regulator Vdd\n");
+ return PTR_ERR(regulator);
+ }
+
+ if (!blocked) {
+ regulator_enable(regulator);
+ gpio_set_value(plat->gpio_reset, 0);
+ msleep(5);
+ gpio_set_value(plat->gpio_reset, 1);
+ } else {
+ gpio_set_value(plat->gpio_reset, 0);
+ regulator_disable(regulator);
+ }
+
+ regulator_put(regulator);
+ return 0;
+}
+
+static struct rfkill_ops lbee9qmb_rfkill_ops = {
+ .set_block = lbee9qmb_rfkill_set_power,
+};
+
+static int lbee9qmb_rfkill_probe(struct platform_device *pdev)
+{
+ struct lbee9qmb_platform_data *plat = pdev->dev.platform_data;
+ struct rfkill *rfkill;
+
+ int rc;
+
+ if (!plat) {
+ dev_err(&pdev->dev, "no platform data\n");
+ return -ENOSYS;
+ }
+
+ rc = gpio_request(plat->gpio_reset, "lbee9qmb_reset");
+ if (rc < 0) {
+ dev_err(&pdev->dev, "gpio_request failed\n");
+ return rc;
+ }
+
+ rfkill = rfkill_alloc("lbee9qmb-rfkill", &pdev->dev,
+ RFKILL_TYPE_BLUETOOTH, &lbee9qmb_rfkill_ops, pdev);
+ if (!rfkill) {
+ rc = -ENOMEM;
+ goto fail_gpio;
+ }
+ platform_set_drvdata(pdev, rfkill);
+ gpio_direction_output(plat->gpio_reset, 0);
+
+ rc = rfkill_register(rfkill);
+ if (rc < 0)
+ goto fail_alloc;
+
+ return 0;
+
+fail_alloc:
+ rfkill_destroy(rfkill);
+fail_gpio:
+ gpio_free(plat->gpio_reset);
+ return rc;
+
+}
+
+static int lbee9qmb_rfkill_remove(struct platform_device *pdev)
+{
+ struct lbee9qmb_platform_data *plat = pdev->dev.platform_data;
+ struct rfkill *rfkill = platform_get_drvdata(pdev);
+
+ rfkill_unregister(rfkill);
+ rfkill_destroy(rfkill);
+ gpio_free(plat->gpio_reset);
+
+ return 0;
+
+}
+
+static struct platform_driver lbee9qmb_rfkill_driver = {
+ .probe = lbee9qmb_rfkill_probe,
+ .remove = lbee9qmb_rfkill_remove,
+ .driver = {
+ .name = "lbee9qmb-rfkill",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init lbee9qmb_rfkill_init(void)
+{
+ return platform_driver_register(&lbee9qmb_rfkill_driver);
+}
+
+static void __exit lbee9qmb_rfkill_exit(void)
+{
+ platform_driver_unregister(&lbee9qmb_rfkill_driver);
+}
+
+module_init(lbee9qmb_rfkill_init);
+module_exit(lbee9qmb_rfkill_exit);
+
+MODULE_DESCRIPTION("Murata LBEE9QMBC rfkill");
+MODULE_AUTHOR("NVIDIA");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/lbee9qmb-rfkill.h b/include/linux/lbee9qmb-rfkill.h
new file mode 100644
index 000000000000..24db7d495242
--- /dev/null
+++ b/include/linux/lbee9qmb-rfkill.h
@@ -0,0 +1,29 @@
+/*
+ * Bluetooth+WiFi Murata LBEE19QMBC rfkill power control via GPIO
+ *
+ * Copyright (C) 2010 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __LBEE9QMB_RFKILL_H
+#define __LBEE9QMB_RFKILL_H
+
+struct lbee9qmb_platform_data {
+ int gpio_reset;
+};
+
+#endif