Commit Graph

3388 Commits

Author SHA1 Message Date
Joe Hershberger
8885c5fe90 net: cosmetic: Clean up TFTP variables and functions
Make a thorough pass through all variables and function names contained
within tftp and remove CamelCase and improve naming.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:33 -06:00
Joe Hershberger
586cbe51ab net: cosmetic: Fixup var names for DHCP strings
Remove CamelCase variable naming.
Move the definition to the same compilation unit as the primary use.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:32 -06:00
Joe Hershberger
1411157d85 net: cosmetic: Fixup var names related to boot file
The variables around the bootfile were inconsistent and used CamelCase.
Update them to make the code more readable.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:32 -06:00
Joe Hershberger
049a95a775 net: cosmetic: Change IPaddr_t to struct in_addr
This patch is simply clean-up to make the IPv4 type that is used match
what Linux uses. It also attempts to move all variables that are IP
addresses use good naming instead of CamelCase. No functional change.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:32 -06:00
Simon Glass
697033cbf0 dm: usb: Support driver model with USB keyboards
Allow USB keyboards to work with driver model. The main difference is that
we can have multiple buses (each with its own device numbering) and each
bus must be scanned.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:25 -06:00
Simon Glass
603afaf0e5 dm: usb: Split out the keyboard probe into its own function
Before adding driver model support, split out code from this over-long
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:25 -06:00
Simon Glass
acf277af68 dm: usb: Convert usb_storage to driver model
Add support for scanning USB storage devices with driver model. This mostly
involves adding a USB device ID for storage devices.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:23 -06:00
Simon Glass
91557579af dm: usb: Move storage device scanning into its own function
The usb_stor_scan() function is quite long, so split out the code that scans
each device into its own function. Also, rather than setting up the block
device list once at the start, set it up as each device is scanned. This
makes it possible to use this code from driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:22 -06:00
Simon Glass
7fc2c1ea7b Revert "usb_storage : scan all interfaces to find a storage device"
This reverts commit cd749658d5.

The conflicts with this commit are hard for me to figure out. I will re-apply
it later.
2015-04-18 11:11:22 -06:00
Simon Glass
051081323f dm: usb: Adjust usb_storage to work with sandbox
With a few tweaks we can compile this code with sandbox and enable testing
of the USB storage layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:22 -06:00
Simon Glass
84073b6f3c dm: usb: Simply device finding code in usb_storage
The for() loop is not needed since the value is immediately accessible.
Use this instead to simplify the code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:22 -06:00
Simon Glass
1d5827a12e dm: usb: Fix type problems in usb_stor_get_info()
This function assumes that unsigned long is 32-bits wide, but it is not
on 64-bit machines. Use the correct type, and add a few debug() lines also.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:22 -06:00
Simon Glass
2e17c87ebb dm: usb: Move USB storage definitions to usb_defs.h
These are better off in a header file so they can be used by other code (e.g.
the sandbox USB storage emulator).

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:22 -06:00
Simon Glass
054fe48eb2 dm: usb: Add driver model support for hubs
Adjust the existing hub code to support driver model, and add a USB driver
for hubs.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:21 -06:00
Simon Glass
361ad6afc4 dm: usb: Split hub detection into its own function
Split out the hub detection logic so it can be used by driver model. Also
adjust the code to return errors correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:21 -06:00
Simon Glass
95fbfe4298 dm: usb: Convert core usb.c file to support driver model
Add the required #ifdefs and remove unwanted data structures so that the
USB uclass will be able to use this file.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:21 -06:00
Simon Glass
0ed27905ce dm: usb: Complete the splitting up of usb_new_device()
This function now calls usb_setup_device() to set up the device and
usb_hub_probe() to check if it is a hub. The XHCI special case is now a
parameter to usb_setup_device(). The latter will be used by the USB uclass
when it is added, since it does not rely on any CONFIGs or legacy data
structures.

Signed-off-by: Simon Glass <sjg@chromium.org>
Bug-fixes for descriptor reading and usb_new_device() return value
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Tested-by: Tom Rini <trini@konsulko.com>
2015-04-18 11:11:21 -06:00
Simon Glass
91398f9854 dm: usb: Split out more code from usb_new_device()
Move the code that sets up the device with a new address into its own
function, usb_prepare_device().

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:21 -06:00
Simon Glass
128fcac087 dm: usb: Move descriptor setup code into its own function
usb_new_device() is far too long and does far too much. As a first step, move
the code that does initial setup and reads a descriptor into its own function
called usb_setup_descriptor().

For XHCI the init order is different - we set up the device but don't
actually read the descriptor until after we set an address. Support this
option as a parameter to usb_setup_descriptor().

