This changes "__nocache K_HEAP_DEFINE()" to use the new
K_HEAP_DEFINE_NOCACHE() macro. This fixes a build error
as K_HEAP_DEFINE() is specifying its own linker section
so that it is no longer possible to specify another
linker section.
Fixes#38108
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Add logging for NRFX_USBD_EP_ABORTED event inside
control transfer events handling, otherwise "Unexpected event"
error message in this regard confuses the users.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add sam4l full finite state machine based on Atmel Software Framework.
This allows driver detect protocol errors and sync all requests. This
version is compliance with Linux USB tests.
Note: Tests are timing sensitive and log may affect results.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
1. Add support for NXP LPC USB controller
2. Do not check the return value from the
kUSB_DeviceControlRun command as not all SDK drivers
return a value
3. Use the kUSB_DeviceControlPreSetDeviceAddress
command to set device address
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The USB configuration option is actually a global switch
to enable USB drivers in general, but currently only
the device controller drivers are meant.
USB device controller drivers also have USB_DEVICE_DRIVER option.
Thus the option USB is actually redundant and can be replaced
by the self-explanatory option USB_DEVICE_DRIVER.
The name USB itself is not unique and should not be used as an
configuration option.
With these changes the option USB_DEVICE_DRIVER generally
enables USB device controller drivers. The option USB_DEVICE_STACK
enables USB device support. It is sufficient to enable only option
USB_DEVICE_STACK because it selects USB_DEVICE_DRIVER.
CONFIG_USB Kconfig option is temporary added to subsys/usb/Kconfig.
This is necessary to pass CI and will be removed again
when the USB configuration has been adapted in modules.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Use macros and types from usb/usb_ch9.h header where it
is possible. This patch also adds local macros, USB_REQTYPE_GET_DIR
and USB_REQTYPE_GET_TYPE, which is an intermediate solution and
these will be removed later.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This is called in ISR context and timeout must be set
to K_NO_WAIT.
Reported-by: Pieter De Gendt <pieter.degendt@basalte.be>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The SoC driver name is 'USB High-Speed Interface (USBHS)'. This rename
from usb_dc_sam to usb_dc_sam_usbhs allowing add others SoC drivers
like 'USB Device Port (UDP)' that is found at SAM4S/E variations.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
Since we removed various series headers, move stm32 driver
under main driver/pinmux folder.
Take this change into account into various drivers.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Add configurable attached event delay. Delay can be used to give
USB Charging Controller time for initialization.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
To allow transition to device tree based clock configuration on
stm32 targets, rework clock_control driver to use intermediate
STM32_ macros initially defined as the equivalent Kconfig macros
for now.
Propagate the change in all code using these macros.
The reason to introduce these new macros instead of configuring
Kconfig flags using dt kconfigfunctions is that we'll need
to be able to inform users that Kconfig flags are deprecated
once the whole family conversion is done, to encourage
out of tree users to adopt this new configuration scheme.
Note: For now STM32H7 series and code is excluded.
This is the same for some series specific code such as
PLL mul/div for L0/L1 and XTRE prescaler on F1 series.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
If a loaded endpoint was disabled and then reconfigured,
it is not possible to start an IN transfer and
usb_dc_ep_write() returns -EAGAIN.
Call ep_ctx_reset() to clear endpoint operations flags
and reset buffer after endpoint is disabled.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Replace all existing deprecated API with the recommended alternative.
Be aware that this does not address architectural errors in the use
of the work API.
Fixes#34092
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
* Assumes that the USB2_OTG peripheral is being used in FS mode, as on
the NUCLEO-H743/753.
* Disable ULPI on USB2_OTFG, enable FS clk.
* Enable USB voltage detect and disable USB reg, per STM app notes.
Signed-off-by: Jeremy Wood <jeremy@bcdevices.com>
Use ep_idx in usbip_send_common() instead of endpoint address
and get direction from endpoint address.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
USB setup packet is a part of USBIP_CMD_SUBMIT, but missing
in struct usbip_submit. This patch fixes it and removes
usbip_skip_setup() and adds an additional integrity check
in handle_usb_control().
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The transfer length is not stored and processed properly.
Use struct usb_ep_ctrl_prv, which we already have, to store
the transfer length and data. Move usbip_recv() to
handle_usb_control() and handle_usb_data(),
and explicitly copy USB setup packet.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Call the IN callback only if data in usb_dc_ep_write()
is actually written to the intermediate buffer and sent.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Use pointer to struct usb_ep_ctrl_prv, which allows to remove
a few variables and simplifies subsequent improvements.
Use consistently ep_idx in handle_usb_control() instead of
ntohl(hdr->common.ep).
Revise logging so that it is clearer what event is being processed.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The comments at the beginning of the file are not quite correct
and instructions regarding configuration are not necessary at all.
Also remove the redundant first line.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Convert from device_get_binding to DEVICE_DT_GET. In doing this we
no longer need the label in the devicetree node so we remove that.
Removed all __ASSERT_NO_MSG(clk) since we'll get a build error if
DEVICE_DT_GET cant be satisfied, and the clock control api's will
handle reporting if the device_is_ready.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
For historical reasons, the maximum speed of the Atmel SAM USB
controller is done by comparing the maximum-speed property string from
the DT using strncmp at runtime.
Now that the DT_ENUM_IDX macro exists, we can use it to get the
maximum-speed property at build time and without string comparison.
Unsupported speed can also be reported at build time.
Note that the default speed in case the optional maximum-speed property
isn't present in the DT is changed from full-speed to high-speed to
match the property description. This is a no-op in practice as this
properties is defined at the soc level.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
The STM32F105xx USB clock goes through a prescaler either PLL1 x2 /2
or PLL1 x2 /3, the output of this must be 48 MHz. As such, the output
of PLL1 must be 48 MHz or 72 MHz.
NOTE: This requires that the system is running from PLL1 (PLLCLK).
Support for running from PLL2 will be implemented in the future.
Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
Change switches to using static memory for out endpoints. Using
heap is not necessary, because number of out endpoints is defined
in DTS.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Use the core k_heap API pervasively within our tree instead of the
z_mem_pool wrapper that provided compatibility with the older mempool
implementation.
Almost all of this is straightforward swapping of one alloc/free call
for another. In a few cases where code was holding onto an old-style
"mem_block" a local compatibility struct with a single field has been
swapped in to keep the invasiveness of the changes down.
Note that not all the relevant changes in this patch have in-tree test
coverage, though I validated that it all builds.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Mark all k_mem_pool APIs deprecated for future code. Remaining
internal usage now uses equivalent "z_mem_pool" symbols instead.
Fixes#24358
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Usage of mem_pool for all IN endpoints was removed in
commit b3c63425a0 ("usb: driver: Reduce Endpoint buffer pool.")
Remove also k_mem_pool_free for all IN endpoints.
Fixes: #30213
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
ZLP - zero length packet is used to indicate that the device
has no more data to send. If the Host asks for more data that the
device can provide and the data size is mutliplication of Endpoint
wMaxPacketSize then the device must terminate the data transfer
with ZLP.
Until this patch Nordic device driver controller was not aware of
the requested data length and could not determine when the ZLP was
required.
This patch introduces a fix that prevents the driver from starting
setup stage before the ZLP is being send.
For consistance with the Zephyr USB stack sending ZLP must be
issued from the stack level. Making trans_zlp flag true results
in blocking the driver from starting setup stage without required
ZLP.
After the data transfer finishes the driver will be prepared for ZLP
and will call back the stack to start writing ZLP. After the ZLP
is being send the driver will automatically start status stage and
end the Control Transfer.
This patch also removes CONFIG_USB_DEVICE_DISABLE_ZLP_EPIN_HANDLING
and aligns Nordic driver with others.
Without this patch the issue could occur when handling get requests.
Typical case is string descriptor of length equal to wMaxPacketSize.
Hosts usually asks for wLength = 255 Bytes when string descriptors
are being requested. In that case to successfully finish the data
stage of the Control transfer the device must send wMacPacketSize
Bytes of actual string descriptor and then ZLP to indicate that no
more data are present. After ZLP the status stage may start and the
request is finished successfully.
Without this patch the driver will not send ZLP making it unable
to end the Control Request successful - this may lead to failing
'Device Descriptor Test' from USB3CV test tool.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This patch adds setup packet copy in the Nordic device
controller driver (ubs_dc_nrfx.c). This patch is required
for subsequent patch that fixes isssues with ZLP handling.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
IN Endpoints does not require to have initialized internal
buffer. The data send are not copied to the internal buffer
anymore. This patch reduces memory usage for IN Endpoints.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Nordic device driver controller (usb_dc_nrfx.c) was fragmenting
IN transfers longer than wMaxPacketSize long using its
internal buffers. Buffers were reserved for each endpoint.
Because the Low level driver (nrfx) is capable of handling
fragmentation, there is no need to do it at the driver
controller level. Data pointer is used directly to create
the nrfx transfer. Endpoint buffers are not required anymore
and could be dropped.
This patch removes fragmentation of in transfers and omits
usage of internal endpoint buffers. Buffer could be later
freed by subsequent patches.
Nordic low level usbd driver is also capable of adding ZLP
if required however for consistance with the Zephyr USB device
stack ZLP must be triggered from stack level.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Endpoint STALL should be cleared when Endpoint is enabled.
In particular when the HOST performs SetInterface requests
and Endpoints associated with that Interface are enabled
STALL should be cleared.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This patch makes the initialization of workqueue earlier
for Nordic driver. Without this change Nordic devices
will fail tests/subsys/usb/device test as it is resetting
USB and by that will try to start already started workqueue
thread. This may lead to Zephyr fatal error.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
The initial configuration provided for the nrfx_power driver cannot
contain just default values, as that mean that DC/DC converters are
to be disabled, while those converters may be (and they actually are
by default for many boards) enabled through Kconfig.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Isochronous transactions do not support handshake phase
so in particular the ISO endpoint cannot be STALLed.
Isochronous transactions do no support data toggle sequencing
and should only send DATA0 PID.
Taking into consideration those requirements do not try to
clear dtoggle or STALL an ISO Endpoint in nRF USBD driver.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
When getting a hfxo manager for USB sybsystem incorrect symbol
was checked. This lead to always enabling HFCLK, even for nRF5340
which needs HFCLK192M.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
MCUX EHCI USB device controller supports a specific
number of bidirectional endpoints. Bidirectional means
that an endpoint object is represented to the outside
as an OUT and an IN Eindpoint with its own buffers
and control structures.
ep_abs_idx index refers to the corresponding control
structure, for example:
EP addr | ep_idx | ep_abs_idx
-------------------------------
0x00 | 0x00 | 0x00
0x80 | 0x00 | 0x01
0x01 | 0x01 | 0x02
0x81 | 0x01 | 0x03
.... | .... | ....
The NUM_OF_EP_MAX (and number of s_ep_ctrl) should be double
of num_bidir_endpoints. There is also no need to reserve
endpoint addresses for this controller type.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>