Commit graph

282 commits

Author SHA1 Message Date
Benjamin Valentin 2ffb8dd9f1 usb: sam0: use TRIM registers when available
Newer SoCs like SAME54 provide dedicated registers to store
the USB trim configuration.

Use those registers if they are defined in ASF to access the
calibration data.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-12-11 11:13:24 +01:00
Benjamin Valentin e0b94e92d5 usb: sam0: Add support for MCLK
On newer sam0 SoCs peripherals are enabled through the MCLK
instead of the PM register.

Use the MCLK register if it's availiable.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-12-11 11:13:24 +01:00
Benjamin Valentin 2ff38cc631 usb: sam0: Support more then one USB IRQ
Newer SoCs like SAME54 have multiple IRQs for the USB peripheral.
Automatically enable all IRQs configured in the DTS.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-12-11 11:13:24 +01:00
Johann Fischer 9a7a1b0132 drivers: usb_dc_nrfx: remove not relevant bashing comments
Remove not relevant bashing comments.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-12-11 11:10:01 +01:00
Johann Fischer b22035de45 drivers: usb_dc_nrfx: free memory if event is intended to be dropped
Free memory block if event is intended to be dropped.

Resolves: #20953

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-12-11 11:10:01 +01:00
Emil Obalski c1f5e11bb6 usb: Cleanup for multiplied defines
Some of defines are present in several header files.
Those defines are the same with value but with different naming.

Common defines are brought to usb_common.h

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-09 12:48:13 -05:00
Josh Gao 2717b28b0f usb: usb_dc_native_posix: fix control transfers with data.
Previously, if a control transfer had data, it would be unhandled and
left in the usbip socket to be interpreted as the next usbip packet,
leading to explosions.

Signed-off-by: Josh Gao <josh@jmgao.dev>
2019-12-09 16:08:27 +01:00
Andrei Emeltchenko 105e0997f2 usb: usb_dc_native_posix: Refactor similar code to function
Use skip_setup() function helper in a place we need to skip setup
data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko 0957f4978c usb: usb_dc_native_posix: Use return code for skip_setup()
Use return code for usbip_skip_setup()

Fixes #20840

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko 80dbcfa306 usb: usb_dc_native_posix: Check return code in handle_usb_data()
Fixes coverity complaints dealing with send()

Fixes #20839
Fixes #20841

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko 1d81c0cf31 usb: usb_dc_native_posix: Fix buffer and max data 0 case
When both buffer and max data to read are zero return
the available data in buffer.

Fixes #20838

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko 5b22c88184 usb: usb_dc_native_posix: Check return values in dc_write()
Fixes coverity issue:

Fixes #20836
Fixes #20837

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Andrei Emeltchenko 959b833f91 usb: usb_dc_native_posix_adapt: Check correct size
Fixes Coverity issues

Fixes #20842

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-11-29 07:54:14 -05:00
Johann Fischer d4ba8fff66 drivers: usb_dc_stm32: do not restrict out stage transfers to one MPS
Do not restrict control out stage transfers to one MPS.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-11-21 11:33:41 +01:00
Emil Obalski 6c82c80a3c drivers: Add support for nRF52833 in several drivers
By adding new SoC to Zephyr drivers has to be updated.
Commit affects:
 - USB driver
	- support for nRF52833 added.
	- support for USB_DEVICE_REMOTE_WAKEUP in hid-mouse added.
 - SPI
 - IEEE 802.15.4
 - CLOCK CONTROL

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-11-13 10:33:38 -06:00
Andrzej Głąbek b1d5eed262 drivers: nrfx: Update implementations after switching to nrfx 2.0.0
Update calls to nrfx HAL functions to reflect API changes introduced in
nrfx 2.0.0. All these functions are now called with the first parameter
pointing to the structure of registers of the relevant peripheral.
Also a few functions got renamed:
- nrf_gpiote_int_is_enabled to nrf_gpiote_int_enable_check
- nrf_gpiote_event_is_set to nrf_gpiote_event_check
- nrf_rng_event_get to nrf_rng_event_check
- nrf_rng_int_get to nrf_rng_int_enable_check
- nrf_rtc_event_pending to nrf_rtc_event_check
- nrf_rtc_int_is_enabled to nrf_rtc_int_enable_check
- nrf_timer_cc_read to nrf_timer_cc_get
- nrf_timer_cc_write to nrf_timer_cc_set

