oweals/u-boot.git
7 years agox86: tsc: Update comments and expand definitions in freq_desc_tables[]
Bin Meng [Wed, 26 Jul 2017 03:12:03 +0000 (20:12 -0700)]
x86: tsc: Update comments and expand definitions in freq_desc_tables[]

Some processor abbreviations in the comments of freq_desc_tables[]
are obscure. This updates part of these to mention processors
that are known to us. Also expand frequency definitions.

This keeps in sync with Linux kernel commit:
  9e0cae9: x86/tsc_msr: Update comments, expand definitions

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agox86: tsc: Remove the fail handling in try_msr_calibrate_tsc()
Bin Meng [Wed, 26 Jul 2017 03:12:02 +0000 (20:12 -0700)]
x86: tsc: Remove the fail handling in try_msr_calibrate_tsc()

If either ratio or freq is zero, the return value is zero. There
is no need to create a fail branch and return zero there.

This keeps in sync with Linux kernel commit:
  14bb4e3: x86/tsc_msr: Remove debugging messages

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agox86: tsc: Identify Intel-specific code
Bin Meng [Wed, 26 Jul 2017 03:12:01 +0000 (20:12 -0700)]
x86: tsc: Identify Intel-specific code

try_msr_calibrate_tsc() is currently Intel-specific, and should not
execute on any other vendor's parts.

This keeps in sync with Linux kernel commit:
  ba82683: x86/tsc_msr: Identify Intel-specific code

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agox86: tsc: Read all ratio bits from MSR_PLATFORM_INFO
Bin Meng [Wed, 26 Jul 2017 03:12:00 +0000 (20:12 -0700)]
x86: tsc: Read all ratio bits from MSR_PLATFORM_INFO

Currently we read the tsc radio like this:

ratio = (MSR_PLATFORM_INFO >> 8) & 0x1f;

Thus we get bit 8-12 of MSR_PLATFORM_INFO, however according to the
Intel manual, the ratio bits are bit 8-15.

Fix this problem by masking 0xff instead.

This keeps in sync with Linux kernel commit:
  886123f: x86/tsc: Read all ratio bits from MSR_PLATFORM_INFO

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agox86: Enforce toolchain to generate 64-bit codes for 64-bit U-Boot
Bin Meng [Thu, 27 Jul 2017 13:12:35 +0000 (06:12 -0700)]
x86: Enforce toolchain to generate 64-bit codes for 64-bit U-Boot

64-bit U-Boot image is a combination of 32-bit U-Boot (SPL) plus
64-bit U-Boot (proper). For the U-Boot proper, it has be compiled
to 64-bit object codes. Attempting to use a toolchain to compile
64-bit U-Boot for qemu-x86_64, like kernel.org 4.9 i386-linux-gcc,
fails with the following errors:

  arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register
  clobbered by 'ebx' in 'asm'

The issue is because toolchain is preconfigured to generate code
for the 32-bit architecture (i386), and currently '-m64' is missing
in the makefile fragment. Using kernel.org 4.9 x86_64-linux-gcc
works out of the box, since it is preconfigured to generate 64-bit
codes.

When compiling U-Boot SPL, '-m32' is passed to the toolchain, no
mater 32-bit (i386-linux-) or 64-bit (x86_64-linux) the toolchain
is preconfigured to generate.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agox86: Use default stack boundary alignment
Bin Meng [Thu, 27 Jul 2017 13:12:34 +0000 (06:12 -0700)]
x86: Use default stack boundary alignment

At present U-Boot x86 build is using -mpreferred-stack-boundary=2
which is 4 bytes stack boundary alignment. With 64-bit U-Boot, the
minimal required stack boundary alignment is 16 bytes.

