Skip to content

Commit

Permalink
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: bluetooth-next 2017-12-18

Here's the first bluetooth-next pull request for the 4.16 kernel.

 - hci_ll: multiple cleanups & fixes
 - Remove Gustavo Padovan from the MAINTAINERS file
 - Support BLE Adversing while connected (if the controller can do it)
 - DT updates for TI chips
 - Various other smaller cleanups & fixes

Please let me know if there are any issues pulling. Thanks.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Dec 19, 2017
2 parents 566bd54 + 22b371c commit 748a709
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 235 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
TI WiLink 7/8 (wl12xx/wl18xx) Shared Transport BT/FM/GPS devices
Texas Instruments Bluetooth Chips
---------------------------------

This documents the binding structure and common properties for serial
attached TI Bluetooth devices. The following chips are included in this
binding:

* TI CC256x Bluetooth devices
* TI WiLink 7/8 (wl12xx/wl18xx) Shared Transport BT/FM/GPS devices

TI WiLink devices have a UART interface for providing Bluetooth, FM radio,
and GPS over what's called "shared transport". The shared transport is
standard BT HCI protocol with additional channels for the other functions.

These devices also have a separate WiFi interface as described in
TI WiLink devices also have a separate WiFi interface as described in
wireless/ti,wlcore.txt.

This bindings follows the UART slave device binding in
../serial/slave-device.txt.

Required properties:
- compatible: should be one of the following:
"ti,cc2560"
"ti,wl1271-st"
"ti,wl1273-st"
"ti,wl1281-st"
Expand All @@ -32,6 +41,9 @@ Optional properties:
See ../clocks/clock-bindings.txt for details.
- clock-names : Must include the following entry:
"ext_clock" (External clock provided to the TI combo chip).
- nvmem-cells: phandle to nvmem data cell that contains a 6 byte BD address
with the most significant byte first (big-endian).
- nvmem-cell-names: "bd-address" (required when nvmem-cells is specified)

Example:

Expand All @@ -43,5 +55,7 @@ Example:
enable-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
clocks = <&clk32k_wl18xx>;
clock-names = "ext_clock";
nvmem-cells = <&bd_address>;
nvmem-cell-names = "bd-address";
};
};
2 changes: 0 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2689,7 +2689,6 @@ F: drivers/mtd/devices/block2mtd.c

BLUETOOTH DRIVERS
M: Marcel Holtmann <marcel@holtmann.org>
M: Gustavo Padovan <gustavo@padovan.org>
M: Johan Hedberg <johan.hedberg@gmail.com>
L: linux-bluetooth@vger.kernel.org
W: http://www.bluez.org/
Expand All @@ -2700,7 +2699,6 @@ F: drivers/bluetooth/

BLUETOOTH SUBSYSTEM
M: Marcel Holtmann <marcel@holtmann.org>
M: Gustavo Padovan <gustavo@padovan.org>
M: Johan Hedberg <johan.hedberg@gmail.com>
L: linux-bluetooth@vger.kernel.org
W: http://www.bluez.org/
Expand Down
10 changes: 10 additions & 0 deletions drivers/bluetooth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ config BT_HCIBTUSB
Say Y here to compile support for Bluetooth USB devices into the
kernel or say M to compile it as module (btusb).

config BT_HCIBTUSB_AUTOSUSPEND
bool "Enable USB autosuspend for Bluetooth USB devices by default"
depends on BT_HCIBTUSB
help
Say Y here to enable USB autosuspend for Bluetooth USB devices by
default.

This can be overridden by passing btusb.enable_autosuspend=[y|n]
on the kernel commandline.

config BT_HCIBTUSB_BCM
bool "Broadcom protocol support"
depends on BT_HCIBTUSB
Expand Down
8 changes: 2 additions & 6 deletions drivers/bluetooth/bluecard_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ static void bluecard_write_wakeup(struct bluecard_info *info)
}

/* Wait until the command reaches the baseband */
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
schedule_timeout(HZ/10);
finish_wait(&wq, &wait);
mdelay(100);

