Commit graph

450 commits

Author SHA1 Message Date
Anas Nashif f641d099cc cleanup: include/: move disk_access.h to disk/disk_access.h
move disk_access.h to disk/disk_access.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 83508a5677 cleanup: include/: move flash_map.h to storage/flash_map.h
move flash_map.h to storage/flash_map.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
Johann Fischer abaeaed2af usb: sort usb config data by section
USBD_CFG_DATA_DEFINE macro has not consider that a class
could have more than one set of usb_cfg_data struct.
If a class has more than one set of usb_cfg_data
then they should be sorted the same way like by
USBD_DEVICE_DESCR_DEFINE macro.

Fixes: #16240

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-06-27 12:18:05 +02: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
Loic Poulain d79bbc6d4d usb: netusb: cdc_eem: Fix Interface select
Parameter of set_interface_status is no more the interface index
but a pointer to interface descriptor.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-06-17 16:25:06 -04: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
Andrei Emeltchenko 26b514dec4 usb: usb_descriptor: Trivial syntax correct
Trivial function name fix.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-06-05 11:44:17 +02:00
Johann Fischer 28f2dc6c69 usb: usb_device: fix handlers call for secondary descriptor
Fix handlers call for secondary descriptor.
USB class like DFU has two sets of descriptors. In the handler
look up function, wind the pointer forward to the range
of the current descriptor.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-05-27 09:25:06 -04:00
Andrei Emeltchenko a68d404833 usb: dfu: Remove old composite configuration
Use new method for USB config and enable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Andrei Emeltchenko 3880a42375 usb: Align legacy and composite interface
Remove duplicated execution path for composite configuration, USB
device stack initialization is done inside stack for both cases.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Andrei Emeltchenko b3355c7924 usb: device: Remove unused variable
Remove unused variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Aurelien Jarno e059d5aa61 usb: simplify request handlers code
Now that Standard, Class and Vendor request handlers are using the same
buffer, we do not need to keep and array installed request data pointer.
This simplifies the code.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Andrei Emeltchenko 24142d0749 usb: Set correct default buffer size for RNDIS
Set correct USB_REQUEST_BUFFER_SIZE for USB_DEVICE_NETWORK_RNDIS.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Aurelien Jarno 327f61076a usb: merge all request handler buffers
Now that we have merged the class and vendor request buffers into the
USB device code, we can also merge the standard request buffer. We just
need to ensure it is at least 8 bytes, by using the range option in
Kconfig. The 64KiB limit is arbitrary.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-05-27 09:25:06 -04:00
Aurelien Jarno 819e749ccd usb: move the request handler buffer to the USB device code
In order to unify the legacy and composite code, move the class and
vendor request handler buffer into the USB device code, just like in
composite mode. The option is renamed from USB_COMPOSITE_BUFFER_SIZE
into USB_REQUEST_BUFFER_SIZE and also replaces the USB_DFU_MAX_XFER_SIZE
and USB_HID_MAX_PAYLOAD_SIZE options.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Andrei Emeltchenko a95f6385f2 usb: device: Do not return error if ep already enabled
Fixes USB3CV Tool tests. One case is enabling endpoints with Set
Interface after Set Configuration. In this case we report warning and
continue without returning error.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Andrei Emeltchenko 1370f16287 usb: device: Disable endpoints on disconnect and suspend
Disable endpoints on following events: USB_DC_DISCONNECTED
and USB_DC_SUSPEND.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Andrei Emeltchenko 83f625b4cc usb: device: Add debug logs catching re-enable failures
Add extra logs catching problem with re-enabling endpoints.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Andrei Emeltchenko 437ee504fa usb: device: Cancel all transfers on disconnect
Cancel all usb transfers when receiving USB_DC_DISCONNECTED.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Andrei Emeltchenko f206170c65 usb: device: Do not call callback when transfer is cancelled
Only call callback when transfer is not cancelled.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Andrei Emeltchenko bf76b2acc3 usb: device: Add transfer cancel helper
Add usb_cancel_transfers() helper to cancel all ongoing transfers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-22 11:19:49 +02:00
Marcin Szymczyk 8f0c3b80cf usb: cdc_acm: reset to default after disconnect
Return to default values after USB is reset or disconnected.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-05-21 08:23:46 -04:00
Marcin Szymczyk 2eb99ea38c usb: cdc_acm: fix typo in CDC_ACM_DEFAULT_BAUDRATE
From CDC_ACM_DEFAUL_BAUDRATE to CDC_ACM_DEFAULT_BAUDRATE.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-05-21 08:23:46 -04:00
Marcin Szymczyk 3c3e267d72 usb: add zero-length packet after MPS-sized IN transaction
Send ZLP when host asks for a bigger length and the last chunk
is wMaxPacketSize long, to indicate the last packet.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-05-12 15:15:08 -04:00
Marcin Szymczyk b1f3825ea3 usb: cdc: add option to force IAD
Interface Association descriptor has to be used with Windows 7.
Add CONFIG_CDC_ACM_IAD option to force its usage, disabled by default.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-05-09 08:20:34 -04:00
Marcin Szymczyk e5cbe6a9e7 usb: cdc: Add unique PIDs for each sample
Unique PID is required for each sample in order
to be recognized by host.

