History log of /u-boot/cmd/usb.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 7a875a8e 21-Jun-2023 Xavier Drudis Ferran <xdrudis@tinet.cat>

cmd: usb: Prevent reset in usb tree/info command

Commands causing reset in some configs:

When bootflow scan is run, this will cause a UCLASS_BOOTDEV device to
be added as sibling of those UCLASS_BLK devices found in the search
chain defined in environment variable "boot_targets", until boot
succeeds from some device. This can happen automatically as part of
the default boot process on some boards (example: Rock Pi 4) depending
on the board configuration (DISTRO_DEFAULTS, BOOTSTD, BOOTCOMMAND,
etc.) because they have bootcmd=bootflow scan.

If boot doesn't succeed from any device, and usb is in boot_targets,
and an usb storage device is plugged to some usb port at boot time,
its UCLASS_MASS_STORAGE device will have a UCLASS_BOOTDEV device as
child, besides a UCLASS_BLK child.

If once the boot fails the user enters at the U-Boot shell prompt:

usb info

or

usb tree

The code in cmd/usb.c will eventually recurse into the UCLASS_BOOTDEV
device and pass a null usb_device pointer to usb_show_tree_graph() or
usb_show_info() (because it has no parent_priv_).

This causes a reset. The expected behaviour would be to ignore the
UCLASS_BOOTDEV device, continue listing the usb information and return
to the prompt.

Minimal test:

Another way to trigger this reset as a minimal test or on boards with
a different bootcmd would be:

- make sure "usb" is in environment variable boot_targets (might need
setenv boot_targets usb; and/or saveenv and reset), then, with a usb
storage device plugged to a usb port, run:

=> usb reset ; bootflow scan ; usb info

Solution:

Fix it (twice) by checking for null parent_priv_ and adding
UCLASS_BOOTDEV to the list of ignored class ids before the recursive
call.

This prevents the current particular problem with UCLASS_BOOTDEV, even
in case it ever gets some parent_priv_ struct which is not an
usb_device, despite being the child of a usb_device->dev. And it also
prevents possible future problems if other children are added to usb
devices that don't have parent_priv_ because they are not part of the
usb tree, just abstractions of functionality (like UCLASS_BLK and
UCLASS_BOOTDEV are now).

Signed-off-by: Xavier Drudis Ferran <xdrudis@tinet.cat>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Tested-by: Marek Vasut <marex@denx.de>

# 9fea3a79 05-May-2023 Simon Glass <sjg@chromium.org>

usb: Tidy up the usb_start flag

This should be declared in a header file so that type-checking works
correctly.

Add a single declaration to usb.h and remove the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

# e524f3a4 27-Nov-2022 Tom Rini <trini@konsulko.com>

net: Remove eth_legacy.c

As there are no more non-DM_ETH cases for networking, remove this legacy
file and update the Makefile to match current usage.

Signed-off-by: Tom Rini <trini@konsulko.com>

# e33a5c6b 11-Aug-2022 Simon Glass <sjg@chromium.org>

blk: Switch over to using uclass IDs

We currently have an if_type (interface type) and a uclass id. These are
closely related and we don't need to have both.

Drop the if_type values and use the uclass ones instead.

Maintain the existing, subtle, one-way conversion between UCLASS_USB and
UCLASS_MASS_STORAGE for now, and add a comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 52f24238 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop bootstage.h from common header

Move this fairly uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e6f6f9e6 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop part.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 51f60a89 01-Apr-2019 Ismael Luceno Cortes <ismael.luceno@silicon-gears.com>

usb: Make portspeed return a read-only string

Current code is plain wrong, and there's no need to have a mutable string,
so fix function type and remove the intermediate variable.

Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# abd7cedb 23-Oct-2017 Suneel Garapati <suneelglinux@gmail.com>

cmd: usb: ignore blk, emulation devices in usb tree/info display

Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# c16ad675 29-Jul-2017 Simon Glass <sjg@chromium.org>

