Commit graph

282 commits

Author SHA1 Message Date
Andrei Emeltchenko 80120871ed usb: native_posix: Move to new logging subsystem
Use new logger log method.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:03:12 -05:00
Andrei Emeltchenko 9f1443e18a usb: native_posix: Use non-blocking connection socket
Use non-blocking connfd from accept4() call for native_posix.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:03:12 -05:00
Andrei Emeltchenko 03b7d9f59d usb: native_posix: Use non-blocking socket
Use non-blocking socket for native_posix to allow other processes to
run.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:03:12 -05:00
Andrei Emeltchenko b8b86c4c75 usb: driver: Add native_posix USB driver
Add native_posix USB virtual driver connected over USBIP to the Host
Linux.

Fixes: #9846

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:03:12 -05:00
Kumar Gala 9e4016d8dc usb: usb_dc_stm32: Convert to DT instance defines to remove dts_fixup.h
Convert usb_dc_stm32 driver GPIO disconnect 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-02-01 04:12:15 -06:00
Kumar Gala 0370dbee4a usb: usb_dc: Replace CONFIG_ symbols that should be DT_
1. Fix trailing comment for DT_USBHS_MAXIMUM_SPEED
2. Fix missed CONFIG_USB_HS_BASE_ADDRES that should be
   DT_USB_HS_BASE_ADDRESS

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-01 04:08:26 -06:00
Paweł Zadrożniak a0e2737aff drivers: nordic: usb: USBD event handling rework
Some of the events from USBD peripheral (i.e. cable disconnect)
were handled in IRQ context and some of them (i.e. ep r/w events) in
system workqueue (inherited from initial driver implementation).
This may lead to race condition in some specific situations.
Currently, all of the events are enqueued in ISR and processed in
workqueue. Driver is reinitialized on queue overflow and queue size
is configurable in KConfig.

Fixes #12016

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-01-23 16:55:15 +01:00
Pawel Dunaj bfb23cc5de drivers: usb: Do not enable non-existing USB endpoints
Number of USB endpoints is set via DTS, nevertheless USB driver
tries to enable all endpoints as it uses number of endpoints from
nRFx.
This commit makes driver enable only these endpoints that were
enabled in DTS.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2019-01-22 17:44:17 +01: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
Paweł Zadrożniak 480b728d52 drivers: usb: nordic: Fix IN transfer fragmentation
Currently, when usb_dc_ep_write is called, data is copied to the
internal buffer, hence the requirement for fragmentation, regardless
of low-level nrfx_usbd driver. This commit forces the fragmentation
and prevents potential internal buffer overflow. Adittional
fragmentation flag was added to prevent triggering status stage
(it is handled by hardware completely on nRF chips).

Fixes #12339

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-01-14 11:02:47 +01:00
Loic Poulain a32a39f3d2 drivers: usb_dc_stm32: Add support for MSI clock
When MSI clock is available and in PLL-Mode (high accuracy), use it as
USB source clock. This allows to enable USB on STM34l475 disco iot
board without having to add external oscillator.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-02 09:33:21 -05:00
Andrzej Głąbek 4b43065cfc drivers: nrf: Enable nRF drivers by default in Kconfig
Make the following nRF peripheral drivers:
- ADC
- GPIO
- I2C
- SPI
- UART
- USB_DEVICE
enabled by default so that users do not need to explicitly enable them
in their applications after choosing an nRF SoC as the build target.

Kconfig options enabling these drivers depend on both a given hardware
feature (e.g. I2C) and an nRF family SoC selected, so effectively they
will be automatically enabled only when it is adequate (and in most
cases these drivers are the only option for a given hardware feature
on nRF SoCs).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-12-21 21:01:37 +01:00
Aurelien Jarno c52a64624e drivers: usb_dc_stm32: add support for SoF event
Add support for SoF events to the USB STM32 device driver. When
CONFIG_USB_DEVICE_SOF is enabled, enable the corresponding interrupt
and provide a non-weak callback function calling status_cb.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:17:58 -06:00
Erwan Gouriou 9062e97a45 drivers: stm32: check clock_control_on return value
Check clock_control_on return value now that it is checking appropriate
bus is used in the request.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-12-07 11:31:48 -05: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
Paweł Zadrożniak 6e460ca64f drivers: usb: nordic: Fix class/vendor request handling
SetAddress request (0x05) is ignored and not propagated, because it
is handled by nRF hardware. Curently, request type is not checked
causing class or vendor request 0x05 to be inappropiately ignored.
Only standard requests (type = 0) shoud be ignored. This commit
fixes the issue.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2018-12-04 13:53:48 +01:00
Andrzej Głąbek 965128bab1 drivers: usb_dc_nrfx: Align with nrfx version 1.4.0
A typo in the name of the bmRequest field in the nrfx_usbd_setup_t
structure was fixed in nrfx version 1.4.0. Update the driver to use
the new correct name: bRequest.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-12-03 17:56:15 +01:00
Paweł Zadrożniak 1da367b5bf drivers: nordic: usbd: Fix long (fragmented) control OUT transfers
Fragmented long CTRL OUT transfers does not work properly, because
they were not handler properly by the shim. In such transfers,
a special call (nrfx_usbd_setup_data_clear()) must be performed
before every data packet and not just before the first one.
This patch adds a byte counter which is set while processing setup
packet (host->device only) to be able to decide whether there will
be more data packets coming (and to call_data_clear() or not).