When creating a new sample:
- Add USB_PID_<SAMPLE_NAME>_SAMPLE
  in samples/subsys/usb/usb_pid.Kconfig
- Create Kconfig file in your sample's subdirectory, containing:
  config USB_DEVICE_PID
	default USB_PID_<SAMPLE_NAME>_SAMPLE

  source "Kconfig.zephyr"

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-05-09 08:20:34 -04:00
Andrei Emeltchenko 98c8a9517d usb: cdc_acm: Refactor USB serial code
Add TX ring buffer, change USB API to transfer API.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-07 23:11:44 -04:00
Andrei Emeltchenko 2c672b92c8 usb: device: Add usb_transfer_is_busy() function
Add usb_transfer_is_busy() function to check if there is ongoing
transfer.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-07 23:11:44 -04:00
Johann Fischer 42bdcccd97 usb: usb_dfu: do not set bwPollTimeout dynamically
Partially revert commit ea177e785ca3
("usb: dfu: set bwPollTimeout dynamically")

Introduced fix does not work proper because there is no way to be
sure that a control stage had success before start erase process.
Instead IMG_ERASE_PROGRESSIVELY configuration should be used
if the erase of the flash takes longer time.

resolves: #15497

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-05-07 08:38:24 -04:00
Andrei Emeltchenko b4204631ee usb: Add log for endpoint assignment
Log fixed endpoint address.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-06 19:00:02 -04:00
Andrei Emeltchenko 3183c103b9 usb: Fix automatic assignment endpoints
Fix endpoints are not assigned correctly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-06 11:14:24 +02:00
Andrei Emeltchenko c77e142fd5 usb: device: Handle EAGAIN for device transfer
Handle EAGAIN for the transfer.

Fixes #13799

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-06 11:14:24 +02:00
Johann Fischer 714c8ff28e usb: usb_device: fix set configuration request
Fix set configuration request for a configuration without
specific endpoint like USB DFU class.

The changes introduced in commit 2b58594e90
("usb: device: Use set_endpoint helper for set_config")
does not take into account that a configuration could only
contain control endpoint.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-05-03 14:30:24 -04:00
Dennis Wildmark 791def84b1 usb: bluetooth: l2cap buffer size now configurable
Added check to see if CONFIG_BT_CTLR_TX_BUFFER_SIZE is defined,
and use that as the BT_L2CAP_MTU if that is the case. Otherwise,
use the previously hard coded MTU size (64). This enables users
to configure the MTU, enabling longer transfers.
The fix was inspired by how this is solved in
samples/bluetooth/hci_uart/src/main.c

Tested on nrf52840_pca10056.