dm: usb: Adjust the 'usb' command to use blk_common_cmd()

Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 78abf14f 19-Jul-2017 Bin Meng <bmeng.cn@gmail.com>

usb: cmd: Print actual packet size for super speed devices

USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

# b984700c 21-Dec-2016 Michal Simek <michal.simek@amd.com>

usb: storage: Show number of storage devices detected for DM_USB

By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
scanning usb for storage devices... 3 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

# e6e188f5 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Make "usb info" use usb_for_each_root_dev()

The old dm "usb info" implementation has several issues:

1) NULL pointer deref when a bus has no children
2) Not showing usb devices on busses without an emulated root-hub (otg host)
3) Attempting to show devices on inactive busses
4) "usb info" Would cause some hosts to get re-probed something which only
"usb reset" should do

TL;DR: proper iterating over usb bus root devs is hard, use the helper
for it.

Reported-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2138fd6d 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Add a usb_for_each_root_dev() helper function

Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 7839f5f8 17-Jun-2016 Peng Fan <van.freenix@gmail.com>

cmd: usb: check if_type before using this device

For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.

So check if_type before using this device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>

# 57ebf67b 01-May-2016 Simon Glass <sjg@chromium.org>

dm: usb: Drop the get_dev() function

This function is implemented by the legacy block functions now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 192eab93 02-Apr-2016 Hans de Goede <hdegoede@redhat.com>

dm: usb: Do not reprobe usb hosts on "usb tree" command

Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 9a80e714 03-Apr-2016 Hans de Goede <hdegoede@redhat.com>

usb: kbd: Do not deregister usbkbd twice when using dm

The dm usb_kbd_remove function() will deregister the usb keyboard for
us on a "usb reset" / "usb stop" so there is no need to manually call
usb_kbd_deregister() in the dm case.

This commit removes usb_kbd_deregister() in the dm case fixing the
following "usb reset" errors:

usb_kbd_remove: warning, ret=-6
device_remove: Device 'usb_kbd' failed to remove, but children are gone

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2a981dc2 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: block: Adjust device calls to go through helpers function

To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.

Use inline functions to avoid increasing code size on some boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 3e8bd469 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: part: Rename some partition functions

Rename three partition functions so that they start with part_. This makes
it clear what they relate to.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 4101f687 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: Drop the block_dev_desc_t typedef

Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
and causes 80-column violations, rename it to struct blk_desc.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 2e192b24 17-Jan-2016 Simon Glass <sjg@chromium.org>

Remove the cmd_ prefix from command files

Now that they are in their own directory, we can remove this prefix.
This makes it easier to find a file since the prefix does not get in the
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

# e524f3a4 27-Nov-2022 Tom Rini <trini@konsulko.com>

net: Remove eth_legacy.c

As there are no more non-DM_ETH cases for networking, remove this legacy
file and update the Makefile to match current usage.

Signed-off-by: Tom Rini <trini@konsulko.com>

# e33a5c6b 11-Aug-2022 Simon Glass <sjg@chromium.org>

blk: Switch over to using uclass IDs

We currently have an if_type (interface type) and a uclass id. These are
closely related and we don't need to have both.

Drop the if_type values and use the uclass ones instead.

Maintain the existing, subtle, one-way conversion between UCLASS_USB and
UCLASS_MASS_STORAGE for now, and add a comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 52f24238 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop bootstage.h from common header

Move this fairly uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e6f6f9e6 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop part.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 51f60a89 01-Apr-2019 Ismael Luceno Cortes <ismael.luceno@silicon-gears.com>

usb: Make portspeed return a read-only string

Current code is plain wrong, and there's no need to have a mutable string,
so fix function type and remove the intermediate variable.

Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# abd7cedb 23-Oct-2017 Suneel Garapati <suneelglinux@gmail.com>

cmd: usb: ignore blk, emulation devices in usb tree/info display

Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# c16ad675 29-Jul-2017 Simon Glass <sjg@chromium.org>

