]> git.kernelconcepts.de Git - karo-tx-uboot.git/log
karo-tx-uboot.git
8 years agosunxi: Update selects in arch/arm/Kconfig for DM conversions
Tom Rini [Tue, 30 Jun 2015 20:51:15 +0000 (16:51 -0400)]
sunxi: Update selects in arch/arm/Kconfig for DM conversions

With certain features being convert to DM now we want sunxi to default
to having DM enabled for ETH/SERIAL and USB in some cases.

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Ian Campbell <ijc@hellion.org.uk>
Signed-off-by: Tom Rini <trini@konsulko.com>
[hdegoede@redhat.com: Also select CONFIG_USB for all sunxi builds]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Reviewed-by: Simon Glass <sjg@chromium.org>
8 years agosunxi: Remove bogus uart entry from utoo-p66 dts file
Hans de Goede [Sat, 25 Jul 2015 09:20:38 +0000 (11:20 +0200)]
sunxi: Remove bogus uart entry from utoo-p66 dts file

At one point in time the utoo-p66 dts file in the kernel had a bogus
uart entry, and it seems like we synced with the kernel at just the wrong
moment.

This commit removes the bogus uart entry, which breaks booting the utoo-p66
when DM_SERIAL=y.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8 years agousb: ci_udc: fix request allocation when endpoints are disabled
Rob Herring [Fri, 24 Jul 2015 15:14:21 +0000 (10:14 -0500)]
usb: ci_udc: fix request allocation when endpoints are disabled

The ci_udc driver request allocation assumes that the endpoint descriptor
pointer is set to retrieve the endpoint number, but that is only true
when the endpoint is enabled. This results in a NULL ptr dereference
which for me happens to return 0 value. This causes the EP0 request
struct to be returned for other endpoints. Some gadget drivers like
fastboot and USB MS work fine, but ethernet does not.

Really, the ci_udc driver is the oddball here doing this EP0 special
case handling Stephen added. All the other drivers alloc/free functions
are pretty much the same with the only variation being the size of the
private struct. This could all be consolidated to a common function.

Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Marek Vasut <marex@denx.de>
Acked-by: Stephen Warren <swarren@nvidia.com>
8 years agosunxi: spl: Remove redundant check from `board_mmc_init` for signature
Daniel Kochmański [Fri, 29 May 2015 15:21:00 +0000 (17:21 +0200)]
sunxi: spl: Remove redundant check from `board_mmc_init` for signature

Remove the boot signature check from board_mmc_init() in spl mode, as it
is already done in spl_boot_device() in this case, and update the comments
to reflect this.

Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
CC: Roy Spliet <r.spliet@ultimaker.com>
Cc: Ian Campbell <ijc@hellion.org.uk>
[hdegoede@redhat.com: Disable the check only for SPL instead of always]
Acked-by: Hans De Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8 years agosunxi: spl: Detect at runtime where SPL was read from
Daniel Kochmański [Fri, 29 May 2015 14:55:42 +0000 (16:55 +0200)]
sunxi: spl: Detect at runtime where SPL was read from

Make possible using a single `u-boot-sunxi-with-spl.bin` binary for both NAND
memory and SD card. Detection where SPL was read from is implemented in
`spl_boot_device`.

Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
CC: Roy Spliet <r.spliet@ultimaker.com>
Cc: Ian Campbell <ijc@hellion.org.uk>
[hdegoede@redhat.com: Some small coding style fixes]
Acked-by: Hans De Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8 years agosunxi: Create helper function veryfing valid boot signature on MMC
Daniel Kochmański [Fri, 29 May 2015 14:55:41 +0000 (16:55 +0200)]
sunxi: Create helper function veryfing valid boot signature on MMC

This patch extracts checking for valid SD card "eGON.BT0" signature from
`board_mmc_init` into function `sunxi_mmc_has_egon_boot_signature`.

Buffer for mmc sector is allocated and freed at runtime. `panic` is
triggered on malloc failure.

Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
CC: Roy Spliet <r.spliet@ultimaker.com>
Cc: Ian Campbell <ijc@hellion.org.uk>
[hdegoede@redhat.com: Small bugfix to make it work for devs other then mmc0]
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8 years agommc: Protect `mmc_initialize` from initialising mmc multiple times
Daniel Kochmański [Fri, 29 May 2015 14:55:43 +0000 (16:55 +0200)]
mmc: Protect `mmc_initialize` from initialising mmc multiple times

`mmc_initialize` might be called multiple times leading to the mmc-controllers
being initialised twice, and initialising the `mmc_devices` list head twice
which may lead to memory leaks.

Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
CC: Roy Spliet <r.spliet@ultimaker.com>
Cc: Ian Campbell <ijc@hellion.org.uk>
CC: Pantelis Antoniou <panto@antoniou-consulting.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8 years agoarm: marvell: Increase MAXARGS to 32
Stefan Roese [Thu, 23 Jul 2015 08:26:11 +0000 (10:26 +0200)]
arm: marvell: Increase MAXARGS to 32

This makes more complex U-Boot scripts possible.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
8 years agoarm: mvebu: db-88f6820-gp: Add SDIO/MMC SPL boot support
Stefan Roese [Mon, 20 Jul 2015 09:20:40 +0000 (11:20 +0200)]
arm: mvebu: db-88f6820-gp: Add SDIO/MMC SPL boot support

This patch adds the configuration options to boot via SDIO/MMC on the
Marvell DB-88F6820-GP Armada A38x board. The default boot device
is still SPI NOR flash.

To enable MMC booting on this board 2 things need to be changes:
a) Change kwbimage.cfg
   BOOT_FROM   sdio
b) In the config header select
   #define CONFIG_SPL_BOOT_DEVICE SPL_BOOT_SDIO_MMC_CARD

The generated image needs to be copied to the first bootable MMC
partition:

dd if=u-boot-spl.kwb of=/dev/sdX1

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Dirk Eibach <eibach@gdsys.de>
8 years agospl: spl_mmc: Add option to boot from a MMC partition with offset
Stefan Roese [Mon, 20 Jul 2015 09:20:39 +0000 (11:20 +0200)]
spl: spl_mmc: Add option to boot from a MMC partition with offset

