Commit graph

94 commits

Author SHA1 Message Date
Andy Shevchenko
212d718333 Bluetooth: hci_bcm: Support platform enumeration
Until now the driver supports only ACPI enumeration. Nevertheless
Intel Edison SoM has Broadcom Wi-Fi + BT chip and neither ACPI nor DT
enumeration mechanism.

Enable pure platform driver in order to support Intel Edison SoM.

Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-12 22:02:38 +02:00
John Keeping
730ce397cd Bluetooth: hci_bcm: Fix clock (un)prepare
The hci_bcm driver currently does not prepare/unprepare the clock and
goes directly to enable, but as the documentation for clk_enable says,
clk_prepare must be called before clk_enable.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-12 22:02:36 +02:00
Daniel Drake
89ab37b489 Bluetooth: hci_bcm: Add support for BCM2E95 and BCM2E96
The BCM2E96 ID is used by the ECS EF20 laptop, and BCM2E95 is present
in the Weibu F3C. Both are now logged as:

     hci0: BCM: chip id 82
     hci0: BCM43341B0 (002.001.014) build 0000
     hci0: BCM (002.001.014) build 0158

The ECS vendor kernel predates the host-wakeup support in hci_bcm but
it explicitly has a comment saying that the GPIO assignment needs to be
reordered for BCM2E96:
 1. (not used in vendor driver)
 2. Device wakeup
 3. Shutdown

For both devices in question, the DSDT has these GPIOs listed in order
of GpioInt, GpioIo, GpioIo. And if we use the first one listed (GpioInt)
as the host wakeup, that interrupt handler fires while doing bluetooth
I/O.

I am assuming the convention of GPIO ordering has been changed for these
new device IDs, so lets use the new ordering on such devices.

Signed-off-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-02-16 17:34:17 +01:00
Jérôme de Bretagne
5e2bd93b8f Bluetooth: hci_bcm: Fix autosuspend PM for Lenovo ThinkPad 8
ACPI table for BCM2E55 of Lenovo ThinkPad 8 is not correct.
Set correctly IRQ polarity for this device, fixing the issue of bluetooth
never resuming after autosuspend PM.

Signed-off-by: Jérôme de Bretagne <jerome.debretagne@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-10-13 09:27:01 +02:00
Loic Poulain
143f0a28ff Bluetooth: hci_bcm: Change protocol name
Use full name instead of abbreviation.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-09-19 20:25:37 +02:00
Loic Poulain
1dbfc59a93 Bluetooth: hci_bcm: Add BCM2E71 ACPI ID
This ID is used at least by Asus T100-CHI.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-04-08 18:54:33 +02:00
Jérôme de Bretagne
c5fd9cbb9d Bluetooth: hci_bcm: Add BCM2E55 ACPI ID used in Lenovo ThinkPad Tablet 8
Lenovo ThinkPad Tablet 8 with BCM43241 rev B5 chipset uses the BCM2E55
ACPI ID for Bluetooth. Add it to the list of supported devices.

Signed-off-by: Jérôme de Bretagne <jerome.debretagne@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-03-10 19:51:28 +01:00
Mika Westerberg
2791b44d6b Bluetooth: hci_bcm: Add BCM2E7C ACPI ID
Recent macbooks (early 2015) with BCM43241 use this ACPI ID. Add it to the
list of supported devices.

Reported-by: Leif Liddy <leif.liddy@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-02-23 20:29:37 +01:00
J.J. Meijer
b013a636b8 Bluetooth: hci_bcm: Add new ACPI ID for bcm43241
This ACPI ID is used at least by HP for their Omni 10 5600eg tablet.

Signed-off-by: J.J. Meijer <jjmeijer88@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-02-23 20:29:37 +01:00
Heikki Krogerus
adbdeae5ce Bluetooth: hci_bcm: new ACPI IDs
These are used at least by Acer with BCM43241.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-01-04 19:22:57 +01:00
Heikki Krogerus
d3d2072540 Bluetooth: hci_bcm: move all Broadcom ACPI IDs to BCM HCI driver
The IDs should all be for Broadcom BCM43241 module, and
hci_bcm is now the proper driver for them. This removes one
of two different ways of handling PM with the module.

Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-01-04 19:22:05 +01:00
Luka Karinja
806f50c729 Bluetooth: hci_bcm: Add BCM2E65 ACPI ID
Add BCM2E65 device in acpi_device_id table used on Asus T100TAF.

