Commit graph

304 commits

Author SHA1 Message Date
Gerson Fernando Budke 92bb6afcdd drivers: ieee802154: rf2xx: Add CS gpio flags from DT
The generic SPI GPIO chip select support now respects devicetree flags
for signal active level. This pass DT information to driver instance to
ensure proper behavior.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-07-08 23:22:19 -04:00
Flavio Ceolin c4f7faea10 random: Include header where it is used
Unit tests were failing to build because random header was included by
kernel_includes.h. The problem is that rand32.h includes a generated
file that is either not generated or not included when building unit
tests. Also, it is better to limit the scope of this file to where it is
used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-07-08 21:05:36 -04:00
Johann Fischer d261de8960 drivers: dw1000: fix SPI GPIO CS
Since commit 5963ebaf33
("drivers: spi: CS configuration through devicetree")
the SPI GPIO CS flags are obtained from DT,
but the patch series has missed the necessary changes
for the ieee802154_dw1000 driver and decawave_dwm1001_dev board.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-07-07 15:08:16 +02:00
Markus Becker 30389e01dd driver: ieee802154: rf2xx: implement setting tx power
Implemented rf2xx_set_txpower() in ieee802154_rf2xx.c by mapping dBm
values to RF2XX register values.

Signed-off-by: Kari Severinkangas <kari.severinkangas@tridonic.com>
Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-07-02 08:51:22 -04:00
Jordan Yates e7a5505e74 ieee802154: mcr20a: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 0d4417d187 ieee802154: cc2520: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 4f07fac5fc ieee802154: cc1200: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Hubert Miś 7f66fd84e8 drivers: ieee802154: fix nrf5 initialization with external irq source
MPSL is a library that provides external radio IRQ source for the
802.15.4 driver. If this library is in use, the driver shall not
configure the radio IRQ.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2020-06-09 13:46:39 +02:00
Markus Becker f253096a9c net: ieee802154: Align thread names of radio drivers
The NRF5 and RF2XX drivers are using different thread names compared
to the other 802.15.4 drivers. Aligned the thread names to <chip>_rx.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-09 11:38:25 +02:00
Markus Becker 2115b575a4 net: ieee802154: Allow to disable auto-start of 802.15.4 interfaces
Some radio drivers need configuration before start-up. Up to now only
the RF2XX drivers allowed this, but other radio drivers need this as
well. In particular for setting EUI64 addresses.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-08 19:55:19 +03:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Vincent Wan f6bbad831a drivers: ieee802154: cc13xx_cc26xx: use HwiP_construct to connect CPE0
IRQ_CONNECT() can only be called at one location to connect the irq for
CPE0. This commit modifies the driver to call into the HwiP layer in TI
HAL so that TI's RF driver can do the same when connecting the irq.

Fixes #25216

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-05-19 17:28:29 +02:00
Vincent Wan e21da06a16 drivers: ieee802154: fix build for cc13xx/cc26xx
New update of hal_ti requires DeviceFamily_CC13X2/DeviceFamily_CC26X2
to be defined in order to include the rfc.h header.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-05-19 17:28:29 +02:00
Peter Bigot 4f16b419e8 device: avoid casting away const from config_info pointer
The driver-specific config_info structure referenced from the device
structure is marked const.  Some drivers fail to preserve that
qualifier when casting the pointer to the driver-specific structure,
violating MISRA 11.8.

Changes produced by scripts/coccinelle/const_config_info.cocci.

Some changes proposed by the script are not included because they
reveal mutation of state through the const pointer, though the
code works as long as the driver-specific object is defined without
the const qualifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-13 18:21:52 +02:00
Kumar Gala db725c0ec9 drivers: Replace GPIO_CS Kconfig with devicetree detection
Use DT_INST_SPI_DEV_HAS_CS_GPIOS() in drivers to determine if we should
utilize CS_GPIO base SPI chipselect handling.  This allows us to remove
Kconfig option for this feature.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-09 13:07:05 +02:00
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Johann Fischer 8f983c3654 drivers: ieee802154: add Decawave DW1000 driver
Add initial support for Decawave DW1000
IEEE 802.15.4-2011 UWB transceiver.

Driver has basic functionality. Additional functions such
as reading out timestamps and delayed TX were implemented
for test purposes, but also require support in the 802154
subsystem.

Register, sub-register, and defaults defines in the file
ieee802154_dw1000_regs.h are taken from the Decawave's
DW1000 driver for the Mynewt OS.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-05-07 23:30:58 -05:00
Martí Bolívar 87e1743ae0 devicetree: replace DT_HAS_DRV_INST with DT_INST_FOREACH
Make drivers multi-instance wherever possible using DT_INST_FOREACH.
This allows removing DT_HAS_DRV_INST in favor of making drivers just
do the right thing regardless of how many instances there are.

There are a few exceptions:

- SoC drivers which use CMake input files (like i2c_dw.c) or otherwise
  would require more time to convert than I have at the moment. For the
  sake of expediency, just inline the DT_HAS_DRV_INST expansion for
  now in these cases.

- SoC drivers which are explicitly single-instance (like the nRF SAADC
  driver). Again for the sake of expediency, drop a BUILD_ASSERT in
  those cases to make sure the assumption that all supported SoCs have
  at most one available instance is valid, failing fast otherwise.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-06 17:35:08 -05:00
Jukka Rissanen db9b47f6fa drivers: ieee802154: mcr20a: Convert to use k_timeout_t
Convert the code to use k_timeout_t when applicable.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-05-01 10:50:03 +03:00
Gerson Fernando Budke 9be1ba9e08 drivers: ieee802154: rf2xx: Add no auto start option
Add a Kconfig option that allows user to set any necessary config
using management interface before interface be operational. A use
case is set the EUI-64 address from an external EEPROM by the
NET_REQUEST_IEEE802154_SET_EXT_ADDR command. After all configs
are done net_if_up() can be invoked to bring interface up.

Fixes #23193.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-04-28 10:30:55 +03:00
Gerson Fernando Budke c755821608 drivers: ieee802154: rf2xx: Add local-mac-address
Add local-mac-address on DT and enable it on rf2xx driver. If user
define local-mac-address this value will be used as default mac address.
Otherwise driver automatically add a random mac address.

On application level user can change default mac address using net_mgmt
command with NET_REQUEST_IEEE802154_SET_EXT_ADDR parameter defined on
include/net/ieee802154_mgmt.h header.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-04-28 10:30:55 +03:00
Robert Lubos f1f2405eb1 drivers: ieee802154_nrf5: Handle frame pending bit mode
Configure FPB handling in the radio driver.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-17 09:17:38 +03:00
Robert Lubos c39d0b6914 drivers: ieee802154_nrf5: Notify about FPB value in ACK reponse
The radio driver will now notify the upper layer about Frame Pending Bit
value in the ACK response it sent.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-17 09:17:38 +03:00
Robert Lubos a4f704d2ec drivers: ieee802154_nrf5: Handle RX timestamp
Obtain RX time from the radio driver. Fill the `net_pkt` with
a timestamp if `NET_PKT_TIMESTAMP` is enabled.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-09 16:56:11 +02:00
Robert Lubos 86f56fcd36 drivers: ieee802154_nrf5: Switch to ACK timeout at nRF driver level
nRF radio driver will call `nrf_802154_transmit_failed` callback in case
no ACK is received, so we do not need to set timeout at the shim layer
anymore.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-09 16:56:11 +02:00
Marek Porwisz f6aa72a4d7 drivers: ieee082154_nrf5: Tx started notification
Notify about actual data transmission start.
Needed when ACK timeout is disabled in the radio driver.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-04-07 14:24:10 +03:00
Robert Lubos d657c6bf57 drivers: ieee802154_nrf5: Add CSMA CA transmit capability
Add CSMA CA capability for the `ieee802154_nrf5` radio driver along with
appropriate implementation in the `nrf5_tx` function.

Introduce 802.15.4 radio driver with CSMA/CA support enabled. Add help
text, mentioning a list of peripherals occupied by the radio driver.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-03 14:07:41 +03:00
Robert Lubos 1fb418df4c net: ieee802154_radio: Allow to specify TX mode
Even though radio driver can report in its capabilities that it does
support CSMA CA, there's no way in the driver to select how the frame
should be transmitted (with CSMA or without). As layers above radio
driver (Thread, Zigbee) can expect that both TX modes are available, we
need to extend the API to allow either of these modes.

This commits extends the API `tx` function with an extra parameter,
`ieee802154_tx_mode`, which informs the driver how the packet should be
transmitted. Currently, the following modes are specified:
* direct (regular tx, no cca, just how it worked so far),
* CCA before transmission,
* CSMA CA before transmission,
* delayed TX,
* delayed TX with CCA

Assume that radios that reported CSMA CA capability transmit in CSMA CA
mode by default, all others will support direct mode.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-03 14:07:41 +03:00
Robert Lubos 111313581d net: ieee802154_radio: Enable ed_scan unconditionally
Energy scan procedure, while introduced specifically for OpenThread in
Zephyr, may also be used by other upper layers (like Zigbee).
Therefore, disable conditional inclusion of the `ed_scan` API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-04-01 15:41:31 +03:00
Oleg Zhurakivskyy 056d57a338 drivers: ieee802154: Add a missing include
Add a missing include of debug/stack.h in order to fix the
compilation warning on implicit declaration of log_stack_usage().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Kumar Gala f078f6527e drivers: ieee802154: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-30 17:04:32 -05:00
Tomasz Bursztyka 4ae72db135 net: Enable PM settings on network devices
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.