Default configuration values were removed from nrfx_config files,
so the drivers pwm_nrfx and spi_nrfx_spis no longer can use those.

Function nrfx_pwm_init() now takes one more parameter - context pointer
that is passed to the event handler, not used in the pwm_nrfx driver.

HALs for UART and UARTE now allow configuration of the parity type
and the number of stop bits, for SoCs that provide the corresponding
registers.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-11-08 14:54:12 +01: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
Peter Bigot 6e5db350b2 coccinelle: standardize k_sleep calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments to
k_sleep to use the standard timeout macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Richard Osterloh 37514ae660 drivers: usb: Add STM32G4X USB support
Add USB driver support for STM32G4X SoC series.

Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
2019-10-04 18:44:24 -07:00
Krzysztof Chruscinski 43af941131 drivers: Align nrf counter, timer and usb driver to new clock_control
Align drivers to use new clock control API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-10-04 17:15:39 +02: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
Johann Fischer 51f550cd07 usb: allow hardware to handle ZLP for Variable-length Data Stage
Allow hardware to handle ZLP for Variable-length Data Stage.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-09-26 13:19:02 +02:00
Ulf Magnusson e833fafd4b drivers: usb: stm32: Fix broken DT_USB_ENABLE_PIN_REMAP test
'enable-pin-remap' is defined as 'type: boolean' in
dts/bindings/usb/st,stm32-usb.yaml, so it generates either

    #define DT_USB_ENABLE_PIN_REMAP 1

or

    #define DT_USB_ENABLE_PIN_REMAP 0

depending on if 'enable-pin-remap;' appears on the node or not.

Since a macro is always generated, #ifdef won't work. The test needs to
be this instead:

    #if DT_USB_ENABLE_PIN_REMAP == 1

(Should be careful with '#if HMZ == 0' though, because it's true even if
HMZ is undefined.)

This behavior was inherited from the old scripts, and some things depend
on it, e.g. by expanding macros in initializers.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-24 09:36:31 -07:00
Anas Nashif d7f2055dd7 usb: remove QMSI include
No users of this after dropping quark platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-18 11:06:18 -05:00
Erwan Gouriou b42ad680c5 dts/Kconfig: Remove symbol HAS_DTC_USB
Symbol not used, so clean it up.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-09-12 08:16:42 -05:00
Johann Fischer e16217aa06 drivers: usb_dc_sam: validate pointer in usb_dc_ep_is_stalled
Validate pointer argument in usb_dc_ep_is_stalled.

Fixes: #18824

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-09-08 12:35:23 +02:00
Anas Nashif 578ae40761 boards: remove quarl_se_c1000
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Andrzej Głąbek f69e194ece drivers: usb_dc_nrfx: Use dedicated work queue for handling ISR events
This patch introduces a dedicated work queue for handling the events
from ISR (i.e. for notifying the USB device stack, for executing the
enpoints callbacks, etc.). The system work queue cannot be used for
this purpose as it might be used in applications for scheduling USB
transfers and this could lead to a deadlock when the USB device stack
would not be notified about certain event because of a system work
queue item waiting for a USB transfer to be finished.