Fixes #11232 .

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2018-12-03 10:28:11 +01:00
Aurelien Jarno 6ed2ea66d0 drivers: usb_dc_sam: add support for SoF event
Add support for SoF events to the USB SAM device driver. When
CONFIG_USB_DEVICE_SOF is enabled, enable the corresponding interrupt
and call the callback function from there.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-02 10:39:39 -05:00
Aurelien Jarno 92f7c7c3b5 drivers: usb_dc_sam: kill a coverity warning
Coverity complains that packet_len can get assigned a negative value if
usb_dc_ep_mps() returns an error. This is correct, however it only
happens if the endpoint address is invalid, and in that case the value
is not used as the endpoint address is also validated in
usb_dc_ep_write().

Fix the issue by moving the assignment after the endpoint address
validation and by accessing the value directly instead of getting it
through usb_dc_ep_mps().

Fixes #11481
Coverity-CID: 189742

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-11-23 09:19:44 -05:00
Marcin Szymczyk e4c447aac3 usb: add SoF event
Start of Frame events can now be accessed from USB classes.
This will be useful when implementing idle rate functionality.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-11-23 09:18:41 -05:00
Paweł Zadrożniak 55674d8e17 drivers: usb: nordic: change USBD driver locking scheme
Nordic USB driver shim uses nrfx_usbd driver from nrfx package.
The driver was protected by a semaphore during every transfer
to prevent access from multiple threads at the same time.
This leads to the problem when a class schedules transfer on one
endpoint before host asks for the data (to be sent later) - driver
is locked and other endpoints (including control EP) are blocked.
Currently, only driver calls are wrapped with semaphore without
waiting for the transfer to complete, allowing scheduling transfers
on different endpoints. This is allowed bu nrfx_usbd, however
shim prevents user from scheduling multiple transfers on one
EP (required by nrfx_usbd).

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2018-11-22 13:13:16 -05:00
Mieszko Mierunski ac4f588e1f dts: nrf: Remove USBD dts.fixup defines and use aliases instead.
Changed driver to use defines from aliases instead of fixup.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2018-11-20 22:18:09 +01:00
Yannis Damigos 954a943854 drivers: usb_dc_stm32: Use DT to check if USBPHYC exists
Use DT to check if SoC has a USBPHYC controller.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-11-15 07:27:23 -06:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Aurelien Jarno 7ef3ddce45 drivers: usb_dc_sam: use original logger functions
Rename USB_{DBG,ERR,INF,WRN} into LOG_{DBG,ERR,INF,WRN}. This driver has
been missed from PR #11001 as it has been committed after.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-11-08 16:33:23 -05:00
Andrei Emeltchenko 93bd26343e usb: logs: Rename USB_WRN to LOG_WRN
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko f22060cdbe usb: logs: Rename USB_INF to LOG_INF
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko 17f7abd3dc usb: logs: Rename USB_ERR to LOG_ERR
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko 92c7ab74c0 usb: logs: Rename USB_DBG to LOG_DBG
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Aurelien Jarno 6b6e54321a drivers: usb: add usb device driver for Atmel SAM E70 family
This patch adds a USB device driver for the USBHS device that can be
found on Atmel SAM E70 SoC family. Only the FIFO mode is supported
(as opposed to DMA). It supports LS, FS and HS modes, but defaults to
FS mode as Zephyr does not fully support HS mode yet.

Tested examples on an Atmel SMART SAM E70 Xplained Board:
* usb/cdc_acm
* usb/hid-mouse
* usb/mass

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-11-06 16:32:35 -05:00
Andrei Emeltchenko 767b4ec6b7 usb: usb_dc_nrfx: Remove dead code
Fix deadcode warning.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-05 08:46:55 -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
Paweł Zadrożniak 7791f58a15 drivers: usb: nordic: Fix max packet size handling
This commit fixes the issue with non-default max packet size (<64).
The max packet size value was not passed to low-level driver
in norfic hal (nrfx_usbd) causing 64-byte being send regardless of
configured endpoint size. Size mismatch results in communication
error on Linux hosts.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2018-10-30 18:14:17 +01:00
Anas Nashif 80ced11209 drivers: usb_dc_nrfx: move to new logger
Move to new logger and apply style guidelines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-16 17:30:09 -04:00
Paweł Zadrożniak 68cb7b3e38 drivers: usb: Add nRF52840 USBD driver
* Add usbd_dc_nrfx shim

The shim is based on the previous one usbd_dc_nrf5.
For handling the USBD hardware, tested nrfx_usbd driver from nRF SDK
was used.