Signed-off-by: Luka Karinja <luka.karinja@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-12-20 14:15:25 +01:00
Marcel Holtmann
618e8bc228 Bluetooth: Use new hci_skb_pkt_* wrappers for drivers
The new hci_skb_pkt_* wrappers are mainly intented for drivers to
require less knowledge about bt_cb(sbk) handling. So after converting
the core packet handling, convert all drivers.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-11-19 17:50:27 +01:00
Dan Carpenter
a1857390e2 Bluetooth: hci_bcm: checking for ERR_PTR instead of NULL
bt_skb_alloc() returns NULL on error, it never returns an ERR_PTR.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-10-22 11:32:47 +02:00
Marcel Holtmann
aee61f7aa8 Bluetooth: hci_uart: Provide initial manufacturer information
Provide an early indication about the manufacturer information so that
it can be forwarded into monitor channel.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-10-21 07:20:44 +03:00
Marcel Holtmann
075e1f5e6c Bluetooth: hci_bcm: Enable support for set_diag driver callback
The set_diag driver callback allows enabling and disabling the vendor
specific diagnostic information. Since Broadcom chips have support for
a dedicated LM_DIAG channel, hook it up accordingly.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-10-08 09:59:16 +03:00
Marcel Holtmann
94c58132c0 Bluetooth: hci_bcm: Enable parsing of LM_DIAG messages
The Broadcom UART based controllers can send LM_DIAG messages with the
identifier 0x07 inside the HCI stream. These messages are 63 octets in
size and have no variable payload or length indicator.

This patch adds correct parsing information for the h4_recv_buf handler
and in case these packets are received, they are forwarded to the
Bluetooth core via hci_recv_diag interface.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-10-08 09:53:16 +03:00
Jarkko Nikula
e98d6d6203 Bluetooth: hci_bcm: Do not test ACPI companion in bcm_acpi_probe()
This device has always ACPI companion because driver supports only ACPI
enumeration. Therefore there is no need to test it in bcm_acpi_probe() and
we can pass it directly to acpi_dev_get_resources() (which will return
-EINVAL in case of NULL argument is passed).

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-10-01 10:03:38 +02:00
Jarkko Nikula
4d1c455802 Bluetooth: hci_bcm: Remove needless looking code
Tree wide grep for "hci_bcm" doesn't reveal there is any code registering
this platform device and "struct acpi_device_id" use for passing the
platform data looks a debug/test code leftover to me.

I'm assuming this driver effectively supports only ACPI enumeration and
thus test for ACPI_HANDLE() and platform data can be removed.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-10-01 10:03:37 +02:00
Jarkko Nikula
5fbae60d43 Bluetooth: hci_bcm: Remove needless acpi_match_device() call
There is no need to call acpi_match_device() in driver's probe path and
verify does it find a match to given ACPI _HIDs in .acpi_match_table as
driver/platform/acpi core code has found the match prior calling the probe.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-10-01 10:03:37 +02:00
Jarkko Nikula
5be00284dc Bluetooth: hci_bcm: Handle possible error from acpi_dev_get_resources()
Driver doesn't handle possible error from acpi_dev_get_resources(). Test it
and return the error code in case of error.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-10-01 10:03:37 +02:00
Jarkko Nikula
09dbf1b784 Bluetooth: hci_bcm: Add missing acpi_dev_free_resource_list()
Caller of acpi_dev_get_resources() should free the constructed resource
list by calling the acpi_dev_free_resource_list() in order to avoid memory
leak.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-10-01 10:03:37 +02:00
Frederic Danis
e88ab30d36 Bluetooth: hci_bcm: Add suspend/resume runtime PM functions
Adds autosuspend runtime functionality to BCM UART driver.
Autosuspend is enabled at end of bcm_setup.

bcm_device_lock is used for system sleep functions as they can be
called at any time.
bcm_device_lock is not held for runtime suspend functions as this
is only enabled as long as platform device is opened.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-24 16:25:44 +02:00
Frederic Danis
b7a622a249 Bluetooth: hci_bcm: Prepare PM runtime support
Change some CONFIG_PM_SLEEP to CONFIG_PM as hu and is_suspended parameters
will be used during PM runtime callbacks.

Add bcm_suspend_device() and bcm_resume_device() which performs link
management for PM callbacks.
These functions will be used for runtime management.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-24 16:25:44 +02:00
Frederic Danis
5cebdfea32 Bluetooth: hci_bcm: Fix IRQ polarity for T100
ACPI table for BCM2E39 of T100TA is not correct.
Set correct irq_polarity for this device.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-24 16:25:44 +02:00
Frederic Danis
6cc4396c88 Bluetooth: hci_bcm: Add wake-up capability
Retrieve the Interruption used by BCM device, which can be declared
as Interruption or GpioInt in the ACPI table.
Retrieve IRQ polarity from the ACPI table to use it for host_wake_active
parameter of Setup Sleep vendor specific command.
Configure BCM device to wake-up the host.
Enable IRQ wake while suspended.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17 13:20:06 +02:00
Frederic Danis
65ad07c9e5 Bluetooth: hci_bcm: Use bt_dev logging helpers
Replace BT_ logging calls by the new bt_dev ones.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17 13:20:01 +02:00
Frederic Danis
bb3ea16a44 Bluetooth: hci_bcm: Replace spinlock by mutex
Replace spinlock by mutex to be able to use bcm_device_lock in
sleepable context like devm_request_threaded_irq or upcomming PM support.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17 13:20:01 +02:00
Frederic Danis
917522aae1 Bluetooth: hci_bcm: Fix crash on suspend
If bcm_suspend is called whithout device opened there is a crash as
it tries to use bdev->hu which is NULL.
Rename bcm_device_list_lock to bcm_device_lock as it does not only apply
to bcm_device_list.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-28 21:09:14 +02:00
Loic Poulain
2af0a70913 Bluetooth: hci_bcm: Use non-sleep version of gpio_set_value
We should not sleep while holding a spinlock.
bcm_gpio_set_power is called while holding the bcm_device_list lock.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-18 00:59:19 +02:00
Frederic Danis
50d78bcf5d Bluetooth: hci_bcm: Fix "implicit declaration"
The kbuild test robot reported implicit declaration of function
'acpi_dev_get_resources'.