This patch introduces the option to boot from a MMC card parition with
an offset. This can be done by using both defines together:

define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION 1
define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR    ((160 << 10) / 512)

The example above loads the main U-Boot at offset 160KiB from the MMC
partition 1.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Dirk Eibach <eibach@gdsys.de>
Cc: Tom Rini <trini@konsulko.com>
8 years agokwbimage: Rename CONFIG_SYS_SPI_U_BOOT_OFFS to CONFIG_SYS_U_BOOT_OFFS
Stefan Roese [Mon, 20 Jul 2015 09:20:38 +0000 (11:20 +0200)]
kwbimage: Rename CONFIG_SYS_SPI_U_BOOT_OFFS to CONFIG_SYS_U_BOOT_OFFS

To use this offset for other boot device (like SDIO/MMC), lets rename
it to a more generic name. This will be used be the SDIO/MMC SPL boot
support for the A38x.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Dirk Eibach <eibach@gdsys.de>
8 years agokwbimage: Add support for SDIO/MMC boot device selection
Stefan Roese [Mon, 20 Jul 2015 09:20:37 +0000 (11:20 +0200)]
kwbimage: Add support for SDIO/MMC boot device selection

This patch adds support to select the "sdio" as boot device in the
kwbimage.cfg file. This line selects this SDIO device:

BOOT_FROM  sdio

Tested on Marvell DB-88F6820-GP board.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Dirk Eibach <eibach@gdsys.de>
8 years agoarm: mvebu: Add SPL SDIO/MMC boot support
Stefan Roese [Mon, 20 Jul 2015 09:20:36 +0000 (11:20 +0200)]
arm: mvebu: Add SPL SDIO/MMC boot support

This patch adds basic SDIO/MMC booting support to MVEBU SoC's. Since
I don't know of a way to test the boot-device upon runtime, this patch
hardcodes the spl_boot_device instead.

Tested on Marvell DB-88F6820-GP board.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Dirk Eibach <eibach@gdsys.de>
8 years agocommon/lcd_simplefb: Add support for 32bit organized framebuffers
Hannes Petermaier [Fri, 24 Apr 2015 22:30:21 +0000 (00:30 +0200)]
common/lcd_simplefb: Add support for 32bit organized framebuffers

Signed-off-by: Hannes Petermaier <oe5hpm@oevsv.at>
8 years agoARM: UniPhier: document reference support card
Masahiro Yamada [Tue, 21 Jul 2015 05:04:24 +0000 (14:04 +0900)]
ARM: UniPhier: document reference support card

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoARM: dts: UniPhier: add I2C ch4 device node for PH1-sLD3
Masahiro Yamada [Tue, 21 Jul 2015 05:04:23 +0000 (14:04 +0900)]
ARM: dts: UniPhier: add I2C ch4 device node for PH1-sLD3

This I2C device is used SoC-internally for controlling the DMD core.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoARM: UniPhier: add PH1-sLD3 SoC support
Masahiro Yamada [Tue, 21 Jul 2015 05:04:22 +0000 (14:04 +0900)]
ARM: UniPhier: add PH1-sLD3 SoC support

The init code for UMC (Unified Memory Controller) and PLL has not
been mainlined yet, but U-boot proper should work.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoARM: UniPhier: update CONFIG_BOOTARGS
Masahiro Yamada [Tue, 21 Jul 2015 05:04:21 +0000 (14:04 +0900)]
ARM: UniPhier: update CONFIG_BOOTARGS

Both "earlyprintk" and "loglevel=8" should be useful for the
development.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoARM: UniPhier: disable CONFIG_FIT
Masahiro Yamada [Tue, 21 Jul 2015 05:04:20 +0000 (14:04 +0900)]
ARM: UniPhier: disable CONFIG_FIT

To use FIT boot, we have to describe Image Tree Source in addition.
So, it is not intended for beginners.  Disable it by default.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoARM: UniPhier: add environment variable for TFTP boot
Masahiro Yamada [Tue, 21 Jul 2015 05:04:19 +0000 (14:04 +0900)]
ARM: UniPhier: add environment variable for TFTP boot

The command "run tftpboot" downloads some files onto the RAM
via TFTP and boots the kernel.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoARM: UniPhier: add environment sets for non-FIT Linux boot
Masahiro Yamada [Tue, 21 Jul 2015 05:04:18 +0000 (14:04 +0900)]
ARM: UniPhier: add environment sets for non-FIT Linux boot

Currently, the environment variables "norboot" and "nandboot" only
work with CONFIG_FIT, but we do not want to depend on CONFIG_FIT to
boot the kernel.

This commit adds environments useful for booting Linux with separate
uImage + ramdisk + DTB.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoARM: dts: UniPhier: add device-specific compatible string for EEPROM
Masahiro Yamada [Mon, 13 Jul 2015 01:35:34 +0000 (10:35 +0900)]
ARM: dts: UniPhier: add device-specific compatible string for EEPROM

For the record, describe exactly which device of which vendor
is used on this board.

I2C EEPROM is bound by the generic compatible string, "i2c-eeprom",
so this commit has no impact on the functionality.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
8 years agoarm: mvebu: db-88f6820: Add SPL support with DDR init code
Stefan Roese [Wed, 25 Mar 2015 12:35:15 +0000 (13:35 +0100)]
arm: mvebu: db-88f6820: Add SPL support with DDR init code

This patch adds SPL support for the Marvell DB-88F6820-GP board.
With this change, the bin_hdr from the original Marvell U-boot
is not needed any more on this board. The sources from bin_hdr
(SERDES/PHY and DDR setup) are now integrated in mainline
U-Boot. And this patch enables them for this board.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: a38x: Use correct PEX register access macros
Stefan Roese [Mon, 8 Jun 2015 15:01:26 +0000 (17:01 +0200)]
arm: mvebu: a38x: Use correct PEX register access macros