Briefly tested examples:
* usb/cdc_acm
* usb/dfu (USB communication only due to flash handling issues)
* usb/hid-mouse
* bluetooth/hci_usb

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2018-10-12 13:14:12 +02:00
Yannis Damigos c9007f0daf drivers: usb_dc_stm32: Add HIGH and HIGH_IN_FULL defines for L4 series
STM32L4 series USB LL API doesn't provide HIGH and HIGH_IN_FULL speed.
Define them on drivers level.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-10-10 12:27:55 -05:00
Carles Cufi 4fe661181c drivers: usb: stm32: Limit the amount of bytes to write
Limit the amount of bytes to write to EP0 to 64 bytes so that there is
no overflow or error when sending.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-10-09 21:37:51 +02:00
Yannis Damigos 3c9f1c9627 drivers: usb_dc_stm32: Get maximum-speed from DT
Get maximum-speed from device tree for OTG FS/HS.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-10-09 12:59:34 -04:00
Yannis Damigos 452c3d6a87 include/usb/usb_device: Add USB_* log macros
Add USB_DBG, USB_WRN, USB_ERR, USB_INF macros
in usb_device header file and remove them
from usb device drivers.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-10-08 12:54:57 -04:00
Yannis Damigos 1674d061b6 drivers: usb: device: Migrate to new logger
Move to new logger subsystem.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-10-08 12:54:57 -04: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
Maureen Helm 95be60a80f usb: device: Fix kinetis driver to compile with SYS_LOG disabled
Fixes a compile error in the kinetis usb device driver when SYS_LOG is
disabled.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2018-09-14 13:22:03 -05:00
Vinayak Kariappa Chettimada 67786e3270 usb: device: nrf5: Fix HF clock enable check
Fixed return value check after HF clock is requested in
non-blocking mode.

hci_usb sample on nRF52840 SoC failed to enumerate USB
device on cold reset, the clock_control_on interface would
return -EINPROGRESS when clock is enabled in non-blocking
mode.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-09-05 15:26:18 +02:00
Istvan Bisz ea9d4a79c9 drivers: usb: add support for USB OTG FS on STM32F2
Add support for usbotg_fs, by adding the DT fixup, pinmux macros,
and the DT entries in stm32f2.dtsi.

Signed-off-by: Istvan Bisz <istvan.bisz@t-online.hu>
2018-08-16 06:19:19 -07:00
Ulf Magnusson 8cf8db3a73 Kconfig: Use a short, consistent style for prompts
Consistently use

    config FOO
            bool/int/hex/string "Prompt text"

instead of

    config FOO
            bool/int/hex/string
            prompt "Prompt text"

(...and a bunch of other variations that e.g. swapped the order of the
type and the 'prompt', or put other properties between them).

The shorthand is fully equivalent to using 'prompt'. It saves lines and
avoids tricking people into thinking there is some semantic difference.

Most of the grunt work was done by a modified version of
https://unix.stackexchange.com/questions/26284/
how-can-i-use-sed-to-replace-a-multi-line-string/26290#26290, but some
of the rarer variations had to be converted manually.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-15 04:10:10 -07:00
Andrei Emeltchenko 1f4e8d679b usb_dc_stm32: Fix FS mode
Fixes FS mode for STM32F7XX devices.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-24 22:27:17 -04:00
Yannis Damigos 48de3ec616 drivers: usb_dc_stm32: Add OTG HS full-speed PHY support
Enable the driver to work in full-speed mode on OTG HS
controller using its full-speed or high-speed internal
PHY.

Please note that only one interface should be enabled
at a time, OTG FS or OTG HS. The driver will raise an
error if both are enabled.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-07-24 22:27:17 -04:00
Johann Fischer f5b91bad17 drivers: usb_dc_kinetis: fix gcc 7.3.1 warning
Use the same variable type for the odd bit handling
and fix the boolean expression warning with gcc 7.3.1.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-07-16 13:54:02 -05:00
Aurelien Jarno 9107e3dac8 drivers: usb: add support for USB OTG FS on STM32F7
The STM32F7 uses the same USB OTG FS controller than the STM32F4 series.
It is therefore trivial to add support for it, by adding the DT fixup
and pinmux macros, and the DT entries in stm32f7.dtsi. Keep it disabled,
it should be enabled at the board level.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-07-11 16:28:10 -05:00
Johannes Hutter 6c0d089594 drivers: usb_dc_stm32: don't wait for semaphore in ISR context
usb_dc_ep_write may be executed in an ISR context and should therefore
not take a semaphore with a timeout. The semaphore was initially
introduced to prevent USB buffer overwrite when writing to an endpoint
in a loop. This is not requested anymore since there is an existing USB
transfer API available.

Signed-off-by: Johannes Hutter <johannes@proglove.de>
2018-07-05 11:06:30 -04:00
Ulf Magnusson 7cdd946d2d drivers: usb: 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
Sathish Kuttan 1b0641e2e2 drivers: usb: Add High Speed support for DesignWare USB
Added CONFIG_USB_DW_USB_2_0
Updated global configuration register to use UTMI 16 bit PHY
Updated device configuration register to use High Speed

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-06-19 20:16:18 -04:00
Savinay Dharmappa e682652d8c drivers: usb: Fix build error for intel_s1000.
As not all controllers using DW usb doesn't inherit
the qmsi related header, use of QM_USB_MAX_PACKET_SIZE,
QM_USB_IN_EP_NUM and QM_USB_OUT_EP_NUM break the build
for such platform. Hence defined new macros and corresponding
change done in driver.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-06-19 15:52:03 -04:00
Aurelien Jarno 7688f49065 drivers: usb_dc_stm32: change all endpoints to bidirectional
The various STM32 reference manuals sometimes define the USB endpoints
as IN or OUT only and sometimes as bidirectional, even in the same
manual. This is likely because the OTG implementation has one set of
registers for the IN endpoints and one other set for OUT endpoints.
However at the end a given endpoint address can both transmit and
receive data.