Signed-off-by: Dennis Wildmark <dennis.wildmark@assaabloy.com>
2019-04-29 13:40:18 +03: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
Andrei Emeltchenko 0d3082cbfc usb: device: Code cleanup
Add missing braces and simple cleanup.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Andrei Emeltchenko e2d1c02770 usb: cdc_acm: Use UTIL_LISTIFY and device count macro
Use new method for defining USB CDC ACM devices using UTIL_LISTIFY and
device count from menuconfig.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Andrei Emeltchenko fbd2713431 usb: hid: Use UTIL_LISTIFY and device count macro
Use UTIL_LISTIFY and Kconfig device count template for specify number
of HID Devices.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Andrei Emeltchenko e79e4d9f1f usb: Add Kconfig template for DEVICE_COUNT
DEVICE_COUNT for some USB classes means how many instances of the
class can be supported by USB stack.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Andrzej Puzdrowski b50fe237f9 usb/class/usb_dfu: support progressive image erase
Disable bulk slot image erase when progressive erase is on.
Erase of image bank is performed by image collection procedure
progressively.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-04-28 12:20:01 -04:00
Andrei Emeltchenko 42b92e254e usb: device: Use set_endpoint helper
Use helper set_endpoint() for endpoint configuration.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-26 03:25:46 -07:00
Andrei Emeltchenko 2b58594e90 usb: device: Use set_endpoint helper for set_config
Refactor code making set_endpoint() helper which check validity of
input parameters.

Fix bug with usb_set_configuration() always returning true.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-26 03:25:46 -07:00
Marcin Szymczyk ea7afdde8f usb: cdc_acm: SerialState notification full support
Added bBreak, bRingSignal, bFraming, bParity and bOverRun
handling in cdc_acm_line_ctrl_set.
Reference: Chapter 6.5.4 of Universal Serial Bus Communications Class
Subclass Specification for PSTN Devices rev 1.2

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2019-04-19 13:36:32 -05:00
Johann Fischer a05ef2559d usb: dfu: set bwPollTimeout dynamically
Set bwPollTimeout for DFU_GETSTATUS request dynamically.
For now, adjust bwPollTimeout only during DNLOAD stage.

Fixes: #8734

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-04-16 08:55:51 -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 4c9ea1e370 usb: netusb: ecm: Enable netusb for the right iface/alt_set
Only enable netusb for the right configuration of interface and
alt_setting.

Fixes #13560

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-11 13:35:24 -04:00
Andrei Emeltchenko 1a1c518c25 usb: device: Change iface set callback parameters
Include to the callback parameters also alt_setting to be able to make
right choice for ECM.

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 721f3d1cd0 usb: Refactor USB status callback
Merge cb_usb_status_composite and cb_usb_status and use common
forward_status_cb for both composite and normal devices.

Fixes #14882

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-05 12:23:57 +02: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
Matias Karhumaa 933acfef43 usb: Fix ACL data tx stalling
This patch increases size of acl_tx_pool and makes sure that acl_read_cb
waits for available buffers.

Size of acl_tx_pool is now configurable with CONFIG_BT_CTLR_TX_BUFFERS.

Previously it was possible to run out of buffers and in that case
acl_read_cb returned. This caused ACL data TX to stall because device
did not read data from HCI out endpoint.

Fixes #14899

Signed-off-by: Matias Karhumaa <matias.karhumaa@gmail.com>
2019-03-28 10:48:26 +01:00
Filip Kubicz 521d046fdc USB: Fix warning in DFU class
Move unused variable to scope where it is used.

Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-03-26 11:21:23 +01:00
Andrei Emeltchenko de17b27886 usb: cdc_acm: Make ring buffer size configurable
Add new configuration parameter USB_CDC_ACM_RINGBUF_SIZE, default to
1024.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-25 12:03:15 +01:00
Andrei Emeltchenko cd95560cce usb: cdc_acm: Use ringbuf for RX path
Use ringbuf library for handling RX CDC ACM path. Remove old code
artifacts handling specific hardware.

