| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
I often get confused by running usb and wondering why devices behind
unconfigured OTG controllers are not enumerated. Improve the user
experience by printing a message when doing a USB scan while some OTG
controllers are not yet configured (i.e. the otg.mode device parameter
hasn't been set to "peripheral" or "host").
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240228160518.1589193-6-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
printf(), and by extension dev_err(), already has built-in support for
formatting error codes, so make use of that instead of manual use of
strerror().
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240219172108.3780861-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we are doing dma_map/unmap we will end up clearing caches. As we
can only do that with the granularity of a cache line, we must ensure
that the corresponding buffers are properly aligned, as otherwise we may
accidentally overwrite some data that happens to reside in the same
cache line. This is exactly what dma_alloc() is for, so use that for
buffers which we are going to map for dma.
Signed-off-by: Denis Orlov <denorl2009@gmail.com>
Link: https://lore.barebox.org/20230629195718.14416-3-denorl2009@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
For easier patch merging and comparison with Linux move the usb
gadget files to where Linux has them. For now do a plain git mv
include/usb include/linux/usb, eventhough there might be some
files which are purely barebox specific.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The new binding allows describing hubs that lacks a control bus (e.g.
I2C) in the DT and thus replaces the ugly hack of specifying USB hub
resets as gpio-hogs. It's already in use for boards we support, like the
STM32MP13/5 Discovery kits and will be useful for the i.MX8MP Debix
board, so port over the driver from Linux.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230217202620.2882141-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
The '_d' suffix was originally meant to distinguish barebox struct
names from Linux struct names. struct driver doesn't exist in Linux,
so we can rename it and remove the meaningless suffix.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The '_d' suffix was originally introduced in case we want to import
Linux struct device as a separate struct into barebox. Over time it
became clear that this won't happen, instead barebox struct device_d
is basically the same as Linux struct device. Rename the struct name
accordingly to make porting Linux code easier.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some USB mass storage devices can take a comparatively long time after
vbus is applied until they can be enumerated. Board code can reissue
usb_rescan() to retry enumeration at a later time. It's useful for
board code to check whether any new devices have been detected by a
usb_rescan() call. To facilitate this, have usb_rescan() return the
number of devices found in addition to printing it to the log.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220929100502.895553-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
struct device_d has some dynamically allocated members, namely .name and
.unique_name. These are normally not freed when a device is freed. Add
two functions to free these resources. free_device_res() only frees the
allocated members, but not the device itself. This is suitable for cases
where the device is embedded in another struct. free_device() frees the
allocated members along with the device itself. This can be called when
the device itself has been directly allocated.
Some users which should use these functions are also fixed in this
patch.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.barebox.org/20220207094953.949868-5-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds the suitable SPDX-License-Identifier to all files in drivers/
that previously lacked one.
To aid manual inspection, following heuristics can be used:
* No changes outside of comments/whitespace:
git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)'
* -or-later come in pairs:
git show --inter-hunk-context=19 HEAD | \
perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }'
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
We already maintain a list of USB host controllers, so we can use that
to implement a generic detect callback. Currently, all drivers define
their own, which uses driver-specific means to arrive at the struct
usb_host and then call usb_host_detect().
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
In case the USB device is a full speed device we have to set
dev->epmaxpacketin[0] and dev->epmaxpacketout[0] before doing a
get_descriptor_len() because otherwise it's unset during that call.
Fixes: 6d1d95a386 ("usb: factor out a usb_setup_descriptor() function")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97
("Remove the CREDITS file"). Remove references to it from several files.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
This adds the missing bits and pieces to add super speed support to the
USB stack. It is based on the corresponding U-Boot code.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This factors out a usb_setup_descriptor() function with the goal to
make the code better comparable to the corresponding U-Boot code.
This also incorporates this U-Boot commit:
| commit 2b338ef41127351089254b748de5cefd95c3e800
| Author: Hans de Goede <hdegoede@redhat.com>
| Date: Tue May 5 23:56:04 2015 +0200
|
| usb: Fix maxpacketsize for first descriptor read for low-speed usb devs
|
| This fixes descriptor reading of lowspeed devices through ohci not working.
|
| Signed-off-by: Hans de Goede <hdegoede@redhat.com>
| Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
"tmp" is only used to store the size of the descriptor. The name is not
very meaningful and "tmp" is not even used everywhere it could be used.
Just replace by using sizeof() directly where needed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
dev->devnum is set once in usb_alloc_new_device(), set to 0 again later
in usb_new_device() and then set back to the original value. This seems
unnecessary, just set devnum once right before calling usb_set_address()
on the device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an adoption of U-Boot commit bbc6f06c0031249bf1983b875e54cb7549bafe60:
| commit bbc6f06c0031249bf1983b875e54cb7549bafe60
| Author: Bin Meng <bmeng.cn@gmail.com>
| Date: Wed Jul 19 21:51:13 2017 +0800
|
| usb: hub: Support 'set hub depth' request for USB 3.0 hubs
|
| USB 3.0 hub uses a hub depth value multiplied by four as an offset
| into the 'route string' to locate the bits it uses to determine the
| downstream port number. We shall set the hub depth value of a USB
| 3.0 hub after it is configured.
|
| Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
| Reviewed-by: Simon Glass <sjg@chromium.org>
In this patch we also support recording the depth of a hub in
struct usb_device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
For controllers which do everything relevant during probe time
make the init hook optional.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Give the USB messages some context by using dev_* functions rather than
printf()/debug().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
in usb_new_device() set the device name as early as possible to let
dev_* functions print a meaningful name.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
U-Boot has this since 3ed9eb93c2 ("usb: Don't reset the USB hub a 2nd
time"), so do the same for barebox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Instead of returning -1 forward the error code and take the opportunity
to print the error string.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The usb_*_msg() functions take a timeout parameter. Make clear which
unit is expected by adding a _ms suffix to the variable name.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
There are no users of usb_control_msg() in the codebase that pass
timeout of 0, so it doesn't look like usb_disable_asynch() has any
effect on USB operation. Drop that function and remove all of its uses
to simplify things.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
We have usb_register_host() which puts a new host on the list
of hosts we should also have the opposite which removes the
host from the list again.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
| |
Introduce dev_set_name() in order to hide implementation details of
setting device's name so it'd be easier to change it.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To account for the possibility of a device coming out of second reset
operating at different speed compared to first, move the code that
stores device speed to be a part of hub_port_reset(). This way any
speed change happening as a result of port reset could be accounted
for.
The above behaviour was observed on i.MX51 ZII RDU1, on USBH2 port
connected to SMSC2660 USB Hub/SD card reader. For reasons unclear,
first reset would put it into Full Speed mode whereas second would
result in switch to High Speed. Artifically disabling second reset
would result in the device operating at Full Speed.
Not doing second speed adjustement on that board result would result
in un-processed control transfer and failure to execute
usb_set_address().
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch creates a consitent set of device parameter functions.
With this we have: dev_add_param_<type><access>
"type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask
The improvement here is that we now can exactly specify the width of the
int type parameters and also correctly distinguish between signed and
unsigned variables which means that a variable no longer ends up with
INT_MAX when it's assigned -1.
"access" can be empty for regular read/write parameter, "_ro" for readonly
parameters which get their value from a variable pointer in the
background or "_fixed" for parameters which are set to a fixed value
(without a pointer in the background).
Some more exotic types are not (yet) implemented, like
dev_add_param_ip_ro.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
Use standard pr_debug instead of homebrew USB_PRINTF
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In drivers/usb/core/usb.c we already have le16_to_cpus() conversion
just after usb_get_descriptor():
390 /* correct le values */
391 le16_to_cpus(&dev->descriptor->bcdUSB);
392 le16_to_cpus(&dev->descriptor->idVendor);
393 le16_to_cpus(&dev->descriptor->idProduct);
394 le16_to_cpus(&dev->descriptor->bcdDevice);
so no additional idVendor/idProduct descriptor fields
le16_to_cpu() conversion is needed after that.
On the big-endian machines extra le16_to_cpu() conversion
leads to wrong idVendor/idProduct USB device parameters values
(e.g. see devinfo <usb-device> output), and to a much more
serious problem: idVendor/idProduct-based USB device detection
does not work.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See the commit
commit 245069bcef15ecc19db616a967501349b76c84d0
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date: Thu Jul 10 11:36:12 2014 +0200
USB: introduce usb_interface/usb_configuration structs
On little endian systems like ARM the le16_to_cpus() macro
is a no op, defined as:
#define le16_to_cpus __le16_to_cpus
#define __le16_to_cpus(x) do {} while (0)
So struct usb_configuration field misuse was discovered
on big-endian MIPS machine.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
USB requests should be processed within a timeframe of 5s.
The linux kernel also uses this timeout value for the control packets.
For the musb the increase in timeout helps successfully probing USB devices
(at least on one test hardware), but on the other hand doesn't slow down the
system, if there are no devices, i.e. the timeout never hits. That means,
that the USB core correctly aborts instead of timing out.
Why and how the 100ms was chosen in the first place, can not be deduced from
the git history, just that it seems to work fine for most boards.
Change USB_CNTL_TIMEOUT to 5000ms and replace all occurences of
`USB_CNTL_TIMEOUT * x`
with just
`USB_CNTL_TIMEOUT`,
as the timeout is now large enough without it.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
This function is only used in drivers/usb/*.
It is equivalent to mdelay().
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\
| |
| |
| |
| | |
Conflicts:
drivers/usb/core/Makefile
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
USB core isn't too strict about allocation/deallocation and
add/remove sequences of usb devices. Especially, error paths
and device tear-down are kind of broken and cause hangs on
failing usb device detect.
This patch improves the situation by introducing a
usb_free_device() that tears down allocated resources by
usb_alloc_new_device(). usb_remove_device() now only deals
with resources that have been added by usb_new_device().
Also, error handling is fixed or improved to ensure that no
devices are unregistered that have not been previously
registered.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Adding a usb device increases dev_index every time a new device is
allocated. Removing a usb device does not decrease again, of course.
As we print the number of detected usb devices after each usb bus
scan based on dev_index, we cannot trust dev_index here. Keep track
of the correct number of (currently) detected usb devices by
introducing an independent dev_count that gets increased on detect
and decreased on remove.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
New usb devices are added to a list of usb devices, but when removing
the corresponding usb_device it was not removed from that list. Fix it
by deleting it properly from the usb_device_list.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| | |
We can now detect changes in the USB device hierarchy properly, so
the 'force' option to the usb command is no longer necessary. We just
scan the busses each time the usb command is called.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| | |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| | |
Make all USB devices children to the hub device they are
attached to.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Since we have a driver model we can make the hub driver a
real driver model driver. Put it into a new file to separate
the hub from the USB core stuff.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
usb_new_device tries to find the port number it is attached to
by iterating over the parents children and using the loop counter
index as port number. Instead, just use the portnr field in struct
usb_device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This patch adds U-Boot 'usb tree' command functionality to barebox.
Here is an example output:
1 ID 0000:0000
| u-boot EHCI Host Controller
|
+-2 ID 05e3:0606
| USB2.0 Hub
|
+-3 ID 10c4:ea60
| Silicon Labs CP2102 USB to UART Bridge Contr P-00-00669
|
+-4 ID 05e3:0606
| | USB2.0 Hub
| |
| +-5 ID 05e3:0608
| | | USB2.0 Hub
| | |
| | +-6 ID 0d8c:000c
| | C-Media USB Headphone Set
| |
| +-7 ID 0d8c:000c
| C-Media USB Headphone Set
|
+-8 ID 0846:1040
NETGEAR NETGEAR FA120 Adapter
The tree view is enabled with 'usb -t'
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
|
| |
This updates the USB Gadget stack to Linux-3.15.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Conflicts:
drivers/usb/core/Makefile
|
|
|
|
|
|
|
|
|
|
|
| |
Currently we have two conflicting definitions of struct usb_config_descriptor
and struct usb_interface_descriptor in the tree. This is because the USB code
uses additional fields in the structs for internal housekeeping. Add
struct usb_interface and struct struct usb_configuration with the housekeeping
data and embed the corresponding hardware structs into them. This frees the
way to use the definitions from ch9.h in the next step.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
This most likely doesn't fix any real bugs, but it's the
right thing to do and reduces the noise level with static
checkers.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|