Commit graph

550 commits

Author SHA1 Message Date
Lukasz Maciejonczyk 4113a43bff drivers: ieee802154: fix serialization issue in nRF5
Function 'nrf_802154_transmitted_timestamp_raw' is not serialized and
connot be used for multi-core devices yet.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-06-09 16:11:58 +03:00
Eduardo Montoya ae44b30b41 drivers: ieee802154: include timestamp in acks
Fill the ACK timestamp field in nRF5 driver. This is required by
OpenThread for the proper CSL transmitter functioning.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-06-08 04:54:38 -05:00
Eduardo Montoya 9c6895105d drivers: ieee802154: fix ACK length handling
OpenThread expects the FCS field at the end of the ACK frame to be
passed with `otPlatRadioTxDone`.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-05-27 12:59:06 -05:00
Jedrzej Ciupis 0923e32fe7 drivers: ieee802154: Udpate nRF IEEE 802.15.4 radio driver
This commit updates the revision of hal_nordic component
and introduces necessary changes to the IEEE 802.15.4 driver
to match latest nRF IEEE 802.15.4 radio driver API.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2021-05-06 08:46:47 -05:00
Gerson Fernando Budke 7a1f26b005 drivers: ieee802154: rf2xx: Add pan coordinator mode
Enable pan coordinator mode.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-05-05 15:55:45 +02:00
Gerson Fernando Budke 0ae119ef3f drivers: ieee802154: rf2xx: Add promiscuous mode
The current rf2xx driver not implement any configuration.  Add
the minimal structre to implement rf2xx driver configuration and
implement IEEE802154_CONFIG_PROMISCUOUS mode.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-05-05 15:55:45 +02:00
Gerson Fernando Budke 2f3644ee0c drivers: ieee802154: rf2xx: Add tx mode CCA
Configure transceiver to create a 0 period backoff and perform only one
time the CCA without transmission retires for failures.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-05-05 15:55:45 +02:00
Gerson Fernando Budke 195800145e drivers: ieee802154: rf2xx: Add tx mode direct
The current RF2XX driver only support IEEE802154_TX_MODE_CSMA_CA.  Add
IEEE802154_TX_MODE_DIRECT to allow transmit packets immediately without
performing random backoff, CCA and retransmission process.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-05-05 15:55:45 +02:00
Eduardo Montoya a47677da06 net: openthread: add CSL transmitter API
This commit implements the OpenThread APIs to pass MAC keys and
frame counter to the radio layer in order to process the
transmission security. This is needed for the correct functioning
of a CSL transmitter.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-05-05 14:33:47 +02:00
Gerard Marull-Paretas ed4dd0e9bb drivers: ieee802154: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 10:55:49 -04:00
Eduardo Montoya 8ff12f3ace net: openthread: enable CSL delayed transmissions
Add support for delayed transmission of frames for the CSL
Transmitter OpenThread function.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-04-26 13:40:43 +02:00
Robert Lubos a586f5818c drivers: ieee802154_nrf5: Remove unnecessary NULL pointer check
After changes in commit a42d6c98d3, the
pkt can no longer be a NULL pointer. Remove the unnecessary NULL pointer
check to silence the Coverity.

Coverity ID: 219536
Fixes #32912

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-15 14:45:50 +03:00
Peter Bigot 74f776c29c drivers: ieee802154: rote conversion of k_work API
Replace all existing deprecated API with the recommended alternative.

Be aware that this does not address architectural errors in the use
of the work API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-14 07:07:40 -04:00
Flavio Ceolin 9fd4ea91b7 coccinelle: Remove extra semicolon
coccicheck --mode=patch --cocci=semicolon.cocci

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-25 11:35:30 -05:00
James Harris b10428163a kernel: sem: add K_SEM_MAX_LIMIT
Currently there is no way to distinguish between a caller
explicitly asking for a semaphore with a limit that
happens to be `UINT_MAX` and a semaphore that just
has a limit "as large as possible".

Add `K_SEM_MAX_LIMIT`, currently defined to `UINT_MAX`, and akin
to `K_FOREVER` versus just passing some very large wait time.

In addition, the `k_sem_*` APIs were type-confused, where
the internal data structure was `uint32_t`, but the APIs took
and returned `unsigned int`. This changes the underlying data
structure to also use `unsigned int`, as changing the APIs
would be a (potentially) breaking change.

These changes are backwards-compatible, but it is strongly suggested
to take a quick scan for `k_sem_init` and `K_SEM_DEFINE` calls with
`UINT_MAX` (or `UINT32_MAX`) and replace them with `K_SEM_MAX_LIMIT`
where appropriate.

Signed-off-by: James Harris <james.harris@intel.com>
2021-03-05 08:13:53 -06:00
Rafał Kuźnia ff1594cf05 drivers: ieee802154: Fix problem with binding IRQ handlers in shim layer
The shim layer could in some circumstances not be properly
configured which would result in an unbound radio interrupt
handler.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2021-03-05 12:56:15 +01:00
Eduardo Montoya 53fd3ae573 drivers: ieee802154: nrf5: load EUI64 from UICR
Add `IEEE802154_NRF5_UICR_EUI64_ENABLE` option to allow loading EUI64
from UICR registers.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-03-03 10:40:29 +02:00
Robert Lubos 56f9efdebf drivers: ieee802154_nrf5: Fix initialization order
The driver was reworked recently so that driver capabilites are
obtained at runtime. The function to obtain the capabilities was
called after L2 initialization though, which is invalid as L2
initialization code already depends on certain driver capabilites.

Move the capability initializer to an earliest possible stage
(i. e. just after the core driver is initialized) to fix the issue.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-02-24 14:16:08 +02:00
Andrzej Głąbek f8036bfae3 drivers: ieee802154_nrf5: Fix inclusion of ieee802154_radio.h
This is a follow-up to commit 9f56cc5531.

Add net/ in the inclusion of ieee802154_radio.h so that the file can
be successfully included.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-02-16 07:57:15 -06:00
Czeslaw Makarski 9f56cc5531 drivers: ieee802154: Make HW Radio Capabilities runtime
This commit introduces runtime query of the HW Capabilities of
the nRF IEEE 802.15.4 Radio Driver.

Signed-off-by: Czeslaw Makarski <Czeslaw.Makarski@nordicsemi.no>
2021-02-15 08:10:19 -05:00
Czeslaw Makarski 3e1c2b7808 drivers: ieee802154: Remove obsolete Kconfig entry.
This commit removes obsolete Kconfig entry.

Signed-off-by: Czeslaw Makarski <Czeslaw.Makarski@nordicsemi.no>
2021-02-15 08:10:19 -05:00
Pawel Kwiek f88cc17627 drivers: ieee802154: Enable CSMA-CA on serialized host
This commit enables CSMA-CA on the serialized host.

Signed-off-by: Pawel Kwiek <pawel.kwiek@nordicsemi.no>
2021-02-15 08:10:19 -05:00
Robert Lubos a42d6c98d3 drivers: ieee802154_nrf5: Block on net_pkt allocation in the RX path
Currently, if no net_pkt's are available, the radio driver RX thread
drops the 802.15.4 frame silently. This causes undesired behaviour,
where we can drop the packet which has already been acknowledged at
the 802.15.4 level.

