Commit graph

656 commits

Author SHA1 Message Date
Mariusz Skamra 8adb16fc32 drivers/nble: Fix missing write flush() callback
This callback is needed to successfully perform write operation.

Change-Id: I09776dda16dac639320a7e83a66e7a9b31ebea6a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-04-28 17:34:23 +02:00
Mariusz Skamra 76b6716452 drivers/nble: Fix passing NULL pointer instead of conn to write() cb
conn object pointer has to be passed to the write callback instead
on NULL pointer.

Change-Id: Ifde88be0a43bcd9e1acbe11b16512776cd18fc66
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-04-28 17:32:05 +02:00
Mariusz Skamra a653f8a168 drivers/nble: Fix status returned from on_nble_gatts_write_evt
If attribute has no write callback, BT_ATT_ERR_WRITE_NOT_PERMITTED
error shall be returned.

Change-Id: I9277f8682597ee7f93a1267d2de31b3cc245f1cd
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-04-28 17:29:17 +02:00
Roger Lendenmann 3278f542eb Bluetooth: gatt: include service api definition proposal
* service include macro definition takes reference to
   first service attribute of the included service

Change-Id: Ib2b1defe2c99aea738da791af74a534d56025eae
Signed-off-by: Roger Lendenmann <roger.lendenmann@intel.com>
2016-04-28 10:35:38 +00:00
Andrei Emeltchenko c6f9941311 drivers/nble: Improve debug
Add debug for bt_gatt_notify() and print parameters in
on_nble_gap_conn_update_evt().

Change-Id: I5b61b5dbf508a2ee8e0b79c8636bc2dc710fb2ef
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-27 12:02:33 +00:00
Andrei Emeltchenko 5a19423bb4 drivers/nble: Remove unneeded type cast
Since the header was updated type cast is not needed.

Change-Id: I6a232cd8515fb48ef2a0d16cc064effac7b80bfd
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-27 12:02:23 +00:00
Johan Hedberg 6a075ace24 Bluetooth: drivers/nble: Initial implementation of bt_storage_clear()
Now that there's a helper for clearing nRF51-side bonds we can use
that in bt_storage_clear().

Change-Id: I9eea4b100834b150e7c55a5141f1624853335c0a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-26 15:21:36 +03:00
Johan Hedberg 0b68af523e Bluetooth: drivers/nble: Clear bonds upon init
To ensure reliable behavior when pairing we need to clear the nRF51
persistent memory upon init.

Change-Id: I204bb27e7c6e33dc5dd006ad9937645e907e770f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-26 15:08:34 +03:00
Johan Hedberg 4832da8db7 Bluetooth: drivers/nble: Fix using too large buffer
The nble firmware supports a max ATT MTU of 23 (i.e. the default).

Change-Id: I70f55b00b50b2ad6540850d594a6d2fb89b11d1a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-25 19:21:28 +00:00
Johan Hedberg 39e63117c4 Bluetooth: drivers/nble: Fix passing NULL to attr->read()
We should be looking up the appropriate connection object and passing
that to the callback.

Change-Id: I04620b301541c8bda45f20e2b1dcca8f71562821
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-25 19:21:10 +00:00
Johan Hedberg 847703d91b Bluetooth: drivers/nble: Fix on_nble_gatts_read_evt() behavior
We need to reset len to 0 in case of failure to prevent the nRF
firmware from reading past the end of buffer. At the same time clean
up the code a bit.

Change-Id: I2ac9a86e0f7704ae55c9b2758e02dfadf650f549
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-25 19:20:58 +00:00
Andrei Emeltchenko 0ff961fb29 drivers/nble: Update Nordic RPC to 0425
Update RPC to Nordic BLE radio module to 0425 revision.

Change-Id: Ieb79821acd5a8fbc4358ea5e1f258834a7932c2c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-25 15:03:53 +03:00
Anas Nashif 1797c8f108 qmsi: uart: use built-in qmsi driver
Change-Id: Ie19aee8dad8ba082891f92a2d42dc71f4ac34dbe
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-22 20:55:36 -04:00
Anas Nashif 324a83bed7 nble: Use string name for GPIO driver
Do not depend on specific implementation of the driver, use
well-known driver name used across multiple IPs.

Change-Id: I823fcfa01ce1484dd89f6ade8fbe7017f2084bc6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-23 00:54:34 +00:00
Johan Hedberg e3e91d3280 Bluetooth: Add name member to HCI driver struct
This is more of a convenience to let the driver identify itself in
debug logs and the monitor protocol.

Change-Id: I73351477e98d45d6344c180b8088bde29df6f7d9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-22 18:49:11 +03:00
Johan Hedberg 4488fc6cab Bluetooth: Move HCI device bus information to the driver
The bus that we notify over the monitor protocol is really driver
specific, so let each driver specify their bus type.

Change-Id: Ic3a086fcc06352dbf051e52cef5bf6b8696349ae
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-22 18:49:11 +03:00
Andrei Emeltchenko 5860325b4f drivers/nble: Cleanup Nordic RPC code
Remove handling not used and obsolete function prototypes.

Change-Id: I6086f2e13efe7fc219f237dda710a545bec07612
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-21 15:31:09 +00:00
Andrei Emeltchenko 642d596d69 drivers/nble: Update RPC to 0422 revision
Update RPC adding gap_tx_power request and event. Corresponds to BLE
version ATLASEDGE/PVT/FACTORY-386-gc1f694b.

Change-Id: I7e47553af63c3c3405522e37f86d9004dcca46f7
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-21 15:30:54 +00:00
Johan Hedberg b090d75d62 Bluetooth: drivers/h5: Remove redundant BT_DBG()
Change-Id: I90e7caadfb357c1c2451b0108d11ce57c0dae77a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-21 10:41:48 +03:00
Andrei Emeltchenko 503d01a96c Bluetooth: Fix typo tupe to type
Fixes compilation with debug for drivers h4 and h5

Change-Id: Ia09ce0a5ca3d684a4f9d25fdfe8530e80a46afac
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-21 10:09:30 +03:00
Johan Hedberg 560956c54d Bluetooth: Kconfig: Split debug selection into a choice
This prepares for adding other debug types besides the printf-style
logging to the console.

Change-Id: Ic2ed305192491734da991c4f61fdaace03fd60f2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-20 17:46:09 +03:00
Johan Hedberg d458c616df Bluetooth: Add missing debug log to HCI driver send()
Change-Id: I0842675192cd1fbf3997a8f0d4906f114c0489c1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-19 14:39:55 +03:00
Johan Hedberg 72ce7c7dc1 Bluetooth: Add support for waiting for "NOP" Command Complete
Some controllers will emit an initial "NOP" Command Complete event
during initialization and expect the host to only send commands once
this event has been received. This patch adds a new Kconfig option to
be used in the case of such controllers and defaults this to true on
Arduino 101 with the H:4 driver where this behavior is currently
observed.