This causes some confusion how to declare the endpoints in the device
tree, and depending on the SoC, they are either the same number of IN
and OUT endpoints declared, or they are declared as bidirectional. At
the end it doesn't really matter given how the driver uses those values:

    #define NUM_IN_EP (CONFIG_USB_NUM_BIDIR_ENDPOINTS + \
                       CONFIG_USB_NUM_IN_ENDPOINTS)

    #define NUM_OUT_EP (CONFIG_USB_NUM_BIDIR_ENDPOINTS + \
                        CONFIG_USB_NUM_OUT_ENDPOINTS)

    #define NUM_BIDIR_EP NUM_OUT_EP

This patch therefore cleanup the driver, the DTS, and the DTS fixups to
only define the number of bidirectional endpoints.

In addition to the cleanup, that fixes a regression introduced by commit
52eacf16a2 ("driver: usb: add check for endpoint capabilities"), which
introduced a wrong check for SoC only defining the number of
bidirectional endpoints.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-06-18 15:24:15 -04:00
Istvan Bisz 49554dd35a drivers: usb_dc_stm32: Change SYS_LOG_LEVEL
Suppress messages by DBG SYS_LOG_LEVEL setting:
[general] [ERR] usb_dc_ep_check_cap: ep 81, mps 64, type 2
[general] [ERR] usb_dc_ep_check_cap: ep 1, mps 64, type 2

Signed-off-by: Istvan Bisz <istvan.bisz@t-online.hu>
2018-06-17 10:49:16 -04:00
Johann Fischer 52eacf16a2 driver: usb: add check for endpoint capabilities
Add function to check capabilities of an endpoint.
Only basic properties are checked, especially on STM32
capabilities of different USB controller configurations
have to be considered in the future.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 4d0a1912a6 drivers: usb_dc_kinetis: fix usb_dc_ep_read_continue
usb_dc_ep_read_continue can be called without usb_dc_ep_read_wait,
check if the current buffer is claimed by the controller
(transfer not finished) to prevent a faulty behavior.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-05-30 11:23:39 -05:00
Aurelien Jarno 80a9b02200 drivers: usb_dc_stm32: enable VDDUSB on STM32L4x2
The STM32L4x2 SoCs need to control the isolation of the USB features
from VDDUSB. This is done through the PWR_CR2 bit USV, however the
current code checks for the PWR_CR2_PVME1 bit instead, which is only
available on Cat. 3 devices. This bug is also present int the HAL and
likely copied from there.

Replace the check by PWR_CR2_USV instead.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-05-24 09:42:30 -05:00
Johann Fischer 192833a828 drivers: usb_dc_kinetis: fix out-of-bounds write/read
Fix out-of-bounds write/read.

fixes: #7714
fixes: #7715
fixes: #7719
fixes: #7721
fixes: #7723
fixes: #7725
fixes: #7727
fixes: #7734
fixes: #7738

Coverity-ID: 186032
Coverity-ID: 186036
Coverity-ID: 186044
Coverity-ID: 186046
Coverity-ID: 186048
Coverity-ID: 186051
Coverity-ID: 186055
Coverity-ID: 186059
Coverity-ID: 186061

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-05-23 18:57:33 -04:00
Johann Fischer 06840af1cc drivers: usb: kinetis: fixup endpoint config, stall and read
This patch fixes some bugs found during testing with testusb from
linux kernel.

An unresolved issue is that the stack is not fast enough
to stall (if necessary) the control endpoint during Setup Stage.
This might require a API change so that the usb device stack
can explicit allow the driver to resume token processing.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-05-17 07:00:49 -05:00
Johann Fischer 5dc6f99cfd drivers: usb: add usb device driver for Kinetis USBFSOTG Controller
Add usb device driver for Kinetis USBFSOTG Controller.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-05-17 07:00:49 -05:00
Yannis Damigos aec465968c drivers/usb_dc_stm32: Check if SYSCFG is enabled
Add a check to raise an error if SYSCFG is disabled,
before doing the pin remaping for F0 SoCs on QFN28
and TSSOP20 packages.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-14 09:45:40 -05:00
Yannis Damigos c9d5b56140 drivers/usb_dc_stm32: HSI48 requires VREFINT in L0
In STM32L0 series, HSI48 requires VREFINT and its buffer
with 48 MHz RC to be enabled. This patch enables
VREFINT reference for HSI48 oscillator.

Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-14 09:33:29 -05:00
Yannis Damigos 2a55fcf607 drivers/usb/usb_dc_stm32: Provide EP_TYPE_* defines for L0
USB LL API provides the EP_TYPE_* defines. STM32Cube does not
provide USB LL API for STM32L0 family. Map EP_TYPE_* defines
to PCD_EP_TYPE_* defines.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-14 09:33:29 -05:00
Yannis Damigos c0b472132c dts/arm/st: Add USB support for stm32l072/73
Add USB support for stm32l072 and stm32l073 SoCs

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-14 09:33:29 -05:00
Yannis Damigos f47b9c2fca drivers/usb/device: Remove USB DISCONNECT gpio options
Remove USB DISCONNECT gpio options from Kconfig.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-11 16:53:12 -04:00
Yannis Damigos 3bbe87e171 dts/arm/st: Add usbotg_fs node to stm32l4 DT
Add otgfs (USB) node to stm32l4.dtsi.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-10 07:47:13 -05:00
Pushpal Sidhu e2b27d820d drivers: usb_dc_stm32: enable VDDUSB if needed
This is required on boards that isolate VDDUSB from the system.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2018-05-10 07:47:13 -05:00
Pushpal Sidhu b1478518c0 drivers: usb_dc_stm32: use HSI48 if available
This clock was designed to power crystal-less usb if available.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2018-05-10 07:47:13 -05:00
Yannis Damigos 47fe4ee78b dts/arm/st: Add USB support for stm32f070/72
Add USB support for stm32f072 and stm32f070 SoCs

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-10 07:47:13 -05:00
Yannis Damigos 38d2567e08 boards: olimexino_stm32: Add USB support
Add USB support to OLIMEXINO-STM32 board

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-10 07:47:13 -05:00
Yannis Damigos 55dada2592 drivers: usb_dc_stm32: Add usb disconnect pin support
Add usb disconnect pin support.
Some boards use a GPIO pin to controll a transistor,
which drives the pull-up resistor on USB DP pin.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-05-10 07:47:13 -05:00
Yannis Damigos 921bfeb05a drivers: usb_dc_stm32: Add support for all STM32 families
Add support for all STM32 families

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-05-10 07:47:13 -05:00
Andrei Emeltchenko 943ca29d4b usb: dw: Fix Coverity issue with get_mps()
Fix issue with Coverity using if / else instead of switch, though it
does not affect code.