Avoid changing this torturous code more than necessary to make it easy to
review.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:21 -06:00
Simon Glass
862e75c0db dm: usb: Refactor port resets
Move the port reset code into its own function. Rename usb_hub_reset() to
indicate that is is now a legacy function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:20 -06:00
Simon Glass
53d8aa0f61 dm: usb: Drop the legacy USB init sequence
This CONFIG is not used anywhere in U-Boot, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:20 -06:00
Simon Glass
6a1b206dc4 dm: usb: Convert 'usb' command to support driver model
Adjust this command to work with the new driver model uclass. It needs to
iterate through multiple independent controllers to find hubs, and work
through their children recursively in a different way. Otherwise the
functionality is much the same.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:20 -06:00
Simon Glass
79b5888729 dm: usb: Adjust usb_alloc_new_device() to return an error
This function returns NULL on error at present. Adjust it so that we can
return a real error, as is needed with driver model. Also improve the
error handling in its caller, usb_hub_port_connect_change(), and adjust
the code order to prepare for driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:20 -06:00
Simon Glass
cad4291cd0 dm: usb: Adjust usb command to prepare for driver model
Use 'udev' instead of 'dev' in a few places, reserving 'dev' for driver
model's struct udevice. Also adjust the code in a few minor ways to make
it easier to plumb in driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-04-18 11:11:20 -06:00
Simon Glass
7e0c77a2b8 cros_ec: Remove unused cros_ec_board_init() function
Now that driver model handles cros_ec init, we can drop this special code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:16 -06:00
Simon Glass
60f37fc6aa cros_ec: Drop unused CONFIG_DM_CROS_EC
Since all supported boards enable this option now, we can remove it along
with the old code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:15 -06:00
Simon Glass
ba4575626e dm: x86: spi: Convert ICH SPI driver to driver model
Convert this driver over to use driver model. Since all x86 platforms use
it, move x86 to use driver model for SPI and SPI flash. Adjust all dependent
code and remove the old x86 spi_init() function.

Note that this does not make full use of the new PCI uclass as yet. We still
scan the bus looking for the device. It should move to finding its details
in the device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:14 -06:00
Joe Hershberger
05c3e68f85 dm: eth: Add basic driver model support to Ethernet stack
First just add support for MAC drivers.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:12 -06:00
Joe Hershberger
85848f0377 cmd: net: Clean up return codes
The return codes in common/cmd_net.c had a number of inconsistencies.
Update them to all use the enum from command.h

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:11 -06:00
Joe Hershberger
d2eaec6006 net: Remove the bd* parameter from net stack functions
This value is not used by the network stack and is available in the
global data, so stop passing it around.  For the one legacy function
that still expects it (init op on old Ethernet drivers) pass in the
global pointer version directly to avoid changing that interface.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reported-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
(Trival fix to remove an unneeded variable declaration in 4xx_enet.c)
2015-04-18 11:11:11 -06:00
Joe Hershberger
0eb25b6196 common: Make sure arch-specific map_sysmem() is defined
In the case where the arch defines a custom map_sysmem(), make sure that
including just mapmem.h is sufficient to have these functions as they
are when the arch does not override it.

Also split the non-arch specific functions out of common.h

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2015-04-18 11:11:09 -06:00
Simon Glass
ff3e077bd2 dm: pci: Add a uclass for PCI
Add a uclass for PCI controllers and a generic one for PCI devices. Adjust
the 'pci' command and the existing PCI support to work with this new uclass.
Keep most of the compatibility code in a separate file so that it can be
removed one day.

TODO: Add more header file comments to the new parts of pci.h

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-04-16 19:27:43 -06:00
Simon Glass
e564f054af dm: core: Add dev_get_uclass_priv() to access uclass private data
Add a convenience function to access the private data that a uclass stores
for each of its devices. Convert over most existing uses for consistency
and to provide an example for others.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-04-16 19:27:42 -06:00
Simon Glass
cc5e196e03 Correct map_sysmem() logic in do_mem_mw()
This function does not unmap what it maps. Correct it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-04-16 19:27:41 -06:00
Simon Glass
d4c671cc27 dm: Add a new CPU init function which can use driver model
Since driver model is set up after arch_cpu_init(), that function cannot
use drivers. Add a new arch_cpu_init_dm() function which is called
immediately after driver model is ready, and can reference devices.

This can be used to probe essential devices for the CPU.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2015-04-16 19:27:41 -06:00
Paul Kocialkowski
a32d279129 fastboot: Proper download gadget unregister and clear when cable is missing
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-04-14 10:19:05 +02:00
Michael Scott
8a41802f21 fastboot: check for alias when looking up partition by name
Implement an alias name check for devices where GPT limitations prevent
user-friendly partition names such as "boot", "system" and "cache". Or,
where the actual partition name doesn't match a standard partition name
used commonly with fastboot.

To set an alias, add an environment setting as follows:
fastboot_partition_alias_<alias partition name>=<actual partition name>

Example: fastboot_partition_alias_boot=LNX