/* Set baud on baseband */
info->ctrl_reg &= ~0x03;
Expand All @@ -316,9 +314,7 @@ static void bluecard_write_wakeup(struct bluecard_info *info)
outb(info->ctrl_reg, iobase + REG_CONTROL);

/* Wait before the next HCI packet can be send */
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
schedule_timeout(HZ);
finish_wait(&wq, &wait);
mdelay(1000);
}

if (len == skb->len) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/bluetooth/btqcomsmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ static int btqcomsmd_send(struct hci_dev *hdev, struct sk_buff *skb)
break;
}

kfree_skb(skb);
if (!ret)
kfree_skb(skb);

return ret;
}
Expand Down
9 changes: 9 additions & 0 deletions drivers/bluetooth/btsdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/errno.h>
#include <linux/skbuff.h>

#include <linux/mmc/host.h>
#include <linux/mmc/sdio_ids.h>
#include <linux/mmc/sdio_func.h>

Expand Down Expand Up @@ -292,6 +293,14 @@ static int btsdio_probe(struct sdio_func *func,
tuple = tuple->next;
}

/* BCM43341 devices soldered onto the PCB (non-removable) use an
* uart connection for bluetooth, ignore the BT SDIO interface.
*/
if (func->vendor == SDIO_VENDOR_ID_BROADCOM &&
func->device == SDIO_DEVICE_ID_BROADCOM_43341 &&
!mmc_card_is_removable(func->card->host))
return -ENODEV;