Fixes: #7257
CID: 185399

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-02 09:26:44 -04:00
Savinay Dharmappa 5060f4bd14 driver: usb: enable usb2.0 on intel_s1000
Change-Id: I59091c465e84f1d6ba64433b7320182d83ff9589
Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-01 16:46:41 -04:00
Andrei Emeltchenko 8d3b2fa8a9 usb: usb_dc_dw: Fix incorrect MPS return
Because of incorrectly set MPS we always got 0 returned for WRITE
transfers and ZLP were always generated for every packet.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:03:33 -07:00
Michael Hope 5a6271b08d usb: sam0: add the new usb_dc_ep_mps() function.
This was added as part of the USB transfer infrastructure.  Implement
for the SAM0.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-27 19:57:38 -04:00
Andrzej Głąbek ad24576501 usb: device: nrf5: Remove support for the ACCESSFAULT event
This event is no longer exposed for the USBD peripheral,
and the newest MDK version (and consequently new nrfx HAL)
does not contain its definition and related bitfields.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-03-27 09:35:21 -04:00
Sundar Subramaniyan 120ddbc089 drivers: usb: nrf5: Fix ISO IN/OUT SOF handling
For ISOOUT transaction, check if the buffer is empty before starting
the DMA and for ISOIN case check if the buffer is available to start
the DMA for IN transaction. This handling was swapped. So, handle it
accordingly.

Signed-off-by: Sundar Subramaniyan <sundar.subramaniyan@gmail.com>
2018-03-17 18:58:06 +01:00
Sundar Subramaniyan cfdaa1dcaf drivers: usb: nrf5: Fix cdc_acm OUT endpoint read size issue
Problem:
cdc_acm sample outputs junk characters to the console when any key
is pressed. It is supposed to echo the same character as the input.

Analysis:
nRF52840 USB driver always reads 64 bytes from the USB peripheral's
local buffer irrespective of the data length. Even when 1 byte
is sent by the host, the usb driver receives as 64 bytes.

Since the maximum packet size value had been used when setting up
the EasyDMA's MAXCNT register for OUT transactions, DMA transffered
the entire 64 bytes of it's local buffer into the data RAM
irrespective of the OUT data length, containing garbage at the end
of useful payload. For some applications like hci_usb the extra
bytes were being ignored. But for cdc_acm, the entire 64 bytes
is getting echoed back displaying garbled characters on the terminal.

Fix:
For OUT endpoints, the amount of data received by USBD to its local
buffer should be read using SIZE.EPOUT[x] registers in the case of
BULK and INTERRUPT endpoints and SIZE.ISOOUT register for ISOOUT
endpoint. This value should be set to the EasyDMA maxcnt register
to DMA into RAM buffer. Fix this issue for Bulk, Interrupt and
ISOOUT endpoints.

Signed-off-by: Sundar Subramaniyan <sundar.subramaniyan@gmail.com>
2018-03-17 18:58:06 +01:00
Sundar Subramaniyan 9a195e36cd drivers: usb: nrf5: Add usb_dc_ep_mps function
This function is now required and used by usb_transfer APIs.