Change-Id: I440f14a7c07ac27545febf9f85ebcc343e2a4558
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-18 12:58:22 +00:00
Andrei Emeltchenko 2329d54546 arduino: Remove Kconfig warnings rearranging GPIO selection
Remove warnings below:
...
warning: (BLUETOOTH_NRF51_PM) selects GPIO which has unmet direct
dependencies (BOARD_GALILEO || BOARD_QUARK_SE_DEVBOARD &&
NETWORKING_WITH_15_4_TI_CC2520 || SOC_FSL_FRDM_K64F)
...

Change-Id: I15db8cf5f9895e0693e3363974e4cdad533b55a4
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-18 12:54:20 +00:00
Anas Nashif 874877519e Bluetooth: include errno.h
Change-Id: I42e9e952780c4ffeba28a857b9a3836dcda5d7ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-16 02:02:11 +00:00
Andrei Emeltchenko 8418b2eeb3 drivers/nble: Implement read multiple response
Implement on_nble_gattc_read_multiple_rsp().

Change-Id: I25e8e7f74325024fde1737086e4674893f4a105a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-15 17:02:11 +00:00
Mariusz Skamra 1bc53f3f47 drivers/nble: Fix NULL pointer dereference
This fixes conn->gatt_private = NULL pointer dereference that occurs
in the next Read Blob Response, here:

/* TODO: Get params from user_data pointer, not working at the moment */
params = conn->gatt_private;

Change-Id: Icf280c856133a4c91fc10475d3a047809f917f46
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-04-15 11:04:20 +02:00
Szymon Janc c2a1ac8ae7 Bluetooth: Add support for confirming incoming JustWorks pairing
If incoming pairing request would result in JustWorks pairing this
can be used to request consent from user for accepting it.

Change-Id: If0695d0e1bb010bade6a16abe1b57a2ce07856cc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-04-14 15:20:03 +00:00
Andrei Emeltchenko 931afc81a4 drivers/nble: Fix spelling typo
Change-Id: Ibe5c910a69fccdf4375738ec13cbea9d6c972a41
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-14 14:48:51 +00:00
Grzegorz Kolodziejczyk 2bae7b4c5f Bluetooth: drivers/nble: Fix returning included service handle
Parse include function intention is to return last parsed included
service handle. Next discovery iteration of included services should be
started from last found included service handle instead of end handle
from included handle value (which contains attribute handle of included
service declaration and the end group handle, BLUETOOTH SPECIFICATION
Version 4.2 [Vol 3, Part G], 4.5.1).

Change-Id: I73fe4027cb616242e838ea54c61b7780f1838e52
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-04-14 13:47:26 +00:00
Mariusz Skamra ff8b88b634 drivers/nble: Fix handling read errors
If on_nble_gattc_read_rsp returns an error, this error shall be
passed to the application to let know that Read Request/Read Blob Request
was aborted due to ATT error received.

Change-Id: I0efe26ec90fe27a1ab3c791e555ebe682927ab57
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-04-14 12:42:09 +02:00
Mariusz Skamra 5047d54403 drivers/nble: Fix compare logic in on_nble_gattc_read_rsp
The Read Response only contains a Characteristic Value that is less
than or equal to (ATT_MTU – 1) octets in length so, condition
(length < bt_att_get_mtu(conn)) is always true, and the full
Characteristic Value will not be read.

Change-Id: Ib18fbedf277c880dc5cf0ce21fd7d550d12a64ef
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-04-14 12:41:39 +02:00
Johan Hedberg bacdf02061 Bluetooth: drivers/nble: Fix minor coding style issue
Change-Id: I71caf45702f053033fde5c5c0bc4dea22dbe95d1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-12 12:33:24 +03:00
Andrei Emeltchenko e12cf24e6d drivers/nble: Implement multiple read in bt_gatt_read
Implement read multiple characteristics in bt_gatt_read().

Change-Id: I18c11275e4352bfc571b06558116bcbb9b4a32d3
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-12 12:09:08 +03:00
Andrei Emeltchenko 424cf4f9d2 drivers/nble: Update RPC to Nordic BLE Module
Add read multiple attributes request and response. Update RPC version
to niko-0412.

Change-Id: I5dfd99a1b8af866b69eae230ad24304eafccab4d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-12 10:32:41 +03:00
Andrei Emeltchenko 37ef89511d drivers/nble: Correct auth configuration for No Input / Output
Change-Id: I5d1a9508ca8deca97149db2faa2f3406517e3b05
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-11 15:24:24 +00:00
Johan Hedberg 30601c09bb Bluetooth: Refactor buffer handling for non-host managed buffers
So far the assumption has been that the host stack manages all
incoming and outgoing buffers. For the incoming buffers (from the
controller) this has required hci_core.c to manage its own pools and
do the host flow control. This setup makes perfect sense for an
architecture where the controller resides remotely on a different CPU
& address space (i.e. the "traditional" HCI transport case).

When the stack runs on a system where the controller resides in the
same address space this setup doesn't work that well. In such a
scenario the incoming buffers are ideally created as low down in the
stack as possible (i.e. below HCI), which means that the current
hci_core.c cannot be responsible for managing their pools.

To allow for both types of architectures this patch introduces a new
BLUETOOTH_HOST_BUFFERS Kconfig option that can be selected to say that
host-side management is desired, or deselected to say that the
controller (residing in the same address space) takes care of managing
the incoming buffers.

So far the incoming buffer types were identified by hci_core.c by
looking at their "free pool" pointers, however as soon as the pools
are allowed to be somewhere else this doesn't work. To solve this we
now require a minimum user data size for all Bluetooth buffers and use
that to store the buffer type.

Change-Id: I14bc32007e3e3f17c654f71f79b520650028d7ce
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-11 11:52:29 +00:00
Johan Hedberg 9d90ef45ec Bluetooth: drivers/nble: Add Kconfig option for conn.c
Without this conn.c will cause logs whenever BLUETOOTH_DEBUG is
enabled.

Change-Id: I03f7d6b5b37e05ca23cba20536b24dbdb850304d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-08 13:27:33 +00:00
Johan Hedberg 8e4582f80d Bluetooth: Kconfig: don't hardcode "UART_0"
Change-Id: Ic1da719450d3ba516d61c67a3256b38e04f7585c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-08 13:27:20 +00:00
Johan Hedberg e5df34041f Bluetooth: Refactor nRF51 API
The previous enable/disable API implementations weren't actually what
their names implied, but simply gave the right result for the
initialization scenario when called after each other. Split these into
proper init/enable/disable APIs which do the exact thing that the
names imply.

