aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/hci_intel.c
AgeCommit message (Collapse)Author
2017-06-16networking: add and use skb_put_u8()Johannes Berg
Joe and Bjørn suggested that it'd be nicer to not have the cast in the fairly common case of doing *(u8 *)skb_put(skb, 1) = c; Add skb_put_u8() for this case, and use it across the code, using the following spatch: @@ expression SKB, C, S; typedef u8; identifier fn = {skb_put}; fresh identifier fn2 = fn ## "_u8"; @@ - *(u8 *)fn(SKB, S) = C; + fn2(SKB, C); Note that due to the "S", the spatch isn't perfect, it should have checked that S is 1, but there's also places that use a sizeof expression like sizeof(var) or sizeof(u8) etc. Turns out that nobody ever did something like *(u8 *)skb_put(skb, 2) = c; which would be wrong anyway since the second byte wouldn't be initialized. Suggested-by: Joe Perches <joe@perches.com> Suggested-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16networking: make skb_put & friends return void pointersJohannes Berg
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions (skb_put, __skb_put and pskb_put) return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_put, __skb_put }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_put, __skb_put }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) which actually doesn't cover pskb_put since there are only three users overall. A handful of stragglers were converted manually, notably a macro in drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many instances in net/bluetooth/hci_sock.c. In the former file, I also had to fix one whitespace problem spatch introduced. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16networking: introduce and use skb_put_data()Johannes Berg
A common pattern with skb_put() is to just want to memcpy() some data into the new space, introduce skb_put_data() for this. An spatch similar to the one for skb_put_zero() converts many of the places using it: @@ identifier p, p2; expression len, skb, data; type t, t2; @@ ( -p = skb_put(skb, len); +p = skb_put_data(skb, data, len); | -p = (t)skb_put(skb, len); +p = skb_put_data(skb, data, len); ) ( p2 = (t2)p; -memcpy(p2, data, len); | -memcpy(p, data, len); ) @@ type t, t2; identifier p, p2; expression skb, data; @@ t *p; ... ( -p = skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); | -p = (t *)skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); ) ( p2 = (t2)p; -memcpy(p2, data, sizeof(*p)); | -memcpy(p, data, sizeof(*p)); ) @@ expression skb, len, data; @@ -memcpy(skb_put(skb, len), data, len); +skb_put_data(skb, data, len); (again, manually post-processed to retain some comments) Reviewed-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-09Bluetooth: hci_intel: Add GPIO ACPI mapping tableAndy Shevchenko
In order to make GPIO ACPI library stricter prepare users of gpiod_get_index() to correctly behave when there no mapping is provided by firmware. Here we add explicit mapping between _CRS GpioIo() resources and their names used in the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-12Bluetooth: hci_intel: add missing tty-device sanity checkJohan Hovold
Make sure to check the tty-device pointer before looking up the sibling platform device to avoid dereferencing a NULL-pointer when the tty is one end of a Unix98 pty. Fixes: 74cdad37cd24 ("Bluetooth: hci_intel: Add runtime PM support") Fixes: 1ab1f239bf17 ("Bluetooth: hci_intel: Add support for platform driver") Cc: stable <stable@vger.kernel.org> # 4.3 Cc: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-12Bluetooth: hci_intel: Add support Intel Bluetooth device 9160/9260 for UARTTedd Ho-Jeong An
This patch adds support for Intel Bluetooth device 9160/9260 also known as ThunderPeak(ThP) for UART. Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-12Bluetooth: hci_intel: Fix firmware file name to use hw_variantTedd Ho-Jeong An
The format of Intel Bluetooth firmware for bootloader product is ibt-<hw_variant>-<device_revision_id>.sfi and .ddc. This patch uses a hw_variant value read from the device during runtime to form the firmware filenames instead of using a constant value, so it can support multiple prouducts. Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2017-04-12Bluetooth: Use switch statement for Intel hardware variantsTedd Ho-Jeong An
Multiple new hardware variants are planned and the simple if statement would get really complicated and unreadable. So instead replace it with a simple switch statement. The change is applied to both USB and UART. Based-on-patch-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-09-19Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checksBart Van Assche
wait_on_bit_timeout() returns one of the following three values: * 0 to indicate success. * -EINTR to indicate that a signal has been received; * -EAGAIN to indicate timeout; Make the wait_on_bit_timeout() callers check for these values. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-07-11Bluetooth: hci_intel: Remove LPM enabling from setup procedureLoic Poulain
LPM can be enabled via a DDC write command at specific DDC ID. As any other DDC value, this is up to the DDC config file to include (or not) the low power mode configuration. Signed-off-by: Loic Poulain <loic.poulain@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-05-02Bluetooth: hci_intel: Fix null gpio desc pointer dereferenceLoic Poulain
gpiod_get_optional can return either ERR_PTR or NULL pointer. NULL case is not tested and then dereferenced later in desc_to_gpio. Fix this by using non optional version which returns ERR_PTR in any error case (this is not an optional gpio). Use the same non optional version for the host-wake gpio. Fixes: 765ea3abd116 ("Bluetooth: hci_intel: Retrieve host-wake IRQ") Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2016-02-23Bluetooth: hci_intel: Fix a wrong comparisonAnton Protopopov
A return value of the intel_wait_booting() function compared with a constant ETIMEDOUT instead of -ETIMEDOUT. Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-12-10Bluetooth: btintel: Create common Intel Version Read functionLoic Poulain
The Intel Version Read command is used to retrieve information about hardware and firmware version/revision of Intel Bluetooth controllers. This is an Intel generic command used in USB and UART drivers. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-12-10Bluetooth: hci_intel: Use shorter timeout for HCI commandsLoic Poulain
Use the standard HCI_CMD_TIMEOUT(1s) for HCI command instead of HCI_INIT_TIMEOUT(10s) which is not justified in these cases. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-11-19Bluetooth: Use new hci_skb_pkt_* wrappers for driversMarcel Holtmann
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-10-21Bluetooth: hci_uart: Provide initial manufacturer informationMarcel Holtmann
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-21Bluetooth: btintel: Add support for enabling tracing functionalityMarcel Holtmann
For Intel controllers with firmware that allows tracing of baseband functionality this allows enabling it via set_diag driver callback. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-10-01Bluetooth: hci_intel: Cleanup the device probe codeJarkko Nikula
There is some unneeded code in "hci_intel" probing. First acpi_match_device() call is needless as driver/platform/acpi core code has already done the matching before calling the probe and the driver does not use the returned pointer to matching _HID other than checking is it NULL. Then tree wide grep for "hci_intel" doesn't reveal that there is any code registering this platform device so it looks this device is always backed with ACPI companion so also ACPI_HANDLE() test can be removed. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Enable IRQ wake capabilityLoic Poulain
We need to explicitly enable the IRQ wakeup mode to let the controller wake the system from sleep states (like suspend-to-ram). PM suspend/resume callbacks now call the generic intel device PM functions after enabling/disabling IRQ wake. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Give priority to LPM packetsLoic Poulain
Change the way to insert LPM packets into the txq. Use skb_queue_head instead of skb_queue_tail to always prioritise LPM packets over potential tx queue content. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Add Device configurationLoic Poulain
Apply DDC parameters once controller is in operational mode. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Fix warnings due to unused lpm functionsLoic Poulain
intel_lpm_suspend/resume are only used in case of CONFIG_PM. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Show error in case of invalid LPM packet sizeLoic Poulain
Don't hide this packet size error. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Add runtime PM supportLoic Poulain
Implement runtime PM suspend/resume callbacks. If LPM supported, controller is put into supsend after a delay of inactivity (1s). Inactivity is based on LPM idle notification and host TX traffic. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Add PM supportLoic Poulain
Add PM suspend/resume callbacks which call lpm_suspend/resume. Add LPM ack in threaded IRQ handler to notify the controller that resume is complete. Protect hci_uart against concurrent removing during suspend/resume. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Implement LPM suspend/resumeLoic Poulain
Add LPM PM suspend/resume/host_wake LPM functions. A LPM transaction is composed with a LPM request and ack/response. Host can send a LPM suspend/resume request to the controller which should respond with a LPM ack. If resume is requested by the controller (irq), host has to send a LPM ack once resumed. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Replace spinlock with mutexLoic Poulain
Replace the device_intel list spinlock with a mutex. devm_request_threaded_irq is not atomic and upcomming PM support should be simpler. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Use bt_dev logging helpersLoic Poulain
Replace BT_ logging calls by the new bt_dev ones. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Introduce LPM supportLoic Poulain
Enable controller Low-Power-Mode if we have a pdev to manage host wake-up. Once LPM is enabled, controller notifies its TX status via a vendor specific packet (tx_idle/tx_active). tx_active means that there is more data upcoming from controller. tx_idle means that controller can be put in suspended state. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-09-17Bluetooth: hci_intel: Retrieve host-wake IRQLoic Poulain
An IRQ can be retrieved from the pdev resources. This irq will be used in case of LPM suspend mode to wake-up the host and resume the link. This resource can be declared as a GPIO-Interrupt which requires to be converted into IRQ. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-28Bluetooth: hci_intel: Add support for platform driverLoic Poulain
A platform device can be used to provide some specific resources in order to manage the controller. In this first patch we retrieve the reset gpio which is used to power on/off the controller. The main issue is to match the current tty with the correct pdev. In case of ACPI, we can easily find the right tty/pdev pair because they are both child of the same UART port. If controller is powered-on from the driver, we need to wait for a HCI boot event before being able to send any command. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-08-28Bluetooth: hci_intel: Add Intel baudrate configuration supportLoic Poulain
Implement the set_baudrate callback for hci_intel. - Controller requires a read Intel version command before updating its baudrate. - The operation consists in an async cmd since the controller does not respond at the same speed. - Wait 100ms to let the controller change its baudrate. - Clear RTS until we change our own UART speed Manage speed change in the setup function, we need to restore the oper speed once chip has booted on patched firmware. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-07-23Bluetooth: btintel: Create common function for Intel version infoMarcel Holtmann
The Intel version information is shared between USB and UART drivers and with that move it into a generic function of the Intel module. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-07-23Bluetooth: btintel: Create common Intel Secure Send functionMarcel Holtmann
The Intel Secure Send command is used the same in USB and UART drivers and with that move a generic version into the Intel module. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-07-23Bluetooth: hci_uart: Add Intel address configuration supportMarcel Holtmann
The Intel specific Bluetooth module provides support for pubic address configuration. So make sure that it is enabled for Intel UART devices. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-07-23Bluetooth: hci_uart: Add basic support for Intel Lightning Peak devicesLoic Poulain
The Intel Lightning Peak devices do not come with Bluetooth firmware loaded and thus require a full download of the operational Bluetooth firmware when the device is attached via the Bluetooth line discipline. Lightning Peak devices start with a bootloader mode that only accepts a very limited set of HCI commands. The supported commands are enough to identify the hardware and select the right firmware to load. Signed-off-by: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-04-07Bluetooth: hci_uart: Use generic Intel support for address settingMarcel Holtmann
The Bluetooth address setting for Intel devices is provided by a generic module now. Start using that module instead of relying it being included in the driver. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-04-07Bluetooth: hci_uart: Add support Intel address configurationMarcel Holtmann
When using vendor detection, this adds support for the Intel specific address configuration command. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>