Signed-off-by: Sundar Subramaniyan <sundar.subramaniyan@gmail.com>
2018-03-17 18:58:06 +01:00
Loic Poulain e7fa746b0c usb: dc_dw: Do not clear RX NAK at init for transfer endpoints
Reading is managed by transfer API.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-03-16 14:45:24 -07:00
Loic Poulain 5beb183879 usb: dc_dw: Fix FIFO available space
For now tx-fifo sizes are not configured (cf usb_dw_set_fifo).
Default fifo size is 136 bytes and sending more than 136 bytes
makes the data split into incorrect chunk size.
This patch prevents this by reducing available fifo size to a
multiple of the endpoint max packet size.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-03-16 14:45:24 -07:00
Loic Poulain 9d1957fae1 usb_dc: Add usb_dc_ep_mps function
This function returns endpoint max packet size (mps).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-03-16 14:45:24 -07:00
Loic Poulain 10923173a6 Revert "usb: stm32: Introduce transfer method"
This reverts commit b23d599682.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-03-16 14:45:24 -07:00
Sundar Subramaniyan 380a25018d drivers: usbd_nrf5: Add nRF52840 USB Device Controller Driver
* Add USB device controller driver for nRF52840 SoC.
* Supports only Bulk and Interrupt endpoints for now.
* ISO endpoint support is WIP.

What's tested:
* BTUSB - LE Scanning and connection.

Known issues in btusb tests:
 * Observed momentary delays during LE scanning. This is possibly
due to hci_usb's way of calling the usb_write().

 * Sometimes, when LE scan stop command is issued, response is not
sent and as a result USB stops functioning. This is also related
to the way btusb is handling the write(). For some reason, the
btusb class handler seems to issue another data packet write before
the USB control transaction is complete.

Miscellaneous:
* Lots of TODO items to discuss and fix.

Origin: Original

Signed-off-by: Sundar Subramaniyan <sundar.subramaniyan@gmail.com>
2018-03-15 12:39:53 +01:00
Savinay Dharmappa 8d7da51827 drivers: usb: device: code cleanup
include clk.h only for system that use QMSI.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-03-12 09:02:03 -04:00
Michael Hope f2651d0cc7 usb: sam0: add a USB device driver.
Implements a USB device driver for the SAM0 series.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-03-10 08:41:39 -05:00
Yannis Damigos 899ed91506 drivers: usb_dc_stm32: Get USB configuration from DT
Use defines generated from DT.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-02-21 09:17:12 -06:00
Savinay Dharmappa 98d6a9928c driver: usb_dw: Move base address and irq num of usb to soc.h
base adrress and irq number moved to soc.h

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-02-07 22:55:11 -05:00
Loic Poulain b23d599682 usb: stm32: Introduce transfer method
Transfer is an important concept of USB specification.
During a transfer, several packets can be transmitted.
Today the usb API only provides ep_read and ep_write
functions but the transfer concept is missing.

This is typically ok for basic drivers which don't have
to take care of how data is transfered/splitted.
However there are some drivers like CDC EEM, in which
transfer concept is important for packet management.

Moreover, current ep-write and ep_read method have a
different implementation in usb_dc_dw and usb_dc_stm32
device drivers. For example usb_dc_dw supports only
1-data-packet transfers due to its implementation.
This can increase latency and reduce performance.

I think this is something we need to fix/improve by
implementing better transfer management.

This patch introduces usb_dc_ ep_transfer method which
can be used to configure IN/OUT transfers. This allows
to configure and request different transfer sizes and
should prevent usage of the current stm32 temporary
buffer.

This method has asynchronous and synchronous mode.
Synchronous mode waits for transfer completion before
returning. Asynchronouse mode (irq safe) configures
the transfer and returns immediately, the provided
callback will be then called on transfer completion.

This also update ep_write and ep_read stm32 implementation
to use this new method but keep their behavior unchanged
for legacy reasons.

Note that for now this method is local to stm32 device
driver, however the goal would be to expose this function
as a new USB device driver API method so that class
drivers use it. This will request same implementation in
the usb_dc_dw_driver.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-01-29 11:26:48 -06:00
qianfan Zhao cd931bb7c4 usb: stm32: add usb_dc_ep_read_wait/conitinue
usb mass example need usb_dc_ep_read_wait/continue API.
test usb mass storage with RAM DISK on stm32f4 series.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-01-29 11:26:48 -06:00
Erwin Rol 780c1efb9f drivers: usb: stm32: use Kconfig to select HAL/LL sources
Use "select USE_STM32_LL_USB/USE_STM32_HAL_PCD/USE_STM32_HAL_PCD_EX"
to select the needed STM32 HAL files, instead of editing
ext/hal/st/stm32cube/CMakeLists.txt

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-01-23 08:46:16 -06:00
Andrei Emeltchenko af0bf06aa3 usb: Fix USB Device dependency
USB Device stack should depend on supported drivers not on menuconfig
option.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-12 07:46:28 -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
Loic Poulain eb83cda770 usb: dc_dw: Improve TX perf and reliability
During large USB transfer it's pretty common to call ep_write whereas
the previous TX transfer is not achieved and so the TX FIFO space is
not available. Sleeping 20ms in this case introduce a relatively high
latency and reduce the throughput.

This can be observed when pinging the board with CDC-ECM net class.
ping reply is split into 2 USB TX transfer, the second one is only
triggered after 20ms, making ping latency > 20ms.

To fix this, just continuously read the FIFO availabilty and fire TX
as soon as possible.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-11-09 09:15:55 -06:00
Loic Poulain fa2da6713b usb: stm32: Fix null dereference in ep_write
ret_bytes param is optional and then can be NULL.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-11-09 09:13:14 -05:00
Loic Poulain 4a2e967a87 usb: stm32: Fix TX FIFO overwrite
In the same way as dw driver, check that FIFO is empty before
writing any new data. This patch introduces a boolean semaphore
which is requested before any new TX transfer and released on
transfer completion.

