1 // SPDX-License-Identifier: GPL-2.0-only
3 * Bluetooth platform data initialization file
5 * (C) Copyright 2017 Intel Corporation
6 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
9 #include <linux/gpio/machine.h>
10 #include <linux/pci.h>
11 #include <linux/platform_device.h>
13 #include <asm/cpu_device_id.h>
14 #include <asm/intel-family.h>
15 #include <asm/intel-mid.h>
20 int (*setup)(struct bt_sfi_data *ddata);
23 static struct gpiod_lookup_table tng_bt_sfi_gpio_table = {
26 GPIO_LOOKUP("0000:00:0c.0", -1, "device-wakeup", GPIO_ACTIVE_HIGH),
27 GPIO_LOOKUP("0000:00:0c.0", -1, "shutdown", GPIO_ACTIVE_HIGH),
28 GPIO_LOOKUP("0000:00:0c.0", -1, "host-wakeup", GPIO_ACTIVE_HIGH),
33 #define TNG_BT_SFI_GPIO_DEVICE_WAKEUP "bt_wakeup"
34 #define TNG_BT_SFI_GPIO_SHUTDOWN "BT-reset"
35 #define TNG_BT_SFI_GPIO_HOST_WAKEUP "bt_uart_enable"
37 static int __init tng_bt_sfi_setup(struct bt_sfi_data *ddata)
39 struct gpiod_lookup_table *table = &tng_bt_sfi_gpio_table;
40 struct gpiod_lookup *lookup = table->table;
43 /* Connected to /dev/ttyS0 */
44 pdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(4, 1));
48 ddata->dev = &pdev->dev;
49 ddata->name = table->dev_id;
51 lookup[0].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_DEVICE_WAKEUP);
52 lookup[1].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_SHUTDOWN);
53 lookup[2].chip_hwnum = get_gpio_by_name(TNG_BT_SFI_GPIO_HOST_WAKEUP);
55 gpiod_add_lookup_table(table);
59 static struct bt_sfi_data tng_bt_sfi_data __initdata = {
60 .setup = tng_bt_sfi_setup,
63 #define ICPU(model, ddata) \
64 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (kernel_ulong_t)&ddata }
66 static const struct x86_cpu_id bt_sfi_cpu_ids[] = {
67 ICPU(INTEL_FAM6_ATOM_SILVERMONT_MID, tng_bt_sfi_data),
71 static int __init bt_sfi_init(void)
73 struct platform_device_info info;
74 struct platform_device *pdev;
75 const struct x86_cpu_id *id;
76 struct bt_sfi_data *ddata;
79 id = x86_match_cpu(bt_sfi_cpu_ids);
83 ddata = (struct bt_sfi_data *)id->driver_data;
87 ret = ddata->setup(ddata);
91 memset(&info, 0, sizeof(info));
92 info.fwnode = ddata->dev->fwnode;
93 info.parent = ddata->dev;
94 info.name = ddata->name,
95 info.id = PLATFORM_DEVID_NONE,
97 pdev = platform_device_register_full(&info);
101 dev_info(ddata->dev, "Registered Bluetooth device: %s\n", ddata->name);
104 device_initcall(bt_sfi_init);