All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Robert Lubos cce9d19ca8 drivers: ieee80154_nrf5: Add support for PAN coordinator mode
Implement `IEEE802154_CONFIG_PAN_COORDINATOR` handling.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-26 17:42:40 +02:00
Robert Lubos f8092789b7 drivers: ieee80154_nrf5: Add support for promiscous mode
Implement `IEEE802154_CONFIG_PROMISCUOUS` handling.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-26 17:42:40 +02:00
Gerson Fernando Budke 8614ea8e0b drivers: ieee802154: rf2xx: Fix OT ACK handling
At OpenThread stack on ieee802154_radio_handle_ack method the
net_pkt_read fail because net_pkt_cursor wasn't proper initialized.
This ensures that net_pkt_cursor is initialized for any ack frame.

Another hidden problem fixed was the frags property on net_buf. Now
it is defined as NULL to ensures that no fragments are available.

The ack frame should be returned to OT only if requested. In this
case, the IEEE 802.15.4 Frame Control field from TX frag is now
verified for an ACK request and if OT requires ACK response it will
be proper handled and dispatched.

Fixes #23595

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-23 12:13:42 +02:00
Markus Becker a64880d9c0 drivers: ieee802154: Fix compile errors in RF2XX
Fix compile errors hidden behind ifdef.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-23 12:13:42 +02:00
Carles Cufi 6574efa232 drivers: Add missing debug/stack.h include
In order to use log_stack_usage(), inclusion of <debug/stack.h> is
required.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Carles Cufi 4810906030 Revert "drivers: ieee802154: Add a missing include"
This reverts commit 979ed4e1cd.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Oleg Zhurakivskyy 979ed4e1cd drivers: ieee802154: Add a missing include
Add a missing include of debug/stack.h in order to fix the
compilation warning on implicit declaration of log_stack_usage().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Andrew Boie 760644041c net: purge NET_STACK and other stack APIs
The current design of the network-specific stack dumping APIs
is fundamentally unsafe. You cannot properly dump stack data
without information which is only available in the thread object.

In addition, this infrastructure is unnecessary. There is already
a core shell command which dumps stack information for all
active threads.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-14 13:10:19 -04:00
Andrew Boie 00f46df6ad drivers: ieee802154: do not use net stack API
Use log_stack_usage() instead, which does the same thing,
safely.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-14 13:10:19 -04:00
Kumar Gala 505591d52a drivers: ieee802154: mcr20a: convert to DT_INST defines
Convert driver to use DT_INST_ defines.  There was just one case for
CS_GPIOS that wasn't using DT_INST defines already.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-11 07:59:38 -06:00
Johan Hedberg 4bdb407d7d drivers: ieee802154_nrf5: Fix build failure
Fix build failure when CONFIG_NET_L2_OPENTHREAD is not enabled. The
failure looks as follows:

drivers/ieee802154/ieee802154_nrf5.c:187:12:
	warning: 'nrf5_energy_scan_start' defined but not used
	[-Wunused-function]
 static int nrf5_energy_scan_start(struct device *dev,
            ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-03-10 14:09:11 -05:00
Marek Porwisz 4ca9b42fbe drivers: ieee802154_nrf5: Implement energy scan function of the nrf5 driver
Implement function and necessary callbacks to handle Energy Scan feature
of the nRF radio driver needed by some radio stacks.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-03-10 14:59:10 +02:00
Gerson Fernando Budke 2cfb11e050 drivers: ieee802154: rf2xx: Rem trx_state variable
The rx timeout timer callback need update trx_state variable and this
variable is protected by a mutex. Because of that, when compiling the
system with CONFIG_ASSERT=y the system reports 'ASSERTION FAIL
[!arch_is_in_isr()] @ ZEPHYR_BASE/kernel/include/ksched.h:262'.

This refactor the driver remove trx_state variable dependency and
consequently removes phy_mutex and rx timeout timer to be compliant
with kernel rules.

Fixes: #23198

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Gerson Fernando Budke be56e36fe4 drivers: ieee802154: rf2xx: Add RX improvements
The current version of at86rf2xx RX implementation don't uses advanced
capabilities offer by the transceiver. This access SRAM space to gatter
PHR information in parallel with transceiver frame reception. It allows
improve RX reception by handling properlly the frame protection feature
removing transceiver states changes.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Gerson Fernando Budke 287f654e68 drivers: ieee802154: rf2xx: Refactor rf2xx_thread_main
Current rf2xx_thread_main code have too many if/for/while imbrication.
Extract methods from rx2xx_thread_main for better readability.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Gerson Fernando Budke d4f39742ea drivers: ieee802154: rf2xx: Add SRAM read method
Add SRAM read method to enable advanced uses on at86rf2xx driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-09 14:17:06 +02:00
Tomasz Bursztyka 62b2cae2ae drivers/ieee802154: Adapt cc1200 driver to new GPIO API
Update to use new API for GPIO pin configuration and operation.  Fix
invalid arithmetic on void pointer.  Convert to support devicetree.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00