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 static const struct x86_cpu_id bt_sfi_cpu_ids
[] = {
64 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID
, &tng_bt_sfi_data
),
68 static int __init
bt_sfi_init(void)
70 struct platform_device_info info
;
71 struct platform_device
*pdev
;
72 const struct x86_cpu_id
*id
;
73 struct bt_sfi_data
*ddata
;
76 id
= x86_match_cpu(bt_sfi_cpu_ids
);
80 ddata
= (struct bt_sfi_data
*)id
->driver_data
;
84 ret
= ddata
->setup(ddata
);
88 memset(&info
, 0, sizeof(info
));
89 info
.fwnode
= ddata
->dev
->fwnode
;
90 info
.parent
= ddata
->dev
;
91 info
.name
= ddata
->name
,
92 info
.id
= PLATFORM_DEVID_NONE
,
94 pdev
= platform_device_register_full(&info
);
98 dev_info(ddata
->dev
, "Registered Bluetooth device: %s\n", ddata
->name
);
101 device_initcall(bt_sfi_init
);