dm: usb: Adjust the 'usb' command to use blk_common_cmd()

Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 78abf14f 19-Jul-2017 Bin Meng <bmeng.cn@gmail.com>

usb: cmd: Print actual packet size for super speed devices

USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

# b984700c 21-Dec-2016 Michal Simek <michal.simek@amd.com>

usb: storage: Show number of storage devices detected for DM_USB

By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
scanning usb for storage devices... 3 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

# e6e188f5 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Make "usb info" use usb_for_each_root_dev()

The old dm "usb info" implementation has several issues:

1) NULL pointer deref when a bus has no children
2) Not showing usb devices on busses without an emulated root-hub (otg host)
3) Attempting to show devices on inactive busses
4) "usb info" Would cause some hosts to get re-probed something which only
"usb reset" should do

TL;DR: proper iterating over usb bus root devs is hard, use the helper
for it.

Reported-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2138fd6d 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Add a usb_for_each_root_dev() helper function

Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 7839f5f8 17-Jun-2016 Peng Fan <van.freenix@gmail.com>

cmd: usb: check if_type before using this device

For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.

So check if_type before using this device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>

# 57ebf67b 01-May-2016 Simon Glass <sjg@chromium.org>

dm: usb: Drop the get_dev() function

This function is implemented by the legacy block functions now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 192eab93 02-Apr-2016 Hans de Goede <hdegoede@redhat.com>

dm: usb: Do not reprobe usb hosts on "usb tree" command

Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 9a80e714 03-Apr-2016 Hans de Goede <hdegoede@redhat.com>

usb: kbd: Do not deregister usbkbd twice when using dm

The dm usb_kbd_remove function() will deregister the usb keyboard for
us on a "usb reset" / "usb stop" so there is no need to manually call
usb_kbd_deregister() in the dm case.

This commit removes usb_kbd_deregister() in the dm case fixing the
following "usb reset" errors:

usb_kbd_remove: warning, ret=-6
device_remove: Device 'usb_kbd' failed to remove, but children are gone

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2a981dc2 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: block: Adjust device calls to go through helpers function

To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.

Use inline functions to avoid increasing code size on some boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 3e8bd469 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: part: Rename some partition functions

Rename three partition functions so that they start with part_. This makes
it clear what they relate to.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 4101f687 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: Drop the block_dev_desc_t typedef

Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
and causes 80-column violations, rename it to struct blk_desc.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 2e192b24 17-Jan-2016 Simon Glass <sjg@chromium.org>

Remove the cmd_ prefix from command files

Now that they are in their own directory, we can remove this prefix.
This makes it easier to find a file since the prefix does not get in the
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

# e33a5c6b 11-Aug-2022 Simon Glass <sjg@chromium.org>

blk: Switch over to using uclass IDs

We currently have an if_type (interface type) and a uclass id. These are
closely related and we don't need to have both.

Drop the if_type values and use the uclass ones instead.

Maintain the existing, subtle, one-way conversion between UCLASS_USB and
UCLASS_MASS_STORAGE for now, and add a comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 52f24238 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop bootstage.h from common header

Move this fairly uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e6f6f9e6 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop part.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 51f60a89 01-Apr-2019 Ismael Luceno Cortes <ismael.luceno@silicon-gears.com>

usb: Make portspeed return a read-only string

Current code is plain wrong, and there's no need to have a mutable string,
so fix function type and remove the intermediate variable.

Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# abd7cedb 23-Oct-2017 Suneel Garapati <suneelglinux@gmail.com>

cmd: usb: ignore blk, emulation devices in usb tree/info display

Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# c16ad675 29-Jul-2017 Simon Glass <sjg@chromium.org>

dm: usb: Adjust the 'usb' command to use blk_common_cmd()

Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 78abf14f 19-Jul-2017 Bin Meng <bmeng.cn@gmail.com>

usb: cmd: Print actual packet size for super speed devices

USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

# b984700c 21-Dec-2016 Michal Simek <michal.simek@amd.com>

usb: storage: Show number of storage devices detected for DM_USB