If -mpreferred-stack-boundary is not specified, the default is 4
(16 bytes). Switch to use the default one.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoPrepare v2017.09-rc1 v2017.09-rc1
Tom Rini [Tue, 1 Aug 2017 00:37:25 +0000 (20:37 -0400)]
Prepare v2017.09-rc1

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoconfigs: Resync with savedefconfig
Tom Rini [Mon, 31 Jul 2017 22:59:01 +0000 (18:59 -0400)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoconfigs: Migrate CMD_NAND*
Tom Rini [Sat, 29 Jul 2017 01:31:42 +0000 (21:31 -0400)]
configs: Migrate CMD_NAND*

Migrate all remaining instances of CMD_NAND, CMD_NAND_TRIMFFS
CMD_NAND_LOCK_UNLOCK and CMD_NAND_TORTURE from the headers into the
defconfig files.

Tested-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agodm: console: Check for serial devices properly
Simon Glass [Thu, 27 Jul 2017 15:31:04 +0000 (09:31 -0600)]
dm: console: Check for serial devices properly

With driver model the serial device is often not called "serial". Mark
driver-model stdio devices so that they can be detected and we can look up
the uclass. This is a more reliable way of finding out whether the console
is connected to a serial device or not.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agoconsole: Unify the check for a serial console
Simon Glass [Thu, 27 Jul 2017 15:31:03 +0000 (09:31 -0600)]
console: Unify the check for a serial console

Put the check for whether a console is a serial device in a function so
that we can share the code in the two places that use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agoarm: mach-omap2: Align image address before cache operations
Andrew F. Davis [Wed, 26 Jul 2017 19:53:19 +0000 (14:53 -0500)]
arm: mach-omap2: Align image address before cache operations

The image address passed to secure_boot_verify_image() may not be
cacheline aligned, round the address down to the nearest cacheline.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
7 years agoti: Default to ENV_IS_IN_FAT if MMC_OMAP_HS
Tom Rini [Wed, 26 Jul 2017 17:11:37 +0000 (13:11 -0400)]
ti: Default to ENV_IS_IN_FAT if MMC_OMAP_HS

When we have MMC available we assume that we want to put the env as a
file on FAT.

Cc: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoam335x_hs_evm: Disable CONFIG_SPL_ENV_SUPPORT
Tom Rini [Wed, 26 Jul 2017 17:11:36 +0000 (13:11 -0400)]
am335x_hs_evm: Disable CONFIG_SPL_ENV_SUPPORT

The main uses of CONFIG_SPL_ENV_SUPPORT are for network support and for
disabling "Falcon Mode" support at run-time.  As this build enables
neither, remove this feature.

Cc: Andrew F. Davis <afd@ti.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoenv: Migrate CONFIG_ENV_IS_IN_FAT options to Kconfig
Tom Rini [Thu, 27 Jul 2017 01:48:00 +0000 (21:48 -0400)]
env: Migrate CONFIG_ENV_IS_IN_FAT options to Kconfig

We rename the various FAT_ENV_xxx options to CONFIG_ENV_FAT_xxx so that
they can be modified via Kconfig.  Migrate all existing users to the new
values.

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoRemove unused CONFIG_TWL4030_PWM
Adam Ford [Wed, 26 Jul 2017 15:04:40 +0000 (10:04 -0500)]
Remove unused CONFIG_TWL4030_PWM

CONFIG_TWL4030_PWM is not being used by any source, so let's remove the #define
and the whitelist entry

Signed-off-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
7 years agoserial: stm32x7: Convert CONFIG_STM32X7_SERIAL to Kconfig
Patrice Chotard [Wed, 26 Jul 2017 13:48:39 +0000 (15:48 +0200)]
serial: stm32x7: Convert CONFIG_STM32X7_SERIAL to Kconfig

Add CONFIG_STM32X7_SERIAL as a Kconfig option.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
7 years agodm: Kconfig: fix typo in help for SPL_PINCTRL
Philipp Tomsich [Wed, 26 Jul 2017 10:27:42 +0000 (12:27 +0200)]
dm: Kconfig: fix typo in help for SPL_PINCTRL

Changes 'controlloers' to 'controllers' in the help-text for
SPL_PINCTRL.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
7 years agoefi_loader: Fix warning in efi_gop
Alexander Graf [Mon, 31 Jul 2017 07:15:57 +0000 (09:15 +0200)]
efi_loader: Fix warning in efi_gop

Commit ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without
CONFIG_LCD") dropped the explicit (void*) cast for fb_base in efi gop support
for CONFIG_LCD without DM. This patch adds it back, eliminating the now occuring
warning again

Fixes: ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without CONFIG_LCD")
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
7 years agoMerge tag 'signed-efi-next' of git://github.com/agraf/u-boot
Tom Rini [Mon, 31 Jul 2017 11:27:45 +0000 (07:27 -0400)]
Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot

Patch queue for efi - 2017-07-29

A lot of EFI greatness this time around. Thanks a lot to the
two amazing new contributors

  Heinrich Schuchardt and
  Rob Clark

we now gain

  - stable objects across multiple bootefi invocations
  - fixes for shim
  - fixes for ipxe
  - protocol installation
  - device path conversion to/from text
  - working "lsefi" support in grub
  - working notifiers
  - various bug fixes

7 years agox86: minnowmax: Remove CONFIG_SMSC_LPC47M
Bin Meng [Sat, 22 Jul 2017 14:39:38 +0000 (07:39 -0700)]
x86: minnowmax: Remove CONFIG_SMSC_LPC47M

There is no SMSC LPC47M Super I/O chipset on the MinnowMax board.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: acpi: Don't touch hardware on HW reduced platforms
Andy Shevchenko [Fri, 21 Jul 2017 19:32:06 +0000 (22:32 +0300)]
x86: acpi: Don't touch hardware on HW reduced platforms

If ACPI HW reduced bit in FADT is set we should ignore any ACPI hardware
communications.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: acpi: Export acpi_fill_mcfg() with __weak attribute
Andy Shevchenko [Fri, 21 Jul 2017 19:32:05 +0000 (22:32 +0300)]
x86: acpi: Export acpi_fill_mcfg() with __weak attribute

Some platforms might require different approach when filling memory
mappings configuration table.

Allow them to override the common method.

At the same time export acpi_create_mcfg_mmconfig().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: acpi: Deduplicate acpi_fill_madt() implementation
Andy Shevchenko [Fri, 21 Jul 2017 19:32:04 +0000 (22:32 +0300)]
x86: acpi: Deduplicate acpi_fill_madt() implementation

In Baytrail and Quark support code acpi_fill_madt() is identical.

Deduplicate its implementation by moving to lib/acpi_tables.c.

At the same time mark acpi_fill_madt() with __weak attribute to keep a
possibility to override it in platform code

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: acpi: Name fields in FADT in accordance with specification
Andy Shevchenko [Fri, 21 Jul 2017 19:32:03 +0000 (22:32 +0300)]
x86: acpi: Name fields in FADT in accordance with specification

ACPI specification defines FADT fields marked as reserved in U-Boot.

Name these fields in accordance with ACPI specification.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: acpi: Fill OEM revision
Andy Shevchenko [Fri, 21 Jul 2017 19:32:02 +0000 (22:32 +0300)]
x86: acpi: Fill OEM revision

Fill OEM revision field in the tables by U-Boot build date.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agoMakefile: Export build date as integer
Andy Shevchenko [Fri, 21 Jul 2017 19:32:01 +0000 (22:32 +0300)]
Makefile: Export build date as integer

In some cases we would need build date as integer value.
Export U_BOOT_BUILD_DATE as %Y%m%d integer value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agoMakefile: Don't shadow actual error when compile ASL
Andy Shevchenko [Fri, 21 Jul 2017 19:32:00 +0000 (22:32 +0300)]
Makefile: Don't shadow actual error when compile ASL

If ASL compiler failed by any reason do not produce output C file.
Otherwise sequential run of make will shadow the actual error in ASL,
i.e.

  CC      board/intel/edison/dsdt.o
board/intel/edison/dsdt.c:1:1: error: unterminated comment
 /*

and user has to remove dsdt.c and run make in order to see the error again.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: conga-qeval20-qa3-e3845.dts: Enable xHCI support in dts
Stefan Roese [Tue, 18 Jul 2017 12:10:50 +0000 (14:10 +0200)]
x86: conga-qeval20-qa3-e3845.dts: Enable xHCI support in dts

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: dfi-bt700: Add xHCI USB support
Stefan Roese [Tue, 18 Jul 2017 12:10:49 +0000 (14:10 +0200)]
x86: dfi-bt700: Add xHCI USB support

Change from EHCI to xHCI on the DFI BayTrail SoM.

The xHCI USB hub is connected to an GPIO on the DFI BayTrail SoM. For
correct operation, it needs to get reset upon power-up. Otherwise it
may happen that the hub is not detected after a software reboot. This
patch also configures this GPIO in the dts for correct operation.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: conga-qeval20-qa3-e3845: Select CONFIG_BOARD_LATE_INIT
Stefan Roese [Tue, 18 Jul 2017 12:10:45 +0000 (14:10 +0200)]
x86: conga-qeval20-qa3-e3845: Select CONFIG_BOARD_LATE_INIT

This config option is needed on the congatec x86 BayTrail board, as
otherwise the USB hub will not get initialized correctly. This
patch selects this Kconfig option again.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: theadorable-x86-dfi-bt700: Add Spansion SPI support and move VIDEO blob
Stefan Roese [Tue, 18 Jul 2017 12:10:41 +0000 (14:10 +0200)]
x86: theadorable-x86-dfi-bt700: Add Spansion SPI support and move VIDEO blob

To support the Spansion SPI NOR flashes, this patch enables the support in
defconfig. This increases the U-Boot binary too much so that it does
not fit into its area in the ROM. So also move the VIDEO BIOS blob
a bit to make some space here.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: Add Intel Edison board files
Andy Shevchenko [Thu, 6 Jul 2017 11:41:53 +0000 (14:41 +0300)]
x86: Add Intel Edison board files

Add Intel Edison board which is using U-Boot.

The patch is based on work done by the following people (in alphabetical
order):
Aiden Park <aiden.park@intel.com>
Dukjoon Jeon <dukjoon.jeon@intel.com>
eric.park <eric.park@intel.com>
Fabien Chereau <fabien.chereau@intel.com>
Felipe Balbi <felipe.balbi@linux.intel.com>
Scott D Phillips <scott.d.phillips@intel.com>
Sebastien Colleur <sebastienx.colleur@intel.com>
Steve Sakoman <steve.sakoman@intel.com>
Vincent Tinelli <vincent.tinelli@intel.com>

In case we're building for Intel Edison, we must have 4096 bytes of
zeroes in the beginning on u-boot.bin. This is done in
board/intel/edison/config.mk.

First run sets hardware_id environment variable which is read from
System Controller Unit (SCU).

Serial number (serial# environment variable) is generated based on eMMC
CID.

MAC address on USB network interface is unique to the board but kept the
same all over the time.

Set mac address from U-Boot using following scheme:
OUI = 02:00:86
next 3 bytes of MAC address set from eMMC serial number

This allows to have a unique mac address across reboot and flashing.

Signed-off-by: Vincent Tinelli <vincent.tinelli@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[bmeng: Add MAINTAINERS file for Intel Edison board]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: Add Intel Tangier support
Felipe Balbi [Thu, 6 Jul 2017 11:41:52 +0000 (14:41 +0300)]
x86: Add Intel Tangier support

Add Intel Tangier SoC support.

Intel Tangier SoC is a core part of Intel Merrifield platform. For
example, Intel Edison board is based on such platform.

The patch is based on work done by the following people (in alphabetical
order):
Aiden Park <aiden.park@intel.com>
Dukjoon Jeon <dukjoon.jeon@intel.com>
eric.park <eric.park@intel.com>
Fabien Chereau <fabien.chereau@intel.com>
Scott D Phillips <scott.d.phillips@intel.com>
Sebastien Colleur <sebastienx.colleur@intel.com>
Steve Sakoman <steve.sakoman@intel.com>
Vincent Tinelli <vincent.tinelli@intel.com>

Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Vincent Tinelli <vincent.tinelli@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7 years agox86: Add dma-mapping.h to architectural code
Andy Shevchenko [Thu, 6 Jul 2017 11:41:51 +0000 (14:41 +0300)]
x86: Add dma-mapping.h to architectural code

Some cross-platform drivers rely on this header present.
Make it so for x86.

It's just a copy'n'paste of arch/arm/include/asm/dma-mapping.h.

Suggested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7 years agowatchdog: Introduce watchdog driver for Intel Tangier
Felipe Balbi [Wed, 5 Jul 2017 17:33:20 +0000 (20:33 +0300)]
watchdog: Introduce watchdog driver for Intel Tangier

Add watchdog driver for Intel Tangier based platforms.

Signed-off-by: Vincent Tinelli <vincent.tinelli@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agoarch/x86: Select USB before selecting host driver
Andy Shevchenko [Tue, 4 Jul 2017 16:32:22 +0000 (19:32 +0300)]
arch/x86: Select USB before selecting host driver

Kbuild complains if USB is not selected before any of host driver.

warning: (X86) selects USB_EHCI_HCD which has unmet direct dependencies (USB)
warning: (X86) selects USB_EHCI_HCD which has unmet direct dependencies (USB)

Select it for X86.

Fixes: 64d6ac5bc4a9 ("Kconfig: USB: Migrate CONFIG_USB_EHCI_HCD users to Kconfig")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
[bmeng: Update all x86 boards' defconfig files to remove CONFIG_USB]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
7 years agoMerge git://git.denx.de/u-boot-socfpga
Tom Rini [Sat, 29 Jul 2017 15:44:08 +0000 (11:44 -0400)]
Merge git://git.denx.de/u-boot-socfpga

7 years agoMerge git://git.denx.de/u-boot-usb
Tom Rini [Sat, 29 Jul 2017 15:43:51 +0000 (11:43 -0400)]
Merge git://git.denx.de/u-boot-usb

7 years agoefi_loader: indent entry/exit prints to show nesting level
Rob Clark [Thu, 27 Jul 2017 12:04:19 +0000 (08:04 -0400)]
efi_loader: indent entry/exit prints to show nesting level

This should make it easier to see when a callback back to UEFI world
calls back in to the u-boot world, and generally match up EFI_ENTRY()
and EFI_EXIT() calls.

Signed-off-by: Rob Clark <robdclark@gmail.com>
[agraf: remove static from const var]
Signed-off-by: Alexander Graf <agraf@suse.de>
7 years agoefi_loader: add checking for incorrect use of EFI_ENTRY/EXIT
Rob Clark [Thu, 27 Jul 2017 12:04:18 +0000 (08:04 -0400)]
efi_loader: add checking for incorrect use of EFI_ENTRY/EXIT

Missing an EFI_ENTRY() or doubling up EFI_EXIT() leads to non-obvious
crashes.  Let's add some error checking.

Signed-off-by: Rob Clark <robdclark@gmail.com>
[agraf: fix bogus assert() and fix app_gd breakage]
Signed-off-by: Alexander Graf <agraf@suse.de>
7 years agoclk: fix compilation errors for poplar platform
Patrice Chotard [Tue, 25 Jul 2017 11:24:45 +0000 (13:24 +0200)]
clk: fix compilation errors for poplar platform

Move clk_release_all() prototype and definition inside
OF_CONTROL flag to avoid following compilation error for
poplar platform:

aarch64:  +   poplar
+drivers/usb/host/built-in.o: In function `ehci_usb_remove':
+drivers/usb/host/ehci-generic.c:159: undefined reference to `clk_release_all'
+drivers/usb/host/built-in.o: In function `ehci_usb_probe':
+drivers/usb/host/ehci-generic.c:133: undefined reference to `clk_release_all'
+make[1]: *** [u-boot] Error 139
+make: *** [sub-make] Error 2

Introduced by 4e542c4 clk: add clk_release_all()

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agousb: host: xhci-dxc3: fix compilation warnings
Patrice Chotard [Tue, 25 Jul 2017 11:24:44 +0000 (13:24 +0200)]
usb: host: xhci-dxc3: fix compilation warnings

Fix following warnings encountered with platforms
dra7xx_evm and dra7xx_hs_evm :

       arm:  +   dra7xx_evm
+  hccr = (struct xhci_hccr *)devfdt_get_addr(dev);
+         ^
+  hcor = (struct xhci_hcor *)((phys_addr_t)hccr +
+                              ^
w+drivers/usb/host/xhci-dwc3.c: In function 'xhci_dwc3_probe':
w+drivers/usb/host/xhci-dwc3.c:124:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
w+drivers/usb/host/xhci-dwc3.c:125:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
w+drivers/usb/host/xhci-dwc3.c:125:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       arm:  +   dra7xx_hs_evm
+  hccr = (struct xhci_hccr *)devfdt_get_addr(dev);
+         ^
+  hcor = (struct xhci_hcor *)((phys_addr_t)hccr +
+                              ^
w+drivers/usb/host/xhci-dwc3.c: In function 'xhci_dwc3_probe':
w+drivers/usb/host/xhci-dwc3.c:124:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
w+drivers/usb/host/xhci-dwc3.c:125:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
w+drivers/usb/host/xhci-dwc3.c:125:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Introduced by 7e65e84 usb: host: xhci-dwc3: Convert driver to DM

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agophy: add a NO-OP phy driver
Jean-Jacques Hiblot [Mon, 24 Jul 2017 13:18:15 +0000 (15:18 +0200)]
phy: add a NO-OP phy driver

This driver is used to stub PHY operations in a driver (USB, SATA).
This is useful when the 'client' driver (USB, SATA, ...) uses the PHY
framework and there is no actual PHY harwdare to drive.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
7 years agousb: host: ohci-generic: initialize PHY only when found
Patrice Chotard [Mon, 24 Jul 2017 15:07:05 +0000 (17:07 +0200)]
usb: host: ohci-generic: initialize PHY only when found

Call generic_phy_init() only when a PHY was found.
This will avoid a crash if no "phys" property is found in DT.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reported-by: Patrick Delaunay <patrick.delaunay@st.com>
7 years agousb: host: ehci-generic: initialize PHY only when found
Patrice Chotard [Mon, 24 Jul 2017 15:07:04 +0000 (17:07 +0200)]
usb: host: ehci-generic: initialize PHY only when found

Call generic_phy_init() only when a PHY was found.
This will avoid a crash if no "phys" property is found in DT.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reported-by: Patrick Delaunay <patrick.delaunay@st.com>
7 years agodm: usb: host: xhci-dwc3: add missing #ifdef CONFIG_DM_USB
Patrice Chotard [Mon, 24 Jul 2017 15:07:03 +0000 (17:07 +0200)]
dm: usb: host: xhci-dwc3: add missing #ifdef CONFIG_DM_USB

Add CONFIG_DM_USB flag to avoid following compilation errors
detected by buildman :
+drivers/usb/host/built-in.o: In function `xhci_dwc3_remove':
+drivers/usb/host/xhci-dwc3.c:168: undefined reference to `xhci_deregister'
+drivers/usb/host/built-in.o: In function `xhci_dwc3_probe':
+drivers/usb/host/xhci-dwc3.c:145: undefined reference to `usb_get_dr_mode'
+drivers/usb/host/xhci-dwc3.c:152: undefined reference to `xhci_register'

introduced by patch d5c3f014da3 "usb: host: xhci-dwc3: Convert driver to DM"

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reported-by: Ran Wang <ran.wang_1@nxp.com>
7 years agodm: phy: add missing #ifdef CONFIG_PHY
Patrice Chotard [Mon, 24 Jul 2017 15:07:02 +0000 (17:07 +0200)]
dm: phy: add missing #ifdef CONFIG_PHY

To avoid compilation breakage on platform that doesn't
support DM PHY but uses xhci-dwc3 driver, add the missing
CONFIG_PHY flag.

Introduced by patch :
84e53877 "usb: host: xhci-dwc3: Add generic PHY support"

Cc: Ran Wang <ran.wang_1@nxp.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reported-by: Ran Wang <ran.wang_1@nxp.com>
7 years agodfu: add common function to initiate transaction
Patrick Delaunay [Wed, 19 Jul 2017 14:39:25 +0000 (16:39 +0200)]
dfu: add common function to initiate transaction

- factorize code between read and write transaction
- always use dfu_transaction_cleanup() to initialize
  the internal variable: easy maintenance
- replace direct access by dfu_get_buf() and dfu_get_buf_size()

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
7 years agodfu: factorize transaction cleanup
Patrick Delaunay [Wed, 19 Jul 2017 14:39:24 +0000 (16:39 +0200)]
dfu: factorize transaction cleanup

rename cleanup function, as now called by read

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
7 years agodfu: remove limitation on partition size
Patrick Delaunay [Wed, 19 Jul 2017 14:39:23 +0000 (16:39 +0200)]
dfu: remove limitation on partition size

Change long (32 bits on arm) to u64 (same type than offset)
for size and read offset r_left

So partition and device used for DFU can be greater than 4GB

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
7 years agodfu: allow dfu read on partition greater than 2GB
Patrick Delaunay [Wed, 19 Jul 2017 14:39:22 +0000 (16:39 +0200)]
dfu: allow dfu read on partition greater than 2GB

solve issue on get_medium_size() function
the detection of error is a simple test < 0
but for ARM platform, long is 32bits and 2GB = 0x80000000
is seen as error.

I solve the issue by changing the prototype fo the function
to separate size and result.
This patch prepare the next patch with size change to u64.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
7 years agousb: gadget: f_thor: Free the allocated out request buffer
Siva Durga Prasad Paladugu [Tue, 21 Jun 2016 12:50:48 +0000 (14:50 +0200)]
usb: gadget: f_thor: Free the allocated out request buffer

Fix the memory leak by freeing the allocated out request buffer

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
7 years agousb: xhci: Enable TT to support LS/FS devices behind a HS hub
Bin Meng [Wed, 19 Jul 2017 13:51:21 +0000 (21:51 +0800)]
usb: xhci: Enable TT to support LS/FS devices behind a HS hub

So far LS/FS devices directly attached to xHC root port can be
successfully enumerated by xHCI driver, but if they are connected
behind a hub, the enumeration process fails to address the device.

It turns out xHCI driver still misses a part that in the device's
input slot context, all Transaction Translator (TT) related fields
are not programmed. The xHCI spec defines how to enable TT.

Now LS/FS devices like USB keyboard/mouse can be enumerated behind
a high speed hub.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: xhci: Correct TT_SLOT and TT_PORT macros
Bin Meng [Wed, 19 Jul 2017 13:51:20 +0000 (21:51 +0800)]
usb: xhci: Correct TT_SLOT and TT_PORT macros

These two macros really need a parameter to make them useful.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: xhci: Implement update_hub_device() operation
Bin Meng [Wed, 19 Jul 2017 13:51:19 +0000 (21:51 +0800)]
usb: xhci: Implement update_hub_device() operation

There is no way to know whether the attached device is a hub or
not in advance before the device's descriptor is fetched. But
once we know it's a high speed hub, per the xHCI spec, we need
to tell xHC it's a hub device by initializing hub-related fields
in the input slot context.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: hub: Call usb_update_hub_device() after hub descriptor is fetched
Bin Meng [Wed, 19 Jul 2017 13:51:18 +0000 (21:51 +0800)]
usb: hub: Call usb_update_hub_device() after hub descriptor is fetched

After fetching hub descriptor, we need to call USB uclass operation
update_hub_device() to notify HCD to do some preparation work.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: usb: Add a new USB controller operation 'update_hub_device'
Bin Meng [Wed, 19 Jul 2017 13:51:17 +0000 (21:51 +0800)]
dm: usb: Add a new USB controller operation 'update_hub_device'

For USB host controllers like xHC, its internal representation of
hub needs to be updated after the hub descriptor is fetched. This
adds a new op that does this.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: hub: Parse and save TT details from device descriptor
Bin Meng [Wed, 19 Jul 2017 13:51:16 +0000 (21:51 +0800)]
usb: hub: Parse and save TT details from device descriptor

A high speed hub has a special responsibility to handle full speed/
low speed devices connected on downstream ports. In this case, the
hub must isolate the high speed signaling environment from the full
speed/low speed signaling environment with the help of Transaction
Translator (TT). TT details are provided by hub descriptors and we
parse and save it to hub uclass_priv for later use.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: xhci: Program 'route string' in the input slot context
Bin Meng [Wed, 19 Jul 2017 13:51:15 +0000 (21:51 +0800)]
usb: xhci: Program 'route string' in the input slot context

xHCI spec says: the values of the 'route string' field shall be
initialized by the first 'Address Device' command issued to a
device slot, and shall not be modified by any other command.

So far U-Boot does not program this field, and it does not prevent
SS device directly attached to root port, or HS device behind an HS
hub, from working, due to the fact that 'route string' is used by
the xHC to target SS packets. But in order to enumerate devices
behind an SS hub, this field must be programmed.

With this commit and along with previous commits, now SS & HS devices
attached to a USB 3.0 hub can be enumerated by U-Boot.

As usual, this new feature is only available when DM is on.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: xhci: Change xhci_setup_addressable_virt_dev() signature
Bin Meng [Wed, 19 Jul 2017 13:51:14 +0000 (21:51 +0800)]
usb: xhci: Change xhci_setup_addressable_virt_dev() signature

For future extension, change xhci_setup_addressable_virt_dev()
signature to accept a pointer to 'struct usb_device', instead
of its members slot_id & speed, as the struct already contains
these two plus some other useful information of the device.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: hub: Support 'set hub depth' request for USB 3.0 hubs
Bin Meng [Wed, 19 Jul 2017 13:51:13 +0000 (21:51 +0800)]
usb: hub: Support 'set hub depth' request for USB 3.0 hubs

USB 3.0 hub uses a hub depth value multiplied by four as an offset
into the 'route string' to locate the bits it uses to determine the
downstream port number. We shall set the hub depth value of a USB
3.0 hub after it is configured.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: hub: Translate USB 3.0 hub port status into old version
Bin Meng [Wed, 19 Jul 2017 13:51:12 +0000 (21:51 +0800)]
usb: hub: Translate USB 3.0 hub port status into old version

USB 3.0 hub port status field has different bit positions from 2.0
hubs. Since U-Boot only understands the old version, translate the
new one into the old one.

Since we are going to add USB 3.0 hub support, this feature is only
available with driver model USB.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: hub: Add a new API to test if a hub device is root hub
Bin Meng [Wed, 19 Jul 2017 13:51:11 +0000 (21:51 +0800)]
usb: hub: Add a new API to test if a hub device is root hub

Sometimes we need know if a given hub device is root hub or not.
Add a new API to test this. This removes the xHCI driver's own
version is_root_hub() and change to use the new API.

While we are here, remove the unused/commented out get_usb_device()
in the xHCI driver too.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
7 years agousb: hub: Remove hub_port_reset()
Bin Meng [Wed, 19 Jul 2017 13:51:10 +0000 (21:51 +0800)]
usb: hub: Remove hub_port_reset()

At present hub_port_reset() is defined in DM USB, but it is never
called hence remove it (removing another ifdefs).

While we are here, change legacy_hub_port_reset() name to
usb_hub_port_reset() to better match other function names in the
same hub module.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv
Bin Meng [Wed, 19 Jul 2017 13:51:09 +0000 (21:51 +0800)]
usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv

Use USB hub device's dev->uclass_priv to point to 'usb_hub_device'
so that with driver model usb_hub_reset() and usb_hub_allocate()
are no longer needed.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: xhci-pci: Clean up the driver a little bit
Bin Meng [Wed, 19 Jul 2017 13:51:08 +0000 (21:51 +0800)]
usb: xhci-pci: Clean up the driver a little bit

This cleans up the driver a little bit.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: xhci-pci: Drop non-DM version of xhci-pci driver
Bin Meng [Wed, 19 Jul 2017 13:51:07 +0000 (21:51 +0800)]
usb: xhci-pci: Drop non-DM version of xhci-pci driver

As there is no board that currently uses xhci-pci driver without DM
USB, drop its support and leave only DM support.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agox86: minnowmax: Enable USB xHCI support
Bin Meng [Wed, 19 Jul 2017 13:50:10 +0000 (21:50 +0800)]
x86: minnowmax: Enable USB xHCI support

BayTrail SoC supports both EHCI and xHCI controllers. However only
one host controller (either EHCI or xHCI) can be used. To enable
HSIC and SS ports, xHCI must be used. This turns on xHCI support on
Intel MinnowMax board.

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>
7 years agox86: minnowmax: Add a environment variable for USB power-on delay
Bin Meng [Wed, 19 Jul 2017 13:50:09 +0000 (21:50 +0800)]
x86: minnowmax: Add a environment variable for USB power-on delay

Occasionally it was observed that on Intel MinnowMax board, with a
USB 2.0 device connected to the bottom port, when doing 'usb start'
on the xHCI controller:

  scanning bus 0 for devices... cannot reset port 3!?

But neither of the two USB ports is routed to xHCI root port 3.
Adding some debug information shows that xHCI port 3 PORTSC register
mysteriously reports both CCS = 1 and CSC = 1.

This is not seen every time. After increasing the timeout to wait
for power to become stable, the issue is gone. So this indicates
current default USB power-on delay (20ms) might be at a critical
region where power is stable/unstable. U-Boot provides a mechanism
to have a environment variable to override the default one. Add
one for MinnowMax.

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>
7 years agousb: xhci: Convert CONFIG_USB_XHCI_PCI to Kconfig
Bin Meng [Wed, 19 Jul 2017 13:50:08 +0000 (21:50 +0800)]
usb: xhci: Convert CONFIG_USB_XHCI_PCI to Kconfig

Add CONFIG_USB_XHCI_PCI as a Kconfig option.

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>
7 years agousb: cmd: Print actual packet size for super speed devices
Bin Meng [Wed, 19 Jul 2017 13:50:07 +0000 (21:50 +0800)]
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>
7 years agoconfigs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards
Bin Meng [Wed, 19 Jul 2017 13:50:06 +0000 (21:50 +0800)]
configs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards

Now that EHCD does not use CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS,
remove it in all boards' config files.

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>
7 years agousb: ehci: Get rid of CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS
Bin Meng [Wed, 19 Jul 2017 13:50:05 +0000 (21:50 +0800)]
usb: ehci: Get rid of CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS

EHC reports supported maximum number of ports in the HCSPARAMS
register, so it's unnecessary to use a hardcoded config option
CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS.

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>
7 years agoconfigs: Remove CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS in all boards
Bin Meng [Wed, 19 Jul 2017 13:50:04 +0000 (21:50 +0800)]
configs: Remove CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS in all boards

Now that xHCD does not use CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS,
remove it in all boards' config files.

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>
7 years agousb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS
Bin Meng [Wed, 19 Jul 2017 13:50:03 +0000 (21:50 +0800)]
usb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS

xHC reports supported maximum number of ports in the HCSPARAMS1
register, so it's unnecessary to use a hardcoded config option
CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS.

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>
7 years agousb: xhci: Change MAX_HC_PORTS to 255
Bin Meng [Wed, 19 Jul 2017 13:50:02 +0000 (21:50 +0800)]
usb: xhci: Change MAX_HC_PORTS to 255

HCSPARAMS1:MaxPorts field specifies the maximum port number value,
and its valid values are in the range of 1 to 255.

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>
7 years agousb: hub: Add 3.0 hub port status mask of 2.0 hub
Bin Meng [Wed, 19 Jul 2017 13:50:01 +0000 (21:50 +0800)]
usb: hub: Add 3.0 hub port status mask of 2.0 hub

USB 3.0 hub port status has different bit position regarding to
port power, port speed, etc. But others are the same as 2.0 hubs.

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>
7 years agousb: hub: Change USB hub descriptor to match USB 3.0 hubs
Bin Meng [Wed, 19 Jul 2017 13:50:00 +0000 (21:50 +0800)]
usb: hub: Change USB hub descriptor to match USB 3.0 hubs

USB 3.0 hubs have a slightly different hub descriptor than USB 2.0
hubs, with a fixed (rather than variable length) size. Change the
host controller drivers that access those last two fields
(DeviceRemovable and PortPowerCtrlMask) to use the union.

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>
7 years agousb: hub: Revise wLength for 'get port status' request
Bin Meng [Wed, 19 Jul 2017 13:49:59 +0000 (21:49 +0800)]
usb: hub: Revise wLength for 'get port status' request

For accuracy, we should use 'sizeof(struct usb_port_status)' as the
wLength for 'get port status' request, although it happens to be
equal to 'sizeof(struct usb_hub_status)'.

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>
7 years agousb: hub: Send correct wValue to get hub descriptor of a USB 3.0 hub
Bin Meng [Wed, 19 Jul 2017 13:49:58 +0000 (21:49 +0800)]
usb: hub: Send correct wValue to get hub descriptor of a USB 3.0 hub

Testing a USB 3.0 hub by connecting it to the xHCI port on Intel
MinnowMax, when issuing 'get hub descriptor' to the hub, xHCI
reports a transfer event TRB with a completion code 6 which means
'Stall Error'.

In fact super speed USB hub descriptor type is 0x2a, not 0x29.
Sending correct SETUP packet to the hub makes it not stall anymore.

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>
7 years agousb: hub: Update handling connect status/change in usb_scan_port()
Bin Meng [Wed, 19 Jul 2017 13:49:57 +0000 (21:49 +0800)]
usb: hub: Update handling connect status/change in usb_scan_port()

It was observed that on Intel MinnowMax board, when xHCI is enabled
in the BayTrail SoC, with a USB 3.0 device connected to the bottom
USB 3.0 port (mapped to xHCI root port #7), its PORTSC register is
always 0x201203 (CCS = 1, CSC = 0). The root cause of such behavior
is unknown yet. Connect status change bit is set on the same port
with a USB 2.0 device (mapped to xHCI port #1, which is a different
port on the root hub).

With current logic in usb_scan_port(), the enumeration process will
abort if it does not detect a connect status change on a hub port.
However since a device connection status is correctly reported, the
enumeration process can still continue.

With this change, USB device connected to the bottom blue port on
MinnowMax board can be enumerated under either SS or HS mode.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Dinh Nguyen <dinguyen@kernel.org>
7 years agousb: xhci: Add input slot context in xhci_set_configuration()
Bin Meng [Wed, 19 Jul 2017 13:49:56 +0000 (21:49 +0800)]
usb: xhci: Add input slot context in xhci_set_configuration()

A valid input slot context for a 'configure endpoint' command requires
the 'Context Entries' field to be initialized to the index of the last
valid endpoint context that is defined by the target configuration. We
set up the 'Context Entries' field, but we forget to include the input
slot context in the input control context 'Add Context flags' bitmap.
So xHC will simply ignore input slot context and continue using its own
which contains old information of the device.

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>
7 years agousb: xhci: Initialize scratchpad buffer array and scratchpad buffers
Bin Meng [Wed, 19 Jul 2017 13:49:55 +0000 (21:49 +0800)]
usb: xhci: Initialize scratchpad buffer array and scratchpad buffers

The scratchpad buffer array is used to define the locations of
statically allocated memory pages that are available for the
private use of the xHC. The xHCI spec explicitly mentions that
system software shall allocate the scratchpad buffers before
placing the xHC in to Run mode (Run/Stop (R/S) = ‘1’), however
U-Boot is missing this part.

This causes xHC on Intel platform does not respond the very first
'enable slot' command that is given to xHC and the 'enable slot'
command completion event TRB is never generated and xHC seems to
hang forever.

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>
7 years agousb: xhci: Correct command TRB 4th dword initialization
Bin Meng [Wed, 19 Jul 2017 13:49:54 +0000 (21:49 +0800)]
usb: xhci: Correct command TRB 4th dword initialization

In xhci_queue_command(), when the command is not 'reset endpoint',
'stop endpoint' or 'set TR dequeue pointer', endpoint ID should not
be encoded in the TRB.

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>
7 years agousb: xhci: Remove incorrect comments for struct xhci_container_ctx
Bin Meng [Wed, 19 Jul 2017 13:49:53 +0000 (21:49 +0800)]
usb: xhci: Remove incorrect comments for struct xhci_container_ctx

There is no member called 'dma' in struct xhci_container_ctx. Remove
the comments that mentions it.

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>
7 years agousb: host: ohci-generic: add generic PHY support
Patrice Chotard [Tue, 18 Jul 2017 09:57:14 +0000 (11:57 +0200)]
usb: host: ohci-generic: add generic PHY support

Extend ohci-generic driver with generic PHY framework

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: host: ohci-generic: add RESET support
Patrice Chotard [Tue, 18 Jul 2017 09:57:13 +0000 (11:57 +0200)]
usb: host: ohci-generic: add RESET support

use array to save deasserted resets reference in order to
assert them in case of error during probe() or during driver
removal.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: host: ohci-generic: add CLOCK support
Patrice Chotard [Tue, 18 Jul 2017 09:57:12 +0000 (11:57 +0200)]
usb: host: ohci-generic: add CLOCK support

use array to save enabled clocks reference in order to
disabled them in case of error during probe() or during
driver removal.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: host: ehci-generic: add generic PHY support
Patrice Chotard [Tue, 18 Jul 2017 09:57:11 +0000 (11:57 +0200)]
usb: host: ehci-generic: add generic PHY support

Extend ehci-generic driver with generic PHY framework

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: host: ehci-generic: add error path and .remove callback
Patrice Chotard [Tue, 18 Jul 2017 09:57:10 +0000 (11:57 +0200)]
usb: host: ehci-generic: add error path and .remove callback

Use an array to save enabled clocks reference and deasserted resets
in order to respectively disabled and asserted them in case of error
during probe() or during driver removal.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: host: ehci-generic: replace printf() by error()
Patrice Chotard [Tue, 18 Jul 2017 09:57:09 +0000 (11:57 +0200)]
usb: host: ehci-generic: replace printf() by error()

this allows to get file, line and function location
of the current error message.

Signed-off-by: patrice chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: add ofnode_count_phandle_with_args()
Patrice Chotard [Tue, 18 Jul 2017 09:57:08 +0000 (11:57 +0200)]
dm: core: add ofnode_count_phandle_with_args()

This function is usefull to get phandle number contained
in a property list.
For example,  this allows to allocate the right amount
of memory to keep clock's reference contained into the
"clocks" property.

To implement it, either of_count_phandle_with_args() or
fdtdec_parse_phandle_with_args() are used respectively
for live tree and flat tree.
By passing index = -1, these 2 functions returns the
number of phandle contained into the property list.

Add also the dev_count_phandle_with_args() based on
ofnode_count_phandle_with_args()

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoclk: add clk_release_all()
Patrice Chotard [Tue, 18 Jul 2017 09:57:07 +0000 (11:57 +0200)]
clk: add clk_release_all()

Add clk_release_all() method which Disable/Free an
array of clocks that has been previously requested by
clk_request/get_by_*()

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoreset: add reset_release_all()
Patrice Chotard [Tue, 18 Jul 2017 09:57:06 +0000 (11:57 +0200)]
reset: add reset_release_all()

Add reset_release_all() method which Assert/Free an
array of resets signal that has been previously successfully
requested by reset_get_by_*()

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoreset: add reset_request()
Patrice Chotard [Tue, 18 Jul 2017 09:57:05 +0000 (11:57 +0200)]
reset: add reset_request()

This is needed in error path to assert previously deasserted
reset by using a saved reset_ctl reference.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: host: xhci-dwc3: Add generic PHY support
Patrice Chotard [Tue, 18 Jul 2017 09:38:44 +0000 (11:38 +0200)]
usb: host: xhci-dwc3: Add generic PHY support

Add support of generic PHY framework support

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodrivers: phy: add generic_phy_valid() method
Patrice Chotard [Tue, 18 Jul 2017 09:38:43 +0000 (11:38 +0200)]
drivers: phy: add generic_phy_valid() method

This allow to check if a PHY has been correctly
initialised and avoid to get access to phy struct.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agodrivers: phy: Set phy->dev to NULL when generic_phy_get_by_index() fails
Patrice Chotard [Tue, 18 Jul 2017 09:38:42 +0000 (11:38 +0200)]
drivers: phy: Set phy->dev to NULL when generic_phy_get_by_index() fails

phy->dev need to be set to NULL in case of generic_phy_get_by_index()
fails. Then phy->dev can be used to check if the phy is valid

Reported-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agousb: host: xhci-dwc3: Add dual role mode support from DT
Patrice Chotard [Tue, 18 Jul 2017 09:38:41 +0000 (11:38 +0200)]
usb: host: xhci-dwc3: Add dual role mode support from DT

DWC3 dual role mode is selected using DT "dr_mode"
property. If not found, DWC3 controller is configured
in HOST mode by default

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>