This fixes usb-ecm support on 96b_carbon board.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-11-09 09:13:14 -05: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
Andrei Emeltchenko fe9dee0107 usb: dw: Add sleep before FIFO flash
Adding sleep before TX FIFO flash fixes splitting networking packets
sent over USB endpoints making ECM broken since there is no flow
control other then frame sizes.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-10-28 14:38:19 -04:00
Andrei Emeltchenko b722dc589e usb: dw: Fix debug log specifier for FIFO not empty
The situation when FIFO is not empty is not a bug and it is spamming
console when only bugs are enabled.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross 5aee94e4cf usb_dw_dc: Cleanup: write DIEPCTL register just once
The enable and clear NAK bit can be legally written together, do it in
just one write.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross eebb17ca52 usb_dc_dw: Correctness: use bytewise I/O in FIFO fill
The Designware FIFO is filled in units of 32 bit words, but the buffer
we are passed is not guaranteed to be a multiple of 4 bytes long, nor
aligned on a 4-byte boundary.  So in theory we are reading 0-3 bytes
of unused garbage from the end of the array.

That's currently benign on supported platforms with this hardware,
which all support misaligned reads.  But not all do.  And the incoming
arrival of memory protection opens the possibility that those extra
bytes would cross a protection boundary and cause a crash or security
bug.

Do this right.

(Note that this is fixed to little endian byte order.  The Designware
databook is frustratingly silent on the endianness it expects, but
existing hardware I can see is definitely LE and I see a few spots in
the Linux dwc2 driver that likewise assume LE).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross f591e58211 usb_dc_dw: Correctly assign endpoint FIFOs
The designware hardware in dedicated FIFO mode (which is all we
support right now for lack of shared-FIFO hardware) has one hardware
FIFO per IN (i.e. transmit) endpoint.  But it doesn't assign them on
its own, it's the drivers responsibility to populate the TxFNum field
of the DIEPCTL registers with integer indices corresponding to the
desired FIFO.

We weren't doing that, which meant that all IN endpoints were sharing
the same FIFO zero which is supposed to be dedicated to EP0 control
transfers.  The net effect is that sometimes outbound transfers would
be corrupted, showing data from the wrong endpoint.  More often that
not this would leak from control transfers over to the
higher-bandwidth bulk endpoints of the application, but occasionally
you'd see a control transfer itself get borked and the USB device
would glitch.

Get this right and set the FIFOs properly.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
Andy Ross e6874a0c61 usb_dw_dc: Fix locking correctness
There is no particular reason this spot in usb_dw_tx() cannot be
reached by racing threads on the same endpoint, though existing API
usage in the tree is all unithreaded.  The FIFO state read at the top
of the function must still be true at the bottom or else the packet
byte count will be corrupt.

Also, as described in an existing comment, the databook has some
scary-sounding warnings about access to the registers during FIFO
operations, even if they "should" be on separate endpoints and
unrelated.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-10-28 14:38:19 -04:00
David B. Kinder 4600c37ff1 doc: Fix misspellings in header/doxygen comments
Occasional scan for misspellings missed during PR reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-17 19:40:29 -04:00
Loic Poulain 8a11f91252 usb: Add support for STM32 family USB driver
This is a USB controller driver for STM32F4xx devices using
the STM32 Cube HAL_PCD framework. This has been tested with
the cdc_acm driver on a 96b_carbon board (STM32F401RE).

This is a refactoring of:
usb: usb_dc_stm: Add support for STM32Cube HAL_PCD USB driver
Signed-off-by: Christer Weinigel <christer@weinigel.se>
[daniel.thompson@linaro.org: Removed STM32F40(157) defconfig changes
together with STM32F4Discovery pinmux and defconfig changes, updated
clock settings and pad configuration to match latest mainline]
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
[giannis.damigos@gmail.com: Change uint*_t types to u*_t types,
change SYS_LOG_USB_DC_STM_LEVEL to SYS_LOG_USB_DRIVER_LEVEL and
update pinmux to match latest arm branch]
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2017-10-17 09:14:47 -04:00
Andrei Emeltchenko 4efaefba5c usb: Allow to select configuration for composite devices
Composite multifunction USB devices should be able to know about
configuration change, implement it through existing callback.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -04:00
Andrei Emeltchenko 5522875a75 usb: Correct length print modifier
Length should be logged in decimal notation.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:00:23 -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
Johann Fischer 3dd51d52a2 drivers: usb: use generic option name for log level
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-06-28 09:02:27 -04:00
David B. Kinder 93e4d7258d spell: fix Kconfig help typos: /boards /drivers
Fix misspellings in Kconfig help text

Change-Id: I3ae28a5d23d8e266612114bc0eb8a6e158129dc7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-21 21:31:30 +00:00
Kumar Gala ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Flavio Santes 358056692f drivers/usb: Use the right data-type
Use uint32_t instead of int.

Change-Id: I7d73a3fea61e48663aeada6792b9b6c19db1cb35
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-21 12:54:53 +00:00
Anas Nashif a9e879e273 logging: move sys_log to subsys/logging
Move logging out of misc/ to its own subsystem. Anything related to
logging and any new logging features or backends could be added here
instead of the generic location in misc/ which is overcrowded with
options that are not related to eachother.