By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
scanning usb for storage devices... 3 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

# e6e188f5 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Make "usb info" use usb_for_each_root_dev()

The old dm "usb info" implementation has several issues:

1) NULL pointer deref when a bus has no children
2) Not showing usb devices on busses without an emulated root-hub (otg host)
3) Attempting to show devices on inactive busses
4) "usb info" Would cause some hosts to get re-probed something which only
"usb reset" should do

TL;DR: proper iterating over usb bus root devs is hard, use the helper
for it.

Reported-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2138fd6d 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Add a usb_for_each_root_dev() helper function

Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 7839f5f8 17-Jun-2016 Peng Fan <van.freenix@gmail.com>

cmd: usb: check if_type before using this device

For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.

So check if_type before using this device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>

# 57ebf67b 01-May-2016 Simon Glass <sjg@chromium.org>

dm: usb: Drop the get_dev() function

This function is implemented by the legacy block functions now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 192eab93 02-Apr-2016 Hans de Goede <hdegoede@redhat.com>

dm: usb: Do not reprobe usb hosts on "usb tree" command

Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 9a80e714 03-Apr-2016 Hans de Goede <hdegoede@redhat.com>

usb: kbd: Do not deregister usbkbd twice when using dm

The dm usb_kbd_remove function() will deregister the usb keyboard for
us on a "usb reset" / "usb stop" so there is no need to manually call
usb_kbd_deregister() in the dm case.

This commit removes usb_kbd_deregister() in the dm case fixing the
following "usb reset" errors:

usb_kbd_remove: warning, ret=-6
device_remove: Device 'usb_kbd' failed to remove, but children are gone

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2a981dc2 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: block: Adjust device calls to go through helpers function

To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.

Use inline functions to avoid increasing code size on some boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 3e8bd469 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: part: Rename some partition functions

Rename three partition functions so that they start with part_. This makes
it clear what they relate to.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 4101f687 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: Drop the block_dev_desc_t typedef

Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
and causes 80-column violations, rename it to struct blk_desc.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 2e192b24 17-Jan-2016 Simon Glass <sjg@chromium.org>

Remove the cmd_ prefix from command files

Now that they are in their own directory, we can remove this prefix.
This makes it easier to find a file since the prefix does not get in the
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 52f24238 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop bootstage.h from common header

Move this fairly uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e6f6f9e6 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop part.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 51f60a89 01-Apr-2019 Ismael Luceno Cortes <ismael.luceno@silicon-gears.com>

usb: Make portspeed return a read-only string

Current code is plain wrong, and there's no need to have a mutable string,
so fix function type and remove the intermediate variable.

Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# abd7cedb 23-Oct-2017 Suneel Garapati <suneelglinux@gmail.com>

cmd: usb: ignore blk, emulation devices in usb tree/info display

Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# c16ad675 29-Jul-2017 Simon Glass <sjg@chromium.org>

dm: usb: Adjust the 'usb' command to use blk_common_cmd()

Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 78abf14f 19-Jul-2017 Bin Meng <bmeng.cn@gmail.com>

usb: cmd: Print actual packet size for super speed devices

USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

# b984700c 21-Dec-2016 Michal Simek <michal.simek@xilinx.com>

usb: storage: Show number of storage devices detected for DM_USB

By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
scanning usb for storage devices... 3 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

# e6e188f5 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Make "usb info" use usb_for_each_root_dev()

The old dm "usb info" implementation has several issues:

1) NULL pointer deref when a bus has no children
2) Not showing usb devices on busses without an emulated root-hub (otg host)
3) Attempting to show devices on inactive busses
4) "usb info" Would cause some hosts to get re-probed something which only
"usb reset" should do

TL;DR: proper iterating over usb bus root devs is hard, use the helper
for it.

Reported-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2138fd6d 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Add a usb_for_each_root_dev() helper function

Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 7839f5f8 17-Jun-2016 Peng Fan <van.freenix@gmail.com>

cmd: usb: check if_type before using this device

For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.

So check if_type before using this device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>