Change-Id: I09a930d3607f4919ecd889ec3ee4ba8d7b12ee36
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-08 13:27:02 +00:00
Johan Hedberg 7f07d28f37 Bluetooth: Fix BLUETOOTH_NRF51_PM Kconfig definition
Clarify the name of the option and add a dependency to Arduino 101
which is the only known board that is currently known to need it.

Change-Id: Ibfb96cba202f34464b45b922da599da70c038d12
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-07 10:50:52 +03:00
Grzegorz Kolodziejczyk 355ded1863 drivers/nble: Add support to bt_gatt_attr_next
This function is needed to get next attribute of  passed to function
attribute.

Change-Id: Iefe2015f2d6bcb650012b1f9d5b1ea98e8fa8f48
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-04-06 12:35:49 +00:00
Andrei Emeltchenko bd5f745e25 Bluetooth: Enable Nordic BLE chip using PM helpers
When Nordic BLE chip is flashed with HCI firmware use H:4 UART driver
and enable chip the same way we enable for NBLE.

Change-Id: Ie14734266803088feadb0d0eb20c49c3615f0267
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-06 12:10:21 +00:00
Johan Hedberg f72063e214 Bluetooth: drivers/nble: Require callback for bt_enable()
The nble nRF51 firmware cannot handle situations where it receives
data before it is ready. The RPC calls otoh cannot be blocking.
Combine this with the fact that bt_enable(NULL) is supposed to be
blocking means we cannot support this mode of operation with nble.

Change-Id: Ib9c2c322b44b04bc48be243c2ba1c1bc4becb8ea
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-06 11:51:27 +00:00
Andrei Emeltchenko 3252f6cf1a drivers/nble: Refactor PM code to make it reusable
Refactoring Power Management related code to special file nrf51_pm
making it possible to reuse the functions for H:4 UART driver when
Nordic BLE is flashed with HCI firmware.

Change-Id: If389c1f4af13fa786e5866129624527cec0928e0
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-06 14:00:56 +03:00
Andrei Emeltchenko 8e4440674e Bluetooth: Add option for PM with Nordic BLE chip
The config option handles enabling, disabling and power management
operations with Nordic nRF51 BLE chip.

Change-Id: I816062a7fb17c9e57c234113a2cecdebceb407b6
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-06 14:00:55 +03:00
Andrei Emeltchenko ecc35267da drivers/nble: Move Nordic Bluetooth LE driver inside drivers/bluetooth
Move NBLE code to the place where other Bluetooth drivers code resides.

Change-Id: Ibcf9ffb016e9b842bed66a61dff5c101b1573aaa
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-04-05 14:04:44 +03:00
Daniel Leung 8df10d4584 kconfig: untangle ordering and dependencies
There are two major issues with the kconfig:

() Some of the config options have incorrect dependencies inside help
   under menuconfig. For example, CONFIG_GPIO depends on BOARD_GALILEO.

() Since the SoC and board specific kconfig files are parsed first,
   the help screen would say, for example, CONFIG_SPI is defined at
   arch/arm/soc/fsl_frdm_k64f/Kconfig. This is incorrect because
   the actual config is defined in drivers/spi/Kconfig.

These cause great confusion to users of menuconfig/xconfig.

To fix these, the SoC and board defaults are now to be parsed last.

Note that the position swapping of defaults in this patch is due to
the fact the the default parsed last will be used.

And, spi_test is broken due to the fact that it requires
CONFIG_SPI_INTEL_PORT_1, but never enables it anywhere. This is
bypassed for now.

Origin: refactored and edited from existing files
Change-Id: I2a4b1ae5be4d27e68c960aa47d91ef350f2d500f
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-26 20:36:32 -04:00
Daniel Leung fa868a7846 drivers: bluetooth: nble: restructures Bluetooth Kconfig options
This moves both the Bluetooth HCI and NBLE drivers under
"Bluetooth Drivers" category. This also adds a selection for
choosing Bluetooth stacks as the bulk of both HCI and NBLE stacks
cannot be compiled together.

Note that this does not move the source files. That should be
done in a separate change.

Change-Id: I32fa7097ada0fdc52bcc745adb78c7273f4023c6
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-19 00:23:11 +00:00
Johan Hedberg b84f60cab3 Bluetooth: Move stack analysis helper to a global location
The helper for analyzing (fiber) stack usage is in no way specific to
Bluetooth and will likely be of use to many other places as well. Move
it therefore to include/misc.

Change-Id: Iedb699dbe248aca305e387998d37bb339cfb0e21
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-17 16:29:05 +00:00
Andre Guedes b3cb3a1f68 drivers: Replace DEV_INVALID_CONF by -EINVAL
This patch replaces all occurences of the macro DEV_INVALID_CONF by
-EINVAL at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/ when applicable.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: Idae0d5af8dd780416977c9261a5fb6188c3aab64
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Andre Guedes 024cfe754e drivers: Replace DEV_OK by 0
This patch replaces all occurences of the macro DEV_OK by the actual
value 0 at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: I69980ecb9755f2fb026de5668ae9c21a4ae62d1e
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Daniel Leung e643cede3a uart: add ISR callback mechanism for UART drivers
The peripherals utilizing UART were required to register their own
ISR rountines. This means that all those peripherals drivers need
to know which IRQ line is attached to a UART controller, and all
the other config values required to register a ISR. This causes
scalibility issue as every board and peripherals have to define
those values.

Another reason for this patch is to support virtual serial ports.
Virtual serial ports do not have physical interrupt lines to
attach, and thus would not work.

This patch adds a simple callback mechanism, which calls a function
when UART interrupts are triggered. The low level plumbing still needs
to be done by the peripheral drivers, as these drivers may need to
access low level capability of UART to function correctly. This simply
moves the interrupt setup into the UART drivers themselves. By doing
this, the peripheral drivers do not need to know all the config values
to properly setup the interrupts and attaching the ISR. One drawback
is that this adds to the interrupt latency.

Note that this patch breaks backward compatibility in terms of
setting up interrupt for UART controller. How to use UART is still
the same.

This also addresses the following issues:

() UART driver for Atmel SAM3 currently does not support interrupts.
   So remove the code from vector table. This will be updated when
   there is interrupt support for the driver.
() Corrected some config options for Stellaris UART driver.

This was tested with samples/shell on Arduino 101, and on QEMU
(Cortex-M3 and x86).