Fix this, by blocking the RX thread if no net_pkt is avaliable. The
packets received while the RX thread is blocked will be accumulated in
the underlying nRF 802.15.4 driver, and eventually when it runs out of
internal buffers before the thread is unblocked, it'll stop
acknowledging the incoming frames.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-01-22 18:48:18 +02:00
Robert Lubos 075445b811 drivers: ieee802154_nrf5: Allocate net_pkt from correct pool
The driver allocated packet from the TX pool on its RX path. Fix this
by using a correct allocator function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-01-21 21:27:14 +02:00
Kumar Gala e2268e1ac4 drivers: ieee802154: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:01:06 -05:00
Kumar Gala 6efb17a821 drivers: ieee802154: Convert drivers to new DT device macros
Convert ieee802154 drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
    NET_DEVICE_INIT -> NET_DEVICE_DT_INST_DEFINE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-18 07:59:07 -06:00
Maciej Fabia 1ca9b38946 drivers: ieee802154: nrf5: Add support for tx in the future
Add support for transmission modes that send a packet
at a specific time in the future.
Remove TXTIME, TXTIME_CCA, CSMA_CA capabilities and their calls when
they are not supported by selected drivers. Add TXTIME flag in
get_capabilites function.

Signed-off-by: Maciej Fabia <maciej.fabia@nordicsemi.no>
Signed-off-by: Pawel Kwiek <pawel.kwiek@nordicsemi.no>
2020-12-08 14:52:08 +02:00
Erik Larson 0a0404df29 drivers: ieee802154: cc13xx_cc26xx: raw mode support
This change adds IEEE802154_RAW_MODE support for the
cc1352r.

This allows using the cc1352r 2.4 GHz radio and Sub Ghz
radio as a transceiver (PHY) instead of using L2 networking.

Signed-off-by: Erik Larson <erik@statropy.com>
2020-11-23 09:46:49 +02:00
Czeslaw Makarski 63fe072a1d drivers: ieee802154: Deny use of nRF FICR registers in NS domain
This commit introduces the catch that prevents building of
IEEE 802.15.4 nRF driver in case the non-secure domain of the core
is used.

Signed-off-by: Czeslaw Makarski <Czeslaw.Makarski@nordicsemi.no>
2020-11-16 15:24:03 +01:00
Jedrzej Ciupis 15fdd7175b drivers: ieee802154: Add support for IEEE 802.15.4 for nRF5340
This commit introduces support for IEEE 802.15.4 on nRF5340.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2020-11-16 15:24:03 +01:00
Czeslaw Makarski b6b613d4db modules: nordic: Introduce nRF IEEE 802.15.4 Service Layer selection
This patch introduces the nRF IEEE 802.15.4 Service Layer configuration.

Signed-off-by: Czeslaw Makarski <Czeslaw.Makarski@nordicsemi.no>
2020-11-16 15:24:03 +01:00
Christopher Friedt c80fe8ae69 drivers: ieee802154: cc13xx_cc26xx: use multi-protocol radio patch
This change enables the multi-protocol rf patch to be used for
the cc13xx_cc26xx IEEE 802.15.4 2.4 GHz PHY, which allows both
the 2.4 GHz and Sub GHz PHY to be used simultaneously.

Eventually, BLE will also work simultaneously on 2.4 GHz (with
arbitration).

Fixes #29883

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-11 17:03:21 +02:00
Christopher Friedt ec0e737b0c drivers: ieee802154: cc13xx_cc26xx: sub-ghz support
This change adds IEEE 802.15.4g (Sub GHz) support for the
cc1352r.

The 2.4 GHz radio and the Sub GHz radio are capable of
operating simultaneously.

Fixes #26315

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-09 10:25:24 +02:00
Christopher Friedt bb7c58f65e ieee802154: cc13xx_cc26xx: workaround for issue in ti driver
This is a temporary workaround for an issue in TI's RF Driver
API. A subsequent release of the SimpleLink SDK will mitigate
the need for it and it can be reverted when hal/ti receives
that update.

Fixes #29418

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-03 11:03:35 +01:00
Christopher Friedt 8e2978d577 drivers: ieee802154: cc13xx_cc26xx: use ti rf driver api
This change reworks the cc13xx_cc26xx IEEE 802.15.4 driver to use
the TI RF driver API that is available in modules/hal/ti.

There are a number of benefits to using TI's API including
 - a stable multi-OS vendor library and API
 - API compatibility with the rest of the SimpleLink SDK and SoC family
 - potential multi-protocol & multi-client radio operation
   (e.g. both 15.4 and BLE)
 - coexistence support with other chipsets via gpio
 - vetted TI RF driver resources, such as
   - the radio command queue
   - highly tuned / coupled RTC & RAT (RAdio Timer) API

Fixes #26312

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-03 11:03:35 +01:00
Marek Porwisz 886cf7a9f3 drivers: ieee802154: nrf5: Add support for failed rx notification
Thread implements couple of counters that require notification of failed
frame reception.
Implemented RX failed notification.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-10-19 12:50:02 +03:00
Xavier Chapron 824f423e54 misc: Replace assert include and calls by sys/__assert.h equivalent
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-10-02 11:42:40 +02:00
Maciej Fabia 06b44b12c7 drivers: ieee802154: Add more error codes to nrf5 driver tx
Add separate error codes in tx function for busy channel error
and ACK-related errors.

Signed-off-by: Maciej Fabia <maciej.fabia@nordicsemi.no>
2020-09-30 14:32:19 +03:00
Tomasz Bursztyka 4dcfb5531c isr: Normalize usage of device instance through ISR
The goal of this patch is to replace the 'void *' parameter by 'struct
device *' if they use such variable or just 'const void *' on all
relevant ISRs

This will avoid not-so-nice const qualifier tweaks when device instances
will be constant.

Note that only the ISR passed to IRQ_CONNECT are of interest here.

In order to do so, the script fix_isr.py below is necessary:

from pathlib import Path
import subprocess
import pickle
import mmap
import sys
import re
import os

cocci_template = """
@r_fix_isr_0
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
 ...
(
 const struct device *D = (const struct device *)P;
|
 const struct device *D = P;
)
 ...
}

@r_fix_isr_1
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
 ...
 const struct device *D;
 ...
(
 D = (const struct device *)P;
|
 D = P;
)
 ...
}

@r_fix_isr_2
@
type ret_type;
identifier A;
@@
-ret_type <!fn!>(void *A)
+ret_type <!fn!>(const void *A)
{
 ...
}

@r_fix_isr_3
@
const struct device *D;
@@
-<!fn!>((void *)D);
+<!fn!>(D);

@r_fix_isr_4
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
 ...
(
-const struct device *D = (const struct device *)P;
|
-const struct device *D = P;
)
 ...
}

@r_fix_isr_5
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
 ...
-const struct device *D;
...
(
-D = (const struct device *)P;
|
-D = P;
)
 ...
}
"""

def find_isr(fn):
    db = []
    data = None
    start = 0

    try:
        with open(fn, 'r+') as f:
            data = str(mmap.mmap(f.fileno(), 0).read())
    except Exception as e:
        return db

    while True:
        isr = ""
        irq = data.find('IRQ_CONNECT', start)
        while irq > -1:
            p = 1
            arg = 1
            p_o = data.find('(', irq)
            if p_o < 0:
                irq = -1
                break;

            pos = p_o + 1

            while p > 0:
                if data[pos] == ')':
                    p -= 1
                elif data[pos] == '(':
                    p += 1
                elif data[pos] == ',' and p == 1:
                    arg += 1

                if arg == 3:
                    isr += data[pos]

                pos += 1

            isr = isr.strip(',\\n\\t ')
            if isr not in db and len(isr) > 0:
                db.append(isr)

            start = pos
            break

        if irq < 0:
            break

    return db