The FIFO named so far `work_queue` is renamed to `usbd_evt_fifo`
to better indicate its purpose and to avoid confusion.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-07-22 18:19:33 +02:00
Francois Ramu 474c99c9ef drivers: usb/stm32: use dts information to populate clock settings
This patch populates "clocks" property in stm32 usb nodes
for clock related usb configuration code of each  dtsi files

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2019-07-16 09:08:51 -04:00
Johann Fischer 1e9a53e548 drivers: usb_dc_nrfx: make macros names less confusing
Rename EP_BUF_* to EP_BUF_POOL*.
Rename MAX_*EP_BUF_SZ to *EP_BUF_MAX_SZ.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-05 08:31:38 -04:00
Johann Fischer 7f118be601 drivers: usb_dc_nrfx: remove unused EPSTATUS defines
Remove unused EPSTATUS defines.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-05 08:31:38 -04:00
Johann Fischer 6904a86835 drivers: usb_dc_nrfx: cleanup USB_NRFX_EVT_QUEUE_SIZE
Cleanup around USB_NRFX_EVT_QUEUE_SIZE option.
Add value range for USB_NRFX_EVT_QUEUE_SIZE to Kconfig.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-05 08:31:38 -04:00
Johann Fischer 226a429c97 drivers: usb_dc_nrfx: fix style issues
Fix style issue reported by checkpatch.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-05 08:31:38 -04:00
Johann Fischer 04b91579ae drivers: usb_dc_nrfx: use REQTYPE_GET_DIR and REQTYPE_GET_TYPE macros
Use REQTYPE_GET_DIR and REQTYPE_GET_TYPE macros from
USB subsystem instead of specially introduced.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-05 08:31:38 -04:00
Johann Fischer eb57607c7d drivers: usb_dc_nrfx: validate pointer in usb_dc_ep_is_stalled
Validate pointer argument in usb_dc_ep_is_stalled.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-04 21:36:07 +02:00
Johann Fischer cb37505976 drivers: usb_dc_nrfx: check the device state before disable or uninit
Check the device state before nrfx_usbd_disable and
nrfx_usbd_uninit. Otherwise it may lead to an ASSERT
inside the HAL driver.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-04 21:36:07 +02:00
Johann Fischer 38cc23a7d9 drivers: usb_dc_nrfx: do not use NRF_USBD_EP_NR_GET in ep_is_valid
Do not use NRF_USBD_EP_NR_GET in ep_is_valid because
it masks the higher nibble. Although this behavior is valid
to get an index from an endpoint, it is not suitable to check
if the address is incorrect, such as: 0x11.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-04 21:36:07 +02:00
Yannis Damigos 2d537f49a9 usb_dc_stm32: Don't update ret_bytes if send fails in usb_dc_ep_write()
Don't update ret_bytes if send fails in usb_dc_ep_write().

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2019-07-02 19:05:37 -04:00
Erwan Gouriou 6b40394df9 drivers/usb/device: stm32: Remove reference to unsupported low speed
Low speed isn't supported in device mode for any of the STM32
references.
Remove the code that refer to it.

Fixes #17114

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-06-28 06:16:10 -04:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.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 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 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 17ddd1714c cleanup: include/: move clock_control.h to drivers/clock_control.h
move clock_control.h to drivers/clock_control.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
Andrzej Głąbek 6e75d644de drivers: usb_dc_nrfx: Add pre-transfer checks if endpoint is enabled
The shim didn't check if a given endpoint was enabled before requesting
the nrfx_usbd driver to perform a read or write operation on it.
In certain circumstances this led to nrfx_usbd driver being stuck in
a loop waiting for the associated DMA transfer to complete.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-06-27 12:17:45 +02:00
Andrzej Głąbek 1b3514a07e Revert "drivers: usb: usb_dc_nrfx: Set cfg.en to false on Reset"
This reverts commit 03ef375f5f.

The cfg.en flag contains only the state of the endpoint as seen by the
shim. It is mainly used to enable the endpoints when the USB peripheral
becomes ready for operation (and the USB stack may want to enable some
endpoints earlier, especially the control ones, so the operation must
be sometimes deferred). In particular, setting this flag to false has
no effect on the actual state of the endpoint in the hardware.
Moreover, this flag was set to false for all the endpoints, including
the control ones which should not be disabled, so such operation
actually fooled the shim.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-06-27 12:17:45 +02:00
Andrzej Głąbek 036791364c usb: kconfig: nrf52840: Enable REMOTE_WAKEUP option only when needed
This patch removes the "hard" selection of the USB_DEVICE_REMOTE_WAKEUP
Kconfig option for USB devices made on the nRF52840 SoC. Now it's up to
the application to decide if it wants to enable the option. This change
makes it possible to pass the USB3CV Chapter 9 Tests for applications
that don't use the remote wakeup feature, since when a USB device only
reports that it supports this feature, and the mentioned option makes
it to do so, one of the test cases expects the USB device to actually
perform the remote wakeup. And when the feature is not reported as
supported, the test case is skipped.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-06-27 12:17:45 +02:00
Kumar Gala dba65ce47c drivers: Update DT IRQ alias defines
The defines should have had a _0 on them, now that we generate the
proper defines, fixup the cases that used that old scheme.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Andrei Emeltchenko d385db0884 usb: drivers: usb_dc_stm32: Fix coverity issue
Fixes coverity issue CID: 198865.