Origin: original code
Change-Id: Ib4593d8ccd711f4e97d388c7293205d213be1aec
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-05 13:37:57 +00:00
Peter Mitsis 06e2b4e129 nanokernel: Change fiber_delayed_start() return type
Instead of returning a 'void *', the nanokernel fiber_delayed_start()
family of routines now return a handle of type nano_thread_id_t.

Consequently, the nanokernel fiber_delayed_start_cancel() family of
routines now accept a parameter of type nano_thread_id_t instead of
'void *'.

The complete list of affected nanokernel routines is:
    fiber_delayed_start()        fiber_delayed_start_cancel()
    fiber_fiber_delayed_start()  fiber_fiber_delayed_start_cancel()
    task_fiber_delayed_start()   task_fiber_delayed_start_cancel()

Change-Id: Ibd4658df3ef07e79a81b7643a8be9ea5ffe08ba0
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-23 10:48:54 -05:00
Johan Hedberg 1bc6597d4d Bluetooth: Take advantage of the new net_buf_pull_u8() helper
Change-Id: I41ac2bc721b916f6d939f23be293750a83d21523
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-12 16:03:43 +00:00
Andrew Boie 897ffaeb2c irq: rename irq_connect() to IRQ_CONNECT()
It's not a function and requires all its arguments to be build-time
constants. Make this more obvious to the end user to ease confusion.

Change-Id: I64107cf4d9db9f0e853026ce78e477060570fe6f
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh a4ec963138 init: use SYS_INIT() where it makes sense
Mostly SoC initialization and some kernel subsystems, but also some
device drivers like the interrupt controllers.

Change-Id: I8dc1844c33acd877c075b6b03558fdca6f87500b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh d340d4cb3f device: use DEVICE_INIT everwhere
This is the last step before obsoleting DEVICE_DEFINE() and
DEVICE_INIT_CONFIG_DEFINE().

Change-Id: Ica4257662969048083ab9839872b4b437b8b351b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh 0303d8cab9 device: rename SYS_DEFINE_DEVICE()
Rename it to DEVICE_DEFINE() so that it fits in the 'device' namespace.

Change-Id: I3af3a39cf9154359b31d22729d0db9f710cd202b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh bfc27206b2 device: rename DECLARE_DEVICE_INIT_CONFIG()
Rename it to DEVICE_INIT_CONFIG_DEFINE(), because (a) it was not fitting
in any namespace and (b) it is not used to declare, but rather define a
object.

Change-Id: I1da5822f06b85a9fb024b5b184afd0ccc01012ec
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Peter Mitsis a0e4568760 c++: Add extern "C" { } block to header files
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ source files.

Change-Id: Ia4db0c36a5dac5d3de351184a297d2af0df64532
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:22 -05:00
Andrei Emeltchenko 1310031915 Bluetooth: Make h4_dev static
Change-Id: I75a5655fafb8ccabbb096777ff0e2fb8be499e4f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:19 -05:00
Andrei Emeltchenko 7b3317bb54 Bluetooth: h5: Fix not handling NULL when there is no buffers
In ISR context we receive NULL when there is no free buffers available.
Add handling similar to H4.

Change-Id: I9c1c2784ceaf31a1b2f9433b142a342e8dcdbc3e
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:18 -05:00
Johan Hedberg 3f667a45f8 Bluetooth: drivers/h5: Further simplify parsing logic
Move rx state to the h5 struct and use a commmon h5_reset_rx() helper
to reset it.

Change-Id: I92af740ae26b443460531b7200dbb0e64fb11d64
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Johan Hedberg 19416fb488 Bluetooth: drivers/h5: Rename 'state' to 'link_state'
Change-Id: Ie188cd34d8006f6c83728bf03cdfc71653c7334a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Johan Hedberg c1e49be194 Bluetooth: drivers/h5: Simplify parsing logic
Change-Id: I2a4a4d42329a407a62539a493dfcdaab666231f1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Johan Hedberg 20967d3f48 Bluetooth: drivers/h5: Split up h5_unslip_byte() return handling
Change-Id: I2d9a2700e5ac8dfb22ee853adc954a0fe02b8439
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Johan Hedberg 9a32952581 Bluetooth: drivers/h5: Remove unnecessary bt_buf_get_sig() helper
Change-Id: I2fd46e325ffba679a0aa27f5b05d4ec9ac67bc13
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Johan Hedberg 5559aa13e1 Bluetooth: drivers/h5: Add explicit RECV_RESERVE in Kconfig
Change-Id: Id0957cbe626f54ee167382dab37414467398462d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Johan Hedberg d1117f8575 Bluetooth: drivers/h5: Remove unnecessary SIGNAL state
The handling of SIGNAL and PAYLOAD states is exactly the same. Just
remove the other one.

Change-Id: Id82524812919658c6b1df76a7081c826aaf3df34
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Johan Hedberg ac35dfa7b2 Bluetooth: drivers/h5: Move h5_set_txwin() closer to the point of usage
Change-Id: I63c4816ec0c7a765be7723c3da82dd165b753fa7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:17 -05:00
Andrei Emeltchenko 3dcb3b8cb4 Bluetooth: h5: Recalculate seq number when retransmitting
When packet is retransmitted we need to recalculate sequence number
since it is not stored in the packet buffer.

Change-Id: Id389fa814e82cfd5e39afba1eaeaa79fc9e337f1
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:17 -05:00
Andrei Emeltchenko 276258e647 Bluetooth: h5: Fix memory leaks in case of error condition
In a case of unexpected SLIP_DELIMETER we need to discard remaining
bytes in UART and start from beginning.

Change-Id: Ib13a885cc1a4a188057c587e9974aff1d90594c3
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:17 -05:00
Andrew Boie d9cfbd5a61 interrupts: new static IRQ API
The interrupt API has been redesigned:

- irq_connect() for dynamic interrupts renamed to irq_connect_dynamic().
  It will be used in situations where the new static irq_connect()
  won't work, i.e. the value of arguments can't be computed at build time
- a new API for static interrupts replaces irq_connect(). it is used
  exactly the same way as its dynamic counterpart. The old static irq
  macros will be removed
- Separate stub assembly files are no longer needed as the stubs are now
  generated inline with irq_connect()

ReST documentation updated for the changed API. Some detail about the
IDT in ROM added, and an oblique reference to the internal-only
_irq_handler_set() API removed; we don't talk about internal APIs in
the official documentation.

Change-Id: I280519993da0e0fe671eb537a876f67de33d3cd4
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:17 -05:00
Andrew Boie 2295e2abf7 uart: remove uart_irq_get()
This API is not being used for anything, the interrupts for UART
drivers are all being configured statically. Saves code space as
gc-sections can't tell that these APIs are unused.