def patch_isr(fn, isr_list):
    if len(isr_list) <= 0:
        return

    for isr in isr_list:
        tmplt = cocci_template.replace('<!fn!>', isr)
        with open('/tmp/isr_fix.cocci', 'w') as f:
            f.write(tmplt)

        cmd = ['spatch', '--sp-file', '/tmp/isr_fix.cocci', '--in-place', fn]

        subprocess.run(cmd)

def process_files(path):
    if path.is_file() and path.suffix in ['.h', '.c']:
        p = str(path.parent) + '/' + path.name
        isr_list = find_isr(p)
        patch_isr(p, isr_list)
    elif path.is_dir():
        for p in path.iterdir():
            process_files(p)

if len(sys.argv) < 2:
    print("You need to provide a dir/file path")
    sys.exit(1)

process_files(Path(sys.argv[1]))

And is run: ./fix_isr.py <zephyr root directory>

Finally, some files needed manual fixes such.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 949b25cf68 drivers: ieee802154: Fix device instance const qualifier loss
In all of these drivers, passing the device's data was sufficient as
only the data is being used by thread.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka af6140cc0d device: Apply config_info rename everywhere
Via coccinelle:

@r_device_config@
struct device *D;
@@

D->
-	config_info
+	config

And 2 grep/sed rules for macros:

git grep -rlz 'dev)->config_info' |
	xargs -0 sed -i 's/dev)->config_info/dev)->config/g'

git grep -rlz 'dev->config_info' |
	xargs -0 sed -i 's/dev->config_info/dev->config/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Kamil Kasperczyk e4d20caee9 drivers: nrf: Added config option for OUI.
Support for defining vendor specific OUI (Organizationally
Unique Identifier) was added.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-08-10 08:42:21 +03:00
Kamil Kasperczyk be372872ea net: openthread: radio: Added sleep to tx as hw radio cap.
OT_RADIO_CAPS_SLEEP_TO_TX was added as a radio capability
for ieee802154 radio. Waiting on RX state before transmission
is alternative condition to OT_RADIO_CAPS_SLEEP_TO_TX support
as it was a result of OpenThread architecture and is actually
not needed in the Zephyr. Such change lets to start transmission
faster and lower SED device power consumption in active state
about 30%.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-08-09 09:32:37 -04:00
Andrew Boie 7d920ba39b drivers: use K_KERNEL_STACK macros
None of these threads run in user mode and we can save some
memory.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-04 12:16:43 -04:00
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
Tomasz Bursztyka 3587fe2fe3 drivers/ieee802154: Adapt cc2520 driver to new GPIO API
Update to use new API for GPIO pin configuration and operation.  Fix
invalid arithmetic on void pointer.  Mark all CC2520 GPIOs as required
in binding.

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
Piotr Mienkowski e1c10f6454 drivers: ieee802154_rf2xx: convert to the new GPIO API
Use new GPIO configuration API, set pin active level in devicetree
source.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Johann Fischer 3eecab88e6 drivers: ieee802154_mcr20a: convert to new GPIO API
Convert MCR20A 802154 controller driver to new GPIO API.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-02-05 12:00:36 +01:00
Carles Cufi 1a37baf24a drivers: ieee802154: rf2xx: Enable sub-GHz L2 conditionally
Enable the sub-GHz L2 only if the main L2 is enabled too.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-02-04 15:49:35 -06:00
Gerson Fernando Budke 268f65d221 drivers: ieee802154: rf2xx: Add missing handle_ack call
The rf2xx driver is doing automatic retransmissions in hardware based
on whether ACKs are received or not. Currently the driver is not
invoking ieee802154_radio_handle_ack() as other drivers are doing and
required by OpenThread since 4fe1da9. This add rf2xx_handle_ack method
to ensures required ACK processing when driver performs TX.

Fixes: #21763

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-01-29 09:01:53 +02:00
Gerson Fernando Budke dbc1e717aa drivers: ieee802154: rf2xx: Fix missing auto ACKs
The RF2XX driver not always sent ACK when a RX frame requests. This
happen because RF2XX transceiver asserts TRX_END interrupt after
confirm that the FCS is valid. The driver can now decode the frame
but in parallel the radio still processing the ACK frame. This will
sync the radio FSM state to ensure that ACK will be send.

Fixes #21659

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-01-28 17:27:10 -05:00
Robert Lubos 7e7f05546d modules: nordic: Allow separate nRF 802.15.4 radio driver build
So far, nRF 802.15.4 radio driver build was dependent on the 802.15.4
subsystem in Zephyr. While this was a reasonable approach for samples,
it prevented the radio driver from being built as a standalone entity,
which could be useful in some applications (e. g. running core nRF
802.15.4 radio driver tests with Zephyr).