data = devm_kzalloc(&func->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
Expand Down
7 changes: 7 additions & 0 deletions drivers/bluetooth/btusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

static bool disable_scofix;
static bool force_scofix;
static bool enable_autosuspend = IS_ENABLED(CONFIG_BT_HCIBTUSB_AUTOSUSPEND);

static bool reset = true;

Expand Down Expand Up @@ -3213,6 +3214,9 @@ static int btusb_probe(struct usb_interface *intf,
}
#endif

if (enable_autosuspend)
usb_enable_autosuspend(data->udev);

err = hci_register_dev(hdev);
if (err < 0)
goto out_free_dev;
Expand Down Expand Up @@ -3425,6 +3429,9 @@ MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size");
module_param(force_scofix, bool, 0644);
MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size");

module_param(enable_autosuspend, bool, 0644);
MODULE_PARM_DESC(enable_autosuspend, "Enable USB autosuspend by default");

module_param(reset, bool, 0644);
MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");

Expand Down
1 change: 1 addition & 0 deletions drivers/bluetooth/hci_bcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ static const struct acpi_device_id bcm_acpi_match[] = {
{ "BCM2E65", (kernel_ulong_t)&acpi_bcm_int_last_gpios },
{ "BCM2E67", (kernel_ulong_t)&acpi_bcm_int_last_gpios },
{ "BCM2E71", (kernel_ulong_t)&acpi_bcm_int_last_gpios },
{ "BCM2E72", (kernel_ulong_t)&acpi_bcm_int_last_gpios },
{ "BCM2E7B", (kernel_ulong_t)&acpi_bcm_int_last_gpios },
{ "BCM2E7C", (kernel_ulong_t)&acpi_bcm_int_last_gpios },
{ "BCM2E7E", (kernel_ulong_t)&acpi_bcm_int_first_gpios },
Expand Down
107 changes: 101 additions & 6 deletions drivers/bluetooth/hci_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <linux/gpio/consumer.h>
#include <linux/nvmem-consumer.h>

#include "hci_uart.h"

/* Vendor-specific HCI commands */
#define HCI_VS_WRITE_BD_ADDR 0xfc06
#define HCI_VS_UPDATE_UART_HCI_BAUDRATE 0xff36

/* HCILL commands */
#define HCILL_GO_TO_SLEEP_IND 0x30
#define HCILL_GO_TO_SLEEP_ACK 0x31
Expand Down Expand Up @@ -86,6 +91,7 @@ struct ll_device {
struct serdev_device *serdev;
struct gpio_desc *enable_gpio;
struct clk *ext_clk;
bdaddr_t bdaddr;
};

struct ll_struct {
Expand Down Expand Up @@ -620,19 +626,19 @@ static int download_firmware(struct ll_device *lldev)
case ACTION_SEND_COMMAND: /* action send */
bt_dev_dbg(lldev->hu.hdev, "S");
cmd = (struct hci_command *)action_ptr;
if (cmd->opcode == 0xff36) {
if (cmd->opcode == HCI_VS_UPDATE_UART_HCI_BAUDRATE) {
/* ignore remote change
* baud rate HCI VS command
*/
bt_dev_warn(lldev->hu.hdev, "change remote baud rate command in firmware");
break;
}
if (cmd->prefix != 1)
bt_dev_dbg(lldev->hu.hdev, "command type %d\n", cmd->prefix);
bt_dev_dbg(lldev->hu.hdev, "command type %d", cmd->prefix);

skb = __hci_cmd_sync(lldev->hu.hdev, cmd->opcode, cmd->plen, &cmd->speed, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
bt_dev_err(lldev->hu.hdev, "send command failed\n");
bt_dev_err(lldev->hu.hdev, "send command failed");
err = PTR_ERR(skb);
goto out_rel_fw;
}
Expand All @@ -659,6 +665,24 @@ static int download_firmware(struct ll_device *lldev)
return err;
}

static int ll_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
{
bdaddr_t bdaddr_swapped;
struct sk_buff *skb;

/* HCI_VS_WRITE_BD_ADDR (at least on a CC2560A chip) expects the BD
* address to be MSB first, but bdaddr_t has the convention of being
* LSB first.
*/
baswap(&bdaddr_swapped, bdaddr);
skb = __hci_cmd_sync(hdev, HCI_VS_WRITE_BD_ADDR, sizeof(bdaddr_t),
&bdaddr_swapped, HCI_INIT_TIMEOUT);
if (!IS_ERR(skb))
kfree_skb(skb);

return PTR_ERR_OR_ZERO(skb);
}

static int ll_setup(struct hci_uart *hu)
{
int err, retry = 3;
Expand All @@ -671,14 +695,20 @@ static int ll_setup(struct hci_uart *hu)

lldev = serdev_device_get_drvdata(serdev);

hu->hdev->set_bdaddr = ll_set_bdaddr;

serdev_device_set_flow_control(serdev, true);

do {
/* Configure BT_EN to HIGH state */
/* Reset the Bluetooth device */
gpiod_set_value_cansleep(lldev->enable_gpio, 0);
msleep(5);
gpiod_set_value_cansleep(lldev->enable_gpio, 1);
msleep(100);
err = serdev_device_wait_for_cts(serdev, true, 200);
if (err) {
bt_dev_err(hu->hdev, "Failed to get CTS");
return err;
}

err = download_firmware(lldev);
if (!err)
Expand All @@ -691,6 +721,18 @@ static int ll_setup(struct hci_uart *hu)
if (err)
return err;

/* Set BD address if one was specified at probe */
if (!bacmp(&lldev->bdaddr, BDADDR_NONE)) {
/* This means that there was an error getting the BD address
* during probe, so mark the device as having a bad address.
*/
set_bit(HCI_QUIRK_INVALID_BDADDR, &hu->hdev->quirks);
} else if (bacmp(&lldev->bdaddr, BDADDR_ANY)) {
err = ll_set_bdaddr(hu->hdev, &lldev->bdaddr);
if (err)
set_bit(HCI_QUIRK_INVALID_BDADDR, &hu->hdev->quirks);
}

/* Operational speed if any */
if (hu->oper_speed)
speed = hu->oper_speed;
Expand All @@ -700,7 +742,12 @@ static int ll_setup(struct hci_uart *hu)
speed = 0;

if (speed) {
struct sk_buff *skb = __hci_cmd_sync(hu->hdev, 0xff36, sizeof(speed), &speed, HCI_INIT_TIMEOUT);
__le32 speed_le = cpu_to_le32(speed);
struct sk_buff *skb;

skb = __hci_cmd_sync(hu->hdev, HCI_VS_UPDATE_UART_HCI_BAUDRATE,
sizeof(speed_le), &speed_le,
HCI_INIT_TIMEOUT);
if (!IS_ERR(skb)) {
kfree_skb(skb);
serdev_device_set_baudrate(serdev, speed);
Expand All @@ -716,6 +763,7 @@ static int hci_ti_probe(struct serdev_device *serdev)
{
struct hci_uart *hu;
struct ll_device *lldev;
struct nvmem_cell *bdaddr_cell;
u32 max_speed = 3000000;

lldev = devm_kzalloc(&serdev->dev, sizeof(struct ll_device), GFP_KERNEL);
Expand All @@ -737,6 +785,52 @@ static int hci_ti_probe(struct serdev_device *serdev)
of_property_read_u32(serdev->dev.of_node, "max-speed", &max_speed);
hci_uart_set_speeds(hu, 115200, max_speed);

/* optional BD address from nvram */
bdaddr_cell = nvmem_cell_get(&serdev->dev, "bd-address");
if (IS_ERR(bdaddr_cell)) {
int err = PTR_ERR(bdaddr_cell);

if (err == -EPROBE_DEFER)
return err;

/* ENOENT means there is no matching nvmem cell and ENOSYS
* means that nvmem is not enabled in the kernel configuration.
*/
if (err != -ENOENT && err != -ENOSYS) {
/* If there was some other error, give userspace a
* chance to fix the problem instead of failing to load
* the driver. Using BDADDR_NONE as a flag that is
* tested later in the setup function.
*/
dev_warn(&serdev->dev,
"Failed to get \"bd-address\" nvmem cell (%d)\n",
err);
bacpy(&lldev->bdaddr, BDADDR_NONE);
}
} else {
bdaddr_t *bdaddr;
size_t len;

bdaddr = nvmem_cell_read(bdaddr_cell, &len);
nvmem_cell_put(bdaddr_cell);
if (IS_ERR(bdaddr)) {
dev_err(&serdev->dev, "Failed to read nvmem bd-address\n");
return PTR_ERR(bdaddr);
}
if (len != sizeof(bdaddr_t)) {
dev_err(&serdev->dev, "Invalid nvmem bd-address length\n");
kfree(bdaddr);
return -EINVAL;
}

/* As per the device tree bindings, the value from nvmem is
* expected to be MSB first, but in the kernel it is expected
* that bdaddr_t is LSB first.
*/
baswap(&lldev->bdaddr, bdaddr);
kfree(bdaddr);
}

return hci_uart_register_device(hu, &llp);
}

Expand All @@ -748,6 +842,7 @@ static void hci_ti_remove(struct serdev_device *serdev)
}

static const struct of_device_id hci_ti_of_match[] = {
{ .compatible = "ti,cc2560" },
{ .compatible = "ti,wl1271-st" },
{ .compatible = "ti,wl1273-st" },
{ .compatible = "ti,wl1281-st" },
Expand Down
3 changes: 3 additions & 0 deletions drivers/bluetooth/hci_qca.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,9 @@ static int qca_setup(struct hci_uart *hu)
if (!ret) {
set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
qca_debugfs_init(hdev);
} else if (ret == -ENOENT) {
/* No patch/nvm-config found, run with original fw/config */
ret = 0;
}

/* Setup bdaddr */
Expand Down
1 change: 1 addition & 0 deletions drivers/bluetooth/hci_serdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ int hci_uart_register_device(struct hci_uart *hu,
hci_set_drvdata(hdev, hu);

INIT_WORK(&hu->write_work, hci_uart_write_work);
percpu_init_rwsem(&hu->proto_lock);

/* Only when vendor specific setup callback is provided, consider
* the manufacturer information valid. This avoids filling in the
Expand Down
Loading

0 comments on commit 748a709

Please sign in to comment.