Some instances where IRQ/priority information was being saved in
data structures and never used fixed.

Change-Id: If56b4fdc251b80be9094ffcbac6f61e265ac2ffd
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:16 -05:00
Peter Mitsis cd6db374de nano_fifo: Simplify nano_xxx_fifo_get() API family
Changes the nanokernel FIFO API so that the timeout parameter must be
specified when invoking nano_isr_fifo_get(), nano_fiber_fifo_get(),
nano_task_fifo_get() and nano_fifo_get().

This obsoletes the following APIs:
	nano_fiber_fifo_get_wait()
	nano_fiber_fifo_get_wait_timeout()
	nano_task_fifo_get_wait()
	nano_task_fifo_get_wait_timeout()
	nano_fifo_get_wait()
	nano_fifo_get_wait_timeout()

Change-Id: Icbd2909292f1ced0bad8a70a075478536a141ef2
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:14 -05:00
Andrei Emeltchenko 9b7fecc86b Bluetooth: h5: Fix clearing unack packet queue
Using number_removed to find out how many packets from unack queue we
need to clear.

Change-Id: Icad948892f3ab1febc939e9ba6d6b3431973633e
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Andrei Emeltchenko 960e1380b2 Bluetooth: h5: Drop out of sync packet
We might get out of sync packet because of race collision, drop it.

Change-Id: Ic84a760199df1520dc7a95383972f9ec428c7fde
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Andrei Emeltchenko cad8ca1025 Bluetooth: Refactoring parsing H5 signalling
Add paring sync_req and conf_req and handling transmit sliding window.

Change-Id: I05827ff81d0bb726e72efec3c7cde161259a10c4
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Andrei Emeltchenko 8ded073b6c Bluetooth: Cleanup H5 driver code
Rename functions to indicate static ones

Change-Id: Ie1f58baf9875c0ce606ce2c3cd0704057a7f8223
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Johan Hedberg 7be985d507 Bluetooth: h5: Fix coding style issues
Change-Id: Ieb25575ed3ef2bb7439531a95e12a7e65eee3d96
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 841f7c120f Bluetooth: Add stack analysis for H5 UART driver
Analyze stack when sending single ACK packet.

Change-Id: Ifd3a54f0d1ad9a644363563fa9b8bea05b895fa9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 3a415c6bfb Bluetooth: Add unacked queue re-queueing
Change-Id: I2a12e6db72046d5ebc78c932ab5054eadbb4308c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 950078b36d Bluetooth: Improve debug for H5 UART driver
Change-Id: I371717d24ff24ab84871b8f29f365e8a65c74832
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 3663d11a6d Bluetooth: h5: Add initial retransmission support
Reuse delayed fiber start stack

Change-Id: I739efbeebca15ed27c2874c6f56da99f514bbce9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 53543c5f6d Bluetooth: Sending ACK packet using delayed fiber method
If there is no packet to be sent after timeout we have to send ACK for
last received packet.

Change-Id: I30bbc4ae1a257f9a7351dc5a5d2f1269740ce447
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 379ae2d043 Bluetooth: Add three-wire (H5) uart driver
Add initial code for three-wire (H5) Bluetooth uart driver.
At the moment the driver is EXPERIMENTAL. To test use following
method with qemu:

Run btproxy with three-wire emulation patches:
$ sudo tools/btproxy -d --pty -3
Opening pseudoterminal
New pts created: /dev/pts/21
Opening user channel for hci0

Notice that new device created: /dev/pts/21, use it with qemu -serial
parameter.

Run qemu target with following parameters:
$ make qemu 'QEMU_EXTRA_FLAGS=-serial /dev/pts/21'

Change-Id: I51579ffd8088583df9106689a03b2a0b4aa9e4cb
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko e28c5cecd0 Bluetooth: trivial: Correct style
Remove extra line and correct style according to common style.

Change-Id: I5fc9434edce44e52b51fc40866638c0899985b1b
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko a8c042827a Bluetooth: Correct headroom calc for outgoing packet
Needed headroom depends on type of the UART driver, change it
accordingly.

Change-Id: Ic9bf5f08a49be6823fce5eff8139d5f949b313ca
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:07 -05:00
Andrei Emeltchenko 2e97cbc55b Bluetooth: trivial style correction
Change-Id: Ib9069e2698614a3f5bb4bc9382aa5d458f007d95
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:07 -05:00
Johan Hedberg 5d80ae929c Bluetooth: Rename NO_DRV to more consistent NO_DRIVER
Change-Id: I30b89607446c9a9926411b5fb210460d076369b1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:07 -05:00
Johan Hedberg b9c8afb353 Bluetooth: Rename DEBUG_UART to more generic DEBUG_DRIVER
Change-Id: I6a47f7579be233d1bcdf01dc9af57f6da62ef75c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:07 -05:00
Johan Hedberg 486167fdee Bluetooth: Kconfig: Remove redundant dependencies
Change-Id: I41013cbea2ec78157b9c5551c3aabecc2daa24a1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:06 -05:00
Johan Hedberg 5305003b32 Bluetooth: Use h4_* prefix for H:4 driver internal symbols
Now that the HCI driver is called H:4 use the shorter driver-specific
prefix h4_* for its internal symbols.

Change-Id: Icdab1147e5ec31f84e0a3d810192ddd462f4dfdd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:03 -05:00
Johan Hedberg 4bb1391c7d Bluetooth: Rename UART driver to H:4 driver
We'll in the future also have a three-wire UART (H:5) HCI driver, so
the current H:4 driver cannot have a generic name.

Change-Id: Id326ae63d6f4d273d0d0c6120143e2f8d62968d1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:03 -05:00
Szymon Janc 51f8ca59cd Bluetooth: Add newline to log macros
Make newline part of log macros so that caller doesn't have to
append '\n' every time logs are used. This make sure that no
log will be missing new line which results in concatenated log
messages.

Change-Id: I3231ae747c790816dbc1608e0a3bd56467ba0a1b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:59 -05:00
Juan Manuel Cruz bc1a79c4c3 irq: removes priority parameter from IRQ_CONFIG macro
Removes the 'priority' parameter from the IRQ_CONFIG macro.
This parameter was not used anymore in any architecture.
The priority is handled in the IRQ_CONNECT macro.
The documentation is updated as well.

Change-Id: I24a293c5e41bd729d5e759113e0c4a8a6a61e0dd
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
2016-02-05 20:24:57 -05:00
Daniel Leung 1720991b81 bluetooth/uart: use device name instead of index
Use device name to find the UART device for Bluetooth usage,
instead of relying on an arbitrary index.