Fixes #14288

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-25 12:03:15 +01:00
Andrei Emeltchenko 57b92e90fe usb: cdc_acm: Make parameters boolean
Remove 'U' after every assignment and make code more logical.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-25 12:03:15 +01:00
Andrei Emeltchenko 5a7fd0ebc9 usb: netusb: ecm: Print packet hexdump only for VERBOSE_DEBUG
Use VERBOSE_DEBUG to enable net_pkt_hexdump().

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 4496e99869 usb: netusb: rndis: Remove old unused code
Remove old unused code sending media status, sending this packet
causes Windows problems although Linux works with it. Removing this
code does not affect RNDIS functionality.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 276f50a623 usb: netusb: rndis: Fix maximum RNDIS frame size
Use standard NET_ETH_MAX_FRAME_SIZE in calculation adding space for
ethernet header.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 48be0443b7 usb: netusb: eem: Add check for large packets
Make sure we do not overwrite tx_buf.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko f4bfca6e44 usb: netusb: eem: Use NET_ETH_MAX_FRAME_SIZE as frame size
Use standard NET_ETH_MAX_FRAME_SIZE for frame size calculation. This
changes buffer from 1522 to 1514 + 2 + 4. Remove also magic numbers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 57041dd9c0 usb: netusb: ecm: Add check for large packets
Make sure we do not overwrite tx_buf.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 7ee481aad7 usb: netusb: ecm: Use NET_ETH_MAX_FRAME_SIZE as frame size
Use standard defined frame size for buffer and wMaxSegmentSize
parameter. Changes frame size from 1522 to 1514.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 00c58f770b usb: netusb: rndis: Add check for large packets
Drop packets larger then tx_buf.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 742c177977 usb: netusb: Cleanup USB Ethernet networking
Cleanup ECM, EEM and RNDIS networking functions, removing unneeded
headers and unused definitions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -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 a25f054cbd net/pkt: Remove _new suffix to net_pkt_read 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
Andrei Emeltchenko d293d0c682 usb: netusb: Remove unused helpers and cleanup
Remove try_write() which is not used anymore and general cleanup.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko db311047d0 usb: rndis: Use usb_transfer() for data transfer
Use USB transfer API for data transfer. Simplify notification count,
removing delayed work, use usb_transfer() logic instead.