Fixes #16582

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-06-19 11:08:26 +02:00
Andrei Emeltchenko 1d61bef39e usb: drivers: usb_dc_stm32: Fix coverity issue
Add __ASSERT() for coverity issue CID: 198874. Assert is used instead
of check since this is callback we get from stm32cube.

Fixes #16573

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-06-19 11:08:26 +02:00
Loic Poulain 4fe7f69182 drivers: usb: nxp: Add cache management
Clean/Invalidate cache before/after usb TX/RX transfers.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-06-17 16:25:06 -04:00
Loic Poulain 7428f9c070 drivers: usb: nxp: Fix board freeze with various USB classes
Prevent to reschedule a transfer if one is already ongoing (occupied).
This happens with USB class drivers scheduling transfer once interface
is enabled (netusb, ACM...) and cause freeze due to infinite loop in
low level driver.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-06-17 16:25:06 -04: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
Anas Nashif 4c32258606 style: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-06 15:20:21 +02:00
Johann Fischer 105fccfb2d drivers: usb_dc_nrfx: cleanup logging and fix style
Cleanup logging and fix style. Use hex format specifier
for endpoint address. Remove periods from log messages.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-05-30 09:31:48 -04:00
Andrei Emeltchenko 03ef375f5f drivers: usb: usb_dc_nrfx: Set cfg.en to false on Reset
Set false to enable flag on USB Reset.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Yannis Damigos a1e3f39214 usb_dc_stm32: Check if functions' arguments are valid
Check if usb_dc_* functions' arguments are valid.
Fixes `tests/subsys/usb/device` on STM32 SoCs.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2019-05-20 13:01:41 -04:00
Mark Wang 5f0d065514 drivers: usb: nxp: add NXP EHCI USB device controller driver shim
usb_dc_mcux_ehci driver is one shim of the NXP SDK ehci driver.
select NOCACHE_MEMORY if HAS_MCUX_CACHE

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2019-05-09 13:37:02 -05:00
Andrei Emeltchenko 5a4a658de1 usb: usb_dc_stm32: Return EAGAIN on lock failure
Return -EAGAIN on k_sem_take() failure to take write lock, the error
code is similar to nrfx write_in_progress flag.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-06 11:14:24 +02:00
Derek Hageman 07d18e3f52 drivers: usb: sam0: Remove defines from dts_fixup.h
Move SAM0 flash to use the raw defines generated from the DTS
parsing.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-03 08:46:57 -05:00
Andrei Emeltchenko 446f5e48cb usb: dc: native_posix: Increase number of endpoints supported
Support 8 endpoints in each direction for native_posix.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Andrei Emeltchenko 8d6fbde898 usb: Remove usb_dc_ep_set_callback return code
Make usb_dc_ep_set_callback() return void since the code is never
used.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Benjamin Valentin c8208a399a usb: sam0: Implement missing API functions
This implements three API functions that are required for
tests/subsys/usb/device to build:

 - usb_dc_ep_disable()
 - usb_dc_ep_halt()
 - usb_dc_ep_flush()

While halt and disable are trivial, flush is just a stub for now.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-04-26 03:20:29 -07:00
Benjamin Valentin f95f5ae41e usb: sam0: Ensure API arguments are valid
Make sure the parameters for the API functions are valid, return error
otherwise.