Remove the incorrect PEX macros from the DDR header. And insert the
correct ones in ctrl_pex.h instead.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: Add Armada 38x DDR3 training code from Marvell bin_hdr
Stefan Roese [Thu, 26 Mar 2015 14:36:56 +0000 (15:36 +0100)]
arm: mvebu: Add Armada 38x DDR3 training code from Marvell bin_hdr

This patch adds the DDR3 setup and training code taken from the Marvell
U-Boot repository. This code used to be included as a binary (bin_hdr)
into the Armada A38x boot image. Not linked with the main U-Boot. With this
code addition and the serdes/PHY setup code, the Armada A38x support
in mainline U-Boot is finally self-contained. So the complete image
for booting can be built from mainline U-Boot. Without any additional
external inclusion.

Note:
This code has undergone many hours (days!) of coding-style cleanup and
refactoring. It still is not checkpatch clean though, I'm afraid. As the
factoring of the code has so many levels of indentation that many lines
are longer than 80 chars.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: drivers/ddr: Move Armada XP DDR init code into new directory
Stefan Roese [Wed, 25 Mar 2015 11:51:18 +0000 (12:51 +0100)]
arm: mvebu: drivers/ddr: Move Armada XP DDR init code into new directory

With the upcoming addition of the Armada 38x DDR support, which is not
compatible to the Armada XP DDR init code, we need to introduce a new
directory infrastructure. To support multiple Marvell DDR controller.

This will be the new structure:

     drivers/ddr/marvell/axp
     Supporting Armada XP (AXP) devices (and perhaps Armada 370)

     drivers/ddr/marvell/a38x
     Supporting Armada 38x devices (and perhaps Armada 39x)

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: Add Armada 38x SERDES / PHY init code from Marvell bin_hdr
Stefan Roese [Mon, 20 Apr 2015 07:31:27 +0000 (09:31 +0200)]
arm: mvebu: Add Armada 38x SERDES / PHY init code from Marvell bin_hdr

This code is ported from the Marvell bin_hdr code into mainline
SPL U-Boot. It needs to be executed very early so that the devices
connected to the serdes PHY are configured correctly.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: serdes: Move Armada XP SERDES / PHY init code into new directory
Stefan Roese [Mon, 20 Apr 2015 07:28:12 +0000 (09:28 +0200)]
arm: mvebu: serdes: Move Armada XP SERDES / PHY init code into new directory

With the upcoming addition of the Armada 38x SPL support, which is not
compatible to the Armada XP SERDES init code, we need to introduce a new
directory infrastructure. So lets move the AXP serdes init code into
a new directory. This way the A38x code can be added in a clean way.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoMakefile: Fix mvebu build target to use SPL load and exe-address
Stefan Roese [Mon, 20 Apr 2015 09:17:16 +0000 (11:17 +0200)]
Makefile: Fix mvebu build target to use SPL load and exe-address

The u-boot-spl.kwb build target needs the SPL text-base
(CONFIG_SPL_TEXT_BASE) as load and execution address.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: Disable MMU before changing register base address
Stefan Roese [Fri, 24 Apr 2015 08:49:11 +0000 (10:49 +0200)]
arm: mvebu: Disable MMU before changing register base address

Only with disabled MMU its possible to switch the base register address on
Armada 38x. Without this the SDRAM located at >= 0x4000.0000 is also not
accessible, as its still locked to cache.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: spl.c: Add call to board_early_init_f()
Stefan Roese [Fri, 17 Apr 2015 16:13:06 +0000 (18:13 +0200)]
arm: mvebu: spl.c: Add call to board_early_init_f()

Pin muxing needs to be done before UART output, since on A38x the UART
pins need some re-muxing for output to work.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoarm: mvebu: Use default reg base address for SPL on A38x
Stefan Roese [Fri, 17 Apr 2015 16:12:41 +0000 (18:12 +0200)]
arm: mvebu: Use default reg base address for SPL on A38x

On A38x switching the regs base address without running from
SDRAM doesn't seem to work. So let the SPL still use the
default base address and switch to the new address in the
mail u-boot later.

Signed-off-by: Stefan Roese <sr@denx.de>
8 years agoci_udc: fix 64-bit compile warnings
Stephen Warren [Wed, 22 Jul 2015 21:16:20 +0000 (15:16 -0600)]
ci_udc: fix 64-bit compile warnings

This is the same as f72d8320b605 "usb: ci_udc: fix warnings on 64-bit
builds", but more.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
8 years agoarm: mvebu: Call timer_init early before PHY and DDR init
Stefan Roese [Wed, 15 Jul 2015 13:36:52 +0000 (15:36 +0200)]
arm: mvebu: Call timer_init early before PHY and DDR init

Without calling timer_init(), the xdelay() functions return immediately.
We need to call timer_init() early, so that these functions work and
the PHY and DDR init code works correctly.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Anton Schubert <anton.schubert@gmx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
8 years agoarm: mvebu: add Armada XP SATA support
Anton Schubert [Wed, 15 Jul 2015 12:50:05 +0000 (14:50 +0200)]
arm: mvebu: add Armada XP SATA support

This patch initializes the SATA address windows on Armada XP and
allows it to work with the existing mvsata_ide driver.
It also adds the necessary configuration for the db-mv784mp-gp board.

Signed-off-by: Anton Schubert <anton.schubert@gmx.de>
Tested-by: Stefan Roese <sr@denx.de>
Cc: Luka Perkov <luka.perkov@sartura.hr>
8 years agolinux_compat: handle __GFP_ZERO in kmalloc()
Masahiro Yamada [Mon, 13 Jul 2015 04:17:07 +0000 (13:17 +0900)]
linux_compat: handle __GFP_ZERO in kmalloc()

Currently, kzalloc() returns zero-filled memory, while kmalloc()
simply ignores the second argument and never fills the memory
area with zeros.

I want kmalloc(size, __GFP_ZERO) to behave as kzalloc() does,
which will make it easier to add more memory allocator variants.

With the introduction of __GFP_ZERO flag, going forward, kzmalloc()
variants can fall back to kmalloc() enabling the __GFP_ZERO flag.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
8 years agolinux_compat: move vzalloc() to header file as an inline function
Masahiro Yamada [Mon, 13 Jul 2015 04:17:06 +0000 (13:17 +0900)]
linux_compat: move vzalloc() to header file as an inline function

