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-06-14

Here's another batch of Bluetooth patches for the 4.13 kernel:

 - Fix for Broadcom controllers not supporting Event Mask Page 2
 - New QCA ROME USB ID for btusb
 - Fix for Security Manager Protocol to use constant-time memcmp
 - Improved support for TI WiLink chips

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

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jun 14, 2017
2 parents 0331402 + 06e41d8 commit 4cbf87c
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 26 deletions.
12 changes: 12 additions & 0 deletions Documentation/devicetree/bindings/net/ti,wilink-st.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Required properties:
- compatible: should be one of the following:
"ti,wl1271-st"
"ti,wl1273-st"
"ti,wl1281-st"
"ti,wl1283-st"
"ti,wl1285-st"
"ti,wl1801-st"
"ti,wl1805-st"
"ti,wl1807-st"
"ti,wl1831-st"
"ti,wl1835-st"
"ti,wl1837-st"
Expand All @@ -22,6 +28,10 @@ Optional properties:
- enable-gpios : GPIO signal controlling enabling of BT. Active high.
- vio-supply : Vio input supply (1.8V)
- vbat-supply : Vbat input supply (2.9-4.8V)
- clocks : Must contain an entry, for each entry in clock-names.
See ../clocks/clock-bindings.txt for details.
- clock-names : Must include the following entry:
"ext_clock" (External clock provided to the TI combo chip).

Example:

Expand All @@ -31,5 +41,7 @@ Example:
bluetooth {
compatible = "ti,wl1835-st";
enable-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
clocks = <&clk32k_wl18xx>;
clock-names = "ext_clock";
};
};
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
bluetooth {
compatible = "ti,wl1835-st";
enable-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
clocks = <&pmic>;
clock-names = "ext_clock";
};
};

Expand Down
36 changes: 36 additions & 0 deletions drivers/bluetooth/btbcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,27 @@ static struct sk_buff *btbcm_read_verbose_config(struct hci_dev *hdev)
return skb;
}

static struct sk_buff *btbcm_read_controller_features(struct hci_dev *hdev)
{
struct sk_buff *skb;

skb = __hci_cmd_sync(hdev, 0xfc6e, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
BT_ERR("%s: BCM: Read controller features failed (%ld)",
hdev->name, PTR_ERR(skb));
return skb;
}

if (skb->len != 9) {
BT_ERR("%s: BCM: Controller features length mismatch",
hdev->name);
kfree_skb(skb);
return ERR_PTR(-EIO);
}

return skb;
}

static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
{
struct sk_buff *skb;
Expand Down Expand Up @@ -417,6 +438,14 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
BT_INFO("%s: BCM: chip id %u", hdev->name, skb->data[1]);
kfree_skb(skb);

/* Read Controller Features */
skb = btbcm_read_controller_features(hdev);
if (IS_ERR(skb))
return PTR_ERR(skb);

BT_INFO("%s: BCM: features 0x%2.2x", hdev->name, skb->data[1]);
kfree_skb(skb);

/* Read Local Name */
skb = btbcm_read_local_name(hdev);
if (IS_ERR(skb))
Expand Down Expand Up @@ -540,6 +569,13 @@ int btbcm_setup_apple(struct hci_dev *hdev)
kfree_skb(skb);
}

/* Read Controller Features */
skb = btbcm_read_controller_features(hdev);
if (!IS_ERR(skb)) {
BT_INFO("%s: BCM: features 0x%2.2x", hdev->name, skb->data[1]);
kfree_skb(skb);
}

/* Read Local Name */
skb = btbcm_read_local_name(hdev);
if (!IS_ERR(skb)) {
Expand Down
1 change: 1 addition & 0 deletions drivers/bluetooth/btusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ static const struct usb_device_id blacklist_table[] = {
{ USB_DEVICE(0x0cf3, 0xe301), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x0cf3, 0xe360), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x0489, 0xe092), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x0489, 0xe0a2), .driver_info = BTUSB_QCA_ROME },
{ USB_DEVICE(0x04ca, 0x3011), .driver_info = BTUSB_QCA_ROME },

/* Broadcom BCM2035 */
Expand Down
5 changes: 1 addition & 4 deletions drivers/bluetooth/hci_bcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,7 @@ static int bcm_acpi_probe(struct bcm_device *dev)
if (id)
gpio_mapping = (const struct acpi_gpio_mapping *) id->driver_data;

ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
gpio_mapping);
ret = devm_acpi_dev_add_driver_gpios(&pdev->dev, gpio_mapping);
if (ret)
return ret;

Expand Down Expand Up @@ -834,8 +833,6 @@ static int bcm_remove(struct platform_device *pdev)
list_del(&dev->list);
mutex_unlock(&bcm_device_lock);

acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));

dev_info(&pdev->dev, "%s device unregistered.\n", dev->name);

return 0;
Expand Down
14 changes: 14 additions & 0 deletions drivers/bluetooth/hci_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,19 @@ static const struct dev_pm_ops intel_pm_ops = {
SET_RUNTIME_PM_OPS(intel_suspend_device, intel_resume_device, NULL)
};

static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
static const struct acpi_gpio_params host_wake_gpios = { 1, 0, false };