Resolve this, by providing a separate set of Kconfigs for the radio
driver, therefore allowing to build it as a separate entity. The 802154
subsystem simply enables the radio driver module in this case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-28 15:18:42 +01:00
Peter Bigot e0aa1b1e1d treewide: use full path to ieee802154/cc2520.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Peter Bigot faa4bf34bd treewide: use full path to ieee802154/cc1200.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Peter Bigot 6a964663b1 treewide: use full path to console/uart_pipe.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Gerson Fernando Budke bd0d8a35c3 drivers: ieee802154: rf2xx: Add GPIO dependency
The rf2xx driver needs GPIO driver to works. The RST, SLPTR and INT
are mandatory signals and driver uses DT to configure them. This add
the GPIO dependency on Kconfig.rf2xx file.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-01-07 13:51:46 +02:00
Ulf Magnusson 9c9eb3452b kconfig: Fix some formatting nits
Same deal as in commit bd6e04411e ("kconfig: Clean up header comments
and make them consistent") and commit 1f38ea77ba ("kconfig: Clean up
'config  FOO' (two spaces) definitions"), for some newly-introduced
stuff.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-21 10:30:02 -05:00
Robert Lubos 649ec80c9e net: openthread: Update OpenThread version and better CMake integration
OpenThread recently introduced CMake build system into its repostiory
so we no longer need autotools to build OpenThread libraries and can
integrate them natively.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-12-16 11:08:09 +02:00
Gerson Fernando Budke 67289d07fe drivers: ieee802154: rf2xx: Add initial driver
Add initial Atmel at86rf2xx transceiver driver. This driver uses device
tree to configure the physical interface. The driver had capability to
use multiple transceiver and systems with multiple bands can be used.
With this, 2.4GHz ISM and Sub-Giga can be used simultaneous.

Below a valid DT example. This samples assume same SPI port with two
transceivers.

&spi0 {
    status = "okay";
    label = "SPI_RF2XX";
    cs-gpios = <&porta 31 0 &porta 30 0>;

    rf2xx@0 {
        compatible = "atmel,rf2xx";
        reg = <0x0>;
        label = "RF2XX_0";
        spi-max-frequency = <7800000>;
        irq-gpios = <&portb 2 0>;
        reset-gpios = <&porta 3 0>;
        slptr-gpios = <&portb 3 0>;
        status = "okay";
    };

    rf2xx@1 {
        compatible = "atmel,rf2xx";
        reg = <0x1>;
        label = "RF2XX_1";
        spi-max-frequency = <7800000>;
        irq-gpios = <&portb 4 0>;
        reset-gpios = <&porta 4 0>;
        slptr-gpios = <&portb 4 0>;
        status = "okay";
    };
};

At the moment driver assume two transceiver are enouth for majority of
appications. Sub-Giga band will be enabled in future.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2019-12-13 11:23:23 +02:00
Kumar Gala cd0f8d5c4f include: Fix use of <sys_io.h> -> <sys/sys_io.h>
Fix #include <sys_io.h> as it has been deprecated and
should be #include <sys/sys_io.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Kumar Gala 24ae1b1aa7 include: Fix use of <misc/FOO.h> -> <sys/FOO.h>
Fix #include <misc/FOO.h> as misc/FOO.h has been deprecated and
should be #include <sys/FOO.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Robert Lubos 44c947ec3e drivers: ieee802154_kw41z: Create a fake ACK frame for upper layers
Upper layers like OpenThread expect the radio driver to forward ACK
frame received by the radio.
Simulate this behavior on kw41z by recreating the ACK frame from the
available data.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-12-09 12:47:45 -05:00
Robert Lubos 2624d65b60 drivers: ieee802154_nrf5: Add ACK handling
nRF5 driver did not utilize `ieee802154_radio_handle_ack` API, therefore
did not provide ACK frames to the upper layer. This commit fixes this
problem.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-12-09 12:47:45 -05:00
Ulf Magnusson 1f38ea77ba kconfig: Clean up 'config FOO' (two spaces) definitions
Must've been copy-pasted around.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Jan Van Winkel 9555f82d28 libc: Use select REQUIRES_FULL_LIBC instead of select NEWLIB_LIBC
Changed select NEWLIB_LIBC to select REQUIRES_FULL_LIBC

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-01 14:18:36 +01:00
Peter Bigot ab91eef23b coccinelle: standardize kernel API timeout arguments
Use the int_literal_to_timeout Coccinelle script to convert literal
integer arguments for kernel API timeout parameters to the standard
timeout value representations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-03 11:55:44 -07:00
Brett Witherspoon 48533751e0 drivers: ieee802154: add CC13xx / CC26xx driver
Add IEEE 802.15.4 suuport for TI CC13xx / CC26xx devices.

Signed-off-by: Brett Witherspoon <spoonb@cdspooner.com>
2019-09-25 08:49:55 +03:00
Andrzej Głąbek 35754375bc soc: nordic: Get rid of nrf_common.h
This file contains redundant definitions of a bunch of nRF IRQ numbers
(not all, however) that only generates confusion, as enumeration values
provided by MDK can be used instead.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-09-24 16:20:16 +02:00
Peter Bigot d566254e3f drivers: fix k_thread_create timeout argument
Use the named representation for no-wait to future-proof against a
change to the representation of timeout values.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-09-19 17:35:53 +02:00
Andrzej Głąbek dd7999d253 soc: nordic: Add HAS_HW_NRF_RADIO_IEEE802154 Kconfig option
Add a hidden Kconfig option indicating that a given SoC is equipped
with the IEEE 802.15.4 capable radio so that the corresponding driver
configuration can depend on it.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-07-31 16:09:30 +03:00
Robert Lubos 5d2002d3dc drivers: ieee802154_nrf: Fix SoC header inclusion
The nRF 802.15.4 radio driver should not include nRF52840 header
directly, but rely on soc.h instead. Otherwise, it will not work with
different SoCs supporting 802.15.4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-07-12 12:16:21 +02:00
Anas Nashif 5d001f3e41 cleanup: include/: move misc/byteorder.h to sys/byteorder.h
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif bd70f6f1ed cleanup: include/: move spi.h to drivers/spi.h
move spi.h to drivers/spi.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 6aa9c3a68f cleanup: include/: move gpio.h to drivers/gpio.h
move gpio.h to drivers/gpio.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif e1e05a2eac cleanup: include/: move atomic.h to sys/atomic.h
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Kumar Gala a614a026b7 dts: Rename DT_.*_GPIO_* to DT_.*_GPIOS_*
Convert DT_.*_GPIO_{CONTROLLER,PIN,FLAGS} ->
	DT_.*_GPIOS_{CONTROLLER,PIN,FLAGS)

Used the following commands to make these conversions:

git grep -l DT_.*_GPIO_CONTROLLER | xargs sed -i 's/DT_\(.*\)_GPIO_CONTROLLER/DT_\1_GPIOS_CONTROLLER/g'
git grep -l DT_.*_GPIO_PIN | xargs sed -i 's/DT_\(.*\)_GPIO_PIN/DT_\1_GPIOS_PIN/g'
git grep -l DT_.*_GPIO_FLAGS | xargs sed -i 's/DT_\(.*\)_GPIO_FLAGS/DT_\1_GPIOS_FLAGS/g'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-27 13:02:34 -05:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Kumar Gala a2693975d7 dts: Convert from DT_<COMPAT>_<INSTANCE>_<PROP> to DT_INST...
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-14 08:02:15 -05:00
Tobias Schlaepfer c88c91942d drivers/ieee802154: Fix KW41Z driver fault
KW41Z IEEE802154 driver fix, by adding an empty configure function
to resolve HardFault at start up

Signed-off-by: Tobias Schlaepfer <scpf@zhaw.ch>
2019-05-31 19:49:27 -04:00
Joao Cordeiro 6746470d1d drivers: ieee802154: nrf5: Support when LOG is off
ieee802154_nrf5 checks if IEEE802154_DRIVER_LOG_LEVEL is set to debug
before initializing the "nRF5 rx stack". This leads to an undefined
reference error in case of the LOG module being disabled.

Avoids this behavior by using the LOG_LEVEL macro and setting it as
LOG_LEVEL_NONE in case of IEEE802154_DRIVER_LOG_LEVEL not defined.

Signed-off-by: Joao Cordeiro <jvcc@cesar.org.br>
2019-05-13 16:30:27 +02:00
Robert Lubos e0ff342a89 drivers: ieee802154_nrf5: Implement configure API
Implement newly introduced `configure` API for nRF 802154 radio driver.

Increase maximum number of slots for Frame Pending bit information in
the radio driver.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-05-06 10:58:04 -04:00
Robert Lubos 93a77c0fa6 drivers: ieee802154_nrf5: Rename nrf5_config to nrf5_irq_config
`nrf5_irq_config` better describes purpose of this function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-05-06 10:58:04 -04:00
Brett Witherspoon cdc29175cc drivers: ieee802154: Make upipe configuration options depend on driver
The upipe specific configuration options are selectable unconditionally.
This commit makes them depend on the upipe driver being enabled.

Signed-off-by: Brett Witherspoon <spoonb@cdspooner.com>
2019-04-28 12:21:12 -04:00
Kumar Gala f92abffe5f ieee802154_kw41z: Fix build error with SYS_LOG_INFO
The following fix:

commit c8b17ec403
Author: Tobias Aschenbrenner <tobias.aschenbrenner@blik.io>
Date:   Tue Dec 18 14:16:00 2018 +0100

    fix: kw41z: Use correct mapping for dBm

Was using SYS_LOG_INFO and should be using LOG_INFO.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-04-17 13:46:07 -05:00
Tobias Aschenbrenner c8b17ec403 fix: kw41z: Use correct mapping for dBm
The radio API expects the setting of the TX-power in dBm. The actual
TX-power is however set by a 6bit register, which mapping between
register value and power in dBm is a lookup-table in the datasheet.

This mapping for the kw41z was off, which not only lead to incorrect
output power, but also to a maximal output power of only -1.9 dBm
instead of the possible +3.5 dBm.

Signed-off-by: Tobias Aschenbrenner <tobias.aschenbrenner@blik.io>
Signed-off-by: Franco Saworski <f.saworski@posteo.de>
2019-04-17 10:26:19 -05:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Andrew Boie 4e5c093e66 kernel: demote K_THREAD_STACK_BUFFER() to private
This macro is slated for complete removal, as it's not possible
on arches with an MPU stack guard to know the true buffer bounds
without also knowing the runtime state of its associated thread.

As removing this completely would be invasive to where we are
in the 1.14 release, demote to a private kernel Z_ API instead.
The current way that the macro is being used internally will
not cause any undue harm, we just don't want any external code
depending on it.

The final work to remove this (and overhaul stack specification in
general) will take place in 1.15 in the context of #14269

Fixes: #14766

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-05 16:10:02 -04:00
Patrik Flykt 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Wentong Wu 94615a4f98 ext: lib: crypto: unify the API of CCM alogrith
unify the API of CCM alogrithm's implemation for TinyCrypt,
mbedTLS and cc2520 crypto device to make users easy to use.

Fixes #8339.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-04-02 21:02:00 -04:00
Patrik Flykt 21358baa72 all: Update unsigend 'U' suffix due to multiplication
As the multiplication rule is updated, new unsigned suffixes
are added in the code.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Tomasz Bursztyka cf322c44db net: Switch usage of net_pkt_get_reserve to net_pkt_alloc
Some places were still using the old allocator. Using the new one does
not change any behavior. This will help to remove the useless data_len
attribute in net_pkt which legacy allocator was still setting.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka 23251b040d drivers/ieee802154: Switch KW41Z to new net_ptk allocator
Now buffer is allocated at the same time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Tomasz Bursztyka fd721328be drivers/ieee802154: Switch NRF5 to new net_ptk allocator
Now buffer is allocated at the same time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Tomasz Bursztyka f63e9d295b drivers/ieee802154: Switch MCR20A to new net_ptk allocator
Now buffer is allocated at the same time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Tomasz Bursztyka 52fd371504 drivers/ieee802154: Switch CC2520 to new net_ptk allocator
Now buffer is allocated at the same time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Tomasz Bursztyka 7981c2792b drivers/ieee802154: Switch CC1200 to new net_ptk allocator
Now buffer is allocated at the same time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Kumar Gala b5a86baa57 ieee802154: mcr20a: Fixup SPI CS handling
Replace undefined Kconfig SPI CS defines with DTS based defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-01 04:10:09 -06:00
Kumar Gala de20c10691 ieee802154: mcr20a: Remove dead Kconfig symbols
We have moved GPIO info to DT so the Kconfig symbols for GPIO lines
aren't used anymore.  We can just remove them.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-01 04:10:09 -06:00
Robert Lubos e0d4036f53 drivers: ieee802154: nrf5: Align to new radio driver API
Align ieee802154_nrf5 driver to a new radio driver API.
Utilize new radio driver features (CCA).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-29 10:37:47 +01:00
Kumar Gala 2492d52f5c ieee802154: cc2520: Convert to new DT_<COMPAT>_<INSTANCE> defines
Convert cc5250 driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-28 10:40:14 -06:00
Kumar Gala 717b647c30 ieee802154: mcr20a: Convert to new DT_<COMPAT>_<INSTANCE> defines
Convert mcr20a driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-18 09:06:10 -06:00
Robert Lubos 635191ac8c net: ieee802154: Fix ack check
15.4 MHR is no longer set in net_buf pointed by net_pkt, but in a
separate net_buf, hence we need to check that net_buf now to
determine if we need to wait for ACK or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-17 11:16:26 +02:00
Ioannis Glaropoulos 2e687653fa drivers: clock control: rename nrf5_power_clock source and header
This commit renames the nrf5_clock_control.h and
nrf5_clock_control.c files to nrf_clock_control.h and
nrf_clock_control.c, respectively, as they are used
in nRF9160 builds, as well.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-01-15 18:03:24 +01:00
Ioannis Glaropoulos 302a746bd6 drivers: clock control: nrf: rename CLOCK_CONTROL_NRF5 Kconfig symbol
This commit renames the CLOCK_CONTROL_NRF5 Kconfig symbol to
CLOCK_CONTROL_NRF. The change is required to aleviates confusion
when selecting the symbol in nRF9160 SOC definition.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-01-15 18:03:24 +01:00
Tomasz Bursztyka 88b2535e0d drivers/ieee802154: Fix UPIPE driver at boot
Before it is initialized, upipe_dev is not set. Fixes this issue:

SeaBIOS (version rel-1.11.2-0-gf9626ccb91-prebuilt.qemu-project.org)
Booting from ROM..***** CPU Page Fault (error code 0x00000000)
Supervisor thread read address 0x00000008
PDE: 0x025 Present, Read-only, User, Execute Enabled
PTE: 0x00 Non-present, Read-only, Supervisor, Execute Enabled
Current thread ID = 0x00401a40
eax: 0x00000000, ebx: 0x0040c668, ecx: 0x00000001, edx: 0x000002f8
esi: 0x0040ac5b, edi: 0x0040ac38, ebp: 0x0040b4a8, esp: 0x0040b498
eflags: 0x00000202 cs: 0x0008
call trace:
eip: 0x00008651
     0x000082a3 (0x400a8d)
     0x00008b12 (0x40c668)
     0x00008632

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-08 11:25:33 +02:00
Robert Lubos 82d956fdf8 drivers: ieee802154: nrf5: Prevent driver from spamming logs
ieee802154_nrf5 uses net_analyze_stack function in a loop, which
prints logs at inf level. As net_core's log level is used in
this function which by default is set to inf, it kept spamming stack
usage logs.

Prevent this behavior by adding additional log level check in the driver
itself, so that this log will only be printed if
IEEE802154_DRIVER_LOG_LEVEL is set to debug.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-12-19 08:20:55 -06:00
Tomasz Bursztyka e97a543e9b net/pkt: Remove parameters to "reserve" some headroom
Such parameter is not used anymore, it was defaulted to 0 previously.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka 6ea225e34a net/ieee802154: Finally removing usage of ll_reserve in L2
Moving towards serialized fragmentation, adapting mac command creation
to avoid the need of ll_reserve etc...

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Johann Fischer 7734627215 drivers: ieee802154_mcr20a: fix style
Fix style before DT_IEEE802154_MCR20A* macros.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-12-10 10:41:22 -06:00
Johann Fischer db64943aa5 drivers: ieee802154_mcr20a: do not initialize reset gpio on KW2XD
Do not initialize reset gpio on KW2XD SIP.
Modem's clock output is used by the SoC for the PLL.
Initialization of the reset gpio may result in the reset of the modem
and the crash of SoC.

Keep reset gpio low until modem initialization.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-12-10 10:41:22 -06:00
Johann Fischer f3a36502a0 drivers: ieee802154_mcr20a: fix update of indirect registers
Fix overwrites update of indirect register.
Since the indirect register should be updated,
the parameter dreg should be false.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-12-10 10:41:22 -06:00
Kumar Gala 1fe9a5b8d8 dts: ieee802154: cc1200: Add DTS support
Add a dts binding file for the cc1200 and move the Kconfig options for
SPI and GPIOs to DTS for the CC1200 driver.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-05 10:13:23 -06:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Tomasz Bursztyka ebb40ba338 net/ieee802154: Switch to L2 sending path
As for Ethernet, up to ieee802154 L2's send to actually sent the packet.
It's currently unoptimized as 6lo compression, 15.4 fragmentation and so
on will reallocate net_buf etc... but it's the first step towards
removing ll reserve space and more.

Applying changes to Openthread L2 as well.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Kumar Gala f249a0f4f2 ieee802154: cc2520: Move to DT only config support
Now that the in tree user of cc2520 uses device tree to configure SPI
and GPIO params, we can remove and convert the driver to utilize DT
only.  This means removing the Kconfig options that come from DT and
rename CONFIG_ to DT_ for those options.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-16 14:02:00 -05:00
Kumar Gala ea198e3e4b ieee802154: mcr20a: Cleanup Kconfig and DT support
Now that all SPI controllers support DTS we can remove the Kconfig
support for non-DTS options.  We also cleanup some defines that should
have be DT_MCR20A_ instead of CONFIG_MCR20A_.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-16 14:02:00 -05:00
Tomasz Bursztyka 1b3b0153a6 boards/x86: Use dts for configuring the cc2520 device
Only the SPI bus for now.
Make cc2520's Kconfig aware of DTS on these settings.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-16 14:02:00 -05:00
Andrei Emeltchenko 13b02d620c ieee802154: Allow to set debug for RAW_CHANNEL
Allow to set debug also for RAW_CHANNEL and set general debug template
instead of networking one.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-15 08:42:52 -05:00
Krzysztof Chruscinski 0df41da4e9 drivers: ieee802154: Fix log configuration in kconfig
Log configuration was included only in case NET_L2_IEEE802154 was
enabled. In case of open thread this is not the case.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-10 12:38:29 -05:00
Kumar Gala aa2bdbe322 drivers: Remove board.h include
We either don't need board.h in the driver or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:21:11 -04:00
Anas Nashif 7147f0ceeb drivers: ieee802154_cc2520: move to new logger
Move to new logger and remove commented logger calls.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-16 17:30:09 -04:00
Jukka Rissanen 009e4dafa7 net: Make Kconfig template variables prettier
Adding spaces around "=" when definining Kconfig template so
that is more consistent with overall style of these template
variables.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-05 09:01:37 -04:00
Jukka Rissanen 90dc38f8c9 drivers: ieee802154: Convert to use new logging
Convert the IEEE 802.15.4 drivers to use the new logging system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Maureen Helm ad32e3b543 drivers: boards: Merge HAS_DTS_SPI_PINS with HAS_DTS_SPI
Every board that uses dts-enabled spi drivers has a board-level dts, so
there is no need to have separate configs HAS_DTS_SPI_PINS and
HAS_DTS_SPI.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-10-01 21:15:06 -05:00
Maureen Helm eeb4411de7 drivers: boards: Merge HAS_DTS_GPIO_DEVICE with HAS_DTS_GPIO
Every board that uses dts-enabled gpio drivers has a board-level dts, so
there is no need to have separate configs HAS_DTS_GPIO_DEVICE and
HAS_DTS_GPIO.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-10-01 21:15:06 -05:00
Maureen Helm 89ccead382 drivers: boards: Merge HAS_DTS_SPI_DEVICE with HAS_DTS_SPI
Every board that uses dts-enabled spi drivers has a board-level dts, so
there is no need to have separate configs HAS_DTS_SPI_DEVICE and
HAS_DTS_SPI.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-10-01 21:15:06 -05:00
Mark Ruvald Pedersen d67096da05 portability: Avoid void* arithmetics which is a GNU extension
Under GNU C, sizeof(void) = 1. This commit merely makes it explicit u8.

Pointer arithmetics over void types is:
 * A GNU C extension
 * Not supported by Clang
 * Illegal across all ISO C standards

See also: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-09-28 07:57:28 +05:30
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Ulf Magnusson ec3eff57e0 Kconfig: Use the first default with a satisfied condition
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.

There are at least three problems with the patch:

  1. It's inconsistent with how Kconfig works in other projects, which
     might confuse newcomers.

  2. Due to oversights, earlier 'range' properties are still preferred,
     as well as earlier 'default' properties on choices.

     In addition to being inconsistent, this makes it impossible to
     override 'range' properties and choice 'default' properties if the
     base definition of the symbol/choice already has 'range'/'default'
     properties.

     I've seen errors caused by the inconsistency, and I suspect there
     are more.

  3. A fork of Kconfiglib that adds the patch needs to be maintained.

Get rid of the patch and go back to standard Kconfig behavior, as
follows:

  1. Include the Kconfig.defconfig files first instead of last in
     Kconfig.zephyr.

  2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
     last in arch/Kconfig.

  3. Include arch/<arch>/soc/*/Kconfig first instead of last in
     arch/<arch>/Kconfig.

  4. Swap a few other 'source's to preserve behavior for some scattered
     symbols with multiple definitions.

     Swap 'source's in some no-op cases too, where it might match the
     intent.

  5. Reverse the defaults on symbol definitions that have more than one
     default.

     Skip defaults that are mutually exclusive, e.g. where each default
     has an 'if <some board>' condition. They are already safe.

  6. Remove the prefer-later-defaults patch from Kconfiglib.

Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions

As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).

This commit includes some default-related cleanups as well:

  - Simplify some symbol definitions, e.g. where a default has 'if FOO'
    when the symbol already has 'depends on FOO'.

  - Remove some redundant 'default ""' for string symbols. This is the
    implicit default.

Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).

Piggyback some fixes for style nits too, e.g. unindented help texts.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 12:38:28 -07:00
Tomasz Bursztyka 39db4f48d7 drivers/ieee802154: Fix settings channel/tx power in uart pipe driver
Being stopped or not should not be a blocker on these settings (real
hardware can get these settings configured while not being in rx/tx
mode for instance).

Fixes #8528

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-07-24 20:40:51 +03:00
Ulf Magnusson a81bc32677 drivers: ieee802154: Kconfig: Remove redundant 'default n' properties
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Ulf Magnusson 8df42eb4dc drivers: Replace ff hex constants with 0xff
This makes it easier to distinguish them from "true" undefined symbols.

Internally, all int/hex literals are treated as undefined symbols, which
always get their name as their value. The C tools work the same way.

The plan is to turn references to undefined Kconfig symbols into an
error later.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-06-13 13:35:56 -04:00
Ulf Magnusson 2e6386f5af drivers: ieee802154: Remove GPIO_MCUX_PORT{A,B}_NAME Kconfig references
These symbols were removed by commit 4e8f29f319 ("gpio: Refactor the
mcux gpio driver to use dts"). The settings should come from DTS now.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-06-13 13:35:56 -04:00
Tomasz Bursztyka 50990cdfaf drivers/ieee802154: KW41Z drivers is missing hw ACK caps
ACK frames are handled on hardware level, so let's expose this
capability in order to avoid L2 waiting for these.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 16:18:53 +03:00
Tomasz Bursztyka 49bd1e9c6f ieee802154: Add support for filtering source short/ieee addresses
L2 could take advantage of such hardware capability, when supported by
the device. This is also required for OpenThread.

Fixes #5714

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 16:18:53 +03:00
Maureen Helm 0d1beb2f9e boards: dts: Add mcr20a bindings and fix networking samples
Adds dts bindings for the mcr20a wireless transceiver. The frdm_k64f
board supports the mcr20a via an Arduino shield, therefore the dts node
is added to the board dts. The kw2xd is a SiP and thus the mcr20a dts
node is added to the soc dts.

The networking samples using prj_frdm_k64f_mcr20a.conf have been broken
since the refactoring of the mcux gpio driver to dts in commit
4e8f29f319. The sample is now fixed.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-05-10 15:43:42 -05:00
Matthias Boesl f618af75a8 driver: ieee802154: cc1200: fix context handling
context was missed during refactoring

Signed-off-by: Matthias Boesl <matthias.boesl@gmail.com>
2018-05-02 14:30:34 +03:00
David Leach 9f7470e240 drivers: ieee802154: Add OpenThread modifications to KW41Z driver
- Add modifications to the KW41Z driver to enable operation with
  OpenThread L2 layer.

Signed-off-by: David Leach <david.leach@nxp.com>
2018-04-11 16:57:12 +03:00
David Leach 7738a501d9 drivers: ieee802154: Add auto-ack support to KW41Z driver
- Enabled and fixed auto-ack offload support for 802.15.4 transmit

Signed-off-by: David Leach <david.leach@nxp.com>
2018-04-11 16:57:12 +03:00
Tomasz Bursztyka d5e6874d64 drivers/ieee802154: No need of semaphore for spi in mcr20a
SPI API is reentrant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Tomasz Bursztyka b62b12eef8 drivers/ieee802154: Switch MCR20A driver to new SPI API
And adding support for GPIO CS as well.
It looks like the driver could benefit from centralizing all SPI access
into a unique function, the protocol does not seem too convoluted to do
so, like CC2520 or CC1200.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Tomasz Bursztyka d4065ae73e drivers/ieee802154: Switch CC2520 to new SPI API
Finally switching to new SPI API. It makes code simpler and performs
better.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Tomasz Bursztyka ea2431f32f api/spi: Reduce parameter number on transceive function
tx_bufs/tx_count and rx_bufs/rx_count can be hold in another dedicated
structure, thus reducing the number of parameters to transceive. This
permits to avoid using the stack when calling transceive.

Since we saved parameters, we can expose back the struct device pointer,
to stay consistent with other device driver APIs.

Fixes #5839

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Tomasz Bursztyka 324265420b api/spi: Disable legacy API by default
Let's start deprecation work of the SPI legacy API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-04 19:02:35 +02:00
Jukka Rissanen 47dafffb67 net: if: Separate IP address configuration from net_if
Move IP address settings from net_if to separate structs.
This is needed for VLAN support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Pedro Martucci ede5b8ffc3 drivers/ieee802154: Add hw filtering support for upipe driver
Implements HW filtering for IEEE802.15.4 UART Pipe driver.

Signed-off-by: Pedro Martucci <pedropaulomartucci@gmail.com>
2018-02-20 14:47:14 +02:00
Anas Nashif 8949233390 kconfig: fix more help spacing issues
Fix Kconfig help sections and add spacing to be consistent across all
Kconfig file. In a previous run we missed a few.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 23:20:55 -05:00
Ravi kumar Veeramally 731c7518d2 drivers: cc2520: Change debug information
Driver is 'Busy' can be a warning message which can be enabled with
minimum debug level CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=2.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
David B. Kinder baed5a59c7 doc: fix misspellings in Kconfig files
Fix misspellings in Kconfig files used for configuration docs.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-01-30 20:03:40 -05:00
Kamil Sroka 32907813b9 drivers: 15.4: nrf5: Add OpenThread support to 802.15.4 driver
Initially add support for OpenThread only for nRF 802.15.4 radio driver.

Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2018-01-29 22:42:03 -05:00
Tomasz Bursztyka 8ded57d3a2 drivers/ieee802154: Add support for Sub-GHz TI CC1200 chip
CC1200 is a sub-ghz chip supporting 6 ISM & SRD bands: 169, 433, 470,
868, 915 and 920 MHz, with features dedicated to IEEE 802.15.4(g).

Current driver enables CC1200 against actual IEEE 802.15.4 Soft-MAC. 'g'
version support in the Soft-MAC will follow later.

The chip itself is closer to a bare metal radio modem than to a usual
15.4 chip: up to the user to provide the right RF settings for the
carrier band. Such settings can be generaten through TI's SmartRF tool.

Hopefully, for channel selection, this driver will be clever enough to
compute the proper register change without any special input from the
user. This will work for all the bands supported by the chip.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka f4664f1d9a drivers/ieee802154: Cleaning up CMakeLists.txt
Old reference on driver's specific raw mode was still lurking around.
Removing those.

Fixes #5270

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-10 21:53:01 -05:00
Tomasz Bursztyka 5195ddf472 drivers/ieee802154: Cleanup Kconfig
A very old reference to former net stack was still lurking around.
Removing it.

Taking the opportunity to clear up dependencies.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-10 21:53:01 -05:00
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Sebastian Bøe 1bb47676a9 kconfig: 802154: nrf: Fix kconfig
This fixes a regression from
https://github.com/zephyrproject-rtos/zephyr/pull/5018

The ieee802154 driver wouldn't build because nrf drivers/ieee802154
depends on the nordic ext drivers to build.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-06 11:11:59 -06:00
Anas Nashif 938a8aadaa kconfig: fix type of config for nrf5 15.4
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-23 07:29:13 -05:00
Tomasz Bursztyka b52c0f24a6 net/ieee802154: Make RAW mode generic
- Renaming NET_L2_RAW_CHANNEL to NET_RAW_MODE
- Create a generic IEEE 802.15.4 raw mode for drivers
- Modify the IEEE 802.15.4 drivers so it passes the packet unmodified,
up to code using that mode to apply the necessary changes on the
received net_pkt according to their needs
- Modify wpanusb/wpan_serial relevantly

Fixes #5004

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-11-22 10:10:09 -05:00
Kumar Gala 4b2348c9e7 drivers/ieee802154_kw41z: Fix interrupt priority
The interrupt priority on KW41Z is from 0..3.  The value of 0x80 is
invalid, so lets set it to 0 for now as all the other interrupt
priorities default to 0 right now.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-11-15 08:30:16 -06:00
Kumar Gala 7cd27be39a drivers/ieee802154_kw41z: Update kw41z to support event trace buffer
Added conditionally enabled event state tracing support.
Needed for enhanced debug visibility of tight timed events where
normal print debug messages affect the timing of things. This is a
simple buffer that allows post analysis via gdb of what sequencer
events occurred.

Signed-off-by: David Leach <david.leach@nxp.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-11-15 08:30:16 -06:00
David Leach fcffac92b7 drivers/ieee802154_kw41z: Reduce debug logging due to false positives
- Removed some debug output and changed the level of others to reduce
  the amount of information logged. The reason is that some of this is
  causing false positive distractions.
- Removed enabling of FILTER error IRQ events. It isn't needed and is
  only informational.
- Changed frame control AR bit inspection to use native retrieval
  routine.
- Addressed some coding style issues.

Signed-off-by: David Leach <david.leach@nxp.com>
2017-11-15 08:30:16 -06:00
David Leach 280ccbaffb drivers/ieee802154_kw41z: Modified RX handling of filter failures
Changed the logic to reset the sequencer when a RX filter
failure has been detected. This also disables the RX timer
until the next watermark detection.

Signed-off-by: David Leach <david.leach@nxp.com>
2017-11-15 08:30:16 -06:00
David Leach e8431daac0 drivers/ieee802154_kw41z: Stabilize the KW41Z IEEE802.15.4 driver
- Reworked the driver logic around TX/RX to correctly handle the
  expectations of the underlying 802.15.4 hardware IP.
- Fixed a problem with TX always reporting an error to the stack
  which resulted in constant retries.
- Fixed bug in RX to TX transition which would occasionally cause the
  driver to error the TX.
- Changed RX logic to ensure that invalid RX frames were not passed up
  the stack.
- Simplified hardware timer usage to only use TMR3.
- Added RX watermark and TMR3 support to fix a hardware problem where
  the hw IP can get stuck on a receive in noisy environments.
- Modified samples/net/echo_client and echo_server kw41z project config
  files to provide enanced debug visibility into stacks and threads.

Signed-off-by: David Leach <david.leach@nxp.com>
2017-11-15 08:30:16 -06:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Leandro Pereira adce1d1888 subsys: Add random subsystem
Some "random" drivers are not drivers at all: they just implement the
function `sys_rand32_get()`.  Move those to a random subsystem in
preparation for a reorganization.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-01 08:26:29 -04:00
KaSroka bea5ccf7ea drivers: 15.4: nrf5: Add timeout when waiting for tx to complete
Waiting for tx to complete should timeout after 10ms
instead of blocking forever in case ack is not received.

Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2017-10-30 12:03:03 +02:00
Johann Fischer d81b332b0d drivers: mcr20a: check AR bit and use appropriate TX sequence
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-10-28 14:22:46 -04:00
Johann Fischer 5db10d072f drivers: mcr20a: small improvements
Issue a error message, if the _mcr20a_read_reg fails.

Do not execute SPI burst read/write if the buffer is too small.

Unlock mutex if set_pan_id, set_short_addr or set_ieee_addr
fail.

Force abort of the sequence when the higher level changes the channel
even though a T or TR sequence is in progress.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-10-28 14:22:46 -04:00
Jukka Rissanen dc3f2455d7 drivers: ieee802154: uart: Do not send FCS bytes to peer
No need to send FCS bytes as the monitor_15_4 is configured to not
expect them. If we change the monitor_15_4 to use them, then we would
need to put correct values into these two FCS bytes.
So cleanest solution is not to send FCS bytes at all.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-26 14:51:56 +03:00
Kamil Sroka 652fbe6756 drivers: 15.4: nrf5: Fix warning during compilation
Fixes #4466

Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2017-10-24 11:00:08 +03:00
Kamil Sroka 22d02db46e drivers: ieee802154: nrf5: Fix typo
Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2017-10-17 10:23:34 +03:00
Tomasz Bursztyka ea0aee2bb3 drivers/ieee802154: Stop exposing old radio API functions
set_ieee_addr, set_short_addr and set_pan_id are now unused by L2, so
removing their exposure through the radio API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka 54b3d6b130 drivers/ieee802154: Implement radio API's set_filter() relevantly
Currently, all drivers seem to support hardware filtering.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka b2726e14a6 drivers/ieee802154: Implement get_capabilities in existing drivers
Further support will need work per-driver basis, as soon as the L2 will
be able to make usage of such support.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka 164cbec9d0 drivers/ieee802154: Set lqi/rssi to net_pkt, stop exposing get_lqi
Both values are now embedded into net_pkt, get_lqi will be removed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Paul Sokolovsky 808b315cf6 arm: nxp: kw41z: Select IEEE802154_KW41Z driver for networking
802.15.4 is the networking hardware available in KW41Z SoC (and
supported by Zephyr). So, if networking in enabled, automatically
select the corresponding driver. This is similar to how frdm_k64f
automatically selects Ethernet driver, 96b_carbon selects BLE/IPSP
drivers, etc. (But we apply it on SoC level to reuse across the
boards.)

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-06 14:39:17 -05:00
Tomasz Bursztyka eb7b29e5cf drivers/ieee802154: Fix regression in uart pipe driver
A wrong name replacement was applied during commit
db11fcd174

Fixes issue #4165

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-04 10:47:08 +03:00
Jukka Rissanen 07b1376c31 drivers: ieee802154: cc2520: Fix compiler warning
The stack address was incorrectly specified when stack usage
was being debugged. This caused compiler to emit this warning

drivers/ieee802154/ieee802154_cc2520.c:1136:16: warning:
    dereferencing type-punned pointer will break strict-aliasing
    rules [-Wstrict-aliasing]
       ((struct cc2520_context *)(&__device_cc2520))->
                ^

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-30 11:54:43 -04:00
Tomasz Bursztyka 05890b32b4 drivers/ieee802154: Fix licence headers in Kconfig files
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-08-16 11:44:39 -04:00
Anas Nashif 09bcd8ee74 Kconfig: make all syslog variables depend on SYS_LOG
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-04 14:34:54 -05:00
Leandro Pereira 732424f065 drivers, net: Clean up semaphore initialization
Change the common "init with 0" + "give" idiom to "init with 1".  This
won't change the behavior or performance, but should decrease the size
ever so slightly.

This change has been performed mechanically with the following
Coccinelle script:

    @@
    expression SEM;
    expression LIMIT;
    expression TIMEOUT;
    @@

    - k_sem_init(SEM, 0, LIMIT);
    - k_sem_give(SEM);
    + k_sem_init(SEM, 1, LIMIT);

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-07-27 15:23:07 -04:00
Johann Fischer 3f05300924 drivers: mcr20a: allow use the driver with KW2xD devices
This patch allows the use of the MCR20A driver with KW2xD devices.
The clock output of the transceiver can be used as an input clock
for the PLL of the SoC. The hardware reset and CLK_OUT setup of
the transceiver should then be performed during the initialization
of the SoC. The driver is not allowed to do it again.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-07-27 11:21:04 +03:00
Johann Fischer 635216533c drivers: mcr20a: minor fixes and correction of the copyright header
Some patches have been lost during rebase before the initial commit,
this path fixes it.
- correct copyright in registers definition header file
- fix undefined macro inside CLK_OUT configuration
- use the return value of k_sem_take if there is a timeout

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-07-27 11:21:04 +03:00
Andrew Boie e8cede7940 net: fix references to stack buffers
The net_stack_analyze function wants to look at the stack buffer,
but it is making assumptions on where this data is that are no
longer valid. Change to use the proper APIs for referencing this.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-26 10:31:46 +03:00
Bogdan Davidoaia e392ef2285 drivers: ieee802154: kw41z: add support for KW40Z
Add support for KW40Z in the KW41Z IEEE 802.15.4 driver as both chips
expose almost the same radio registers.

Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-07-06 14:20:32 -05:00
Bogdan Davidoaia 3389ee4eb4 drivers: ieee802154: kw41z: fix issue in RX sequence
The chip seems to require a wait time before reading packet
data after the RX sequence done interrupt, as imidiate reading
of it will indicate a packet size of zero and cause the RX
sequence done to be continually retriggered.

In addition, the extra clearing of the interrupt flags can be
removed, as this is already done at the beginning of the isr.

Jira: ZEP-2278
Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-07-06 14:20:32 -05:00
Bogdan Davidoaia 2b1dfbcd7c drivers: ieee802154: kw41z: remove unnecessary cast for PKT_BUFFER_RX
The cast to u16_t in not needed as PKT_BUFFER_RX already is
of that type.

Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-07-06 14:20:32 -05:00
Anas Nashif 397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Andrew Boie 2d4a36fc1c drivers: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Andrew Boie 27bcdc571b drivers: ieee802154: use k_thread_create()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Kumar Gala c11877941a drivers: ieee802154_kw41z: Cleanup use of C99 types
We introduced some see C99 types, so convert them over to the Zephyr
types.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-05-09 17:06:28 -04:00
David B. Kinder f930480e16 doc: misspellings in Kconfig files
fix misspelling in Kconfig files that would show up in configuration
documentation and screens.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-05-05 19:38:53 -04:00
Bogdan Davidoaia 15e55e1823 ieee802154: kw41z: keep global transceiver interrupt unmasked
There is no need to unmask/mask the global transceiver interrupt
in kw41z_start/stop as the radio interrupt line is enabled/disabled
anyway with irq_enable/disable calls.

Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-05-04 11:58:46 -04:00
Bogdan Davidoaia cbe030d444 ieee802154: kw41z: fix sync issue in CCA sequence
- set state to IDLE if TMR1 expires, but CCA reports channel as free
- no need to check for CCABFRTX, as the hardware isn't setup to do
CCA before TX

Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-05-04 11:58:46 -04:00