The vzalloc(size) is equivalent to kzalloc(size, 0).  Move it to
include/linux/compat.h as an inline function in order to avoid the
function call overhead.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agolinux_compat: remove cpu_relax() define
Masahiro Yamada [Mon, 13 Jul 2015 04:17:05 +0000 (13:17 +0900)]
linux_compat: remove cpu_relax() define

The macro cpu_relax() is defined by several headers in different
ways.

arch/{arm,avr32,mips}/include/asm/processor.h defines it as follows:
  #define cpu_relax() barrier()

On the other hand, include/linux/compat.h defines it as follows:
  #define cpu_relax() do {} while (0)

If both headers are included from the same source file, the warning
  warning: "cpu_relax" redefined [enabled by default]
is displayed.

It effectively makes it impossible to include <linux/compat.h>
from some sources.  Drop the latter.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Acked-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
8 years agox86: delete unneeded declarations of disable_irq() and enable_irq()
Masahiro Yamada [Mon, 13 Jul 2015 04:17:04 +0000 (13:17 +0900)]
x86: delete unneeded declarations of disable_irq() and enable_irq()

These two declarations in arch/x86/include/asm/interrupt.h conflict
with ones in include/linux/compat.h, so x86 boards cannot include
<linux/compat.h>.

The comment /* arch/x86/lib/interrupts.c */ is bogus now, and we do
not see any definitions of disable_irq() and enable_irq() in there.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agousb: ehci-marvell: Drop wrl accessor function
Stefan Roese [Wed, 22 Jul 2015 08:01:30 +0000 (10:01 +0200)]
usb: ehci-marvell: Drop wrl accessor function

This patch removes the wrl accessor function from the Marvell EHCI
driver by replacing it with the writel function.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Marek Vasut <marex@denx.de>
8 years agousb: CONFIG_USB_FASTBOOT prefix replacement for consistency
Paul Kocialkowski [Mon, 20 Jul 2015 10:38:22 +0000 (12:38 +0200)]
usb: CONFIG_USB_FASTBOOT prefix replacement for consistency

FASTBOOT is defined both by CONFIG_USB_FUNCTION_FASTBOOT AND CONFIG_CMD_FASTBOOT, so it doesn't
make much sense to have a CONFIG_USB_FASTBOOT prefix for fastboot-specific options, especially
given that other config options for fastboot use the CONFIG_FASTBOOT prefix.

This replaces the CONFIG_USB_FASTBOOT prefix with CONFIG_FASTBOOT, for consistency.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
8 years agoimplement Fastboot via USB OTG on bcm28155_ap boards
Jiandong Zheng [Thu, 9 Jul 2015 21:26:40 +0000 (14:26 -0700)]
implement Fastboot via USB OTG on bcm28155_ap boards

Signed-off-by: Jiandong Zheng <jdzheng@broadcom.com>
Signed-off-by: Steve Rae <srae@broadcom.com>
8 years agousb: gadget: bcm_udc_otg files
Jiandong Zheng [Thu, 9 Jul 2015 21:26:39 +0000 (14:26 -0700)]
usb: gadget: bcm_udc_otg files

Add the required files for the Broadcom UDC OTG interface.

Signed-off-by: Jiandong Zheng <jdzheng@broadcom.com>
Signed-off-by: Steve Rae <srae@broadcom.com>
8 years agog_dnl: add missing declaration
Steve Rae [Thu, 9 Jul 2015 21:26:38 +0000 (14:26 -0700)]
g_dnl: add missing declaration

Signed-off-by: Steve Rae <srae@broadcom.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Exynos 4210 (trats), Exynos 5422 (Odroid XU3)

8 years agousb: gadget: fastboot: Dequeue the previous IN request for the current request
Paul Kocialkowski [Sat, 4 Jul 2015 14:46:16 +0000 (16:46 +0200)]
usb: gadget: fastboot: Dequeue the previous IN request for the current request

Recent versions of the fastboot tool will query the partition type before doing
an operation on a partition (such as erase, flash, etc). It will then submit
the operation as soon as the response for the partition type is received.

Usually, the MUSB controller will see that the partition type request return
status was read by the host at the very same time as the actual operation
request is submitted by the host. However, the operation will be read first
(int_rx is handled first in musb_interrupt) and after it is completed, the
fastboot USB gadget driver will send another return status. Hence, this happens
before the musb gadget framework has had a chance to handle the previous
acknowledgement that the host read the return status and dequeue the request.

The host will then usually empty the FIFO by the time musb_interrupt gets around
handling the return status acknowledgement (for the previous request, this is
still on the same musb_interrupt call), so no other interrupt is generated and
the most recent return status acknowledgement remains unaccounted for.

It will then be used as a response for the next command, and the proper response
for it will be delayed to the next command, and so on.

Dequeuing the previous IN request in the fastboot code ensures that no previous
return status remains. It is acceptable to do it since there is no callback to
it anyways.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
8 years agousb: gadget: fastboot: Request status and length check in rx handler
Paul Kocialkowski [Sat, 4 Jul 2015 14:46:15 +0000 (16:46 +0200)]
usb: gadget: fastboot: Request status and length check in rx handler

This avoids handling requests that have an error status or no data.
In particular, this avoids showing unnecessary error messages when the USB
gadget gets disconnected (e.g. with fastboot continue) and the fastboot USB
gadget driver sends an error back to the host (that has disconnected already).

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
8 years agofastboot: Dynamic controller index for usb_gadget_handle_interrupts
Paul Kocialkowski [Sun, 24 May 2015 09:41:04 +0000 (11:41 +0200)]
fastboot: Dynamic controller index for usb_gadget_handle_interrupts