static const struct acpi_gpio_mapping acpi_hci_intel_gpios[] = {
{ "reset-gpios", &reset_gpios, 1 },
{ "host-wake-gpios", &host_wake_gpios, 1 },
{ },
};

static int intel_probe(struct platform_device *pdev)
{
struct intel_device *idev;
int ret;

idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL);
if (!idev)
Expand All @@ -1217,6 +1227,10 @@ static int intel_probe(struct platform_device *pdev)

idev->pdev = pdev;

ret = devm_acpi_dev_add_driver_gpios(&pdev->dev, acpi_hci_intel_gpios);
if (ret)
dev_dbg(&pdev->dev, "Unable to add GPIO mapping table\n");

idev->reset = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(idev->reset)) {
dev_err(&pdev->dev, "Unable to retrieve gpio\n");
Expand Down
22 changes: 21 additions & 1 deletion drivers/bluetooth/hci_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <linux/serdev.h>
#include <linux/skbuff.h>
#include <linux/ti_wilink_st.h>
#include <linux/clk.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
Expand Down Expand Up @@ -84,6 +85,7 @@ struct ll_device {
struct hci_uart hu;
struct serdev_device *serdev;
struct gpio_desc *enable_gpio;
struct clk *ext_clk;
};

struct ll_struct {
Expand Down Expand Up @@ -146,8 +148,12 @@ static int ll_open(struct hci_uart *hu)

hu->priv = ll;

if (hu->serdev)
if (hu->serdev) {
struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev);
serdev_device_open(hu->serdev);
if (!IS_ERR(lldev->ext_clk))
clk_prepare_enable(lldev->ext_clk);
}

return 0;
}
Expand Down Expand Up @@ -181,6 +187,8 @@ static int ll_close(struct hci_uart *hu)
struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev);
gpiod_set_value_cansleep(lldev->enable_gpio, 0);

clk_disable_unprepare(lldev->ext_clk);

serdev_device_close(hu->serdev);
}

Expand Down Expand Up @@ -721,6 +729,10 @@ static int hci_ti_probe(struct serdev_device *serdev)
if (IS_ERR(lldev->enable_gpio))
return PTR_ERR(lldev->enable_gpio);

lldev->ext_clk = devm_clk_get(&serdev->dev, "ext_clock");
if (IS_ERR(lldev->ext_clk) && PTR_ERR(lldev->ext_clk) != -ENOENT)
return PTR_ERR(lldev->ext_clk);

of_property_read_u32(serdev->dev.of_node, "max-speed", &max_speed);
hci_uart_set_speeds(hu, 115200, max_speed);

Expand All @@ -741,6 +753,14 @@ static void hci_ti_remove(struct serdev_device *serdev)
}

static const struct of_device_id hci_ti_of_match[] = {
{ .compatible = "ti,wl1271-st" },
{ .compatible = "ti,wl1273-st" },
{ .compatible = "ti,wl1281-st" },
{ .compatible = "ti,wl1283-st" },
{ .compatible = "ti,wl1285-st" },
{ .compatible = "ti,wl1801-st" },
{ .compatible = "ti,wl1805-st" },
{ .compatible = "ti,wl1807-st" },
{ .compatible = "ti,wl1831-st" },
{ .compatible = "ti,wl1835-st" },
{ .compatible = "ti,wl1837-st" },
Expand Down
17 changes: 15 additions & 2 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ static void hci_set_event_mask_page_2(struct hci_request *req)
{
struct hci_dev *hdev = req->hdev;
u8 events[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
bool changed = false;

/* If Connectionless Slave Broadcast master role is supported
* enable all necessary events for it.
Expand All @@ -557,6 +558,7 @@ static void hci_set_event_mask_page_2(struct hci_request *req)
events[1] |= 0x80; /* Synchronization Train Complete */
events[2] |= 0x10; /* Slave Page Response Timeout */
events[2] |= 0x20; /* CSB Channel Map Change */
changed = true;
}

/* If Connectionless Slave Broadcast slave role is supported
Expand All @@ -567,13 +569,24 @@ static void hci_set_event_mask_page_2(struct hci_request *req)
events[2] |= 0x02; /* CSB Receive */
events[2] |= 0x04; /* CSB Timeout */
events[2] |= 0x08; /* Truncated Page Complete */
changed = true;
}

/* Enable Authenticated Payload Timeout Expired event if supported */
if (lmp_ping_capable(hdev) || hdev->le_features[0] & HCI_LE_PING)
if (lmp_ping_capable(hdev) || hdev->le_features[0] & HCI_LE_PING) {
events[2] |= 0x80;
changed = true;
}

hci_req_add(req, HCI_OP_SET_EVENT_MASK_PAGE_2, sizeof(events), events);
/* Some Broadcom based controllers indicate support for Set Event
* Mask Page 2 command, but then actually do not support it. Since
* the default value is all bits set to zero, the command is only
* required if the event mask has to be changed. In case no change
* to the event mask is needed, skip this command.
*/
if (changed)
hci_req_add(req, HCI_OP_SET_EVENT_MASK_PAGE_2,
sizeof(events), events);
}

static int hci_init3_req(struct hci_request *req, unsigned long opt)
Expand Down
Loading

0 comments on commit 4cbf87c

Please sign in to comment.