Jira: ZEP-1467
Change-Id: If6a3ea625c3a3562a7a61a0ba5fd7e6ca75518ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:39 +00:00
Kumar Gala fe144ff2d4 drivers: usb: remove unneeded include path additions
We can locally reference the file we need, so don't add a -I we don't
need.

Change-Id: I4d9507d5368073443dcc78a5821fe09d3e0b9bfc
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-12-10 02:15:48 +00:00
Sergio Rodriguez 3932dd98a7 drivers: usb: update to unified kernel
Change-Id: Ie0cb514f3d84f7f87a0cf3f3a477df5cf04886d4
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-11-11 02:48:20 +00:00
Jithu Joseph 7eab305593 usb: Add end-point stall APIs and flow control APIS
USB class drivers may need to offload some work from
upcall interrupt context to a background fiber. This
requires some way to defer taking more data from host
till the offloaded work completes. Two APIs are added to
achieve this.

Further USB class drivers sometimes need to set STALL condition
on end-points to signal errors to host.These too are
added.

Change-Id: Ic973522c3394e23d7f9c4c67affc0cd050afc20f
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-11-09 02:45:46 +00:00
Iván Briano 0094ab228d ext qmsi: Update to QMSI 1.3 release
Update the QMSI drop we maintain in Zephyr, and fix the build where
needed:

- QM_SCSS_INT is renamed to QM_INTERRUPT_ROUTER;
- every member of QM_INTERRUPT_ROUTER was renamed as well;
- QM_IRQ_* renamed too, mostly added _INT at the end;
- some isr functions were renamed to keep their names consistent;
- build for x86 needs to define QM_LAKEMONT, as QM_SENSOR was for ARC.

Change-Id: I459029ca0d373f6c831e2bb8ebd52402a55994d1
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-10-31 13:26:06 +00:00
Jesus Sanchez-Palencia 7c0fc99c79 ext qmsi: Update to QMSI 1.2 release
Update the QMSI drop we maintain in Zephyr, and fix the build where
needed:

- QM_USB_BASE is renamed to QM_USB_0_BASE;
- parameter int_en from qm_uart cfg struct was removed;
- driver's folder now has a new structure, fix makefiles accordingly;
- QM_WDT_MODE and related renamed to QM_WDT_CR_RMOD;
- QM_SCSS_AON renamed to QM_AONC.

Change-Id: Iffe9c66b7a3f2fe64418326e20ff0894149b3044
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-10-18 23:26:01 +00:00
Jesus Sanchez-Palencia 8108aa8990 usb_dw: Clear device address on USB Reset
During USB device reset, the controller must have its device address
cleared (set to 0). This is not really taken into account by most host
side stacks, which is the reason why this bug didn't show up before.
It was found when we were trying to run the USB20CV [1] compliance test
suite on Windows.

Without this fix the device doesn't show up on the targets list, which
means device enumeration failed. With this patch in place the bug is
fixed and the device gets listed.

Tested with the CDC ACM sample application.

Jira: ZEP-950

[1] http://www.usb.org/developers/tools/usb20_tools/

Change-Id: I0b78f7ce043fa29dde0fb7f3b3aecee9844f4d11
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-09-21 12:19:05 +00:00
Anas Nashif 5363d14a9e boards: rename Quark SE Devboard to Quark SE C1000
This board now has an official name and will be available soon:

http://www.intel.com/content/www/us/en/embedded/products/quark/mcu/se-soc/overview.html

Jira: ZEP-758
Change-Id: Ia16d33722308cf81471321c3063bdc75055a4d50
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-09-16 03:10:31 +00:00
Andrei Emeltchenko ecdcbe5077 usb: Add error log to help debugging
Change-Id: Id320dc2b85f0a48a8f81425468aa3229b1e7d0cb
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-08-10 15:27:36 +00:00
Genaro Saucedo Tejada 7a0b987dc5 sys_log: replace old debug macros at DesignWare USB driver
DesignWare USB driver is now using new system log macros, updated
the Kconfig variable to be a level rather than a bool and the .conf
files at samples.

JIRA: ZEP-311

Change-Id: Ief46cadd954ca4b30a3a1cf2eba6e44ccbc9bc9f
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
2016-08-01 01:54:56 +00:00
Adrian Bradianu 6840ee35a4 usb: dw: Protect FIFO writes
Protect FIFO writes against other USB register accesses.
According to "DesignWare Cores USB 1.1/2.0 Device Subsystem-AHB/VCI Databook":
"During FIFO access, the application must not access the UDC/Subsystem
registers or vendor registers (for ULPI mode). After starting to access a
FIFO, the application must complete the transaction before accessing the
register."

Change-Id: I2aed833acaa2970310b6fd48f41a95bee2182ec1
Signed-off-by: Adrian Bradianu <adrian.bradianu@windriver.com>
2016-07-08 18:22:18 +00:00
Adrian Bradianu ff712114ef usb: dw: Add Quark SE USB device controller driver
Quark SE USB device (Designware IP) controller driver implements
the low level control routines to deal directly with the hardware.
Only FIFO mode supported.

Change-Id: I086186df017734579f0363ed79effc1481ff32c2
Signed-off-by: Adrian Bradianu <adrian.bradianu@windriver.com>
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-06-30 00:21:39 +00:00