Fixes #14127

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko 31ed124692 usb: netusb: rndis: Cleanup code
Remove unnecessary line breaks.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko fd496a5e67 usb: netusb: ecm: Remove forward declaration
Make code more readable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko 8a5cbb47cc usb: netusb: eem: Use sys_get_le16() helper
Use helper to make code cleaner.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Ulf Magnusson 94a9342843 kconfig: subsys: usb: Remove redundant USB_DEVICE_STACK deps.
subsys/usb/Kconfig 'source's subsys/usb/class/Kconfig (which in turn
'source's subsys/usb/class/netusb/Kconfig) within an
'if USB_DEVICE_STACK', so the dependencies on USB_DEVICE_STACK added
within those files are redundant.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 10:03:27 -05:00
Rajavardhan Gundi fa49e3e4c7 usb: dfu: Signal completion of DFU
Generally when DFU is in progress, the system is not expected to
be doing anything else in addition. Hence, a completion signal
would help the system to know that DFU is over and it can proceed
towards next tasks.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-03-08 08:35:59 -05:00
Tomasz Bursztyka 7b2d33f432 usb/net: Switch RNDIS netusb driver to new net_pkt API
Using new allocator and pkt writer instead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka 28f499ee15 usb/net: Fix MTU size
Commit 766101c was a wrong fix as NETUSB_MTU is the actual network MTU.
Instead of using this value in EEM/ECM drivers, a relevant value should
be set for each there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka 846f84a20f usb/net: Switch ECM netusb driver to new net_pkt API
Using new allocator and pkt writer instead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka b8b63e06db usb/net: Switch EEM netusb driver to new net_pkt API
Using new allocator and pkt writer instead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka e911f3821b usb/net: Extend netusb API to get the actual network interface pointer
This will be needed from receiver implementation (eem or ecm).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
David B. Kinder e731bdc81a doc: fix docs, include, and Kconfig misspellings
Fix misspellings missed during regular reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-02-28 09:32:12 +01:00
Andrei Emeltchenko 4035cb62dd usb: dfu: Fix missing break in case statement
Fixes #13870

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-27 08:49:13 -06:00
Paweł Zadrożniak 3ecbff501a usb: Add remote wakeup support
This commit adds support for remote wakeup and extends USB api
with a wakeup request call. Remote wakeup can be dsabled in kconfig
when a specific driver does not support this feature.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-02-27 10:37:16 +01:00
Ulf Magnusson 40436f730b kconfig: Use a short consistent prompt style
Same change as in commit 8cf8db3a73 ("Kconfig: Use a short, consistent
style for prompts"), fixing stuff that got introduced since then.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-27 09:23:30 +01:00
Aurelien Jarno 2c41103c8f usb/net: fix ECM driver in composite mode
Since commit b48a8c3247 ("usb: device: Add composite status callback")
the cb_usb_status callback is not called anymore in composite mode. The
cb_usb_status_composite callback is called instead.

This patch updates the ECM driver to use either one or the other
depending on CONFIG_USB_COMPOSITE_DEVICE.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-19 11:26:47 -05:00
Aurelien Jarno 70d13d87e2 usb/net: fix EEM driver in composite mode
Since commit b48a8c3247 ("usb: device: Add composite status callback")
the cb_usb_status callback is not called anymore in composite mode. The
cb_usb_status_composite callback is called instead.

This patch updates the EEM driver to use either one or the other
depending on CONFIG_USB_COMPOSITE_DEVICE.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-19 11:26:47 -05:00
Aurelien Jarno 70a0137f1f usb/net: fix RNDIS driver in composite mode
Since commit b48a8c3247 ("usb: device: Add composite status callback")
the cb_usb_status callback is not called anymore in composite mode. The
cb_usb_status_composite callback is called instead.

This patch updates the RNDIS driver to use either one or the other
depending on CONFIG_USB_COMPOSITE_DEVICE.

Note that in practice the RNDIS driver is forced to composite mode for
better compatility with Windows, so this fix is required to get the
RNDIS driver working.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-19 11:26:47 -05: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
Tomasz Bursztyka a6426620da net/private: Rename net_hexdump_frags to net_pkt_hexdump
And remove the parameter "full" as there is no "ll reserve" distinction
anymore. The parameter was unused since the ll reserve concept removal.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Andrei Emeltchenko d402d03555 usb: msc: Fix redeclaration of enumerators
Add prefixes to MSC enumerators, otherwise they are (ERROR) are
conflicting with other enumerators.

...
subsys/usb/class/mass_storage.c:149:2: error: redeclaration of
enumerator ‘ERROR’
 ERROR,        /* error */
 ^~~~~
...
ext/hal/st/stm32cube/stm32f4xx/soc/stm32f4xx.h:216:3: note: previous
 definition of ‘ERROR’ was here
   ERROR = 0U,
   ^~~~~
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 873ae0b14b usb: cdc_acm: Refactor Kconfig for CDC ACM
Remove unneeded "depends on" and use "if USB_CDC_ACM" instead of.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko d083067424 usb: cdc_acm: Use new device data interface
Use device data interface to handle device data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 00339509b3 usb: hid: Use new device data interface
Use new interface for getting device data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 9d85b2add0 usb: Add helpers for getting common device data
Add helpers to be used in USB classes for getting device data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 495426e4d9 usb: hid: Add sys_le16_to_cpu() conversion
Add conversion since interface number is stored in lower byte of
wIndex.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 5863680b2c usb: hid: Add get_dev_data_by_cfg helper
Reduce time by using the helper.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 81f06f6117 usb: cdc_acm: Use u8_t for interface number
Change argument for get_dev_data_by_iface().

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko ca85890dc2 usb: hid: Add HID Device concept
Add HID Device associated with the instance of the HID. This allows to
create several HID instances for multifunction composite device.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko c725a90084 usb: hid: Add configuration options for second HID instance
Add configuration option for enabling second HID Device

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 6aefb16964 usb: cdc_acm: Add menuconfig option for multiple instances
Add menuconfig option to select another instance of CDC ACM device.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 5c5bb7409b usb: cdc_acm: Add macros for multi instance configuration
Add macros for defining multiple instances of CDC ACM devices.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 11201a1236 usb: cdc_acm: Use usb_cfg_data from config_info
Use saved data in dev->config->config_info.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko b48a8c3247 usb: device: Add composite status callback
Add new status callback with usb_cfg_data parameter to be able to
identify instance callback.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 9ef8ad412f usb: Refactor usb_interface_config callback
Add interface parameter to interface configuration callback to be able
to configure several instances of the same class.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko b5786aded7 usb: cdc_acm: Correct debug logging
Remove extra newline characters.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko eb86b5ccc5 usb: cdc_acm: Allow to create several CDC ACM devices
Change global device pointer to device list where every device
registers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrzej Puzdrowski 40da5f3f40 usb/class/usb_dfu: use predefined string for image descriptors
Use predefined string for images string descriptors instead
of from DTS build-time generated labels.
This labels will be deprecated.

String content are kept the same as before.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-08 09:13:09 -06:00
Andrzej Puzdrowski ee7dfc1b34 usb/class/usb_dfu: use flash_map data instead of macro labels
Now flash_map is proper place to obtain all information about
flash-areas boundaries.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-08 09:13:09 -06:00
Findlay Feng 6199e97836 usb/class/usb_dfu: align to changes in dfu subsys'es
Changes in flash_map API makes flash_area structure proper
interface for point the image area instead of direct flash-bank-offsets.

This patch align code to changed APIa and allows to support operation
on the partition in any flash device.

Signed-off-by: Findlay Feng <i@fengch.me>
2019-02-08 09:13:09 -06:00
Andrei Emeltchenko f9293a0db3 usb: Remove unused variable
Cleanup code removing unused variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-05 11:08:24 -05:00
Aurelien Jarno 192fe2a528 usb: class: dfu: always provide payload_data
Given the device can be enumerated as both legacy and composite, we
always need to provide the payload_data buffer.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno b613864c8e usb: class: dfu: fix USB descriptors in composite mode
In composite mode the request handler buffer is common to all functions,
and its size is defined by CONFIG_USB_COMPOSITE_BUFFER_SIZE.

Given the device is enumerated as composite in runtime mode and
as legacy in download mode, we need to define wTransferSize as
the minimum of the two.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno ef2871dec9 usb: class: dfu: use the request handler provided buffer
The upload code assumes the buffer to use is the DFU provide one, and
not the one provided by the request handler, which is different in
composite mode.

This is only a theoretical issue, as this function is only executed
once the device has been re-enumerated in legacy mode, but that is a
required step before unifying legacy and composite code.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno 9550f9c358 usb: class: dfu: fix firmware upload
The flash_read() function takes an offset from beginning of the flash.
This patch subtract FLASH_BASE_ADDRESS from the absolute address. This
fixes DFU firmware upload.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno d77b1c843d usb: class: dfu: fix support for SPI based flash
With an SPI based flash, CONFIG_FLASH_BASE_ADDRESS is not defined. In
that case it is safe to assume that the base address is 0.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Nicolas LANTZ 766101cf09 usb: netusb: Align NETUSB_MTU & wMaxSegmentSize and increase it to 1522
As rx_buf & tx_buf are defined with a NETUSB_MTU size, this cause
that the frames over 1500 bytes can not be received and are discarded.

Secondly, as fragmentation is not supported (for UDP and TCP datagram),
increase NETUSB_MTU to the maximum possible ethernet frame size :1522

Signed-off-by: Nicolas LANTZ <nicolas.lantz@ubicore.net>
2019-02-04 17:52:35 +01:00
Andrei Emeltchenko bf9c6d72e8 usb: Add instance parameter to descriptors definitions
This allows to place instances of the class one after another in the
linker section.

Fixes #12908

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:11:32 -05:00
Andrei Emeltchenko 372fb5da51 usb: cdc_acm: Fix composite build
Fixes bug below:
subsys/usb/class/cdc_acm.c:554:15: error: ‘dev_data’ undeclared (first
use in this function) k_work_init(&dev_data->cb_work,
cdc_acm_irq_callback_work_handler); ^~~~~~~~

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-01-24 08:37:16 -05:00
Aurelien Jarno 7f334c84d6 usb: cdc_acm: call the IRQ callback from the system work queue
The IRQ callback function of the USB CDC ACM driver can currently be
called from:
- the USB thread when a bulk in or a bulk out interrupt has been
  triggered
- the thread calling cdc_acm_irq_rx_enable or cdc_acm_irq_tx_enable when
  enabling the interrupt fires an irq (ie if there is data to read or if
  there is no pending data to send)

This causes some issues with at least the shell uart backend, as the
IRQ callback function ends up being called twice concurrently in case a
USB driver sends the requested data almost instantaneously. This is the
case for example of the USB nRF driver which uses DMA. In turn this
cause ring_buf_item_get to be called concurrently, leading to data
corruption:

  uart:~$ help
  Please press the <Tab> button to see all available commandands.
  You can also use the e <Tab> button to prompt or auto-coomplelete all
  commands or its subcommands.
  You can try toto call commands with <-h> or <--help> parameter for
  more informatation.
  uart:~$

Fix that by always calling the IRQ callback function through the system
work queue.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-09 07:47:43 -06:00
Savinay Dharmappa 0fb1a8a836 usb: class: dfu: Add a worker thread to flash data from usb to flash
The bulk of implementation in the current DFU arch is done in the ISR.
This works well when the Flash device is memory mapped as these writes
get done comparatively quickly. However, in case of platforms where
the flash device is sitting on the SPI Bus, this was observed to
cause an exception. This exception may be because there are multiple
function calls consuming larger processing time inside the ISR. The
ISR stack may also end up going deeper and risk stack corruption on
devices with low RAM. To resolve this, we deferred flash write to a
worker thread. Also, some handshaking was added to have synchronization
with the host in accordance with the Host-Device DFU protocol.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-12-30 16:24:33 -05:00
Savinay Dharmappa b9b8daa3bc samples: subsys: usb: dfu: Fix build error for intel_s1000
intel_s1000 uses DT_SPI_NOR_DRV_NAME instead of DT_FLASH_DEV_NAME
for device binding of flash device.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-12-30 16:24:33 -05:00
Marcin Szymczyk 801b54edb9 usb: hid: boot protocol
Set_Protocol and Get_Protocol requests are handled now.
Tested with USB3CV.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-19 07:36:18 -06:00
Aurelien Jarno a1c3b0aad3 usb: fix CDC ACM breakage with CONFIG_USB_DEVICE_SOF
Commit e4c447aac3 ("usb: add SoF event") added support for calling the
status callback with the USB_DC_SOF value for each SoF when
CONFIG_USB_DEVICE_SOF is enabled. The CDC ACM driver saves the latest
received status and compares it USB_DC_CONFIGURED to decide if it can
send data to the host. This therefore doesn't work any more when the
status callback is called regulary with USB_DC_SOF.

Fix that by ignoring USB_DC_SOF when saving the latest received status.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:16:49 -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 01a5238ee8 usb/netusb: Let's remove the use for ll reserve
It's useless now.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Marcin Szymczyk c6d5d09d70 usb: hid: allow hid_ops to be null
Allows for hid_ops argument in usb_hid_register_device() to be NULL.
In that case, application does not implement any custom callbacks.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-14 13:19:04 +01:00
Aurelien Jarno 46a1bb7cdd usb: cdc_acm: select SERIAL_HAS_DRIVER and SERIAL_SUPPORT_INTERRUPT
USB CDC ACM is a serial driver like another. Therefore select both
SERIAL_HAS_DRIVER and SERIAL_SUPPORT_INTERRUPT. This allows one to
enable the console driver without having to enable another serial
driver.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-05 08:53:15 -05:00
Aurelien Jarno 3eda3b61f8 usb: cdc_acm: fix interrupt mode
The CDC ACM driver has to emulate the TX and RX interrupts from the USB
ones. However it does not correctly emulate them as "TX buffer empty"
and "RX buffer not empty" interrupts.

For "TX buffer empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the TX buffer is
  empty
- An interrupt should be triggered when the USB device get configured

For "RX buffer not empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the RX buffer is
  not empty

This make the a console on the USB CDC ACM port usable for the shell
and the logs.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-05 08:53:15 -05:00
Patrik Flykt b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
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
Marcin Szymczyk d5b79ff42c usb: hid: implement idle rate
Idle rate functionality has been implemented for HID USB class.
Bassed on Device Class Definition for Human Interface Devices 1.11.
Tested with USB3CV and host with idle rate.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-04 15:58:19 -05:00
Marcin Szymczyk 6a4ddffaf9 usb: hid: default request handlers
HID class now defaults to universal request callbacks in case they
are not provided by the application. This applies to following,
class-specific requests: Get_Report, Set_Report, Get_Idle, Set_Idle,
Get_Protocol and Set_Protocol.
Tested with USB3CV.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-04 15:58:19 -05:00
Tomasz Bursztyka 9464ec3343 net/iface: Switch fully to a one-pass sending logic in net_if
Now instead of such path:

net_if_send_data -> L2's send -> net_if tx_queue -> net_if_tx -> driver
net_if's send

It will be:

net_if_send_data -> net_if tx_queue -> net_if_tx -> L2's send -> driver
net_if's send

Only Ethernet is adapted, but 15.4 and bt will follow up.
All Ethernet drivers are made compatible with that new scheme also.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Andrei Emeltchenko e209ebe05a usb: device: Use sys_le16_to_cpu conversion
USB protocol is Little Endian so make conversions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-30 07:58:31 -08:00
Flavio Ceolin 98d03266f1 serial: Change poll_out signature
poll_out function was returning the character that was sent. It
happens that it is always constant and the return of this functions is
never tested. Changing it to be a void function.

MISRA-C rule 17.7

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-11-29 10:18:59 -08:00
Andrei Emeltchenko 575bd0bbc9 usb: Fix unaligned access
Use sys_put_le16() for unaligned access, this is refactored work of
PR #8495
PR #11432

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-26 09:13:56 -08: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
Savinay Dharmappa 0576f93ff8 usb: class: hid: Fix fault due to unaligned access
patch fix fault due to unaligned access while setting hid
report size on xtensa platform.

Fixes #11266

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-11-21 12:25:22 -05:00
Anas Nashif 065903f3c7 usb: netusb: fix log level macro
Using the wrong Kconfig for log level.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-15 15:24:32 -05:00
Andrei Emeltchenko db42716cde usb: msc: Check input parameters for class handle
Fixes USB Certification tests for class requests.

Fixes #11359

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-14 23:54:08 -05:00
Andrei Emeltchenko 5bf12356e2 usb: msc: Do not give warning after SET_INTERFACE
Add USB_DC_INTERFACE 'handling'.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-14 23:54:08 -05:00
Andrei Emeltchenko 3f698494bb usb: msc: Set default Serial Number string
According to the "USB Mass Storage Class" Spec. the serial
number shall contain at least 12 valid digits, represented
as a UNICODE string.

Fixes: #11336

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-14 23:54:08 -05: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
Kumar Gala e8587f4493 usb: Make USB_VBUS_GPIO a Kconfig option
Previously we had a set of magic #define's in board.h that would both
enable and set the GPIO controller & pin if a given board used a GPIO
for USB VBUS.  Now we make it a proper Kconfig set of options that
specify if the feature is needed, the GPIO controller device name, and
pin number.  In the future this should move to devicetree.

Updated the related boards that used this feature to set the Kconfig
options in the Kconfig.defconfig

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-13 07:10:04 -06:00
Andrei Emeltchenko 40f7a49ffe usb: hid: Trivial syntax fix
Fix typo

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-13 12:41:39 +01:00
Andrei Emeltchenko 85cfe33262 usb: hid: Define helper definitions and cleanup code
Use newly defined definitions for cleaning the code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-13 12:41:39 +01:00
Andrei Emeltchenko f6a20b83d6 usb: hid: Implement Return HID Descriptor
Resolves certification USB tests.
Fixes #11321

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-13 12:41:39 +01:00
Krzysztof Chruscinski 97345dbb1b logging: Fix errors in log usage
Couple of findings which were revealed after changing
LOG_MODULE_REGISTER macro:
- missing semicolons after LOG_MODULE_REGISTER()
- missing LOG_LEVEL defines
- other

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-10 12:38:29 -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 fdfa975b9d usb: device: fix wrong direction in usb_transfer_ep_callback
In case no transfer is ongoing, the usb_transfer_ep_callback consumes
the received data. This is however associated with the wrong test. USB
is host centric, so data reception on the device is signaled by
USB_DC_EP_DATA_OUT and not USB_DC_EP_DATA_IN.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-11-05 16:33:01 +01:00