Surround ACPI function by CONFIG_ACPI test.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-12 16:41:32 +02:00
Uwe Kleine-König
62aaefa7d0 Bluetooth: hci_bcm: improve use of gpios API
devm_gpiod_get currently has an optional parameter to set initial
direction and value for the requested gpio. Make use of this to simplify
the driver and make it not fail to build when this parameter is made
mandatory (which is scheduled for 4.3-rc1).

Moreover use the _optional variant of devm_gpiod_get to simplify error
handling (which also gets more strict for free).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-12 16:35:44 +02:00
Frederic Danis
118612fb91 Bluetooth: hci_bcm: Add suspend/resume PM functions
Add reference to hci_uart structure to bcm_device.
This allows suspend/resume callbacks to manage UART flow control.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-11 21:59:38 +02:00
Frederic Danis
ae05690886 Bluetooth: hci_bcm: Retrieve UART speed from ACPI
Parse platform_device's ACPI to retrieve UART init speed.
When BCM device is open, check if its TTY has same parent as one of the
platform devices saved. If yes, use platform_device's init speed.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-11 21:26:27 +02:00
Frederic Danis
0395ffc1ee Bluetooth: hci_bcm: Add PM for BCM devices
Retrieve "shutdown" and "device_wakeup" GPIOs from ACPI.
Set device off during platform device enumeration.
Set device on only when attached.
As driver can be unbound we need to check if the bcm_device still exists
before calling GPIO's functions, this is protected using device_list_lock.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-11 21:26:26 +02:00
Frederic Danis
960ef1d72f Bluetooth: hci_uart: Fix speed selection
hu->proto->*speed will always be used for all device where it is set.
But hu->*speed should be used if exist, so the test should be swapped.

The equivalent change is needed in bcm_setup() of hci_bcm.c.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-06-18 13:47:14 +02:00
Chan-yeol Park
3713416763 Bluetooth: hci_uart: Fix dereferencing of ERR_PTR
If h4_recv_buf() return ERR_PTR instead sk_buff pointer, it should be
cleared once PTR_ERR is completed for the further dereference such as
h4_recv(), or h4_close().

Signed-off-by: Chan-yeol Park <chanyeol.park@samsung.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-06-17 14:21:08 +02:00
Frederic Danis
61b2fc2bb5 Bluetooth: hci_uart: Add bcm_set_baudrate()
Add vendor specific command to change controller device speed.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-06-09 23:27:35 +02:00
Frederic Danis
6be09b48ae Bluetooth: hci_uart: Update Broadcom UART setup
Use btbcm helpers to perform controller setup.
Perform host UART reset to init speed between btbcm_patchram() and
btbcm_finalize(). This may be need because firmware loading may have
reseted controller UART to init speed.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-06-06 07:37:33 +02:00
Frederic Danis
18aeb4445a Bluetooth: btbcm: Move request/release_firmware()
Move request/release_firmware() out of btbcm_patchram().
This allows a better error management, if request_firmware() returns an
error then the controller will be used without firmware loading and 0 is
returned.
This will imply to change btbcm_patchram() to accept a firmware instead
of firmware name.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-06-06 07:29:56 +02:00
Marcel Holtmann
79b8df9362 Bluetooth: hci_uart: Provide generic H:4 receive framework
Future H:4 based UART drivers require custom packet types and custom
receive functions. To support this, extended the h4_recv_buf function
with a packet definition table.

For the default H:4 packets types of ACL data, SCO data and events,
provide helpers to reduce the amount of code duplication.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-04-07 18:48:21 +02:00
Marcel Holtmann
bdd8818e05 Bluetooth: hci_uart: Add protocol support for Broadcom UART devices
This adds the protocol support for Broadcom based UART devices to
enable firmware and patchram download procedure. It is a pretty
straight forward H:4 driver with the exception of actually having
its own setup and address configuration callbacks.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-04-07 18:47:12 +02:00
Marcel Holtmann
3e0ac12a1a Bluetooth: hci_uart: Use generic functionality from Broadcom module
The new Broadcom Bluetooth support module provides generic functionality
for changing and checking the Bluetooth device address. Use these new
features instead of keeping a duplicate in the driver.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-04-07 18:47:11 +02:00
Marcel Holtmann
e9a2dd261a Bluetooth: hci_uart: Add support Broadcom address configuration
When using vendor detection, this adds support for the Broadcom
specific address configuration command.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-04-07 18:47:08 +02:00