The default device names being used are derived from the original
board.h for each platform. Some of them point to the same device
as UART console. Since this is a Kconfig option, the default
can be overridden so this is not a serious issue.

Change-Id: Ibe82f3968e72ba60f9c033aa3dfcb2fb3c41dc75
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:56 -05:00
Daniel Leung 3d361603e5 bluetooth/uart: let UART driver do the initialization
Remove the call to uart_init(), and let the UART drivers take care of
the port initialization.

Change-Id: Ibeca65b3fe64feb7a203a793c01c525ff5e6afda
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:56 -05:00
Dmitriy Korovkin 57f2741e4f init: Implement fine-grained initialization policy
Put initialization priorities as device driver Kconfig
parameter.

Initialization priority value for each platform is defined
in the platform Kconfig file.

Drivers and platform code use SYS_DEFINE_DEVICE to add
and initialization function.

Change-Id: I2f4f3c7370dac02408a1b50a0a1bade8b427a282
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:54 -05:00
Daniel Leung d3d64ca4cf bluetooth/uart: register driver at boot if enabled
The driver should handle the initialization instead of relying on
platform initialization. This is to conform to the driver model.

Change-Id: Idc95d59bce2470b5118e416ee05f07548991a15c
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:48 -05:00
Johan Hedberg 72e3b3fdb2 Bluetooth: uart: Simplify bt_uart_discard() with the help of min()
There's no need to do manual minumum calculation when there's the
min() helper available.

Change-Id: I4d5cfb088d9e6499750664680419ab4beb56e0d5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg 1d92308078 Bluetooth: uart: Simplify send callback logic
We can remove the need for the extra 1-byte headroom by simply
directly writing the H:4 header with uart_poll_out(). Also the
separate uart_out() function can be removed by taking advantage of the
counters already present in the net_buf.

Change-Id: I54bd852e28f416b3de250cd9f8a126269cccfc14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg 1f6841c9c1 Bluetooth: Convert driver header info to hidden Kconfig options
We know the needed values at build-time, so there's no point in having
a runtime mechanism of accessing them in the code. Having the values
as defines makes it e.g. possible to use them as input for defining
the size of buffer pools.

Change-Id: Ib7556644719bfb631e638fa5bf29f3d1747a5072
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg 3cae902928 Bluetooth: Make HCI driver send() consume the given buffer
It is more intuitive to assume that the driver send() consumes (takes
ownership) of the buffer given to it.

Change-Id: I53d9cbebc0564d1d11110fc78a62ce0bbb3cdfd2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:44 -05:00
Dmitriy Korovkin f1420515a7 irq: Add flags to IRQ_CONNECT_STATIC() macro and irq_connect() function
Flags allow passing IRQ triggering option for x86 architecture.
Each platform defines flags for a particular device and then
device driver uses them when registers the interrupt handler.

The change in API means that device drivers and sample
applications need to use the new API.

IRQ triggering configuration is now handled by device drivers
by using flags passed to interrupt registering API:
IRQ_CONNECT_STATIC() or irq_connect()

Change-Id: Ibc4312ea2b4032a2efc5b913c6389f780a2a11d1
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:24:44 -05:00
Johan Hedberg 2b68871f7c Bluetooth: uart: Fix discarding data in case of too small buffer
Even if a buffer can't hold the needed amount of data we should still
cleanly discard the bytes so that the driver doesn't loose sync of the
next packet boundary. This way we also get to remove the now
unnecesary 'failed' label.

Change-Id: Ic921fbf6c0ddef4a7721cee7fa3e01a31b127778
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg fc6b853211 Bluetooth: Clean up Kconfig
Clean up Kconfig conventions.

Change-Id: I06df0b6363cd2dab72e93456455aaef219340e4d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:40 -05:00
Johan Hedberg 4b433d4fa6 Bluetooth: Differentiate send/recv of needed driver headroom
The space that the HCI driver needs to reserve for its own use is not
necessarily symmetrical. E.g. even with the current H4 driver we only
need to reserve space for sending data but not for receiving it.
Keeping track of these values independently enables more efficient use
of the buffers.

Change-Id: I64917b545c5cd77356ed038d09afe76422334661
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg 5f4daa1551 Bluetooth: Merge send_acl/cmd back to a single callback
Now that we have the buffer type enum as part of the HCI driver API we
can take advantage of it to pass the buffer type information and not
have to have two separate callbacks.

Change-Id: Ib2ee5b1540e532c9b27903e97660a276c1293fbc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg 1ddc3edcaa Bluetooth: Introduce HCI-driver specific buffer functions
This way we avoid dealing with the specific buffer type value and to
make it clear that these are for drivers onle.

Change-Id: I8aef7ec6a767b2fa68cbe374eb371e2a6192f675
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg 7ff1cbd976 Bluetooth: Split HCI driver ACL/CMD send callback
This is a necessary step in preparation for removing the buffer type
information from the buffers.

Change-Id: I29d8fae32aa660416a1c12e87840499c711e659f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg f1baa0b8fc Bluetooth: uart: Remove incorrect buffer type check
It's invalid to try to send HCI events to the controller so we should
treat such buffer types as invalid in bt_uart_send().

Change-Id: I4108a158d5b91f364a9f3c56e3037f03755daa19
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg ea11d4b5cd Bluetooth: Add helper macros for accessing Bluetooth user data
To avoid unnecessary stack variables and to simplify code, add helper
macros to access the Bluetooth specific ACL and HCI user data that's
part of the buffers.

Change-Id: Idc337537721115c4091982c04f8a05bbbf0d5a19
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Johan Hedberg 1f01f1da16 Bluetooth: uart: Convert to net_buf API
Convert the code to use the net_buf API instead of the soon to be
removed bt_buf API.

Change-Id: I8df37d214e1f93ee472cde82c4198d667709ff5a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg 581fa90ea8 Bluetooth: Initial conversion to net_buf API
This patch performs the minimal necessary conversion to the net_buf
API. It uses a temporary "#define bt_buf net_buf" to make it possible
to convert the code in smaller increments. Most old bt_buf function
also serve as one-line wrappers to the matching net_buf APIs. Once
everything is converted these helpers will be removed.

Change-Id: Ie31433d33576022c9c193a35d2389267005545d6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Johan Hedberg 79bd18e683 Bluetooth: uart: Remove dead code
There's no point in having a return value for uart_out() if it always
returns the same length that was passed to it. Just make it return
void and remove the error handling code from the caller (which would
never have been run).