Signed-off-by: Michael Scott <michael.scott@linaro.org>
Acked-by: Steve Rae <srae@broadcom.com>
Cc: Steve Rae <srae@broadcom.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14 10:19:04 +02:00
Heiko Schocher
0a9ac5cb5e dfu: cmd: trigger watchdog before calling usb_gadget_handle_interrupts
trigger watchdog before calling usb_gadget_handle_interrupts()
This prevents board resets when calling dfu command on boards
which have a watchdog.

Signed-off-by: Heiko Schocher <hs@denx.de>
[ Reedition by Lukasz Majewski <l.majewski@samsung.com> to apply to
v2014.04 release ]
2015-04-14 10:18:49 +02:00
Fabio Estevam
ee02a65e99 cmd_usb_mass_storage: Use 'USB Mass Storage' in the help text
USB Mass Storage is the standard name, so let's use it here.

Suggested-by: Soeren Moch <smoch@web.de>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Marek Vasut <marex@denx.de>
2015-04-14 09:50:47 +02:00
Inha Song
d281730f9c usb: gadget: thor: Invoke board specific USB cleanup interface
This patch invokes board-specific USB cleanup (board_usb_cleanup)
function in the thor gadget.

Signed-off-by: Inha Song <ideal.song@samsung.com>
2015-04-14 05:48:11 +02:00
Inha Song
375f2d785c usb: gadget: UMS: Invoke board specific USB cleanup interface
This patch invokes board-specific USB cleanup (board_usb_cleanup)
function in the mass storage gadget

Signed-off-by: Inha Song <ideal.song@samsung.com>
2015-04-14 05:48:11 +02:00
Kishon Vijay Abraham I
2d48aa69bd usb: modify usb_gadget_handle_interrupts to take controller index
Since we support multiple dwc3 controllers to be existent at the same
time, in order to handle the interrupts of a particular dwc3 controller
usb_gadget_handle_interrutps should take controller index as an
argument.

Hence the API of usb_gadget_handle_interrupts is modified to take
controller index as an argument and made the corresponding changes to all
the usb_gadget_handle_interrupts calls.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14 05:48:11 +02:00
Kishon Vijay Abraham I
db378d786d common: cmd_dfu: invoke board_usb_cleanup() for cleaning up
Invoked board_usb_cleanup for cleaning up initialized USB. It
will be invoked if the user enterts ctrl-C.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
2015-04-14 05:48:11 +02:00
Tim Harvey
319418c01c usb: hub: allow pgood_delay to be specified via env
Some USB devices break the spec and require longer warm-up times. Allow
the usb_pgood_delay env variable to override the calculated time.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
2015-04-14 05:47:48 +02:00
Stephen Warren
25c0673635 usb: fix first descriptor fetch error handling
When fetching the first descriptor from a new device, only validate that
we received at least 8 bytes, not that we received the entire descriptor.
The reasoning is:
- The code only uses fields in the first 8 bytes, so that's all we need
  to have fetched at this stage.
- The smallest maxpacket size is 8 bytes. Before we know the actual
  maxpacket the device uses, the USB controller may only accept a single
  packet (see the DWC2 note in the comment added in the commit).
  Consequently we are only guaranteed to receive 1 packet (at least 8
  bytes) even in a non-error case.

Fixes: 1a7758044b04 ("usb: Early failure when the first descriptor read
fails or is invalid")
Cc: Paul Kocialkowski <contact@paulk.fr>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
2015-04-14 05:47:48 +02:00
Paul Kocialkowski
04ee6ee2ca usb: Early failure when the first descriptor read fails or is invalid
This may happen when using an USB1 device on a controller that only supports
USB2 (e.g. EHCI). Reading the first descriptor will fail (read 0 byte), so we
can abort the process at this point instead of failing later and wasting time.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-04-14 05:47:48 +02:00
Paul Kocialkowski
8879be8857 usb: Check usb_new_device for failure
This checks that a new USB device is correctly initialized and frees it if not.
In addition, this doesn't report that USB was started when no device was found.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-04-14 05:47:48 +02:00
Paul Kocialkowski
5a80b3449b usb: usb_new_device return codes consistency
This makes use of errno return codes for representing error codes in a unified
way.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
2015-04-14 05:47:48 +02:00
Sergey Temerkhanov
f657087134 usb_storage:Fix USB storage capacity detection on 64 bit architectures
This patch fixes USB storage capacity detection breakage on 64-bit systems
which arises due to 'unsigned long' length difference. Old code assumes that
to be 32 bit and breaks because of inappropriate response buffer layout.
Also this fixes a number of build warnings and changes big-endian values
treatment style to be architecture-independent

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
2015-04-14 05:47:48 +02:00
Franck Jullien
cd749658d5 usb_storage : scan all interfaces to find a storage device
Mass storage is not necessary present on interface 0. This
patch allow usb_stor_scan to look in every available interface.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
2015-04-14 05:47:47 +02:00