Since we're now using a dynamic controller index for fastboot too,
usb_gadget_handle_interrupts should be using it instead of 0 (despite the fact
that it's currently not being used at all in the musb-new implementation).

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
8 years agousb: gadget: Weak board_usb_init/cleanup definitions in USB download gadget code
Paul Kocialkowski [Fri, 12 Jun 2015 17:57:01 +0000 (19:57 +0200)]
usb: gadget: Weak board_usb_init/cleanup definitions in USB download gadget code

Weak versions of board_usb_init and board_usb_cleanup are defined in common USB
host code, but it is also used for USB device gadgets, so we also need a weak
definition of it when there is no USB host enabled.
Both weak definitions do not conflict.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Odroid_XU3 (Exynos5422), trats (Exynos4210)

8 years agousb: board_usb_init and board_usb_cleanup calls in the fastboot command
Paul Kocialkowski [Fri, 12 Jun 2015 17:57:00 +0000 (19:57 +0200)]
usb: board_usb_init and board_usb_cleanup calls in the fastboot command

Each USB download function command calls board_usb_init before registering the
USB gadget and board_usb_cleanup after de-registering it. On devices currently
using fasboot, musb-new is usually initialized earlier, but some other boards
might need the board_usb_init call to properly initialize musb-new.

This requires adding an argument (the USB controller index) to the fastboot
command, as it is currently done with other USB download gadget functions.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Odroid_XU3 (Exynos5422), trats (Exynos4210)

8 years agousb: Fastboot function config for better consistency with other functions
Paul Kocialkowski [Fri, 12 Jun 2015 17:56:59 +0000 (19:56 +0200)]
usb: Fastboot function config for better consistency with other functions

USB download gadget functions such as thor and dfu have a separate config option
for the USB gadget part of the code, independent from the command part.
This switches the fastboot USB gadget to the same scheme, for better
consistency.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Odroid_XU3 (Exynos5422), trats (Exynos4210)

8 years agousb: USB download gadget and functions config options coherent naming
Paul Kocialkowski [Fri, 12 Jun 2015 17:56:58 +0000 (19:56 +0200)]
usb: USB download gadget and functions config options coherent naming

This introduces a coherent scheme for naming USB download gadget and functions
config options. The download USB gadget config option is moved to
CONFIG_USB_GADGET_DOWNLOAD for better consistency with other gadgets and each
function's config option is moved to a CONFIG_USB_FUNCTION_ prefix.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Odroid_XU3 (Exynos5422), trats (Exynos4210)

8 years agodrivers: usb: fsl: Remove LS102XA immap inclusion
Nikhil Badola [Wed, 24 Jun 2015 05:22:48 +0000 (10:52 +0530)]
drivers: usb: fsl: Remove LS102XA immap inclusion

Remove LS102XA immap header inclusion from xhci fsl driver.
It removes redefinition warnings when built for platforms
other than LS102XA

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
8 years agoinclude: usb: Map USB controller base addresses for LS2085A
Nikhil Badola [Tue, 23 Jun 2015 03:48:20 +0000 (09:18 +0530)]
include: usb: Map USB controller base addresses for LS2085A

Map USB XHCI controller base addresses for LS2085A SOC

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
8 years agoinclude: usb: Move USB controller base address mapping
Nikhil Badola [Tue, 23 Jun 2015 03:48:03 +0000 (09:18 +0530)]
include: usb: Move USB controller base address mapping

Move USB controller Base address mapping from ls102xa immap
to fsl xhci header. This is required to remove any warnings when
controller base addresses are mapped for multiple platforms
in their respective files.

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
8 years agodrivers: usb: fsl: Implement Erratum A-009116 for XHCI controller
Nikhil Badola [Tue, 23 Jun 2015 03:47:49 +0000 (09:17 +0530)]
drivers: usb: fsl: Implement Erratum A-009116 for XHCI controller

This adjusts (micro)frame length to appropriate value thus
avoiding USB devices to time out over a longer run

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
8 years agodrivers: usb: fsl: Remove warnings for 64-bit architectures
Nikhil Badola [Tue, 23 Jun 2015 03:47:32 +0000 (09:17 +0530)]
drivers: usb: fsl: Remove warnings for 64-bit architectures

Replace uint32_t with uintptr_t to remove compilation
warnings for 64-bit architectures.

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
8 years agols1021aqds: Enable USB IP support
Ramneek Mehresh [Fri, 29 May 2015 09:17:22 +0000 (14:47 +0530)]
ls1021aqds: Enable USB IP support

Enable USB IP support for both EHCI and XHCI for
ls1021aqds platform

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agols1021atwr: Enable USB IP support
Ramneek Mehresh [Fri, 29 May 2015 09:17:21 +0000 (14:47 +0530)]
ls1021atwr: Enable USB IP support

Enable USB IP support for both EHCI and XHCI for
ls1021atwr platform

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agoarch: arm: fsl: Add XHCI support for LS1021A
Ramneek Mehresh [Fri, 29 May 2015 09:17:20 +0000 (14:47 +0530)]
arch: arm: fsl: Add XHCI support for LS1021A

Add base register address information for USB
XHCI controller on LS1021A

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agousb: fsl: Add XHCI driver support
Ramneek Mehresh [Fri, 29 May 2015 09:17:19 +0000 (14:47 +0530)]
usb: fsl: Add XHCI driver support

Add xhci driver support for all FSL socs

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agousb: xhci: keystone: Remove common dwc3 drv functions calls
Ramneek Mehresh [Fri, 29 May 2015 09:17:18 +0000 (14:47 +0530)]
usb: xhci: keystone: Remove common dwc3 drv functions calls

Remove all redundant dwc3 driver function calls that
are defined by dwc3 driver

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agousb: xhci: omap: Remove common dwc3 drv functions calls
Ramneek Mehresh [Fri, 29 May 2015 09:17:17 +0000 (14:47 +0530)]
usb: xhci: omap: Remove common dwc3 drv functions calls

Remove all redundant dwc3 driver function calls that
are defined by dwc3 driver

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agousb: xhci: exynos: Remove common dwc3 drv functions calls
Ramneek Mehresh [Fri, 29 May 2015 09:17:16 +0000 (14:47 +0530)]
usb: xhci: exynos: Remove common dwc3 drv functions calls

Remove all redundant dwc3 driver function calls that
are defined by dwc3 driver

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agousb: dwc3: Add DWC3 controller driver support
Ramneek Mehresh [Fri, 29 May 2015 09:17:15 +0000 (14:47 +0530)]
usb: dwc3: Add DWC3 controller driver support

Add support for DWC3 XHCI controller driver

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
8 years agonet: Allow drivers to return -ENOSYS with the write_hwaddr() method
Simon Glass [Mon, 6 Jul 2015 22:47:55 +0000 (16:47 -0600)]
net: Allow drivers to return -ENOSYS with the write_hwaddr() method

Some drivers may want to implement this method for some of their devices but
not for others. So it is not possible to just leave the operation out of
the table. Drivers could get around this by masquerading as two separate
drivers but that seems unpleasant.

Allow the driver to return an error when it does not want to process the
write_hwaddr() method.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: eth: Add driver-model support to the asix driver
Simon Glass [Mon, 6 Jul 2015 22:47:54 +0000 (16:47 -0600)]
dm: usb: eth: Add driver-model support to the asix driver

This USB Ethernet driver is quite widely use. Allow it to work with
CONFIG_DM_ETH enabled. Most of the code remains common but there is a new
packet receive flow which is handled specially.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Add driver-model support to ehci-pci
Simon Glass [Mon, 6 Jul 2015 22:47:53 +0000 (16:47 -0600)]
dm: usb: Add driver-model support to ehci-pci

Support driver model in this driver. This uses the normal USB driver search
mechanism. Any EHCI controllers will be set up as they are found during
usb_init().

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
8 years agox86: minnowmax: Drop the cache line size hack
Simon Glass [Mon, 6 Jul 2015 22:47:52 +0000 (16:47 -0600)]
x86: minnowmax: Drop the cache line size hack

Now that the RTL8169 driver warning is fixed we can drop this. The incorrect
value is causing problems with USB EHCI.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
8 years agodm: usb: Adjust the USB_DEVICE() macro naming
Simon Glass [Mon, 6 Jul 2015 22:47:51 +0000 (16:47 -0600)]
dm: usb: Adjust the USB_DEVICE() macro naming

In Linux USB_DEVICE() is used to declare a USB device by vendor/device ID.
We should follow the same convention in U-Boot. Rename the existing
USB_DEVICE() macro to U_BOOT_USB_DEVICE() and bring in the USB_DEVICE()
macro from Linux for use in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: eth: Support driver model with USB Ethernet
Simon Glass [Mon, 6 Jul 2015 22:47:50 +0000 (16:47 -0600)]
dm: usb: eth: Support driver model with USB Ethernet

At present USB Ethernet does not work with CONFIG_DM_ETH. Add driver model
support to this feature, so that it can work alongside other Ethernet
devices with driver model.

It was found that quite a bit of code is common in most of the USB Ethernet
drivers. Add this code to the common layer to reduce the amount of duplicate
code needed in USB Ethernet drivers when CONFIG_DM_ETH is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
8 years agodm: eth: Avoid blocking on packet reception
Simon Glass [Mon, 6 Jul 2015 22:47:49 +0000 (16:47 -0600)]
dm: eth: Avoid blocking on packet reception

Some devices can take a long time to work out whether they have a new packet
or now. For example the ASIX USB Ethernet dongle can take 5 seconds to do
this, since it waits until it gets a new packet on the wire before allowing
the USB bulk read packet to be submitted.

At present with driver mode the Ethernet receive code reads 32 packets. This
can take a very long time if we must wait for all 32 packets. The old code
(before driver model) worked by reading a single set of packets from the USB
device, then processing all the packets with in. It would be nice to use
the same behaviour with driver model.

Add a flag to the receive method which indicates that the driver should try
to find a packet if available, by consulting the hardware. When the flag is
not set, it should just return any packet data it has already received. If
there is none, it should return -EAGAIN so that the loop will terminate.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Avoid using USB ethernet with CONFIG_DM_USB and no DM_ETH
Simon Glass [Mon, 6 Jul 2015 22:47:48 +0000 (16:47 -0600)]
dm: usb: Avoid using USB ethernet with CONFIG_DM_USB and no DM_ETH

If driver model is used for Ethernet then USB Ethernet does not build. This
can be made to work with driver model is used for USB also. Add #ifdef logic
to make this clear when building.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
8 years agodm: usb: Correct the struct usb_driver_entry comment
Simon Glass [Mon, 6 Jul 2015 22:47:47 +0000 (16:47 -0600)]
dm: usb: Correct the struct usb_driver_entry comment

The function documentation is incorrect. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Marek Vasut <marex@denx.de>
8 years agodm: pci: Add a function to get the BDF for a device
Simon Glass [Mon, 6 Jul 2015 22:47:46 +0000 (16:47 -0600)]
dm: pci: Add a function to get the BDF for a device

It is useful to be able to find the full PCI address (bus, device and
function) for a PCI device. Add a function to provide this.

Adjust the existing code to use this.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: eth: Add driver-model support to the rtl8169 driver
Simon Glass [Mon, 6 Jul 2015 22:47:45 +0000 (16:47 -0600)]
dm: eth: Add driver-model support to the rtl8169 driver

This driver is used by the Intel Minnowmax board. Convert it to driver model
so it can use the new Ethernet implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: pci: Add support for PCI driver matching
Simon Glass [Mon, 6 Jul 2015 22:47:44 +0000 (16:47 -0600)]
dm: pci: Add support for PCI driver matching

At present all PCI devices must be present in the device tree in order to
be used. Many or most PCI devices don't require any configuration other than
that which is done automatically by U-Boot. It is inefficent to add a node
with nothing but a compatible string in order to get a device working.

Add a mechanism whereby PCI drivers can be declared along with the device
parameters they support (vendor/device/class). When no suitable driver is
found in the device tree the list of such devices is consulted to determine
the correct driver. If this also fails, then a generic driver is used as
before.

The mechanism used is very similar to that provided by Linux and the header
file defintions are copied from Linux 4.1.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
8 years agousb: Update some EHCI driver licenses to use SPDX
Simon Glass [Mon, 6 Jul 2015 22:47:42 +0000 (16:47 -0600)]
usb: Update some EHCI driver licenses to use SPDX

A few drivers still write out the license in full. Fix these.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Marek Vasut <marex@denx.de>
8 years agousb: ehci: Correct a missing hypen in an error message
Simon Glass [Mon, 6 Jul 2015 22:47:41 +0000 (16:47 -0600)]
usb: ehci: Correct a missing hypen in an error message

Add a hyphen to correct the grammar.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: core: Add \n to two dm_warn() messages
Simon Glass [Mon, 6 Jul 2015 22:47:40 +0000 (16:47 -0600)]
dm: core: Add \n to two dm_warn() messages

These should finish with a newline like the others.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agomusb: Add device-model support to the musb-host u-boot glue
Hans de Goede [Wed, 17 Jun 2015 19:33:58 +0000 (21:33 +0200)]
musb: Add device-model support to the musb-host u-boot glue

Add device-model support to the musb-host u-boot glue, note this only
adds device-model support to the musb-core glue code, it does not add
support for device-model to any of the SoC specific musb glue code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agomusb: Add musb_host_data struct to hold global data
Hans de Goede [Wed, 17 Jun 2015 19:33:57 +0000 (21:33 +0200)]
musb: Add musb_host_data struct to hold global data

Add a musb_host_data struct to hold all the global data host related musb
data. This is a preparation patch for adding device-model support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agomusb: Rename and wrap public functions
Hans de Goede [Wed, 17 Jun 2015 19:33:56 +0000 (21:33 +0200)]
musb: Rename and wrap public functions

Rename and wrap the usb host API public functions, this is a preparation
patch for adding device-model support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agomusb: Update usb-compat to work with struct usb_device without a parent ptr
Hans de Goede [Wed, 17 Jun 2015 19:33:55 +0000 (21:33 +0200)]
musb: Update usb-compat to work with struct usb_device without a parent ptr

When building with CONFIG_DM_USB=y struct usb_device does not have a parent
pointer. This commit adds support to the musb code to deal with this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agomusb: Allow musb_platform_enable to return an error code
Hans de Goede [Wed, 17 Jun 2015 19:33:54 +0000 (21:33 +0200)]
musb: Allow musb_platform_enable to return an error code

Allow musb_platform_enable to return an error code and propagate it up to
usb_lowlevel_init().

This allows moving the checks for an external vbus being present to be
moved from platform_init to platform_enable, so that the user can unplug a
charger, plug in a host adapter with a usb-device, do a "usb reset" and
have things working.

This also allows adding a check for the id-pin to platform_enable, so that
it can short circuit the 1s delay in usb_lowlevel_init() when no host cable
is plugged in and thus waiting for a device to show up is useless.

Note that all the changes to code shared with the kernel are wrapped in
the kernel.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Do not assume that first child is always a hub
Hans de Goede [Wed, 17 Jun 2015 19:33:53 +0000 (21:33 +0200)]
dm: usb: Do not assume that first child is always a hub

On some single port (otg) controllers there is no emulated root hub, so
the first child (if any) may be one of: UCLASS_MASS_STORAGE,
UCLASS_USB_DEV_GENERIC or UCLASS_USB_HUB.

All three of these (and in the future others) are suitable for our
purposes, remove the check for the device being a hub, and add a check to
deal with the fact that there may be no child-dev.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Allow usb host drivers to implement usb_reset_root_port
Hans de Goede [Wed, 17 Jun 2015 19:33:52 +0000 (21:33 +0200)]
dm: usb: Allow usb host drivers to implement usb_reset_root_port

Allow usb uclass host drivers to implement usb_reset_root_port, this is
used by single port usb hosts which do not emulate a hub, such as otg
controllers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Rename usb_find_child to usb_find_emul_child
Hans de Goede [Wed, 1 Jul 2015 18:53:01 +0000 (20:53 +0200)]
dm: usb: Rename usb_find_child to usb_find_emul_child

Now that we unbind usb devices from usb_stop() usb_find_child() is
only necessary to deal with emulated usb devices.

Rename it to make this clear and add a #ifdef to make it a nop in
other cases.

Note the #ifdef turns usb_find_emul_child() into a nop, rather then not
building it and adding another #ifdef to the caller, this is done this way
because adding a #ifdef to the caller is somewhat hairy.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Use device_unbind_children to clean up usb devs on stop
Hans de Goede [Wed, 1 Jul 2015 18:53:00 +0000 (20:53 +0200)]
dm: usb: Use device_unbind_children to clean up usb devs on stop

On an usb stop instead of leaving orphan usb devices behind simply remove
them.

The result of this commit is best seen in the output of "dm tree" after
plugging out an usb hub with 2 devices plugges in and plugging in a keyb.
instead, before this commit the output would be:

 usb         [ + ]    `-- sunxi-musb
 usb_hub     [   ]        |-- usb_hub
 usb_mass_st [   ]        |   |-- usb_mass_storage
 usb_dev_gen [   ]        |   `-- generic_bus_0_dev_3
 usb_dev_gen [ + ]        `-- generic_bus_0_dev_1

Notice the non active usb_hub child and its 2 non active children. The
first child being non-active as in this example also causes usb_get_dev_index
to return NULL when probing the first child, which results in the usb kbd
code not binding to the keyboard.

With this commit in place the output after swapping and "usb reset" is:

 usb         [ + ]    `-- sunxi-musb
 usb_dev_gen [ + ]        `-- generic_bus_0_dev_1

As expected, and usb_get_dev_index works properly and the keyboard works.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Document that mixing DM_DEVICE_REMOVE and DM_USB is a bad idea
Hans de Goede [Wed, 1 Jul 2015 18:52:59 +0000 (20:52 +0200)]
dm: usb: Document that mixing DM_DEVICE_REMOVE and DM_USB is a bad idea

Document that mixing DM_DEVICE_REMOVE and DM_USB is a bad idea, and also why
this is a bad idea.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: usb: Fix "usb tree" output
Hans de Goede [Wed, 17 Jun 2015 19:33:50 +0000 (21:33 +0200)]
dm: usb: Fix "usb tree" output

last_child was abused by the old usb code to first store 1 if the
usb_device was not the root of the usb tree, and then later on re-used
to store whether or not the usb_device is actually the last child.

The dm-usb code was always setting it to actually reflect the last-child
status which is wrong for the last child leading to output like this:

USB device tree:
  1  Hub (12 Mb/s, 100mA)
  |  ALCOR USB Hub 2.0
  |
  | 2  Mass Storage (12 Mb/s, 100mA)
  |    USB Flash Disk 4C0E960F
  |
  +-3  Human Interface (1.5 Mb/s, 100mA)
       SINO WEALTH USB Composite Device

Instead of this:

USB device tree:
  1  Hub (12 Mb/s, 100mA)
  |  ALCOR USB Hub 2.0
  |
  +-2  Mass Storage (12 Mb/s, 100mA)
  |    USB Flash Disk 4C0E960F
  |
  +-3  Human Interface (1.5 Mb/s, 100mA)
       SINO WEALTH USB Composite Device

This commit fixes this by first checking that the device is not root,
and then setting last_child. This commit also updates the old code to not
abuse the last_child variable to store the root check result.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: Export device_remove_children / device_unbind_children
Hans de Goede [Wed, 1 Jul 2015 18:52:58 +0000 (20:52 +0200)]
dm: Export device_remove_children / device_unbind_children

These functions are useful to remove all children from an usb bus before
rescanning the bus. Give them a better name and export them.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agousb: Add an usb_device parameter to usb_reset_root_port
Hans de Goede [Wed, 17 Jun 2015 19:33:48 +0000 (21:33 +0200)]
usb: Add an usb_device parameter to usb_reset_root_port

Add an usb_device parameter to usb_reset_root_port so that it knows which
root-port it is resetting. This is necessary for proper device-model support
for usb_reset_root_port.

Also remove a duplicate declaration of usb_reset_root_port() from usb.h .

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agousb: Pass device instead of portnr to usb_legacy_port_reset
Hans de Goede [Wed, 17 Jun 2015 19:33:47 +0000 (21:33 +0200)]
usb: Pass device instead of portnr to usb_legacy_port_reset

Pass the usb_device instead of the portnr to usb_legacy_port_reset and
rename it to usb_hub_port_reset as there is nothing legacy about it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agousb: usb_setup_device: Drop unneeded portnr function argument
Hans de Goede [Wed, 17 Jun 2015 19:33:46 +0000 (21:33 +0200)]
usb: usb_setup_device: Drop unneeded portnr function argument

Drop the unneeded portnr function argument, the portnr is part of the
usb_device struct which is passed via the dev argument.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agousb: Drop device-model specific copy of usb_legacy_port_reset
Hans de Goede [Wed, 17 Jun 2015 19:33:45 +0000 (21:33 +0200)]
usb: Drop device-model specific copy of usb_legacy_port_reset

The device-model usb_legacy_port_reset function calls the device-model
usb_port_reset function which is a 1 on 1 copy of the non dm
usb_legacy_port_reset and this is the only use of usb_port_reset in all
of u-boot.

Drop both, and alway use the usb_legacy_port_reset() version in
common/usb.c .

Also while at it make it static as it is only used in common/usb.c .

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: remove redundant CONFIG_DM from driver/core/Makefile
Masahiro Yamada [Mon, 13 Jul 2015 04:17:16 +0000 (13:17 +0900)]
dm: remove redundant CONFIG_DM from driver/core/Makefile

As you see in driver/Makefile, Kbuild descends into the driver/core/
directory only when CONFIG_DM is enabled.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: do not set DM_FLAG_ACTIVATED twice
Masahiro Yamada [Thu, 9 Jul 2015 13:11:49 +0000 (22:11 +0900)]
dm: do not set DM_FLAG_ACTIVATED twice

Currently, DM_FLAG_ACTIVATED is set twice; before calling
uclass_pre_probe_device() and again before calling drv->probe().

It looks like Simon's intention is the first one.
The DM_FLAG_ACTIVATED was moved twice, by commit 02eeb1bbb174
(dm: core: Mark device as active before calling its probe()
method), and then by commit 206d4d2b4b30 (dm: core: Mark device
as active before calling uclass probe() methods).
The first marking was added by the last move.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agodm: change dm_warn() message into debug() in uclass_add()
Masahiro Yamada [Tue, 7 Jul 2015 09:51:32 +0000 (18:51 +0900)]
dm: change dm_warn() message into debug() in uclass_add()

The command "dm uclass" tries to display all the UClasses, but
some of them might be disabled by Kconfig.

The function do_dm_dump_uclass() iterates over all the UClass IDs
and calls uclass_get() for each of them.  Then, it displays annoying
message "Cannot find uclass for id ..." every time it fails to get
the UClass.

As a result, we get much noisier log for the "dm uclass" command.

  => dm uclass
  uclass 0: root
  - * root_driver @ bfb54028, seq 0, (req -1)

  Cannot find uclass for id 1: please add the UCLASS_DRIVER() ...
  Cannot find uclass for id 2: please add the UCLASS_DRIVER() ...
  Cannot find uclass for id 3: please add the UCLASS_DRIVER() ...
  Cannot find uclass for id 4: please add the UCLASS_DRIVER() ...
  Cannot find uclass for id 5: please add the UCLASS_DRIVER() ...
  Cannot find uclass for id 6: please add the UCLASS_DRIVER() ...

This commit suppresses these warnings.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
8 years agotest: Add a test for regmap
Simon Glass [Mon, 6 Jul 2015 18:54:39 +0000 (12:54 -0600)]
test: Add a test for regmap

We use syscon to test that the regmap functions work as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
8 years agodm: core: Add device checking to syscon_get_regmap()
Simon Glass [Mon, 6 Jul 2015 18:54:38 +0000 (12:54 -0600)]
dm: core: Add device checking to syscon_get_regmap()

This function can only handle a syscon device. It is possible that someone
will make a mistake, so add a check for this.

Also we should return -ENODEV when a device cannot be found, so update the
syscon_get_regmap_by_driver_data() to follow this convention.

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