This is expected by the tests/subsys/usb/device test case.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2019-04-26 03:20:29 -07:00
Benjamin Valentin 4d9486fc22 soc: sam0: Enable generic peripheral selection
Make sure that when e.g. CONFIG_SERIAL is set, CONFIG_UART_SAM0 is
selected automatically when the sam0 SoC family is used.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-04-19 14:37:17 -05:00
Andrei Emeltchenko f6784ed1d7 usb: usb_dc_stm32: Add missing function
Add missing API functions which will be tested with harness tests.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Andrei Emeltchenko cf349df34d usb: usb_dc_kinetis: Fix using invalid index
I does make sense to use index only after we make sure it is valid,
issue is found in harness tests.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Andrei Emeltchenko cc9c91513f usb: usb_dc_kinetis: Verify endpoint is valid
Verify endpoint before usb_dc_ep_set_callback().

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Andrei Emeltchenko 53ab1e2414 usb: usb_dc_native_posix: Check endpoint is valid
Fix harness tests.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Andrei Emeltchenko 582b44014c usb: usb_dc_dw: Check endpoint is valid
Fix harness test issues.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Andrei Emeltchenko 81fbf0f4b5 usb: usb_dc_native_posix: Fix valid endpoints check
Fix check for valid endpoints; issue is found in harness testing.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Andrei Emeltchenko 23d22043a4 usb: usb_dc_dw: Fix valid endpoints check
Fix check for valid endpoints; issue is found in harness testing.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Josef Gajdusek f01a7250f0 drivers: usb_dc_stm32: Reinitialize the write semaphores on bus reset
If the user attempts to send data before the USB connection is
established (see the HID sample for an example of such code), the
DataInCallback never gets called which leaves the write semaphore in a
taken state forever.

Signed-off-by: Josef Gajdusek <atx@atx.name>
2019-04-17 09:58:09 -05:00
Josef Gajdusek 29ffcae80c drivers: usb_dc_stm32: Make pin remapping part of the device tree
The SYSCFG_CFGR1_PA11_PA12_RMP define is present even on packages where
the remap isn't strictly required. This commit makes the remap optional
based on a DT property.

Also fixes syntax error caused by a missing );.

Signed-off-by: Josef Gajdusek <atx@atx.name>
2019-04-17 09:58:09 -05:00
Paweł Zadrożniak b2a3e12d86 drivers: usb: nordic: Do not log an error if HFCLK is busy
HFCLK may be requested for multiple modules, i.e. Bluetooth stack.
When any other module has requested HFCLK to run, the driver will
return -EBUSY on free attempt which is not an error - thie means
that free request has been processed, but someone else is still
requiring the clock to run. When all clock users free the clock,
it may be disabled.

Related issue: #15145

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-04-15 11:10:19 +02:00
Johann Fischer d2c6869e30 drivers: usb: check maximum packet size
Check maximum packet size (MPS) of an endpoint in usb_dc_kinetis
and usb_dc_native_posix drivers.

resolves #14957
resolves #14954

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-04-11 13:35:24 -04:00
Johann Fischer c13e201b18 usb: replace MAX_PACKET_SIZE0 with meaningful USB_MAX_CTRL_MPS
Replace MAX_PACKET_SIZE0 with meaningful USB_MAX_CTRL_MPS.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-04-11 13:35:24 -04:00
Andrei Emeltchenko 5b74fb4f23 usb: usb_dc_kinetis: Fix endpoint index check
Fix check for maximum endpoint index.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-11 13:35:24 -04:00
Andrei Emeltchenko 40774007c3 usb: usb_dc_kinetis: Fix access wrong memory
Add appropriate check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-11 13:35:24 -04:00
Andrei Emeltchenko 08f53a435c usb: usb_dc_kinetis: Fix setting address for not attached device
Add appropriate check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-11 13:35:24 -04: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
Andrei Emeltchenko 8ed215e011 usb: usb_dc_stm32: Fix reading invalid EP
Fix crash when reading invalid endpoint found in harness test.

Fixes #13560

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-05 16:12:46 -04:00
Andrei Emeltchenko 06ef0ca0fc usb: usb_dc_stm32: Add placeholders for missing API
Fix build error when executing sanitycheck on stm32 devices.

