* [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison
@ 2017-03-30 10:04 Andy Shevchenko
2017-03-31 10:07 ` [tip:x86/platform] x86/platform/intel-mid: Enable Bluetooth support " tip-bot for Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-30 10:04 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, linux-kernel
Cc: Andy Shevchenko
Intel Edison has Wi-Fi + BT module attached and, since it's an SFI-enumerated
platform, needs a platform data. Here we add bits to enable bluetooth device.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/platform/intel-mid/device_libs/Makefile | 3 +-
.../platform/intel-mid/device_libs/platform_bt.c | 108 +++++++++++++++++++++
2 files changed, 110 insertions(+), 1 deletion(-)
create mode 100644 arch/x86/platform/intel-mid/device_libs/platform_bt.c
diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile
index 3dbde04febdc..53e0235e308f 100644
--- a/arch/x86/platform/intel-mid/device_libs/Makefile
+++ b/arch/x86/platform/intel-mid/device_libs/Makefile
@@ -2,8 +2,9 @@
obj-$(subst m,y,$(CONFIG_PINCTRL_MERRIFIELD)) += platform_mrfld_pinctrl.o
# SDHCI Devices
obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += platform_mrfld_sd.o
-# WiFi
+# WiFi + BT
obj-$(subst m,y,$(CONFIG_BRCMFMAC_SDIO)) += platform_bcm43xx.o
+obj-$(subst m,y,$(CONFIG_BT_HCIUART_BCM)) += platform_bt.o
# IPC Devices
obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic.o
obj-$(subst m,y,$(CONFIG_SND_MFLD_MACHINE)) += platform_msic_audio.o
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bt.c b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
new file mode 100644
index 000000000000..5a0483e7bf66
--- /dev/null
+++ b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
@@ -0,0 +1,108 @@
+/*
+ * Bluetooth platform data initialization file
+ *
+ * (C) Copyright 2017 Intel Corporation
+ * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *
+ * 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; version 2
+ * of the License.
+ */
+
+#include <linux/gpio/machine.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>
+#include <asm/intel-mid.h>
+
+struct bt_sfi_data {
+ struct device *dev;
+ const char *name;
+ int (*setup)(struct bt_sfi_data *ddata);
+};
+
+static struct gpiod_lookup_table tng_bt_sfi_gpio_table = {
+ .dev_id = "hci_bcm",
+ .table = {
+ GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup", GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown", GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup", GPIO_ACTIVE_HIGH),
+ { },
+ },
+};
+
+#define TNG_BT_SFI_GPIO_DEVICE_WAKEUP "bt_wakeup"
+#define TNG_BT_SFI_GPIO_SHUTDOWN "BT-reset"
+#define TNG_BT_SFI_GPIO_HOST_WAKEUP "bt_uart_enable"
+
+static int __init tng_bt_sfi_setup(struct bt_sfi_data *ddata)
+{
+ struct gpiod_lookup_table *table = &tng_bt_sfi_gpio_table;
+ struct gpiod_lookup *lookup = table->table;
+ struct pci_dev *pdev;
+
+ /* Connected to /dev/ttyS0 */
+ pdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(4, 1));
+ if (!pdev)
+ return -ENODEV;
+
+ ddata->dev = &pdev->dev;
+ ddata->name = table->dev_id;
+
+ lookup[0].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_DEVICE_WAKEUP);
+ lookup[1].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_SHUTDOWN);
+ lookup[2].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_HOST_WAKEUP);
+
+ gpiod_add_lookup_table(table);
+ return 0;
+}
+
+static struct bt_sfi_data tng_bt_sfi_data __initdata = {
+ .setup = tng_bt_sfi_setup,
+};
+
+#define ICPU(model, ddata) \
+ { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (kernel_ulong_t)&ddata }
+
+static const struct x86_cpu_id bt_sfi_cpu_ids[] = {
+ ICPU(INTEL_FAM6_ATOM_MERRIFIELD, tng_bt_sfi_data),
+ {}
+};
+
+static int __init bt_sfi_init(void)
+{
+ struct platform_device_info info;
+ struct platform_device *pdev;
+ const struct x86_cpu_id *id;
+ struct bt_sfi_data *ddata;
+ int ret;
+
+ id = x86_match_cpu(bt_sfi_cpu_ids);
+ if (!id)
+ return -ENODEV;
+
+ ddata = (struct bt_sfi_data *)id->driver_data;
+ if (!ddata)
+ return -ENODEV;
+
+ ret = ddata->setup(ddata);
+ if (ret)
+ return ret;
+
+ memset(&info, 0, sizeof(info));
+ info.fwnode = ddata->dev->fwnode;
+ info.parent = ddata->dev;
+ info.name = ddata->name,
+ info.id = PLATFORM_DEVID_NONE,
+
+ pdev = platform_device_register_full(&info);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
+ dev_info(ddata->dev, "Registered Bluetooth device: %s\n", ddata->name);
+ return 0;
+}
+device_initcall(bt_sfi_init);
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [tip:x86/platform] x86/platform/intel-mid: Enable Bluetooth support on Intel Edison
2017-03-30 10:04 [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison Andy Shevchenko
@ 2017-03-31 10:07 ` tip-bot for Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Andy Shevchenko @ 2017-03-31 10:07 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, linux-kernel, peterz, andriy.shevchenko, hpa, torvalds, mingo
Commit-ID: d4d969909bef4c1e103eec0fc2c820773811fb72
Gitweb: http://git.kernel.org/tip/d4d969909bef4c1e103eec0fc2c820773811fb72
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Thu, 30 Mar 2017 13:04:43 +0300
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 31 Mar 2017 08:06:29 +0200
x86/platform/intel-mid: Enable Bluetooth support on Intel Edison
Intel Edison has Wi-Fi + BT module attached and, since it's an SFI-enumerated
platform, needs platform data. Here we add bits to enable the Bluetooth device.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170330100443.22701-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/platform/intel-mid/device_libs/Makefile | 3 +-
.../platform/intel-mid/device_libs/platform_bt.c | 108 +++++++++++++++++++++
2 files changed, 110 insertions(+), 1 deletion(-)
diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile
index a7dbec4..36f0fdf 100644
--- a/arch/x86/platform/intel-mid/device_libs/Makefile
+++ b/arch/x86/platform/intel-mid/device_libs/Makefile
@@ -2,8 +2,9 @@
obj-$(subst m,y,$(CONFIG_PINCTRL_MERRIFIELD)) += platform_mrfld_pinctrl.o
# SDHCI Devices
obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += platform_mrfld_sd.o
-# WiFi
+# WiFi + BT
obj-$(subst m,y,$(CONFIG_BRCMFMAC_SDIO)) += platform_bcm43xx.o
+obj-$(subst m,y,$(CONFIG_BT_HCIUART_BCM)) += platform_bt.o
# IPC Devices
obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic.o
obj-$(subst m,y,$(CONFIG_SND_MFLD_MACHINE)) += platform_msic_audio.o
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bt.c b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
new file mode 100644
index 0000000..5a0483e
--- /dev/null
+++ b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
@@ -0,0 +1,108 @@
+/*
+ * Bluetooth platform data initialization file
+ *
+ * (C) Copyright 2017 Intel Corporation
+ * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *
+ * 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; version 2
+ * of the License.
+ */
+
+#include <linux/gpio/machine.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>
+#include <asm/intel-mid.h>
+
+struct bt_sfi_data {
+ struct device *dev;
+ const char *name;
+ int (*setup)(struct bt_sfi_data *ddata);
+};
+
+static struct gpiod_lookup_table tng_bt_sfi_gpio_table = {
+ .dev_id = "hci_bcm",
+ .table = {
+ GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup", GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown", GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup", GPIO_ACTIVE_HIGH),
+ { },
+ },
+};
+
+#define TNG_BT_SFI_GPIO_DEVICE_WAKEUP "bt_wakeup"
+#define TNG_BT_SFI_GPIO_SHUTDOWN "BT-reset"
+#define TNG_BT_SFI_GPIO_HOST_WAKEUP "bt_uart_enable"
+
+static int __init tng_bt_sfi_setup(struct bt_sfi_data *ddata)
+{
+ struct gpiod_lookup_table *table = &tng_bt_sfi_gpio_table;
+ struct gpiod_lookup *lookup = table->table;
+ struct pci_dev *pdev;
+
+ /* Connected to /dev/ttyS0 */
+ pdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(4, 1));
+ if (!pdev)
+ return -ENODEV;
+
+ ddata->dev = &pdev->dev;
+ ddata->name = table->dev_id;
+
+ lookup[0].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_DEVICE_WAKEUP);
+ lookup[1].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_SHUTDOWN);
+ lookup[2].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_HOST_WAKEUP);
+
+ gpiod_add_lookup_table(table);
+ return 0;
+}
+
+static struct bt_sfi_data tng_bt_sfi_data __initdata = {
+ .setup = tng_bt_sfi_setup,
+};
+
+#define ICPU(model, ddata) \
+ { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (kernel_ulong_t)&ddata }
+
+static const struct x86_cpu_id bt_sfi_cpu_ids[] = {
+ ICPU(INTEL_FAM6_ATOM_MERRIFIELD, tng_bt_sfi_data),
+ {}
+};
+
+static int __init bt_sfi_init(void)
+{
+ struct platform_device_info info;
+ struct platform_device *pdev;
+ const struct x86_cpu_id *id;
+ struct bt_sfi_data *ddata;
+ int ret;
+
+ id = x86_match_cpu(bt_sfi_cpu_ids);
+ if (!id)
+ return -ENODEV;
+
+ ddata = (struct bt_sfi_data *)id->driver_data;
+ if (!ddata)
+ return -ENODEV;
+
+ ret = ddata->setup(ddata);
+ if (ret)
+ return ret;
+
+ memset(&info, 0, sizeof(info));
+ info.fwnode = ddata->dev->fwnode;
+ info.parent = ddata->dev;
+ info.name = ddata->name,
+ info.id = PLATFORM_DEVID_NONE,
+
+ pdev = platform_device_register_full(&info);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
+ dev_info(ddata->dev, "Registered Bluetooth device: %s\n", ddata->name);
+ return 0;
+}
+device_initcall(bt_sfi_init);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison
2017-03-30 9:54 ` Ingo Molnar
@ 2017-03-30 10:34 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-30 10:34 UTC (permalink / raw)
To: Ingo Molnar
Cc: Andy Shevchenko, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
x86, linux-kernel
On Thu, Mar 30, 2017 at 12:54 PM, Ingo Molnar <mingo@kernel.org> wrote:
>> > Minor nit: just out of general principle (because the rest of the code
>> > looks so
>> > nice) I'd properly tabulate the last column as well - something like:
>> >
>> > GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup",
>> > GPIO_ACTIVE_HIGH),
>> > GPIO_LOOKUP("0000:00:0c.0", -1,
>> > "shutdown", GPIO_ACTIVE_HIGH),
>> > GPIO_LOOKUP("0000:00:0c.0", -1, "host-
>> > wakeup", GPIO_ACTIVE_HIGH),
>> >
>> > Formatted that way the reviewer's eye can skip over those values in
>> > 100
>> > milliseconds, determining that all 3 values are GPIO_ACTIVE_HIGH.
>>
>> Thanks for a hint.
>> Should I resend it?
>
> Yeah, please send a v2.
Sent and just noticed I forgot to increase version number.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison
2017-03-30 9:44 ` Andy Shevchenko
@ 2017-03-30 9:54 ` Ingo Molnar
2017-03-30 10:34 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2017-03-30 9:54 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
* Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Thu, 2017-03-30 at 09:23 +0200, Ingo Molnar wrote:
> > * Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >
> > > Intel Edison has Wi-Fi + BT module attached and, since it's an SFI-
> > > enumerated
> > > platform, needs a platform data. Here we add bits to enable
> > > bluetooth device.
>
> > > +
> > > +static struct gpiod_lookup_table tng_bt_sfi_gpio_table = {
> > > + .dev_id = "hci_bcm",
> > > + .table = {
> > > + GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup",
> > > GPIO_ACTIVE_HIGH),
> > > + GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown",
> > > GPIO_ACTIVE_HIGH),
> > > + GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup",
> > > GPIO_ACTIVE_HIGH),
> >
> > Minor nit: just out of general principle (because the rest of the code
> > looks so
> > nice) I'd properly tabulate the last column as well - something like:
> >
> > GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup",
> > GPIO_ACTIVE_HIGH),
> > GPIO_LOOKUP("0000:00:0c.0", -1,
> > "shutdown", GPIO_ACTIVE_HIGH),
> > GPIO_LOOKUP("0000:00:0c.0", -1, "host-
> > wakeup", GPIO_ACTIVE_HIGH),
> >
> > Formatted that way the reviewer's eye can skip over those values in
> > 100
> > milliseconds, determining that all 3 values are GPIO_ACTIVE_HIGH.
>
> Thanks for a hint.
> Should I resend it?
Yeah, please send a v2.
Thanks!
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison
2017-03-30 7:23 ` Ingo Molnar
@ 2017-03-30 9:44 ` Andy Shevchenko
2017-03-30 9:54 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-30 9:44 UTC (permalink / raw)
To: Ingo Molnar
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
On Thu, 2017-03-30 at 09:23 +0200, Ingo Molnar wrote:
> * Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > Intel Edison has Wi-Fi + BT module attached and, since it's an SFI-
> > enumerated
> > platform, needs a platform data. Here we add bits to enable
> > bluetooth device.
> > +
> > +static struct gpiod_lookup_table tng_bt_sfi_gpio_table = {
> > + .dev_id = "hci_bcm",
> > + .table = {
> > + GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup",
> > GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown",
> > GPIO_ACTIVE_HIGH),
> > + GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup",
> > GPIO_ACTIVE_HIGH),
>
> Minor nit: just out of general principle (because the rest of the code
> looks so
> nice) I'd properly tabulate the last column as well - something like:
>
> GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup",
> GPIO_ACTIVE_HIGH),
> GPIO_LOOKUP("0000:00:0c.0", -1,
> "shutdown", GPIO_ACTIVE_HIGH),
> GPIO_LOOKUP("0000:00:0c.0", -1, "host-
> wakeup", GPIO_ACTIVE_HIGH),
>
> Formatted that way the reviewer's eye can skip over those values in
> 100
> milliseconds, determining that all 3 values are GPIO_ACTIVE_HIGH.
Thanks for a hint.
Should I resend it?
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison
2017-03-29 14:18 [PATCH v1] x86/platform/intel-mid: Enable bluetooth " Andy Shevchenko
@ 2017-03-30 7:23 ` Ingo Molnar
2017-03-30 9:44 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2017-03-30 7:23 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
* Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> Intel Edison has Wi-Fi + BT module attached and, since it's an SFI-enumerated
> platform, needs a platform data. Here we add bits to enable bluetooth device.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> arch/x86/platform/intel-mid/device_libs/Makefile | 3 +-
> .../platform/intel-mid/device_libs/platform_bt.c | 108 +++++++++++++++++++++
> 2 files changed, 110 insertions(+), 1 deletion(-)
> create mode 100644 arch/x86/platform/intel-mid/device_libs/platform_bt.c
>
> diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile
> index 3dbde04febdc..53e0235e308f 100644
> --- a/arch/x86/platform/intel-mid/device_libs/Makefile
> +++ b/arch/x86/platform/intel-mid/device_libs/Makefile
> @@ -2,8 +2,9 @@
> obj-$(subst m,y,$(CONFIG_PINCTRL_MERRIFIELD)) += platform_mrfld_pinctrl.o
> # SDHCI Devices
> obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += platform_mrfld_sd.o
> -# WiFi
> +# WiFi + BT
> obj-$(subst m,y,$(CONFIG_BRCMFMAC_SDIO)) += platform_bcm43xx.o
> +obj-$(subst m,y,$(CONFIG_BT_HCIUART_BCM)) += platform_bt.o
> # IPC Devices
> obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic.o
> obj-$(subst m,y,$(CONFIG_SND_MFLD_MACHINE)) += platform_msic_audio.o
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bt.c b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
> new file mode 100644
> index 000000000000..b8dcf7190e63
> --- /dev/null
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
> @@ -0,0 +1,108 @@
> +/*
> + * Bluetooth platform data initialization file
> + *
> + * (C) Copyright 2017 Intel Corporation
> + * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> + *
> + * 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; version 2
> + * of the License.
> + */
> +
> +#include <linux/gpio/machine.h>
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
> +
> +#include <asm/cpu_device_id.h>
> +#include <asm/intel-family.h>
> +#include <asm/intel-mid.h>
> +
> +struct bt_sfi_data {
> + struct device *dev;
> + const char *name;
> + int (*setup)(struct bt_sfi_data *ddata);
> +};
> +
> +static struct gpiod_lookup_table tng_bt_sfi_gpio_table = {
> + .dev_id = "hci_bcm",
> + .table = {
> + GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown", GPIO_ACTIVE_HIGH),
> + GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup", GPIO_ACTIVE_HIGH),
Minor nit: just out of general principle (because the rest of the code looks so
nice) I'd properly tabulate the last column as well - something like:
GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup", GPIO_ACTIVE_HIGH),
Formatted that way the reviewer's eye can skip over those values in 100
milliseconds, determining that all 3 values are GPIO_ACTIVE_HIGH.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison
@ 2017-03-29 14:18 Andy Shevchenko
2017-03-30 7:23 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-29 14:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
Cc: Andy Shevchenko
Intel Edison has Wi-Fi + BT module attached and, since it's an SFI-enumerated
platform, needs a platform data. Here we add bits to enable bluetooth device.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/platform/intel-mid/device_libs/Makefile | 3 +-
.../platform/intel-mid/device_libs/platform_bt.c | 108 +++++++++++++++++++++
2 files changed, 110 insertions(+), 1 deletion(-)
create mode 100644 arch/x86/platform/intel-mid/device_libs/platform_bt.c
diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile
index 3dbde04febdc..53e0235e308f 100644
--- a/arch/x86/platform/intel-mid/device_libs/Makefile
+++ b/arch/x86/platform/intel-mid/device_libs/Makefile
@@ -2,8 +2,9 @@
obj-$(subst m,y,$(CONFIG_PINCTRL_MERRIFIELD)) += platform_mrfld_pinctrl.o
# SDHCI Devices
obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += platform_mrfld_sd.o
-# WiFi
+# WiFi + BT
obj-$(subst m,y,$(CONFIG_BRCMFMAC_SDIO)) += platform_bcm43xx.o
+obj-$(subst m,y,$(CONFIG_BT_HCIUART_BCM)) += platform_bt.o
# IPC Devices
obj-$(subst m,y,$(CONFIG_MFD_INTEL_MSIC)) += platform_msic.o
obj-$(subst m,y,$(CONFIG_SND_MFLD_MACHINE)) += platform_msic_audio.o
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bt.c b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
new file mode 100644
index 000000000000..b8dcf7190e63
--- /dev/null
+++ b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
@@ -0,0 +1,108 @@
+/*
+ * Bluetooth platform data initialization file
+ *
+ * (C) Copyright 2017 Intel Corporation
+ * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *
+ * 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; version 2
+ * of the License.
+ */
+
+#include <linux/gpio/machine.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>
+#include <asm/intel-mid.h>
+
+struct bt_sfi_data {
+ struct device *dev;
+ const char *name;
+ int (*setup)(struct bt_sfi_data *ddata);
+};
+
+static struct gpiod_lookup_table tng_bt_sfi_gpio_table = {
+ .dev_id = "hci_bcm",
+ .table = {
+ GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup", GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown", GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup", GPIO_ACTIVE_HIGH),
+ { },
+ },
+};
+
+#define TNG_BT_SFI_GPIO_DEVICE_WAKEUP "bt_wakeup"
+#define TNG_BT_SFI_GPIO_SHUTDOWN "BT-reset"
+#define TNG_BT_SFI_GPIO_HOST_WAKEUP "bt_uart_enable"
+
+static int __init tng_bt_sfi_setup(struct bt_sfi_data *ddata)
+{
+ struct gpiod_lookup_table *table = &tng_bt_sfi_gpio_table;
+ struct gpiod_lookup *lookup = table->table;
+ struct pci_dev *pdev;
+
+ /* Connected to /dev/ttyS0 */
+ pdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(4, 1));
+ if (!pdev)
+ return -ENODEV;
+
+ ddata->dev = &pdev->dev;
+ ddata->name = table->dev_id;
+
+ lookup[0].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_DEVICE_WAKEUP);
+ lookup[1].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_SHUTDOWN);
+ lookup[2].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_HOST_WAKEUP);
+
+ gpiod_add_lookup_table(table);
+ return 0;
+}
+
+static struct bt_sfi_data tng_bt_sfi_data __initdata = {
+ .setup = tng_bt_sfi_setup,
+};
+
+#define ICPU(model, ddata) \
+ { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (kernel_ulong_t)&ddata }
+
+static const struct x86_cpu_id bt_sfi_cpu_ids[] = {
+ ICPU(INTEL_FAM6_ATOM_MERRIFIELD, tng_bt_sfi_data),
+ {}
+};
+
+static int __init bt_sfi_init(void)
+{
+ struct platform_device_info info;
+ struct platform_device *pdev;
+ const struct x86_cpu_id *id;
+ struct bt_sfi_data *ddata;
+ int ret;
+
+ id = x86_match_cpu(bt_sfi_cpu_ids);
+ if (!id)
+ return -ENODEV;
+
+ ddata = (struct bt_sfi_data *)id->driver_data;
+ if (!ddata)
+ return -ENODEV;
+
+ ret = ddata->setup(ddata);
+ if (ret)
+ return ret;
+
+ memset(&info, 0, sizeof(info));
+ info.fwnode = ddata->dev->fwnode;
+ info.parent = ddata->dev;
+ info.name = ddata->name,
+ info.id = PLATFORM_DEVID_NONE,
+
+ pdev = platform_device_register_full(&info);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
+ dev_info(ddata->dev, "Registered Bluetooth device: %s\n", ddata->name);
+ return 0;
+}
+device_initcall(bt_sfi_init);
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-03-31 10:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30 10:04 [PATCH v1] x86/platform/intel-mid: Enable bluetooth on Intel Edison Andy Shevchenko
2017-03-31 10:07 ` [tip:x86/platform] x86/platform/intel-mid: Enable Bluetooth support " tip-bot for Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2017-03-29 14:18 [PATCH v1] x86/platform/intel-mid: Enable bluetooth " Andy Shevchenko
2017-03-30 7:23 ` Ingo Molnar
2017-03-30 9:44 ` Andy Shevchenko
2017-03-30 9:54 ` Ingo Molnar
2017-03-30 10:34 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.