Change-Id: I88dab7499a5f526ca65058640021f84e1b3486ca
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:38 -05:00
Andrei Emeltchenko 82f33267c5 Bluetooth: Change fifo_fill to poll_out
The reason why fifo_fill works in qemu but not on real hardware is
that qemu serializes all byte transmission 1 by 1. There is no
real hardware fifo emulated, and "fifo" depth is 1. On real
hardware, the controller owns an internal fifo, with a depth like
8 bytes on Quark x1000. And because of execution flow, how fast is
the controller etc etc... a fifo_fill call might fill in the
internal fifo of 8 bytes and then controller says "I am full"
(which means: "wait for the fifo to have space again"). That's
why poll_out() works: it does the same as fifo_fill and wait
that the internal fifo gets some space again before continuing.
And only when all bytes have been pushed in, it returns.

Change-Id: I452a6ebb2913c5e52ed01d999185e250aa3ed474
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:24:38 -05:00
Dan Kalowsky da67b29569 checkpatch: warning - block_comment_style
Change-Id: I6da43e41f9c6efee577b70513ec368ae3cce0144
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Tomasz Bursztyka 17e06fb457 uart: Move generic API to root directory of include
Only driver specific public headers should be found in include/drivers.
All generic API are found in include/ directory.

Change-Id: Ic50931987bb9460fd4a3843abc6f5de107faf045
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:32 -05:00
Dirk Brandewie 147d6585ae x86: arm: Modify IRQ_CONFIG macro to have same signature as ARC
In order to have drivers that are usable cross architecture the
signature for IRQ_CONFIG needs to be the same to avoid #ifdef hell in
the driver code based on architecture.

Update the macro and it usage for existing drivers

Change-Id: I22e142b21d4e984add231d1dbd97020e4823985f
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky 3bc4039601 checkpatch: error - switch_case_indent_level
Change-Id: I9cbd6ab80b0c0f170626bb1c6b2d07498038fb8f
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Johan Hedberg 4cdcd228a2 Bluetooth: UART: Fix bt_uart_send error return values
The send() callback of HCI drivers should be returning 0 on success
and a negative value on error. The uart_fifo_fill() function returns
the number of transmitted bytes so it can not be directly mapped to
the send() return value.

Change-Id: I59be478c1985f44a46f2a9613f61471423b0e63a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:16:16 -05:00
Szymon Janc 109d6fb21b Bluetooth: Make bt_uart_open parameters explicit void
Change-Id: I87826f2ab662bb07428cb0ba1edded0ab26d2d5b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:40 -05:00
Johan Hedberg 49cc10dcfd Bluetooth: uart: Minor coding style fix
Change-Id: Ide37ce471d99e911507316ea720e7aaff1dac744
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:15:37 -05:00
Daniel Leung e564035521 serial: rename struct field int_pri to irq_pri
This is just a cosmetic change to unify anything interrupt related
under 'irq'.

Change-Id: Ib8804d194e11eb49526fda952d9efc0f2ffac2df
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Daniel Leung 0f7a78ce1b bluetooth: move static device definition to platform configs
This moves the static device definition from the driver file,
drivers/bluetooth/uart.c, into the platform config files for
each platform.

This is another step towards converting UART drivers to
the new driver model. Also, platform config files are a more
logical place for the definition.

Change-Id: I668a52de5a38005b8b2bcb67d74437ead377cb16
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Daniel Leung 1ad2a56ee3 serial: rework functions to use struct device...
... instead of an array index to a global array. This is
an intermediate step to make the drivers conform to
the new driver model.

This only changes from using a direct array index to using
device structs. The UARTs are still staticlly defined.
Later patches will make the drivers utilize the driver
initialization procedure specified by the driver model.

Change-Id: I18041bbb4b0efdf8ae87088fd000b391d0827e9b
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Anas Nashif d2fff1fb7a drivers: use subdir-ccflags-y for all drivers
All driver Makefiles are adding the same cflags and they
have been done inconsistenly, make all drivers inherit
from the top level Makefile and remove unused includes.

Change-Id: Ie66d0ba7a418ac26f7eb709f50c887dc682e935c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:15:19 -05:00
Peter Mitsis 213db12fbf Move platforms to new arch/<arch>/platforms directory
Change-Id: I9ad5d51329d381c091aa47b482a8e38e7c194118
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Peter Mitsis 1ffabeaf3d Rename BSP_DIR to PLATFORM
Updates references to CONFIG_BSP_DIR to CONFIG_PLATFORM as part of the
BSP -> platform clean up.

Note that despite the renaming, the usage of the config option remains
unchanged.

Change-Id: I2846c3f761cf09871019c0855bf1824ae03e6b3c
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:27 -05:00
Dmitriy Korovkin 8d065343c2 Use static interrupt registration in device drivers
Make device drivers use static interrupt registration procedure.

DYNAMIC_INT_STUBS configuration parameter was used only by device
drivers to switch between static and dynamic interrupt registration
procedures. Now it is obsolete and is removed.

uart_int_connect() function is removed. If UART device driver still
needs to register interrupt dynamically, it should use
irq_connect(uart_irq_get()).

Change-Id: I80c695f337456e9b0c1b0fd56716e35794f7bdb7
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:14:25 -05:00
Dmitriy Korovkin b1b20e4129 Conditional build of bluetooth driver uart component
UART bluetooth driver build depends on CONFIG_BLUETOOTH_UART.

Change-Id: I95561f8daef494507e65e7977f444d861f2dac74
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:14:25 -05:00
Johan Hedberg 9bea2c3cfc Bluetooth: Move HCI driver API to dedicated header file
This makes it clearer that this is a specialized API not intended for
general app usage (unlike most other things in bluetooth.h).

Change-Id: I0ce1d5903610a9b3a99cf0be9f0e1462b04bf45a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 939544b75d Bluetooth: Move logging helpers to a dedicated header file
To make it clearer that these helpers are intended only for
Bluetooth-subsystem internal code, move them to a separate file.

Change-Id: Iea64780f5c61c1c96e12c9df378676bc49498fe4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 68773aa74e Bluetooth: Fix CONFIG_BLUETOOTH_DEBUG_UART dependency
The BLUETOOTH_DEBUG_UART config option should depend on BLUETOOTH_UART
and also be sorted after it in the hierarchy.

Change-Id: I3e049e52c2e353cd0c6f1a99ca8934a289e0cce8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:17 -05:00
Andrei Emeltchenko 1c65da5ed7 Bluetooth: Check returned buffer is not NULL
Buffers returned by bt_uart_evt_recv() and bt_uart_acl_recv() may be
NULL in theory. This makes code consistent by checking return value.