# 57ebf67b 01-May-2016 Simon Glass <sjg@chromium.org>

dm: usb: Drop the get_dev() function

This function is implemented by the legacy block functions now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 192eab93 02-Apr-2016 Hans de Goede <hdegoede@redhat.com>

dm: usb: Do not reprobe usb hosts on "usb tree" command

Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 9a80e714 03-Apr-2016 Hans de Goede <hdegoede@redhat.com>

usb: kbd: Do not deregister usbkbd twice when using dm

The dm usb_kbd_remove function() will deregister the usb keyboard for
us on a "usb reset" / "usb stop" so there is no need to manually call
usb_kbd_deregister() in the dm case.

This commit removes usb_kbd_deregister() in the dm case fixing the
following "usb reset" errors:

usb_kbd_remove: warning, ret=-6
device_remove: Device 'usb_kbd' failed to remove, but children are gone

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2a981dc2 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: block: Adjust device calls to go through helpers function

To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.

Use inline functions to avoid increasing code size on some boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 3e8bd469 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: part: Rename some partition functions

Rename three partition functions so that they start with part_. This makes
it clear what they relate to.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 4101f687 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: Drop the block_dev_desc_t typedef

Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
and causes 80-column violations, rename it to struct blk_desc.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 2e192b24 17-Jan-2016 Simon Glass <sjg@chromium.org>

Remove the cmd_ prefix from command files

Now that they are in their own directory, we can remove this prefix.
This makes it easier to find a file since the prefix does not get in the
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

We should not use typedefs in U-Boot. They cannot be used as forward
declarations which means that header files must include the full header to
access them.

Drop the typedef and rename the struct to remove the _s suffix which is
now not useful.

This requires quite a few header-file additions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 52f24238 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop bootstage.h from common header

Move this fairly uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e6f6f9e6 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop part.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 51f60a89 01-Apr-2019 Ismael Luceno Cortes <ismael.luceno@silicon-gears.com>

usb: Make portspeed return a read-only string

Current code is plain wrong, and there's no need to have a mutable string,
so fix function type and remove the intermediate variable.

Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# abd7cedb 23-Oct-2017 Suneel Garapati <suneelglinux@gmail.com>

cmd: usb: ignore blk, emulation devices in usb tree/info display

Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# c16ad675 29-Jul-2017 Simon Glass <sjg@chromium.org>

dm: usb: Adjust the 'usb' command to use blk_common_cmd()

Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 78abf14f 19-Jul-2017 Bin Meng <bmeng.cn@gmail.com>

usb: cmd: Print actual packet size for super speed devices

USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

# b984700c 21-Dec-2016 Michal Simek <michal.simek@xilinx.com>

usb: storage: Show number of storage devices detected for DM_USB

By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
scanning usb for storage devices... 3 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

# e6e188f5 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Make "usb info" use usb_for_each_root_dev()

The old dm "usb info" implementation has several issues:

1) NULL pointer deref when a bus has no children
2) Not showing usb devices on busses without an emulated root-hub (otg host)
3) Attempting to show devices on inactive busses
4) "usb info" Would cause some hosts to get re-probed something which only
"usb reset" should do

TL;DR: proper iterating over usb bus root devs is hard, use the helper
for it.

Reported-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2138fd6d 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Add a usb_for_each_root_dev() helper function

Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 7839f5f8 17-Jun-2016 Peng Fan <van.freenix@gmail.com>

cmd: usb: check if_type before using this device

For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.

So check if_type before using this device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>

# 57ebf67b 01-May-2016 Simon Glass <sjg@chromium.org>

dm: usb: Drop the get_dev() function

This function is implemented by the legacy block functions now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 192eab93 02-Apr-2016 Hans de Goede <hdegoede@redhat.com>

dm: usb: Do not reprobe usb hosts on "usb tree" command

Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 9a80e714 03-Apr-2016 Hans de Goede <hdegoede@redhat.com>

usb: kbd: Do not deregister usbkbd twice when using dm