Command to execute tests:
sanitycheck --device-testing --device-serial /dev/ttyACM0 -p <board>
    -t usb

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-05 16:12:46 -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
Paweł Zadrożniak e01662d387 drivers: usb: nordic: Fix for startup with USB cable attached.
Fixes bug introduced in #14875.
USBDETECTED event is be generated on cable attachment and
when cable is already attached during reset, but not when
the peripheral is re-initialized. When USB-enabled bootloader
is used, target application will not receive this event
and it needs to be generated again. This commit implements
a check against driver being enabled multiple times in case
of application without bootlader starting with cable attached
(both "fake" and "real" events are generated). Such dirty
trick allows bootloader to leave the peripheral in any state
before jumping to target application.

Fixes #15073

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-04-02 11:16:27 -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
Takumi Ando bdde5fd984 driver: usb: nordic: Enable USB DC when VBUS is Hi
We want to enable USB DC at not only VBUS detection event
but also it has been already high.

Signed-off-by: Takumi Ando <takumi.ando@atmark-techno.com>
2019-03-28 14:59:01 +01:00
Ioannis Glaropoulos 6a546d1938 drivers: usb: nrfx: initialize local struct to zero
Initialize a local struct variable to zero, to suppress
un-initialized variable error.

Fixes #14422.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2019-03-15 09:26:43 -05:00
Kumar Gala 626dd420fc drivers: usb: nrf: Fix mixing of enum types
When we build with clang we can a warning related to mixing of enum
types.  Just use nrfx_usbd_ep_status_t since that is the type returned
by nrfx_usbd_ep_status_get.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-15 05:53:32 +01:00
Paweł Zadrożniak 79dc1feeb3 drivers: usb: nordic: Fix for events when cable is detached
When user disconnects the USB cable, peripheral should be
immediately disabled, howewer a delay may occur when driver
events are processed from a workqueue or higher-priority
thread/ISR is active. This may lead to a fake resume/reset
event (peripheral-specific behavior). This fix drops such
events when cable is detached.

Fixes #13822

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-03-13 17:35:55 +01:00
Andrei Emeltchenko f8e1dfc331 usb: dc: native_posix: Fix Coverity bug
Fixes Untrusted array index read bug.

Fixes #14406

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:35:25 -05:00
Paweł Zadrożniak 804b9e1ada drivers: usb: nordic: implement remote wakeup
Adds remote wakeup support for nRF chips.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-02-27 10:37:16 +01:00
Piotr Zięcik d30c9aeafd drivers: nrf_power_clock: Migrate to DTS.
This commit migrates the nrf_power_clock driver to DTS.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-25 17:51:24 +01:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Yannis Damigos 6a676caab6 usb_dc_stm32: Fix check endpoint capabilities
DT_USB_NUM_BIDIR_ENDPOINTS includes EP0, which we should not
take it into account when we check endpoint capabilities

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2019-02-09 16:58:22 -06:00
Andrei Emeltchenko bd7d48a61f usb: native_posix: Fix ep_configure() and ep_mps()
Fix issues found in unit tests.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 07:56:24 -05:00
Takumi Ando 782a88f2c1 driver: usb: nordic: Fix compile warning with newlib
This commit fixes compile warning with CONFIG_NRFX_USB
and CONFIG_NEWLIB_LIBC.

Signed-off-by: Takumi Ando <takumi.ando@atmark-techno.com>
2019-02-06 14:25:09 +01:00
Paweł Zadrożniak 85d75ec853 drivers: usb: nordic: Power consumption fix with cable detached
This commit fixes the issue with excess current being drawn
during sleep due to active HFCLK with external crystal.
Clock-related operations were moved to cable attachmend and
detachment handlers to ensure that HFCLK is not requested
when it's not needed.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-02-04 20:48:25 -05:00
Tom Burdick 08d900df4b usb: fix usb data race
Clock ISR would callback into the USB driver before it was initialized
and ready to deal with events. This caused a fault.

Statically initialize the fifo to queue events and process them when the
USB device is initialized to avoid the problem.

Signed-off-by: Tom Burdick <thomas.burdick@gmail.com>
2019-02-01 19:04:07 -05:00
Andrei Emeltchenko b6b5fdac32 usb: native_posix: Implement other then Control transfers
Add support for other transfers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:03:12 -05:00