linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Raghuram Hegde <raghuram.hegde@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com,
	sukumar.ghorai@intel.com, amit.k.bag@intel.com
Subject: [PATCH 1/2] Bluetooth: btintel: Add platform device for rfkill signal
Date: Tue, 21 Aug 2018 15:04:39 +0530	[thread overview]
Message-ID: <1534844080-31240-1-git-send-email-raghuram.hegde@intel.com> (raw)

From: Sukumar Ghorai <sukumar.ghorai@intel.com>

Driver to add INTL6205 platform ACPI device to enable out
of band GPIO signalling to handle rfkill and reset the
bluetooth controller. Expose an interface in kernel to
assert GPIO signal.

Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Sukumar Ghorai <sukumar.ghorai@intel.com>
Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com>
---
 drivers/bluetooth/btintel.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btintel.h |  6 ++++
 2 files changed, 74 insertions(+)

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 5270d5513201..538cd6b6c524 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -24,6 +24,9 @@
 #include <linux/module.h>
 #include <linux/firmware.h>
 #include <linux/regmap.h>
+#include <linux/acpi.h>
+#include <linux/platform_device.h>
+#include <linux/gpio/consumer.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -375,6 +378,71 @@ int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver)
 }
 EXPORT_SYMBOL_GPL(btintel_read_version);
 
+static struct gpio_desc *reset_gpio_handler;
+void btintel_reset_bt(struct hci_dev *hdev, unsigned char code)
+{
+	if (!reset_gpio_handler)
+		return;
+
+	gpiod_set_value(reset_gpio_handler, 0);
+	mdelay(100);
+	gpiod_set_value(reset_gpio_handler, 1);
+}
+EXPORT_SYMBOL_GPL(btintel_reset_bt);
+
+static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
+static const struct acpi_gpio_mapping acpi_btintel_gpios[] = {
+	{ "reset-gpios", &reset_gpios, 1 },
+	{ },
+};
+
+static int btintel_probe(struct platform_device *pdev)
+{
+	struct device *hdev;
+
+	hdev = devm_kzalloc(&pdev->dev, sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
+	if (!ACPI_HANDLE(&pdev->dev))
+		return -ENODEV;
+
+	if (acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
+				     acpi_btintel_gpios))
+		return -EINVAL;
+
+	reset_gpio_handler = devm_gpiod_get_optional(&pdev->dev,
+					"reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(reset_gpio_handler))
+		return PTR_ERR(reset_gpio_handler);
+
+	return 0;
+}
+
+static int btintel_remove(struct platform_device *pdev)
+{
+	acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
+	return 0;
+}
+
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id btintel_acpi_match[] = {
+	{ "INTL6205", 0 },
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, btintel_acpi_match);
+#endif
+
+static struct platform_driver btintel_driver = {
+	.probe = btintel_probe,
+	.remove = btintel_remove,
+	.driver = {
+		.name = "btintel",
+		.acpi_match_table = ACPI_PTR(btintel_acpi_match),
+	},
+};
+module_platform_driver(btintel_driver);
+
 /* ------- REGMAP IBT SUPPORT ------- */
 
 #define IBT_REG_MODE_8BIT  0x00
diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
index 41c642cc523f..7686fab52054 100644
--- a/drivers/bluetooth/btintel.h
+++ b/drivers/bluetooth/btintel.h
@@ -94,6 +94,7 @@ int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name);
 int btintel_set_event_mask(struct hci_dev *hdev, bool debug);
 int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug);
 int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver);
+void btintel_reset_bt(struct hci_dev *hdev, unsigned char code);
 
 struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
 				   u16 opcode_write);
@@ -171,6 +172,11 @@ static inline int btintel_read_version(struct hci_dev *hdev,
 	return -EOPNOTSUPP;
 }
 
+static inline void btintel_reset_bt(struct hci_dev *hdev, unsigned char code)
+{
+	return -EOPNOTSUPP;
+}
+
 static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev,
 						 u16 opcode_read,
 						 u16 opcode_write)
-- 
2.7.4

             reply	other threads:[~2018-08-21  9:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21  9:34 Raghuram Hegde [this message]
2018-08-21  9:34 ` [PATCH 2/2] Bluletooth: Add hardware reset callback to reset intel bluetooth chip Raghuram Hegde
2018-08-21 14:14   ` Marcel Holtmann
2018-08-21 14:42     ` chethan tn
2018-08-21 14:13 ` [PATCH 1/2] Bluetooth: btintel: Add platform device for rfkill signal Marcel Holtmann
2018-08-21 14:58   ` chethan tn
2018-08-21 15:09     ` Marcel Holtmann
2018-09-11  4:45       ` chethan tn
2018-09-11  5:13         ` Hegde, Raghuram
2018-09-27 10:44           ` Marcel Holtmann
2018-08-21 14:54 ` kbuild test robot
2018-08-21 16:55 ` kbuild test robot
2018-08-21 16:55 ` [PATCH] Bluetooth: btintel: fix ptr_ret.cocci warnings kbuild test robot
2018-08-21 20:20   ` Marcel Holtmann
2018-08-22  1:52     ` [kbuild-all] " Li, Philip
2018-08-22  2:00     ` Fengguang Wu
2018-08-22  1:59 ` Fengguang Wu
2018-08-22  6:08   ` Marcel Holtmann
2018-08-22  6:35     ` Fengguang Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1534844080-31240-1-git-send-email-raghuram.hegde@intel.com \
    --to=raghuram.hegde@intel.com \
    --cc=amit.k.bag@intel.com \
    --cc=chethan.tumkur.narayan@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=sukumar.ghorai@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).