The dm usb_kbd_remove function() will deregister the usb keyboard for
us on a "usb reset" / "usb stop" so there is no need to manually call
usb_kbd_deregister() in the dm case.

This commit removes usb_kbd_deregister() in the dm case fixing the
following "usb reset" errors:

usb_kbd_remove: warning, ret=-6
device_remove: Device 'usb_kbd' failed to remove, but children are gone

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2a981dc2 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: block: Adjust device calls to go through helpers function

To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.

Use inline functions to avoid increasing code size on some boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 3e8bd469 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: part: Rename some partition functions

Rename three partition functions so that they start with part_. This makes
it clear what they relate to.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 4101f687 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: Drop the block_dev_desc_t typedef

Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
and causes 80-column violations, rename it to struct blk_desc.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 2e192b24 17-Jan-2016 Simon Glass <sjg@chromium.org>

Remove the cmd_ prefix from command files

Now that they are in their own directory, we can remove this prefix.
This makes it easier to find a file since the prefix does not get in the
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

# 51f60a89 01-Apr-2019 Ismael Luceno Cortes <ismael.luceno@silicon-gears.com>

usb: Make portspeed return a read-only string

Current code is plain wrong, and there's no need to have a mutable string,
so fix function type and remove the intermediate variable.

Signed-off-by: Ismael Luceno <ismael.luceno@silicon-gears.com>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# abd7cedb 23-Oct-2017 Suneel Garapati <suneelglinux@gmail.com>

cmd: usb: ignore blk, emulation devices in usb tree/info display

Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# c16ad675 29-Jul-2017 Simon Glass <sjg@chromium.org>

dm: usb: Adjust the 'usb' command to use blk_common_cmd()

Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 78abf14f 19-Jul-2017 Bin Meng <bmeng.cn@gmail.com>

usb: cmd: Print actual packet size for super speed devices

USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

# b984700c 21-Dec-2016 Michal Simek <michal.simek@xilinx.com>

usb: storage: Show number of storage devices detected for DM_USB

By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
scanning usb for storage devices... 3 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

# e6e188f5 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Make "usb info" use usb_for_each_root_dev()

The old dm "usb info" implementation has several issues:

1) NULL pointer deref when a bus has no children
2) Not showing usb devices on busses without an emulated root-hub (otg host)
3) Attempting to show devices on inactive busses
4) "usb info" Would cause some hosts to get re-probed something which only
"usb reset" should do

TL;DR: proper iterating over usb bus root devs is hard, use the helper
for it.

Reported-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2138fd6d 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Add a usb_for_each_root_dev() helper function

Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 7839f5f8 17-Jun-2016 Peng Fan <van.freenix@gmail.com>

cmd: usb: check if_type before using this device

For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.

So check if_type before using this device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>

# 57ebf67b 01-May-2016 Simon Glass <sjg@chromium.org>

dm: usb: Drop the get_dev() function

This function is implemented by the legacy block functions now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 192eab93 02-Apr-2016 Hans de Goede <hdegoede@redhat.com>

dm: usb: Do not reprobe usb hosts on "usb tree" command

Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 9a80e714 03-Apr-2016 Hans de Goede <hdegoede@redhat.com>

usb: kbd: Do not deregister usbkbd twice when using dm

The dm usb_kbd_remove function() will deregister the usb keyboard for
us on a "usb reset" / "usb stop" so there is no need to manually call
usb_kbd_deregister() in the dm case.

This commit removes usb_kbd_deregister() in the dm case fixing the
following "usb reset" errors:

usb_kbd_remove: warning, ret=-6
device_remove: Device 'usb_kbd' failed to remove, but children are gone

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

# 2a981dc2 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: block: Adjust device calls to go through helpers function

To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.

Use inline functions to avoid increasing code size on some boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 3e8bd469 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: part: Rename some partition functions

Rename three partition functions so that they start with part_. This makes
it clear what they relate to.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 4101f687 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: Drop the block_dev_desc_t typedef

Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
and causes 80-column violations, rename it to struct blk_desc.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