Change-Id: Id39def39c8b1c4c6eefc7b2bf01702c54b3e565c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:17 -05:00
Anas Nashif bbe84f8ae5 Use ccflags-y and asflags-y instead of EXTRA_CFLAGS
According to section 3.7 of Documentation/kbuild/makefiles.txt, using
EXTRA_CFLAGS in Makefiles is "still supported but their usage is
deprecated." However, using make EXTRA_CFLAGS="-DSOMETHING" results in
EXTRA_CFLAGS from Makefiles being overwritten, obviously breaking the
build.  This patch converts to them to the newer ccflags-y which also
fixes the problem.

Change-Id: I6309439599d4c9cc184f9ecd941bde841982ef07
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:14 -05:00
Dan Kalowsky c02dd34277 Renaming include/nanokernel to include/arch
Renaming the directory include/nanokernel to be include/arch, which
better reflects the real nature of the directory and the contents
inside.

Change-Id: I2bc33ebc6715e2f0403227a558279fdf52398ade
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:14:12 -05:00
Anas Nashif f4f5cc138c Kbuild: include files dynamically based on BSP_DIR
Change-Id: If36a03acb633c772d599ae1492ebabf04c432306
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:10 -05:00
Juan Manuel Cruz d15251fec5 Kbuild: Kconfig license headers.
This commit add license headers to Kconfig files.

Change-Id: I79e60263b8c7b696463ecc84b8ad411af5415117
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
2016-02-05 20:14:10 -05:00
Anas Nashif c4b860cff1 Kbuild: Rename menu for bluetooth uart driver
Change-Id: Ibfc45a91d39fa78406115e209d71d820b028af45
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:09 -05:00
Anas Nashif d2ca03270e Kbuild: Fix sanity checks for quark
Change-Id: Id142f337f715590fa63d9f7b957f51c203743566
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:08 -05:00
Juan Manuel Cruz b7fcfd53e5 Kconfig: Organization of Ksymbols for bluetooth.
This commit organizes the bluetooth Ksymbols in:
 - Driver symbols at drivers/bluetooth/Kconfig
 - Stack symbols at net/bluetooth/Kconfig

Change-Id: I8ebadeb8ac7f8a769d7620e4e44077a05915dc86
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
2016-02-05 20:14:08 -05:00
Juan Manuel Cruz 638fb2c181 Kbuild: Bluetooth driver support.
This commit adds the Makefile and Kconfig files
to support the bluetooth driver in the Kbuild system.

Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
Change-Id: I1f72b13aca8fb098eece04c4f0e1b680639b520f
2016-02-05 20:14:08 -05:00
Tomasz Bursztyka ea4c3d1c0f bluetooth: UART based driver no longer needs to set regs and irq
Now that UART drivers are configured internally when it comes to
hardware specific information such as IRQ and registers (or mmaped
registers), bluetooth UART driver no longer needs to do it by itself. It
only requires to select the port it wants to use.

Change-Id: I5a30500f4b6f4155292609d0ed4a758f91930817
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:14:01 -05:00
Johan Hedberg a0bb20f4d1 Bluetooth: coding-style: fix one-line branch braces usage
The coding guidelines make an exception to the Linux kernel style
where all branches, even one-liners, should use braces.

Change-Id: I368930af3033eac15f0152a6671909e401d332e6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:56 -05:00
Andrei Emeltchenko ea1f5f3785 Bluetooth: Add Bluetooth UART driver specific debug support
Configuration option BLUETOOTH_DEBUG_UART enables debug support for
Bluetooth UART driver.

Change-Id: I192f380be492df1a52ad212239447b6ee4b50aac
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg caf5141de5 Bluetooth: Remove unnecessary error checks for bt_uart_read() calls
When the 'len' and 'min' parameters passed to bt_uart_read() are equal
the function is guaranteed to always return 'len' (it will keep
looping until that). This patch removes bt_uart_read() error checks
which would never occur in practice.

Change-Id: Icd879f1e15c6d33acc549155aabd24490098ffc5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 099ecbfa7c Bluetooth: Add minimum required length parameter to bt_uart_read()
There are some places where it's forgivable if bt_uart_read() wasn't
able to read as many bytes as requested. In other places it's not
acceptable (e.g. when reading ACL or event header). To avoid failing
in situations where we can handle receiving less data than requested
this patch adds a new parameter to bt_uart_read() to specify the
minimum required data amount.

Change-Id: I372e3af7aaa6bfabe14896eb10cc71c3deff94f2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 935198e715 Bluetooth: Fix UART driver robustness when out of buffers
If we're out of buffers the UART driver would previously loose sync of
where the packet boundaries go, because it was using the buffer itself
to store and parse the HCI packet headers. This patch modifies the
UART driver to use stack variable for initial header parsing, thereby
being able to always determine how many remaining bytes there are and
cleanly discard the bytes until the beginning of the next packet.

Change-Id: I278f3fc0c983e6a2a6904356ef1af1d25c9f06e4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg c96f8e484c Bluetooth: Fix potential NULL-pointer access in UART driver
If we get an invalid packet type here the buf pointer will be NULL.
Going to the cleanup section at the end of the function would trigger
a bt_but_put() call which would cause a NULL pointer access. Directly
returning from the function is the right thing to do instead.

Change-Id: I0c18646e0820cf829ef8aa3f77835ba0a14375b5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg d829fe9755 Bluetooth: Consolidate bt_buf_get* functions
We may soon want to have a _wait() variant of bt_buf_get, so to avoid
the number of 'get' function growing too large consolidate the
existing get() and get_reserve() functions into a single one. The new
consolidated function also takes the type as input parameter so that
we know this from the very start and thereby plan for the split into
multiple buffer pools.

Change-Id: Ia09448565349def2be9bc08d9510fedd029480b4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 4e65d0aac2 Bluetooth: Split ACL buffers into two distinct types
We'll soon want to have dedicated pools for outgoing and incoming ACL
data. To know from which pool to get and put the buffers each buffer
should contain enough information to distinguish the two types. This
patch splits the old BT_ACL type into two new BT_ACL_IN & BT_ACL_OUT
types.

Change-Id: I7d3c05c26d2a70f80fb1229e245aa21673ec378b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 2581ad9313 Bluetooth: Add HCI UART (H4) driver
This patch adds a simple HCI UART (H4) driver that currently maps to
the second UART in the system. The main intention is to use this
together with qemu for accessing the Bluetooth controller available on
the host OS side.

The H4 HCI transport protocol is perhaps the simplest of the standard
HCI transports. It consists of a single byte in the beginning of each
packet which indicates the type of the packet: HCI event, HCI command,
ACL data, or SCO data (which we don't use at the moment).

Change-Id: I225a2a2361fbd7cd4ba82ea1f81ddc1271e9e7c2
Co-authored-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:44 -05:00