# 2e192b24 17-Jan-2016 Simon Glass <sjg@chromium.org>

Remove the cmd_ prefix from command files

Now that they are in their own directory, we can remove this prefix.
This makes it easier to find a file since the prefix does not get in the
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>


# abd7cedb 23-Oct-2017 Suneel Garapati <suneelglinux@gmail.com>

cmd: usb: ignore blk, emulation devices in usb tree/info display

Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>


# c16ad675 29-Jul-2017 Simon Glass <sjg@chromium.org>

dm: usb: Adjust the 'usb' command to use blk_common_cmd()

Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


# 78abf14f 19-Jul-2017 Bin Meng <bmeng.cn@gmail.com>

usb: cmd: Print actual packet size for super speed devices

USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>


# b984700c 21-Dec-2016 Michal Simek <michal.simek@xilinx.com>

usb: storage: Show number of storage devices detected for DM_USB

By enabling DM_USB information about number of storage devices
was lost.
Get this information back simply by printing number of devices detected
via BLK uclass.

For example:
scanning bus 0 for devices... 7 USB Device(s) found
scanning usb for storage devices... 3 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found

Signed-off-by: Michal Simek <michal.simek@xilinx.com>


# e6e188f5 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Make "usb info" use usb_for_each_root_dev()

The old dm "usb info" implementation has several issues:

1) NULL pointer deref when a bus has no children
2) Not showing usb devices on busses without an emulated root-hub (otg host)
3) Attempting to show devices on inactive busses
4) "usb info" Would cause some hosts to get re-probed something which only
"usb reset" should do

TL;DR: proper iterating over usb bus root devs is hard, use the helper
for it.

Reported-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 2138fd6d 03-Jul-2016 Hans de Goede <hdegoede@redhat.com>

usb: dm: Add a usb_for_each_root_dev() helper function

Iterating over usb-root devs and doing something for all of them is
a bit tricky with dm, factor out the proven usb_show_tree() for this
into a helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 7839f5f8 17-Jun-2016 Peng Fan <van.freenix@gmail.com>

cmd: usb: check if_type before using this device

For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7.
If we only have one usb disk on board, `usb dev 0` is ok.
But if `usb dev 1`, still ok, then `usb read xxx` will trigger
system fault and reboot.

So check if_type before using this device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stephen Warren <swarren@nvidia.com>


# 57ebf67b 01-May-2016 Simon Glass <sjg@chromium.org>

dm: usb: Drop the get_dev() function

This function is implemented by the legacy block functions now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 192eab93 02-Apr-2016 Hans de Goede <hdegoede@redhat.com>

dm: usb: Do not reprobe usb hosts on "usb tree" command

Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 9a80e714 03-Apr-2016 Hans de Goede <hdegoede@redhat.com>

usb: kbd: Do not deregister usbkbd twice when using dm

The dm usb_kbd_remove function() will deregister the usb keyboard for
us on a "usb reset" / "usb stop" so there is no need to manually call
usb_kbd_deregister() in the dm case.

This commit removes usb_kbd_deregister() in the dm case fixing the
following "usb reset" errors:

usb_kbd_remove: warning, ret=-6
device_remove: Device 'usb_kbd' failed to remove, but children are gone

Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 2a981dc2 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: block: Adjust device calls to go through helpers function

To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.

Use inline functions to avoid increasing code size on some boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>


# 3e8bd469 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: part: Rename some partition functions

Rename three partition functions so that they start with part_. This makes
it clear what they relate to.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>


# 4101f687 29-Feb-2016 Simon Glass <sjg@chromium.org>

dm: Drop the block_dev_desc_t typedef

Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
and causes 80-column violations, rename it to struct blk_desc.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>


# 2e192b24 17-Jan-2016 Simon Glass <sjg@chromium.org>

Remove the cmd_ prefix from command files

Now that they are in their own directory, we can remove this prefix.
This makes it easier to find a file since the prefix does not get in the
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>