[U-Boot] [PATCH v3 3/3] whitelist: Remove "CONFIG_SYS_CCI400_ADDR" from whitelist

2017-07-19 Thread Ashish Kumar
This config is depricated and new config SYS_CCI400_OFFSET
is introduced in Kconfig

Signed-off-by: Ashish Kumar 
---
v3: 
 This is v3 for https://patchwork.ozlabs.org/patch/731464/

 scripts/config_whitelist.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index e261d02..c29f8f3 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -2516,7 +2516,6 @@ CONFIG_SYS_CACHE_STASHING
 CONFIG_SYS_CADMUS_BASE_REG
 CONFIG_SYS_CBSIZE
 CONFIG_SYS_CCCR
-CONFIG_SYS_CCI400_ADDR
 CONFIG_SYS_CCSRBAR
 CONFIG_SYS_CCSRBAR_PHYS
 CONFIG_SYS_CCSRBAR_PHYS_HIGH
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 2/3] armv7: Consolidate registers space defination for CCI-400 bus

2017-07-19 Thread Ashish Kumar
CoreLink Cache Coherent Interconnect (CCI) is ARM BUS which
provides full cache coherency between two clusters of multi-core
CPUs and I/O coherency for devices and I/O masters.

This patch add new CONFIG defination "FSL_SYS_HAS_CCI400" and
removes register space definaton of CCI-400 bus from
immap_ls102xa to fsl_immap, since same is defined there already

"CONFIG_SYS_CCI400_ADDR" is depricated and new SYS_CCI400_OFFSET
is introduced in Kconfig

Signed-off-by: Ashish Kumar 
---
v3: 
 This is v3 for https://patchwork.ozlabs.org/patch/731464/

 arch/arm/cpu/armv7/ls102xa/Kconfig| 12 ++
 arch/arm/cpu/armv7/ls102xa/soc.c  |  3 +-
 arch/arm/include/asm/arch-ls102xa/config.h|  1 -
 arch/arm/include/asm/arch-ls102xa/immap_ls102xa.h | 49 +--
 4 files changed, 16 insertions(+), 49 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/Kconfig 
b/arch/arm/cpu/armv7/ls102xa/Kconfig
index 6a013b2..61dd522 100644
--- a/arch/arm/cpu/armv7/ls102xa/Kconfig
+++ b/arch/arm/cpu/armv7/ls102xa/Kconfig
@@ -5,6 +5,7 @@ config ARCH_LS1021A
select SYS_FSL_ERRATUM_A009663
select SYS_FSL_ERRATUM_A009942
select SYS_FSL_ERRATUM_A010315
+   select SYS_FSL_HAS_CCI400
select SYS_FSL_SRDS_1
select SYS_HAS_SERDES
select SYS_FSL_DDR_BE if SYS_FSL_DDR
@@ -48,9 +49,20 @@ config SECURE_BOOT
Enable Freescale Secure Boot feature. Normally selected
by defconfig. If unsure, do not change.
 
+config SYS_CCI400_OFFSET
+   hex "Offset for CCI400 base"
+   depends on SYS_FSL_HAS_CCI400
+   default 0x18
+   help
+ Offset for CCI400 base.
+ CCI400 base addr = CCSRBAR + CCI400_OFFSET
+
 config SYS_FSL_ERRATUM_A010315
bool "Workaround for PCIe erratum A010315"
 
+config SYS_FSL_HAS_CCI400
+   bool
+
 config SYS_FSL_SRDS_1
bool
 
diff --git a/arch/arm/cpu/armv7/ls102xa/soc.c b/arch/arm/cpu/armv7/ls102xa/soc.c
index b84a1a6..c043b82 100644
--- a/arch/arm/cpu/armv7/ls102xa/soc.c
+++ b/arch/arm/cpu/armv7/ls102xa/soc.c
@@ -80,7 +80,8 @@ void erratum_a010315(void)
 int arch_soc_init(void)
 {
struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
-   struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
+   struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
+   CONFIG_SYS_CCI400_OFFSET);
unsigned int major;
 
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
diff --git a/arch/arm/include/asm/arch-ls102xa/config.h 
b/arch/arm/include/asm/arch-ls102xa/config.h
index fc954c5..ff0fc47 100644
--- a/arch/arm/include/asm/arch-ls102xa/config.h
+++ b/arch/arm/include/asm/arch-ls102xa/config.h
@@ -20,7 +20,6 @@
 
 #define SYS_FSL_GIC_ADDR   (CONFIG_SYS_IMMR + 0x0040)
 #define CONFIG_SYS_FSL_DDR_ADDR(CONFIG_SYS_IMMR + 
0x0008)
-#define CONFIG_SYS_CCI400_ADDR (CONFIG_SYS_IMMR + 0x0018)
 #define CONFIG_SYS_FSL_CSU_ADDR (CONFIG_SYS_IMMR + 0x0051)
 #define CONFIG_SYS_IFC_ADDR(CONFIG_SYS_IMMR + 0x0053)
 #define CONFIG_SYS_FSL_ESDHC_ADDR  (CONFIG_SYS_IMMR + 0x0056)
diff --git a/arch/arm/include/asm/arch-ls102xa/immap_ls102xa.h 
b/arch/arm/include/asm/arch-ls102xa/immap_ls102xa.h
index c34fd63..1415b0b 100644
--- a/arch/arm/include/asm/arch-ls102xa/immap_ls102xa.h
+++ b/arch/arm/include/asm/arch-ls102xa/immap_ls102xa.h
@@ -6,6 +6,7 @@
 
 #ifndef __ASM_ARCH_LS102XA_IMMAP_H_
 #define __ASM_ARCH_LS102XA_IMMAP_H_
+#include 
 
 #define SVR_MAJ(svr)   (((svr) >>  4) & 0xf)
 #define SVR_MIN(svr)   (((svr) >>  0) & 0xf)
@@ -374,53 +375,7 @@ struct ccsr_serdes {
u8  res_a00[0x1000-0xa00];  /* from 0xa00 to 0xfff */
 };
 
-#define CCI400_CTRLORD_TERM_BARRIER0x0008
-#define CCI400_CTRLORD_EN_BARRIER  0
-#define CCI400_SHAORD_NON_SHAREABLE0x0002
-#define CCI400_DVM_MESSAGE_REQ_EN  0x0002
-#define CCI400_SNOOP_REQ_EN0x0001
-
-/* CCI-400 registers */
-struct ccsr_cci400 {
-   u32 ctrl_ord;   /* Control Override */
-   u32 spec_ctrl;  /* Speculation Control */
-   u32 secure_access;  /* Secure Access */
-   u32 status; /* Status */
-   u32 impr_err;   /* Imprecise Error */
-   u8 res_14[0x100 - 0x14];
-   u32 pmcr;   /* Performance Monitor Control */
-   u8 res_104[0xfd0 - 0x104];
-   u32 pid[8]; /* Peripheral ID */
-   u32 cid[4]; /* Component ID */
-   struct {
-   u32 snoop_ctrl; /* Snoop Control */
-   u32 sha_ord;/* Shareable Override */
-   u8 res_1008[0x1100 - 0x1008];
-   u32 rc_qos_ord; /* read channel QoS Value 

[U-Boot] [PATCH v3 1/3] armv8:fsl-layerscape: Consolidate registers space defination for CCI-400 bus

2017-07-19 Thread Ashish Kumar
CoreLink Cache Coherent Interconnect (CCI) is ARM BUS which
provides full cache coherency between two clusters of multi-core
CPUs and I/O coherency for devices and I/O masters.

This patch add new CONFIG defination "SYS_FSL_HAS_CCI400" and
moves existing register space definaton of CCI-400 bus
from immap_lsch2 to fsl_immap, so that it can be used
for both chasis 2 and chasis 3.

"CONFIG_SYS_CCI400_ADDR" is depricated and new SYS_CCI400_OFFSET
is introduced in Kconfig

Signed-off-by: Ashish Kumar 
Signed-off-by: Prabhakar Kushwaha 
---
v3: 
 This is v3 for https://patchwork.ozlabs.org/patch/731464/

 README |  9 
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig  | 13 ++
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c|  1 +
 arch/arm/cpu/armv8/fsl-layerscape/soc.c| 10 +++--
 .../include/asm/arch-fsl-layerscape/immap_lsch2.h  | 49 -
 board/freescale/ls1012afrdm/ls1012afrdm.c  |  4 +-
 board/freescale/ls1012aqds/ls1012aqds.c|  4 +-
 board/freescale/ls1012ardb/ls1012ardb.c|  3 +-
 board/freescale/ls1021aqds/ls1021aqds.c|  9 ++--
 include/fsl_immap.h| 51 ++
 10 files changed, 94 insertions(+), 59 deletions(-)

diff --git a/README b/README
index c73f6dd..165f403 100644
--- a/README
+++ b/README
@@ -312,6 +312,15 @@ Many of the options are named exactly as the corresponding 
Linux
 kernel configuration options. The intention is to make it easier to
 build a config tool - later.
 
+- ARM Platform Bus Type(CCI):
+   CoreLink Cache Coherent Interconnect (CCI) is ARM BUS which
+   provides full cache coherency between two clusters of multi-core
+   CPUs and I/O coherency for devices and I/O masters
+
+   CONFIG_SYS_FSL_HAS_CCI400
+
+   Defined For SoC that has cache coherent interconnect
+   CCN-400
 
 The following options need to be configured:
 
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 5825f9b..1132969 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -84,6 +84,7 @@ config ARCH_LS2080A
 
 config FSL_LSCH2
bool
+   select SYS_FSL_HAS_CCI400
select SYS_FSL_HAS_SEC
select SYS_FSL_SEC_COMPAT_5
select SYS_FSL_SEC_BE
@@ -247,6 +248,15 @@ config QSPI_AHB_INIT
  But some QSPI flash size up to 64MBytes, so initialize the QSPI AHB
  bus for those flashes to support the full QSPI flash size.
 
+config SYS_CCI400_OFFSET
+   hex "Offset for CCI400 base"
+   depends on SYS_FSL_HAS_CCI400
+   default 0x309 if ARCH_LS1088A
+   default 0x18 if FSL_LSCH2
+   help
+ Offset for CCI400 base
+ CCI400 base addr = CCSRBAR + CCI400_OFFSET
+
 config SYS_FSL_IFC_BANK_COUNT
int "Maximum banks of Integrated flash controller"
depends on ARCH_LS1043A || ARCH_LS1046A || ARCH_LS2080A
@@ -254,6 +264,9 @@ config SYS_FSL_IFC_BANK_COUNT
default 4 if ARCH_LS1046A
default 8 if ARCH_LS2080A
 
+config SYS_FSL_HAS_CCI400
+   bool
+
 config SYS_FSL_HAS_DP_DDR
bool
 
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index c6fede3..f38e388 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -214,6 +214,7 @@ static inline void final_mmu_setup(void)
}
}
 #endif
+#include 
 
/* Reset the fill ptr */
gd->arch.tlb_fillptr = tlb_addr_save;
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index aee1ffa..ddb7d82 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -285,7 +286,8 @@ static void erratum_a008850_early(void)
 {
 #ifdef CONFIG_SYS_FSL_ERRATUM_A008850
/* part 1 of 2 */
-   struct ccsr_cci400 __iomem *cci = (void *)CONFIG_SYS_CCI400_ADDR;
+   struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
+   CONFIG_SYS_CCI400_OFFSET);
struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
 
/* Skip if running at lower exception level */
@@ -304,7 +306,8 @@ void erratum_a008850_post(void)
 {
 #ifdef CONFIG_SYS_FSL_ERRATUM_A008850
/* part 2 of 2 */
-   struct ccsr_cci400 __iomem *cci = (void *)CONFIG_SYS_CCI400_ADDR;
+   struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
+   CONFIG_SYS_CCI400_OFFSET);
struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
u32 tmp;
 
@@ -439,7 +442,8 @@ int setup_chip_volt(void)
 
 void 

[U-Boot] [PATCH v3 1/1] efi_loader: implement ConvertDeviceNodeToText

2017-07-19 Thread Heinrich Schuchardt
Move the logic for converting a node to text from
efi_convert_device_path_to_text to convert_device_node_to_text.

Provide a wrapper function convert_device_node_to_text_ext.

As we use only shallow device paths so we can call
directly call efi_device_node_to_text from efi_device_path_to_text.

Add output for MAC addresses.

Add output for not yet supported types/subtypes.

Signed-off-by: Heinrich Schuchardt 
---
v3
This patch replaces the patch series starting at
https://patchwork.ozlabs.org/patch/787983/
https://lists.denx.de/pipermail/u-boot/2017-July/298142.html
---
 lib/efi_loader/efi_device_path_to_text.c | 126 +++
 1 file changed, 96 insertions(+), 30 deletions(-)

diff --git a/lib/efi_loader/efi_device_path_to_text.c 
b/lib/efi_loader/efi_device_path_to_text.c
index a7a513047f..57e00bf777 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -6,62 +6,128 @@
  *  SPDX-License-Identifier: GPL-2.0+
  */
 
+#define DEBUG 1
+
 #include 
 #include 
 
-#define MEDIA_DEVICE_PATH 4
-#define FILE_PATH_MEDIA_DEVICE_PATH 4
+#define MAC_OUTPUT_LEN 22
+#define UNKNOWN_OUTPUT_LEN 23
 
 const efi_guid_t efi_guid_device_path_to_text_protocol =
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
 
-uint16_t *efi_convert_device_node_to_text(
+static uint16_t *efi_convert_device_node_to_text(
struct efi_device_path_protocol *device_node,
bool display_only,
bool allow_shortcuts)
 {
-   EFI_ENTRY("%p, %d, %d", device_node, display_only, allow_shortcuts);
-
-   EFI_EXIT(EFI_UNSUPPORTED);
-   return NULL;
-}
-
-uint16_t *efi_convert_device_path_to_text(
-   struct efi_device_path_protocol *device_path,
-   bool display_only,
-   bool allow_shortcuts)
-{
-   EFI_ENTRY("%p, %d, %d", device_path, display_only, allow_shortcuts);
-
unsigned long buffer_size;
efi_status_t r;
uint16_t *buffer = NULL;
+   int i;
+
+
+   EFI_ENTRY("%p, %d, %d", device_node, display_only, allow_shortcuts);
+
+   switch (device_node->type) {
+   case DEVICE_PATH_TYPE_END:
+   return NULL;
+   case DEVICE_PATH_TYPE_MESSAGING_DEVICE:
+   switch (device_node->sub_type) {
+   case DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR: {
+   struct efi_device_path_mac_addr *dp =
+   (struct efi_device_path_mac_addr *)device_node;
 
-   switch (device_path->type) {
-   case MEDIA_DEVICE_PATH:
-   switch (device_path->sub_type) {
-   case FILE_PATH_MEDIA_DEVICE_PATH:
-   buffer_size = device_path->length - 4;
+   if (dp->if_type != 0 && dp->if_type != 1)
+   break;
+   r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
+ 2 * MAC_OUTPUT_LEN,
+ (void **));
+   if (r != EFI_SUCCESS)
+   return NULL;
+   sprintf((char *)buffer,
+   "MAC(%02x%02x%02x%02x%02x%02x,0x%1x)",
+   dp->mac.addr[0], dp->mac.addr[1],
+   dp->mac.addr[2], dp->mac.addr[3],
+   dp->mac.addr[4], dp->mac.addr[5],
+   dp->if_type);
+   for (i = MAC_OUTPUT_LEN - 1; i >= 0; --i)
+   buffer[i] = ((uint8_t *)buffer)[i];
+   break;
+   }
+   }
+   case DEVICE_PATH_TYPE_MEDIA_DEVICE:
+   switch (device_node->sub_type) {
+   case DEVICE_PATH_SUB_TYPE_FILE_PATH:
+   buffer_size = device_node->length - 4;
r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
  buffer_size, (void **) );
-   if (r == EFI_SUCCESS)
-   memcpy(buffer, device_path->data, buffer_size);
+   if (r != EFI_SUCCESS)
+   return NULL;
+   memcpy(buffer, device_node->data, buffer_size);
break;
}
}
 
-   if (buffer) {
-   EFI_EXIT(EFI_SUCCESS);
-   } else {
-   debug("type %d, subtype %d\n",
- device_path->type, device_path->sub_type);
-   EFI_EXIT(EFI_UNSUPPORTED);
+   /*
+* For all node types that we do not yet support return
+* 'UNKNOWN(type,subtype)'.
+*/
+   if (!buffer) {
+   r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
+ 2 * UNKNOWN_OUTPUT_LEN,
+ 

Re: [U-Boot] [PATCH v2 1/1] mmc: Add MMC support for stm32h7 Socs

2017-07-19 Thread Jaehoon Chung
Hi Patrice

On 07/19/2017 09:20 PM, Patrice CHOTARD wrote:
> Hi Jaehoon
> 
> On 07/19/2017 12:11 PM, Jaehoon Chung wrote:
>> Hi,
>>
>> On 07/19/2017 04:27 PM, patrice.chot...@st.com wrote:
>>> From: Patrice Chotard 
>>>
>>> This patch adds SD/MMC support for STM32H7 SoCs.
>>>
>>> Here is an extraction of SDMMC main features, embedded in
>>> STM32H7 SoCs.
>>> The SD/MMC block include the following:
>>>   _ Full compliance with MultiMediaCard System Specification
>>> Version 4.51. Card support for three different databus modes:
>>> 1-bit (default), 4-bit and 8-bit.
>>>   _ Full compatibility with previous versions of MultiMediaCards
>>> (backward compatibility).
>>>   _ Full compliance with SD memory card specifications version 4.1.
>>> (SDR104 SDMMC_CK speed limited to maximum allowed IO speed,
>>>  SPI mode and UHS-II mode not supported).
>>>   _ Full compliance with SDIO card specification version 4.0.
>>> Card support for two different databus modes: 1-bit (default)
>>> and 4-bit. (SDR104 SDMMC_CK speed limited to maximum allowed IO
>>> speed, SPI mode and UHS-II mode not supported).
>>>   _ Data transfer up to 208 Mbyte/s for the 8 bit mode.
>>> (depending maximum allowed IO speed).
>>>   _ Data and command output enable signals to control external
>>> bidirectional drivers.
>>>
>>> The current version of the SDMMC supports only one SD/SDIO/MMC card
>>> at any one time and a stack of MMC Version 4.51 or previous.
>>>
>>> Signed-off-by: Christophe Kerello 
>>> Signed-off-by: Patrice Chotard 
>>> ---
>>>
>>> v2: _ add .get_cd() callback support
>>>
>>>   drivers/mmc/Kconfig|   8 +
>>>   drivers/mmc/Makefile   |   1 +
>>>   drivers/mmc/stm32_sdmmc2.c | 619 
>>> +
>>>   3 files changed, 628 insertions(+)
>>>   create mode 100644 drivers/mmc/stm32_sdmmc2.c
>>>
>>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
>>> index 82b8d75..f2e4c26 100644
>>> --- a/drivers/mmc/Kconfig
>>> +++ b/drivers/mmc/Kconfig
>>> @@ -377,6 +377,14 @@ config GENERIC_ATMEL_MCI
>>>   the SD Memory Card Specification V2.0, the SDIO V2.0 specification
>>>   and CE-ATA V1.1.
>>>   
>>> +config STM32_SDMMC2
>>
>> Why add the SDMMC2? not SDMMC?
>> Is there a special reason?
> 
> It's simply the IP name
> 
>>
>>> +   bool "STMicroelectronics STM32H7 SD/MMC Host Controller support"
>>> +   depends on DM_MMC && OF_CONTROL && DM_MMC_OPS
>>> +   help
>>> + This selects support for the SD/MMC controller on STM32H7 SoCs.
>>> + If you have a board based on such a SoC and with a SD/MMC slot,
>>> + say Y or M here.
>>> +
>>>   endif
>>>   
>>>   config TEGRA124_MMC_DISABLE_EXT_LOOPBACK
>>> diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
>>> index 2d781c3..2584663 100644
>>> --- a/drivers/mmc/Makefile
>>> +++ b/drivers/mmc/Makefile
>>> @@ -43,6 +43,7 @@ obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
>>>   obj-$(CONFIG_MMC_SANDBOX) += sandbox_mmc.o
>>>   obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o
>>>   obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
>>> +obj-$(CONFIG_STM32_SDMMC2) += stm32_sdmmc2.o
>>>   
>>>   # SDHCI
>>>   obj-$(CONFIG_MMC_SDHCI)   += sdhci.o
>>> diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
>>> new file mode 100644
>>> index 000..84f96e5
>>> --- /dev/null
>>> +++ b/drivers/mmc/stm32_sdmmc2.c
>>> @@ -0,0 +1,619 @@
>>> +/*
>>> + *  Copyright (c) 2017 STMicrelectronics
>>> + *
>>> + * SPDX-License-Identifier:GPL-2.0
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +struct stm32_sdmmc2 {
>>> +   u32 power;  /* SDMMC power control [0x00] */
>>> +   u32 clkcr;  /* SDMMC clock control [0x04] */
>>> +   u32 arg;/* SDMMC argument  [0x08] */
>>> +   u32 cmd;/* SDMMC command   [0x0C] */
>>> +   u32 respcmd;/* SDMMC command response  [0x10] */
>>> +   u32 resp1;  /* SDMMC response 1[0x14] */
>>> +   u32 resp2;  /* SDMMC response 2[0x18] */
>>> +   u32 resp3;  /* SDMMC response 3[0x1C] */
>>> +   u32 resp4;  /* SDMMC response 4[0x20] */
>>> +   u32 dtimer; /* SDMMC data timer[0x24] */
>>> +   u32 dlen;   /* SDMMC data length   [0x28] */
>>> +   u32 dctrl;  /* SDMMC data control  [0x2C] */
>>> +   u32 dcount; /* SDMMC data counter  [0x30] */
>>> +   u32 sta;/* SDMMC status[0x34] */
>>> +   u32 icr;/* SDMMC interrupt clear   [0x38] */
>>> +   u32 mask;   /* SDMMC mask  

[U-Boot] [PATCH 1/1] efi_console: use EFIAPI for callback functions

2017-07-19 Thread Heinrich Schuchardt
The call to efi_create_event requires notification functions
flagged as EFIAPI.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_console.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index f37d457847..13279d3f48 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -437,11 +437,12 @@ struct efi_simple_input_interface efi_con_in = {
 
 static struct efi_event *console_timer_event;
 
-static void efi_key_notify(struct efi_event *event, void *context)
+static void EFIAPI efi_key_notify(struct efi_event *event, void *context)
 {
 }
 
-static void efi_console_timer_notify(struct efi_event *event, void *context)
+static void EFIAPI efi_console_timer_notify(struct efi_event *event,
+   void *context)
 {
EFI_ENTRY("%p, %p", event, context);
if (tstc())
-- 
2.13.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] clk: Kconfig: Add dependences of SPL_CLK

2017-07-19 Thread Wenyou Yang
The SPL_CLK config should depend on SPL && SPL_DM.

Signed-off-by: Wenyou Yang 
---

 drivers/clk/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 44da716b26..628f76bc48 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -12,7 +12,7 @@ config CLK
 
 config SPL_CLK
bool "Enable clock support in SPL"
-   depends on CLK
+   depends on CLK && SPL && SPL_DM
help
  The clock subsystem adds a small amount of overhead to the image.
  If this is acceptable and you have a need to use clock drivers in
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 0/5] Extend xhci-dwc3

2017-07-19 Thread Masahiro Yamada
Hi.


2017-07-18 18:40 GMT+09:00 Marek Vasut :
> On 07/18/2017 11:38 AM, patrice.chot...@st.com wrote:
>> From: Patrice Chotard 
>>
>> This series extend xhci-dwc3.c drivers by :
>>   _ converting it to DM model,
>>   _ adding dual role mode support from DT
>>   _ adding new generic_phy_valid() method in PHY framework
>>   _ adding support of generic PHY framework
>>
>>
>> v7:   _ add Reviewed-by in patch 1
>>   _ declare bool generic_phy_valid(struct phy *phy) as static inline in
>> patch 4
>> v6:   _ remove useless struct xhci_dwc3 in patch 1
>> v5:   _ rebase on top of dm/master in order to use the last livetree update
>>   _ replace dev_get_addr() by devfdt_get_addr() in patch 1
>> v4:   _ set phy->dev to NULL in case of generic_phy_get_by_index()
>> v3:   _ introduce generic_phy_valid() method
>>   _ add Reviewed-by
>> v2:   _ use dev_get_addr() in PATCH 1 and removed useless piece of code
>>
>> Patrice Chotard (5):
>>   usb: host: xhci-dwc3: Convert driver to DM
>>   usb: host: xhci-dwc3: Add dual role mode support from DT
>>   drivers: phy: Set phy->dev to NULL when generic_phy_get_by_index()
>> fails
>>   drivers: phy: add generic_phy_valid() method
>>   usb: host: xhci-dwc3: Add generic PHY support
>>
>>  drivers/phy/phy-uclass.c |  1 +
>>  drivers/usb/host/xhci-dwc3.c | 87 
>> 
>>  include/generic-phy.h| 11 ++
>>  3 files changed, 99 insertions(+)
>>
> Applied all, thanks.
>
> --


I tried to convert xhci-dwc3.c into a DM driver one year before:
http://patchwork.ozlabs.org/patch/622563/

After our discussion,
a problem was duplication between
drivers/usb/host/xhci-dwc3.c and drivers/usb/dwc3/.

I has been too busy to track this work, but
was that problem solved?

How will glue-layers work?


-- 
Best Regards
Masahiro Yamada
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] armv8: errata: Implement workaround for Cortex-A53 Erratum 855873

2017-07-19 Thread Alison Wang
855873: An eviction might overtake a cache clean operation
Workaround: The erratum can be avoided by upgrading cache clean by
address operations to cache clean and invalidate operations. For
Cortex-A53 r0p3 and later release, this can be achieved by setting
CPUACTLR.ENDCASCI to 1.

This patch is to implement the workaround for this erratum.

Signed-off-by: Alison Wang 
---
 arch/arm/Kconfig  |  3 +++
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  2 ++
 arch/arm/cpu/armv8/start.S| 15 ++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d43aaac..4a885a3 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -103,6 +103,9 @@ config ARM_ERRATA_852421
 config ARM_ERRATA_852423
bool
 
+config ARM_ERRATA_855873
+   bool
+
 config CPU_ARM720T
bool
select SYS_CACHE_SHIFT_5
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 5825f9b..63658b5 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -1,6 +1,7 @@
 config ARCH_LS1012A
bool
select ARMV8_SET_SMPEN
+   select ARM_ERRATA_855873
select FSL_LSCH2
select SYS_FSL_DDR_BE
select SYS_FSL_MMDC
@@ -11,6 +12,7 @@ config ARCH_LS1012A
 config ARCH_LS1043A
bool
select ARMV8_SET_SMPEN
+   select ARM_ERRATA_855873
select FSL_LSCH2
select SYS_FSL_DDR
select SYS_FSL_DDR_BE
diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index 5c500be..3484fd8 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -170,7 +170,10 @@ reset_sctrl:
 WEAK(apply_core_errata)
 
mov x29, lr /* Save LR */
-   /* For now, we support Cortex-A57 specific errata only */
+   /* For now, we support Cortex-A53, Cortex-A57 specific errata */
+
+   /* Check if we are running on a Cortex-A53 core */
+   branch_if_a53_core x0, apply_a53_core_errata
 
/* Check if we are running on a Cortex-A57 core */
branch_if_a57_core x0, apply_a57_core_errata
@@ -178,6 +181,16 @@ WEAK(apply_core_errata)
mov lr, x29 /* Restore LR */
ret
 
+apply_a53_core_errata:
+
+#ifdef CONFIG_ARM_ERRATA_855873
+   mrs x0, S3_1_c15_c2_0   /* cpuactlr_el1 */
+   /* Enable data cache clean as data cache clean/invalidate */
+   orr x0, x0, #1 << 44
+   msr S3_1_c15_c2_0, x0   /* cpuactlr_el1 */
+#endif
+   b 0b
+
 apply_a57_core_errata:
 
 #ifdef CONFIG_ARM_ERRATA_828024
-- 
2.1.0.27.g96db324

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Uboot compatible with board Tegra124-nyan-big (ChromeBook G3 HP 14")

2017-07-19 Thread Alexandre N. Perfeito
  Hi Simon,

Could you Help ?


Best regards

Perfeito, Alexander



De: Alexandre N. Perfeito 
Enviado: terça-feira, 18 de julho de 2017 11:50
Para: u-boot@lists.denx.de
Cc: Simon Glass
Assunto: Enc: Uboot compatible with board Tegra124-nyan-big (ChromeBook G3 HP 
14")


  Hi,



   I resend the e-mail as you asked !


  Can help in this tip .


Best Regards

Perfeito,Alexander


De: s...@google.com  em nome de Simon Glass 
Enviado: segunda-feira, 17 de julho de 2017 19:50
Para: Alexandre N. Perfeito
Assunto: Re: Uboot compatible with board Tegra124-nyan-big (ChromeBook G3 HP 
14")

Hi,

On 17 July 2017 at 10:33, Alexandre N. Perfeito 
> wrote:


Simon,


Hi , My Name is Alexander and i need some tip information about U-boot 
Board Nyan-Big to runinng Linux v4.4.x.x.

Can you please resend this to the U-Boot mailing list and cc me?

Thanks,
Simon


I compiled source 4.4.0.70 Ubuntu distribution in chroot environment in my 
chormebook Tegra Tk1.
After compilation the generated files were the following:


[aperfeito@alarm boot]$ ls -l
total 24992
-rw-r--r-- 1 root root98874 Jul 13 14:54 config-4.4.70-ARCH
-rw-r--r-- 1 root root  8277506 Jul 13 14:54 initrd.img-4.4.70-ARCH
-rw-r--r-- 1 root root  2033244 Jul 13 14:54 System.map-4.4.70-ARCH
-rw-r--r-- 1 root root 15175680 Jul 13 14:54 vmlinuz-4.4.70-ARCH


I also compiled the u-boot-tegra in the same environment in chroot Ubuntu 
Xenial distribution these were compiled according to the email of Tom Warren 
send before

  Make 'nyan-big_defconfig' and everything ok as you see below the generated 
files:


[aperfeito@alarm u-boot-tegra]$ ls *.bin
u-boot.bin  u-boot-dtb-tegra.bin  u-boot-nodtb-tegra.bin
u-boot-dtb.bin  u-boot-nodtb.bin  u-boot-tegra.bin


Now is the tip I'm asking you:
I have two suggestions on how to put this in the KERNEL partition of my USB.
  My USB has two partitions
   To 1st. KERNEL Name with 16 megabytes of space dev / sda6
   A 2st.  ROOFS   Name approximately 29 Gigabytes of space where I worked to 
compile the UbuntuXenial and Uboot-Tegra srcs kernel as you see in the email.



Sugestion : 1
mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg
  dd if=/dev/zero of=bootloader.bin bs=512 count=1
  vbutil_kernel \
--pack vmlinux.kpart \
--version 1 \
--vmlinuz vmlinux.uimg \
--arch arm \
--keyblock kernel.keyblock \   --> How I do This  if necessary
--signprivate kernel_data_key.vbprivk \  --> How I do This if necessary
--config cmdline \ --> TXT file whit this config below
--bootloader bootloader.bin


  *   kernel.its adjust to files below as given to te src kernel 4.4.0-70
./arch/arm/boot/dts/tegra124-nyan-blaze.dtb
./arch/arm/boot/dts/tegra124-nyan-big.dtb
  *
___TXT CONFIG FILE 
__
  *
console=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd 
lsm.module_locking=0  ## OR ###
  *
initrd=/boot/initrd.img-4.4.0-ARCH console=ttyS0,115200n8 console=tty1 
ignore_loglevel earlyprintk cgroup_enable=memory root=/dev/sda7

  ###  For config line need your sugestion with is the best.


Sugestion: 2

  I have to copy the kernel, generated initramfs, and dtb to the SDA6 partition 
and added the following kernel config to /dev/sda7/roofsparttion 
:/boot/extlinux/extlinux.conf


LABEL UbuntuXenial
 MENU LABEL UbuntuXenial on sda7 with 4.4 kernel
 LINUX /boot/vmlinuz-4.4.0
 FDT /boot/dtb/tegra124-nyan-big.dtb
 APPEND initrd=/boot/initrd.img-4.4.0-ARCH console=ttyS0,115200n8 console=tty1 
ignore_loglevel earlyprintk cgroup_enable=memory root=/dev/sda7


How to make U-boot-Tegra now Work with Kernel 4.4.x.x as v3.10.x.x Kernels 
booting on USB.

Best Regards
Perfeito Alexander









De: Tom Warren >
Enviado: segunda-feira, 17 de julho de 2017 10:48
Para: Alexandre N. Perfeito
Cc: Simon Glass
Assunto: RE: Uboot compatible with board Tegra124-nyan-big (ChromeBook G3 HP 
14")


See ‘nyan-big_defconfig’. Added Simon to CC as he’s used this build quite a lot.



HTH,



Tom



From: Alexandre N. Perfeito 
[mailto:perfeit...@hotmail.com]
Sent: Wednesday, July 12, 2017 11:02 AM
To: Tom Warren >
Subject: Uboot compatible with board Tegra124-nyan-big (ChromeBook G3 HP 14")



Tom,



   Hi,

  I woud like to know if exist u-boot/configs/defconfig-for-this-board , to 
build a Das-U-boot to running Mainline Kernel 4.4



Thanks



Best Regards



Perfeito,Alexander






This email message is for the sole use of the intended recipient(s) and may 
contain confidential information.  Any unauthorized review, use, 

[U-Boot] [PATCH v1 1/1] net: phy: Add AFE settings to the Broadcom Cygnus phy

2017-07-19 Thread Arun Parameswaran
Added the AFE (Analog Front End) settings for stability to the
Broadcom Cygnus phy. This improves the time take to perform
auto negotiation.

Signed-off-by: Arun Parameswaran 
---
 drivers/net/phy/broadcom.c | 64 +-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 9871cc3..e4afa90 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -30,6 +30,29 @@
 #define MIIM_BCM54XX_EXP_SEL_SSD   0x0e00  /* Secondary SerDes select */
 #define MIIM_BCM54XX_EXP_SEL_ER0x0f00  /* Expansion register 
select */
 
+#define MIIM_BCM_AUXCNTL_SHDWSEL_MISC  0x0007
+#define MIIM_BCM_AUXCNTL_ACTL_SMDSP_EN 0x0800
+
+#define MIIM_BCM_CHANNEL_WIDTH0x2000
+
+static void bcm_phy_write_misc(struct phy_device *phydev,
+  u16 reg, u16 chl, u16 value)
+{
+   int reg_val;
+
+   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54xx_AUXCNTL,
+ MIIM_BCM_AUXCNTL_SHDWSEL_MISC);
+
+   reg_val = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54xx_AUXCNTL);
+   reg_val |= MIIM_BCM_AUXCNTL_ACTL_SMDSP_EN;
+   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54xx_AUXCNTL, reg_val);
+
+   reg_val = (chl * MIIM_BCM_CHANNEL_WIDTH) | reg;
+   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL, reg_val);
+
+   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA, value);
+}
+
 /* Broadcom BCM5461S */
 static int bcm5461_config(struct phy_device *phydev)
 {
@@ -152,11 +175,50 @@ static int bcm_cygnus_startup(struct phy_device *phydev)
return genphy_parse_link(phydev);
 }
 
+static void bcm_cygnus_afe(struct phy_device *phydev)
+{
+   /* ensures smdspclk is enabled */
+   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54xx_AUXCNTL, 0x0c30);
+
+   /* AFE_VDAC_ICTRL_0 bit 7:4 Iq=1100 for 1g 10bt, normal modes */
+   bcm_phy_write_misc(phydev, 0x39, 0x01, 0xA7C8);
+
+   /* AFE_HPF_TRIM_OTHERS bit11=1, short cascode for all modes*/
+   bcm_phy_write_misc(phydev, 0x3A, 0x00, 0x0803);
+
+   /* AFE_TX_CONFIG_1 bit 7:4 Iq=1100 for test modes */
+   bcm_phy_write_misc(phydev, 0x3A, 0x01, 0xA740);
+
+   /* AFE TEMPSEN_OTHERS rcal_HT, rcal_LT 1 */
+   bcm_phy_write_misc(phydev, 0x3A, 0x03, 0x8400);
+
+   /* AFE_FUTURE_RSV bit 2:0 rccal <2:0>=100 */
+   bcm_phy_write_misc(phydev, 0x3B, 0x00, 0x0004);
+
+   /* Adjust bias current trim to overcome digital offSet */
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x1E, 0x02);
+
+   /* make rcal=100, since rdb default is 000 */
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x17, 0x00B1);
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x15, 0x0010);
+
+   /* CORE_EXPB0, Reset R_CAL/RC_CAL Engine */
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x17, 0x00B0);
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x15, 0x0010);
+
+   /* CORE_EXPB0, Disable Reset R_CAL/RC_CAL Engine */
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x17, 0x00B0);
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x15, 0x);
+}
+
 static int bcm_cygnus_config(struct phy_device *phydev)
 {
genphy_config_aneg(phydev);
-
phy_reset(phydev);
+   /* AFE settings for PHY stability */
+   bcm_cygnus_afe(phydev);
+   /* Forcing aneg after applying the AFE settings */
+   genphy_restart_aneg(phydev);
 
return 0;
 }
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mkimage: check environment for dtc binary location

2017-07-19 Thread Hauke Mehrtens
Currently mkimage assumes the dtc binary is in the path and fails
otherwise. This patch makes it check the DTC environment variable first
for the dtc binary and then fall back to the default path. This makes
it possible to call the u-boot build with make DTC=... and build a fit
image with the dtc binary not being the the default path.

Signed-off-by: Hauke Mehrtens 
Cc: Simon Glass 
---
 tools/fit_image.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 4dc8bd8862..d7a7b07faf 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -647,9 +647,14 @@ static int fit_handle_file(struct image_tool_params 
*params)
}
*cmd = '\0';
} else if (params->datafile) {
+   const char* dtc = getenv("DTC");
+
+   if (!dtc)
+   dtc = MKIMAGE_DTC;
+
/* dtc -I dts -O dtb -p 500 datafile > tmpfile */
snprintf(cmd, sizeof(cmd), "%s %s %s > %s",
-MKIMAGE_DTC, params->dtc, params->datafile, tmpfile);
+dtc, params->dtc, params->datafile, tmpfile);
debug("Trying to execute \"%s\"\n", cmd);
} else {
snprintf(cmd, sizeof(cmd), "cp %s %s",
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 13/13] usb: xhci: Set 'Average TRB Length' to 8 for control endpoints

2017-07-19 Thread Bin Meng
Update the codes to conform with xHCI spec 6.2.3.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 drivers/usb/host/xhci-mem.c | 6 ++
 drivers/usb/host/xhci.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index d5eab3a..2f63fc4 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -840,6 +840,12 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl 
*ctrl,
trb_64 = (uintptr_t)virt_dev->eps[0].ring->first_seg->trbs;
ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
 
+   /*
+* xHCI spec 6.2.3:
+* software shall set 'Average TRB Length' to 8 for control endpoints.
+*/
+   ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(8));
+
/* Steps 7 and 8 were done in xhci_alloc_virt_device() */
 
xhci_flush_cache((uintptr_t)ep0_ctx, sizeof(struct xhci_ep_ctx));
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 3508004..5fd200a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -602,6 +602,12 @@ static int xhci_set_configuration(struct usb_device *udev)
ep_ctx[ep_index]->deq = cpu_to_le64(trb_64 |
virt_dev->eps[ep_index].ring->cycle_state);
 
+   /*
+* xHCI spec 6.2.3:
+* 'Average TRB Length' should be 8 for control endpoints.
+*/
+   if (usb_endpoint_xfer_control(endpt_desc))
+   avg_trb_len = 8;
ep_ctx[ep_index]->tx_info =
cpu_to_le32(EP_MAX_ESIT_PAYLOAD_LO(max_esit_payload) |
EP_AVG_TRB_LENGTH(avg_trb_len));
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 10/13] usb: xhci: Honor endpoint's interval

2017-07-19 Thread Bin Meng
USB endpoint reports the period between consecutive requests to send
or receive data as bInverval in its endpoint descriptor. So far this
is ignored by xHCI driver and the 'Interval' field in xHC's endpoint
context is always programmed to zero which means 1ms for low speed
or full speed , or 125us for high speed or super speed. We should
honor the interval by getting it from endpoint descriptor.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 drivers/usb/host/xhci.c | 196 
 drivers/usb/host/xhci.h |   5 +-
 include/linux/usb/ch9.h |  20 +
 3 files changed, 219 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 88e18cf..02bbab5 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -257,6 +257,173 @@ static unsigned int xhci_get_ep_index(struct 
usb_endpoint_descriptor *desc)
return index;
 }
 
+/*
+ * Convert bInterval expressed in microframes (in 1-255 range) to exponent of
+ * microframes, rounded down to nearest power of 2.
+ */
+static unsigned int xhci_microframes_to_exponent(unsigned int desc_interval,
+unsigned int min_exponent,
+unsigned int max_exponent)
+{
+   unsigned int interval;
+
+   interval = fls(desc_interval) - 1;
+   interval = clamp_val(interval, min_exponent, max_exponent);
+   if ((1 << interval) != desc_interval)
+   debug("rounding interval to %d microframes, "\
+ "ep desc says %d microframes\n",
+ 1 << interval, desc_interval);
+
+   return interval;
+}
+
+static unsigned int xhci_parse_microframe_interval(struct usb_device *udev,
+   struct usb_endpoint_descriptor *endpt_desc)
+{
+   if (endpt_desc->bInterval == 0)
+   return 0;
+
+   return xhci_microframes_to_exponent(endpt_desc->bInterval, 0, 15);
+}
+
+
+static unsigned int xhci_parse_frame_interval(struct usb_device *udev,
+   struct usb_endpoint_descriptor *endpt_desc)
+{
+   return xhci_microframes_to_exponent(endpt_desc->bInterval * 8, 3, 10);
+}
+
+/*
+ * Convert interval expressed as 2^(bInterval - 1) == interval into
+ * straight exponent value 2^n == interval.
+ */
+static unsigned int xhci_parse_exponent_interval(struct usb_device *udev,
+   struct usb_endpoint_descriptor *endpt_desc)
+{
+   unsigned int interval;
+
+   interval = clamp_val(endpt_desc->bInterval, 1, 16) - 1;
+   if (interval != endpt_desc->bInterval - 1)
+   debug("ep %#x - rounding interval to %d %sframes\n",
+ endpt_desc->bEndpointAddress, 1 << interval,
+ udev->speed == USB_SPEED_FULL ? "" : "micro");
+
+   if (udev->speed == USB_SPEED_FULL) {
+   /*
+* Full speed isoc endpoints specify interval in frames,
+* not microframes. We are using microframes everywhere,
+* so adjust accordingly.
+*/
+   interval += 3;  /* 1 frame = 2^3 uframes */
+   }
+
+   return interval;
+}
+
+/*
+ * Return the polling or NAK interval.
+ *
+ * The polling interval is expressed in "microframes". If xHCI's Interval field
+ * is set to N, it will service the endpoint every 2^(Interval)*125us.
+ *
+ * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval
+ * is set to 0.
+ */
+static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
+   struct usb_endpoint_descriptor *endpt_desc)
+{
+   unsigned int interval = 0;
+
+   switch (udev->speed) {
+   case USB_SPEED_HIGH:
+   /* Max NAK rate */
+   if (usb_endpoint_xfer_control(endpt_desc) ||
+   usb_endpoint_xfer_bulk(endpt_desc)) {
+   interval = xhci_parse_microframe_interval(udev,
+ endpt_desc);
+   break;
+   }
+   /* Fall through - SS and HS isoc/int have same decoding */
+
+   case USB_SPEED_SUPER:
+   if (usb_endpoint_xfer_int(endpt_desc) ||
+   usb_endpoint_xfer_isoc(endpt_desc)) {
+   interval = xhci_parse_exponent_interval(udev,
+   endpt_desc);
+   }
+   break;
+
+   case USB_SPEED_FULL:
+   if (usb_endpoint_xfer_isoc(endpt_desc)) {
+   interval = xhci_parse_exponent_interval(udev,
+   endpt_desc);
+   break;
+   }
+   /*
+* Fall through for interrupt endpoint interval decoding
+* since it uses the same rules as low speed interrupt
+* endpoints.
+*/
+
+ 

[U-Boot] [PATCH v3 11/13] usb: xhci: Program max burst size for endpoint

2017-07-19 Thread Bin Meng
The 'Max Burst Size' indicates to the xHC the maximum number of
consecutive USB transactions that should be executed per scheduling
opportunity. This is a “zero-based” value, where 0 to 15 represents
burst sizes of 1 to 16, but at present this is always set to zero.
Let's program the required value according to real needs.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 drivers/usb/host/xhci.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 02bbab5..b039ab0 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -396,6 +396,22 @@ static u32 xhci_get_endpoint_mult(struct usb_device *udev,
return ss_ep_comp_desc->bmAttributes;
 }
 
+static u32 xhci_get_endpoint_max_burst(struct usb_device *udev,
+   struct usb_endpoint_descriptor *endpt_desc,
+   struct usb_ss_ep_comp_descriptor *ss_ep_comp_desc)
+{
+   /* Super speed and Plus have max burst in ep companion desc */
+   if (udev->speed >= USB_SPEED_SUPER)
+   return ss_ep_comp_desc->bMaxBurst;
+
+   if (udev->speed == USB_SPEED_HIGH &&
+   (usb_endpoint_xfer_isoc(endpt_desc) ||
+usb_endpoint_xfer_int(endpt_desc)))
+   return usb_endpoint_maxp_mult(endpt_desc) - 1;
+
+   return 0;
+}
+
 /*
  * Return the maximum endpoint service interval time (ESIT) payload.
  * Basically, this is the maxpacket size, multiplied by the burst size
@@ -494,6 +510,7 @@ static int xhci_set_configuration(struct usb_device *udev)
u32 max_esit_payload;
unsigned int interval;
unsigned int mult;
+   unsigned int max_burst;
unsigned int avg_trb_len;
 
out_ctx = virt_dev->out_ctx;
@@ -546,6 +563,8 @@ static int xhci_set_configuration(struct usb_device *udev)
interval = xhci_get_endpoint_interval(udev, endpt_desc);
mult = xhci_get_endpoint_mult(udev, endpt_desc,
  ss_ep_comp_desc);
+   max_burst = xhci_get_endpoint_max_burst(udev, endpt_desc,
+   ss_ep_comp_desc);
avg_trb_len = max_esit_payload;
 
ep_index = xhci_get_ep_index(endpt_desc);
@@ -571,7 +590,7 @@ static int xhci_set_configuration(struct usb_device *udev)
(get_unaligned(_desc->wMaxPacketSize)));
 
ep_ctx[ep_index]->ep_info2 |=
-   cpu_to_le32(((0 & MAX_BURST_MASK) << MAX_BURST_SHIFT) |
+   cpu_to_le32(MAX_BURST(max_burst)|
((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT));
 
trb_64 = (uintptr_t)
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 05/13] usb: Read device descriptor after device is addressed for xHCI

2017-07-19 Thread Bin Meng
For xHCI it is not possible to read a device descriptor before it
has been assigned an address. That's why usb_setup_descriptor()
was called with 'do_read' being false. But we really need try to
read the device descriptor before starting any real communication
with the default control endpoint.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 common/usb.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/common/usb.c b/common/usb.c
index 2aaf932..e469534 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -1051,6 +1051,17 @@ static int usb_prepare_device(struct usb_device *dev, 
int addr, bool do_read,
 
mdelay(10); /* Let the SET_ADDRESS settle */
 
+   /*
+* If we haven't read device descriptor before, read it here
+* after device is assigned an address. This is only applicable
+* to xHCI so far.
+*/
+   if (!do_read) {
+   err = usb_setup_descriptor(dev, true);
+   if (err)
+   return err;
+   }
+
return 0;
 }
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 08/13] usb: hub: Clear BH reset status change for a 3.0 hub

2017-07-19 Thread Bin Meng
USB 3.0 hubs report bit[5] in the port status change response as BH
reset. The hub shall set the C_BH_PORT_RESET field for this port.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 common/usb_hub.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index ce85ac6..dc115ad 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -494,6 +494,12 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)
usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_RESET);
}
 
+   if ((portchange & USB_SS_PORT_STAT_C_BH_RESET) &&
+   usb_hub_is_superspeed(dev)) {
+   debug("port %d BH reset change\n", i + 1);
+   usb_clear_port_feature(dev, i + 1, USB_SS_PORT_FEAT_C_BH_RESET);
+   }
+
/* A new USB device is ready at this point */
debug("devnum=%d port=%d: USB dev found\n", dev->devnum, i + 1);
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 12/13] usb: xhci: Set 'Error Count' to 0 for isoch endpoints

2017-07-19 Thread Bin Meng
Per xHCI spec, 'Error Count' should be set to 0 for isoch endpoints.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 drivers/usb/host/xhci.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b039ab0..3508004 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -512,6 +512,7 @@ static int xhci_set_configuration(struct usb_device *udev)
unsigned int mult;
unsigned int max_burst;
unsigned int avg_trb_len;
+   unsigned int err_count = 0;
 
out_ctx = virt_dev->out_ctx;
in_ctx = virt_dev->in_ctx;
@@ -589,9 +590,12 @@ static int xhci_set_configuration(struct usb_device *udev)
cpu_to_le32(MAX_PACKET
(get_unaligned(_desc->wMaxPacketSize)));
 
+   /* Allow 3 retries for everything but isoc, set CErr = 3 */
+   if (!usb_endpoint_xfer_isoc(endpt_desc))
+   err_count = 3;
ep_ctx[ep_index]->ep_info2 |=
cpu_to_le32(MAX_BURST(max_burst)|
-   ((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT));
+   ERROR_COUNT(err_count));
 
trb_64 = (uintptr_t)
virt_dev->eps[ep_index].ring->enqueue;
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 09/13] usb: Handle audio extension endpoint descriptor in usb_parse_config()

2017-07-19 Thread Bin Meng
Normal endpoint descriptor size is 7, but for audio extension it is
9. Handle that correctly when parsing endpoint descriptor.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 common/usb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/usb.c b/common/usb.c
index e469534..35408ba 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -437,12 +437,13 @@ static int usb_parse_config(struct usb_device *dev,
}
break;
case USB_DT_ENDPOINT:
-   if (head->bLength != USB_DT_ENDPOINT_SIZE) {
+   if (head->bLength != USB_DT_ENDPOINT_SIZE &&
+   head->bLength != USB_DT_ENDPOINT_AUDIO_SIZE) {
printf("ERROR: Invalid USB EP length (%d)\n",
head->bLength);
break;
}
-   if (index + USB_DT_ENDPOINT_SIZE >
+   if (index + head->bLength >
dev->config.desc.wTotalLength) {
puts("USB EP descriptor overflowed buffer!\n");
break;
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 06/13] usb: xhci: Fix max packet size for full speed device endpoint 0

2017-07-19 Thread Bin Meng
In xhci_check_maxpacket(), the control endpoint 0 max packet size
is wrongly taken from the interface's endpoint descriptor. However
the default endpoint 0 does not come with an endpoint descriptor
hence is not included in the interface structure. Change to use
epmaxpacketin[0] instead.

The other bug in this routine is that when setting max packet size
to the xHC endpoint 0 context, it does not clear its previous value
at all before programming a new one.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 drivers/usb/host/xhci.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 044d3c2..88e18cf 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -546,16 +546,13 @@ int xhci_check_maxpacket(struct usb_device *udev)
int max_packet_size;
int hw_max_packet_size;
int ret = 0;
-   struct usb_interface *ifdesc;
-
-   ifdesc = >config.if_desc[0];
 
out_ctx = ctrl->devs[slot_id]->out_ctx;
xhci_inval_cache((uintptr_t)out_ctx->bytes, out_ctx->size);
 
ep_ctx = xhci_get_ep_ctx(ctrl, out_ctx, ep_index);
hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2));
-   max_packet_size = usb_endpoint_maxp(>ep_desc[0]);
+   max_packet_size = udev->epmaxpacketin[0];
if (hw_max_packet_size != max_packet_size) {
debug("Max Packet Size for ep 0 changed.\n");
debug("Max packet size in usb_device = %d\n", max_packet_size);
@@ -567,7 +564,8 @@ int xhci_check_maxpacket(struct usb_device *udev)
ctrl->devs[slot_id]->out_ctx, ep_index);
in_ctx = ctrl->devs[slot_id]->in_ctx;
ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index);
-   ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK);
+   ep_ctx->ep_info2 &= cpu_to_le32(~((0x & MAX_PACKET_MASK)
+   << MAX_PACKET_SHIFT));
ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
 
/*
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 04/13] usb: Only get 64 bytes device descriptor for full speed devices

2017-07-19 Thread Bin Meng
Full speed device endpoint 0 can have 8/16/32/64 bMaxPacketSize0.
Other speed devices report fixed value per USB spec. So it only
makes sense if we send a get device descriptor with 64 bytes to
full speed devices.

While we are here, update the comment block to be within 80 cols.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 common/usb.c | 29 +++--
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/common/usb.c b/common/usb.c
index 0904259..2aaf932 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -969,23 +969,24 @@ static int usb_setup_descriptor(struct usb_device *dev, 
bool do_read)
dev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0;
dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0;
 
-   if (do_read) {
+   if (do_read && dev->speed == USB_SPEED_FULL) {
int err;
 
/*
-* Validate we've received only at least 8 bytes, not that we've
-* received the entire descriptor. The reasoning is:
-* - The code only uses fields in the first 8 bytes, so that's 
all we
-*   need to have fetched at this stage.
-* - The smallest maxpacket size is 8 bytes. Before we know the 
actual
-*   maxpacket the device uses, the USB controller may only 
accept a
-*   single packet. Consequently we are only guaranteed to 
receive 1
-*   packet (at least 8 bytes) even in a non-error case.
+* Validate we've received only at least 8 bytes, not that
+* we've received the entire descriptor. The reasoning is:
+* - The code only uses fields in the first 8 bytes, so
+*   that's all we need to have fetched at this stage.
+* - The smallest maxpacket size is 8 bytes. Before we know
+*   the actual maxpacket the device uses, the USB controller
+*   may only accept a single packet. Consequently we are only
+*   guaranteed to receive 1 packet (at least 8 bytes) even in
+*   a non-error case.
 *
-* At least the DWC2 controller needs to be programmed with the 
number
-* of packets in addition to the number of bytes. A request for 
64
-* bytes of data with the maxpacket guessed as 64 (above) 
yields a
-* request for 1 packet.
+* At least the DWC2 controller needs to be programmed with
+* the number of packets in addition to the number of bytes.
+* A request for 64 bytes of data with the maxpacket guessed
+* as 64 (above) yields a request for 1 packet.
 */
err = get_descriptor_len(dev, 64, 8);
if (err)
@@ -1008,7 +1009,7 @@ static int usb_setup_descriptor(struct usb_device *dev, 
bool do_read)
dev->maxpacketsize = PACKET_SIZE_64;
break;
default:
-   printf("usb_new_device: invalid max packet size\n");
+   printf("usb_setup_descriptor: invalid max packet size\n");
return -EIO;
}
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 07/13] usb: hub: Clear port reset before usb_hub_port_connect_change()

2017-07-19 Thread Bin Meng
During usb_hub_port_connect_change(), a port reset set feature
request is issued to the port, and later a port reset clear feature
is done to the same port before the function returns. However at
the end of usb_scan_port(), we attempt to clear port reset again
on a cached port status change variable, which should not be done.

Adjust the call to clear port reset to right before the call to
usb_hub_port_connect_change().

Signed-off-by: Bin Meng 
---

Changes in v3: None

 common/usb_hub.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 70bc6e2..ce85ac6 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -489,6 +489,11 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)
return 0;
}
 
+   if (portchange & USB_PORT_STAT_C_RESET) {
+   debug("port %d reset change\n", i + 1);
+   usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_RESET);
+   }
+
/* A new USB device is ready at this point */
debug("devnum=%d port=%d: USB dev found\n", dev->devnum, i + 1);
 
@@ -543,11 +548,6 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)
   hub->overcurrent_count[i]);
}
 
-   if (portchange & USB_PORT_STAT_C_RESET) {
-   debug("port %d reset change\n", i + 1);
-   usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_RESET);
-   }
-
/*
 * We're done with this device, so let's remove this device from
 * scanning list
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 02/13] usb: configs: Clean up CONFIG_SYS_USB_EVENT_POLL_(xxx) in board configs

2017-07-19 Thread Bin Meng
The following 3 Kconfig options
- CONFIG_SYS_USB_EVENT_POLL
- CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP
- CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE

are already converted to Kconfig. Let's clean up all board configs to
switch over to use them.

Signed-off-by: Bin Meng 
Reviewed-by: Simon Glass 

---

Changes in v3:
- rebase on u-boot-usb/master
- add changes to poplar.h

 configs/A10-OLinuXino-Lime_defconfig   | 1 +
 configs/A10s-OLinuXino-M_defconfig | 1 +
 configs/A13-OLinuXinoM_defconfig   | 1 +
 configs/A13-OLinuXino_defconfig| 1 +
 configs/A20-OLinuXino-Lime2_defconfig  | 1 +
 configs/A20-OLinuXino-Lime_defconfig   | 1 +
 configs/A20-OLinuXino_MICRO_defconfig  | 1 +
 configs/A20-Olimex-SOM-EVB_defconfig   | 1 +
 configs/A33-OLinuXino_defconfig| 1 +
 configs/Ainol_AW1_defconfig| 1 +
 configs/Ampe_A76_defconfig | 1 +
 configs/Auxtek-T003_defconfig  | 1 +
 configs/Auxtek-T004_defconfig  | 1 +
 configs/Bananapi_M2_Ultra_defconfig| 1 +
 configs/Bananapi_defconfig | 1 +
 configs/Bananapro_defconfig| 1 +
 configs/CHIP_defconfig | 1 +
 configs/CHIP_pro_defconfig | 1 +
 configs/CSQ_CS908_defconfig| 1 +
 configs/Chuwi_V7_CW0825_defconfig  | 1 +
 configs/Colombus_defconfig | 1 +
 configs/Cubieboard2_defconfig  | 1 +
 configs/Cubieboard4_defconfig  | 1 +
 configs/Cubieboard_defconfig   | 1 +
 configs/Cubietruck_defconfig   | 1 +
 configs/Cubietruck_plus_defconfig  | 1 +
 configs/Empire_electronix_d709_defconfig   | 1 +
 configs/Empire_electronix_m712_defconfig   | 1 +
 configs/Hummingbird_A31_defconfig  | 1 +
 configs/Hyundai_A7HD_defconfig | 1 +
 configs/Itead_Ibox_A20_defconfig   | 1 +
 configs/Lamobo_R1_defconfig| 1 +
 configs/LicheePi_Zero_defconfig| 1 +
 configs/Linksprite_pcDuino3_Nano_defconfig | 1 +
 configs/Linksprite_pcDuino3_defconfig  | 1 +
 configs/Linksprite_pcDuino_defconfig   | 1 +
 configs/MK808C_defconfig   | 1 +
 configs/MSI_Primo73_defconfig  | 1 +
 configs/MSI_Primo81_defconfig  | 1 +
 configs/Marsboard_A10_defconfig| 1 +
 configs/Mele_A1000G_quad_defconfig | 1 +
 configs/Mele_A1000_defconfig   | 1 +
 configs/Mele_I7_defconfig  | 1 +
 configs/Mele_M3_defconfig  | 1 +
 configs/Mele_M5_defconfig  | 1 +
 configs/Mele_M9_defconfig  | 1 +
 configs/Merrii_A80_Optimus_defconfig   | 1 +
 configs/Mini-X_defconfig   | 1 +
 configs/Nintendo_NES_Classic_Edition_defconfig | 1 +
 configs/Orangepi_defconfig | 1 +
 configs/Orangepi_mini_defconfig| 1 +
 configs/Sinlinx_SinA31s_defconfig  | 1 +
 configs/Sinlinx_SinA33_defconfig   | 1 +
 configs/Sinovoip_BPI_M2_Plus_defconfig | 1 +
 configs/Sinovoip_BPI_M2_defconfig  | 1 +
 configs/Sinovoip_BPI_M3_defconfig  | 1 +
 configs/Sunchip_CX-A99_defconfig   | 1 +
 configs/UTOO_P66_defconfig | 1 +
 configs/Wexler_TAB7200_defconfig   | 1 +
 configs/Wits_Pro_A20_DKT_defconfig | 1 +
 configs/Wobo_i5_defconfig  | 1 +
 configs/Yones_Toptech_BD1078_defconfig | 1 +
 configs/Yones_Toptech_BS1078_V2_defconfig  | 1 +
 configs/ba10_tv_box_defconfig  | 1 +
 configs/bananapi_m64_defconfig | 1 +
 configs/cgtqmx6eval_defconfig  | 1 +
 configs/colorfly_e708_q1_defconfig | 1 +
 configs/difrnce_dit4350_defconfig  | 1 +
 configs/dms-ba16-1g_defconfig  | 1 +
 configs/dms-ba16_defconfig | 1 +
 configs/dserve_dsrv9703c_defconfig | 1 +
 configs/ga10h_v1_1_defconfig   | 1 +
 configs/gt90h_v4_defconfig | 1 +
 configs/gwventana_emmc_defconfig   | 1 +
 configs/gwventana_gw5904_defconfig | 1 +
 configs/gwventana_nand_defconfig   | 1 +
 configs/h8_homlet_v2_defconfig | 1 +
 configs/i12-tvbox_defconfig| 1 +
 configs/iNet_3F_defconfig  | 1 +
 configs/iNet_3W_defconfig  | 1 +
 configs/iNet_86VS_defconfig| 1 +
 configs/iNet_D978_rev2_defconfig   | 1 +
 configs/icnova-a20-swac_defconfig  | 1 +
 configs/inet1_defconfig| 1 +
 configs/inet86dz_defconfig | 1 

[U-Boot] [PATCH v3 03/13] usb: kbd: kconfig: Set a default polling mechanism for USB keyboard

2017-07-19 Thread Bin Meng
The choice of "USB keyboard polling" cannot be optional as without
one mechanism being set, it just doesn't work. Set the default one
to CONFIG_SYS_USB_EVENT_POLL.

Signed-off-by: Bin Meng 
---

Changes in v3: None

 drivers/usb/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index da3ec2f..acbac69 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -75,7 +75,7 @@ if USB_KEYBOARD
 
 choice
prompt "USB keyboard polling"
-   optional
+   default SYS_USB_EVENT_POLL
---help---
  Enable a polling mechanism for USB keyboard.
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 00/13] usb: xhci: Add interrupt transfer support and full speed device support

2017-07-19 Thread Bin Meng
This series is the final series of the xHCI driver update.

This adds the missing interrupt transfer support to xHCI driver, so
that devices like USB keyboard that uses interrupt transfer when
CONFIG_SYS_USB_EVENT_POLL is defined can work.

This also adds full speed device support. Unlike low/high/super speed
devices, full speed device may report its endpoint 0 max packet size
as 8/16/32/64. xHCI driver guesses 64 for the first attempt to get the
initial 8 bytes device descriptor, and later adjusts the context for
endpoint 0.

This series also made several updates to xHCI driver to conform with
the spec.

Previous two series:
[1]: usb: xhci: Fix USB xHCI support on Intel platform
https://lists.denx.de/pipermail/u-boot/2017-June/296166.html
[2]: usb: hub: Support USB 3.0 hubs
https://lists.denx.de/pipermail/u-boot/2017-June/296284.html

This series is available at u-boot-x86/xhci-working3 for testing.

Changes in v3:
- rebase on u-boot-usb/master
- add changes to poplar.h

Bin Meng (13):
  usb: xhci: Add interrupt transfer support
  usb: configs: Clean up CONFIG_SYS_USB_EVENT_POLL_(xxx) in board
configs
  usb: kbd: kconfig: Set a default polling mechanism for USB keyboard
  usb: Only get 64 bytes device descriptor for full speed devices
  usb: Read device descriptor after device is addressed for xHCI
  usb: xhci: Fix max packet size for full speed device endpoint 0
  usb: hub: Clear port reset before usb_hub_port_connect_change()
  usb: hub: Clear BH reset status change for a 3.0 hub
  usb: Handle audio extension endpoint descriptor in usb_parse_config()
  usb: xhci: Honor endpoint's interval
  usb: xhci: Program max burst size for endpoint
  usb: xhci: Set 'Error Count' to 0 for isoch endpoints
  usb: xhci: Set 'Average TRB Length' to 8 for control endpoints

 common/usb.c   |  45 +++--
 common/usb_hub.c   |  16 +-
 configs/A10-OLinuXino-Lime_defconfig   |   1 +
 configs/A10s-OLinuXino-M_defconfig |   1 +
 configs/A13-OLinuXinoM_defconfig   |   1 +
 configs/A13-OLinuXino_defconfig|   1 +
 configs/A20-OLinuXino-Lime2_defconfig  |   1 +
 configs/A20-OLinuXino-Lime_defconfig   |   1 +
 configs/A20-OLinuXino_MICRO_defconfig  |   1 +
 configs/A20-Olimex-SOM-EVB_defconfig   |   1 +
 configs/A33-OLinuXino_defconfig|   1 +
 configs/Ainol_AW1_defconfig|   1 +
 configs/Ampe_A76_defconfig |   1 +
 configs/Auxtek-T003_defconfig  |   1 +
 configs/Auxtek-T004_defconfig  |   1 +
 configs/Bananapi_M2_Ultra_defconfig|   1 +
 configs/Bananapi_defconfig |   1 +
 configs/Bananapro_defconfig|   1 +
 configs/CHIP_defconfig |   1 +
 configs/CHIP_pro_defconfig |   1 +
 configs/CSQ_CS908_defconfig|   1 +
 configs/Chuwi_V7_CW0825_defconfig  |   1 +
 configs/Colombus_defconfig |   1 +
 configs/Cubieboard2_defconfig  |   1 +
 configs/Cubieboard4_defconfig  |   1 +
 configs/Cubieboard_defconfig   |   1 +
 configs/Cubietruck_defconfig   |   1 +
 configs/Cubietruck_plus_defconfig  |   1 +
 configs/Empire_electronix_d709_defconfig   |   1 +
 configs/Empire_electronix_m712_defconfig   |   1 +
 configs/Hummingbird_A31_defconfig  |   1 +
 configs/Hyundai_A7HD_defconfig |   1 +
 configs/Itead_Ibox_A20_defconfig   |   1 +
 configs/Lamobo_R1_defconfig|   1 +
 configs/LicheePi_Zero_defconfig|   1 +
 configs/Linksprite_pcDuino3_Nano_defconfig |   1 +
 configs/Linksprite_pcDuino3_defconfig  |   1 +
 configs/Linksprite_pcDuino_defconfig   |   1 +
 configs/MK808C_defconfig   |   1 +
 configs/MSI_Primo73_defconfig  |   1 +
 configs/MSI_Primo81_defconfig  |   1 +
 configs/Marsboard_A10_defconfig|   1 +
 configs/Mele_A1000G_quad_defconfig |   1 +
 configs/Mele_A1000_defconfig   |   1 +
 configs/Mele_I7_defconfig  |   1 +
 configs/Mele_M3_defconfig  |   1 +
 configs/Mele_M5_defconfig  |   1 +
 configs/Mele_M9_defconfig  |   1 +
 configs/Merrii_A80_Optimus_defconfig   |   1 +
 configs/Mini-X_defconfig   |   1 +
 configs/Nintendo_NES_Classic_Edition_defconfig |   1 +
 configs/Orangepi_defconfig |   1 +
 configs/Orangepi_mini_defconfig|   1 +
 configs/Sinlinx_SinA31s_defconfig  |   1 +
 configs/Sinlinx_SinA33_defconfig   |   1 +
 configs/Sinovoip_BPI_M2_Plus_defconfig |   1 +
 configs/Sinovoip_BPI_M2_defconfig  |   1 +
 

Re: [U-Boot] [PATCH] net: Mark the ip_udp_hdr struct as packed

2017-07-19 Thread Jeroen Hofstee

Hi,


On 07/18/2017 08:10 PM, Joe Hershberger wrote:

Hi Maxime,

On Wed, Jul 12, 2017 at 9:34 AM, Maxime Ripard
 wrote:

The -mno-unaligned-access flag used on ARM to prevent GCC from generating
unaligned accesses (obviously) will only do so on packed structures.

It seems like gcc 7.1 is a bit stricter than previous gcc versions on this,
and using it lead to data abort for unaligned accesses when generating
network traffic.

Fix this by adding the packed attribute to the ip_udp_hdr structure in
order to let GCC do its job.

Signed-off-by: Maxime Ripard 
---
  include/net.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net.h b/include/net.h
index 997db9210a8f..7b815afffafa 100644
--- a/include/net.h
+++ b/include/net.h
@@ -390,7 +390,7 @@ struct ip_udp_hdr {
 u16 udp_dst;/* UDP destination port */
 u16 udp_len;/* Length of UDP packet */
 u16 udp_xsum;   /* Checksum */
-};
+} __attribute__ ((packed));

Do you have an example of why this is unaligned? It seems that the
structure itself is naturally packed (each element is aligned to its
access size). It seems the only time this would hit a dabort is if the
head of the buffer is not 32-bit aligned. Maybe we should address the
place where that is the case instead of forcing byte-wise accesses in
general for this structure?


|Perhaps __attribute__((aligned(2))) can prevent byte wise accesses? 
Regards, Jeroen |



___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] net: Mark the ip_udp_hdr struct as packed

2017-07-19 Thread Joe Hershberger
On Wed, Jul 19, 2017 at 2:01 AM, Maxime Ripard
 wrote:
> Hi Joe,
>
> On Tue, Jul 18, 2017 at 01:10:59PM -0500, Joe Hershberger wrote:
>> On Wed, Jul 12, 2017 at 9:34 AM, Maxime Ripard
>>  wrote:
>> > The -mno-unaligned-access flag used on ARM to prevent GCC from generating
>> > unaligned accesses (obviously) will only do so on packed structures.
>> >
>> > It seems like gcc 7.1 is a bit stricter than previous gcc versions on this,
>> > and using it lead to data abort for unaligned accesses when generating
>> > network traffic.
>> >
>> > Fix this by adding the packed attribute to the ip_udp_hdr structure in
>> > order to let GCC do its job.
>> >
>> > Signed-off-by: Maxime Ripard 
>> > ---
>> >  include/net.h | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/include/net.h b/include/net.h
>> > index 997db9210a8f..7b815afffafa 100644
>> > --- a/include/net.h
>> > +++ b/include/net.h
>> > @@ -390,7 +390,7 @@ struct ip_udp_hdr {
>> > u16 udp_dst;/* UDP destination port */
>> > u16 udp_len;/* Length of UDP packet */
>> > u16 udp_xsum;   /* Checksum */
>> > -};
>> > +} __attribute__ ((packed));
>>
>> Do you have an example of why this is unaligned?
>
> You can have the discussion that led to this patch in "Data abort with
> gcc 7.1", started a week ago.
>
>> It seems that the structure itself is naturally packed (each element
>> is aligned to its access size).
>
> That's true.
>
>> It seems the only time this would hit a dabort is if the head of the
>> buffer is not 32-bit aligned. Maybe we should address the place
>> where that is the case instead of forcing byte-wise accesses in
>> general for this structure?
>
> That's exactly what happens, the pointer to the ip_up_hdr is not
> aligned on 32 bits, and triggers an alignment error.
>
> However, I'm not sure how feasible it would be to align the IP packets
> on 32-bits, since the Ethernet header is only 14 bytes, right?  We
> could use a bounce buffer for each packet, but that's not really
> optimized either.

Yeah, good point.

> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/1] efi_loader: initalize EFI object list only once

2017-07-19 Thread Schuchardt
From: Heinrich Schuchardt 

If several EFI applications are executed in sequence we want
to keep the content of the EFI object list.

Signed-off-by: Heinrich Schuchardt 
---
v2
Rebase based on efi-next 8787b02e32dc
---
 cmd/bootefi.c | 61 ++-
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index e9f14d54af..cf717564c4 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -20,6 +20,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static uint8_t efi_obj_list_initalized;
+
 /*
  * When booting using the "bootefi" command, we don't know which
  * physical device the file came from. So we create a pseudo-device
@@ -104,6 +106,37 @@ static struct efi_object bootefi_device_obj = {
},
 };
 
+/* Initialize and populate EFI object list */
+static void efi_init_obj_list(void)
+{
+   efi_obj_list_initalized = 1;
+   list_add_tail(_image_info_obj.link, _obj_list);
+   list_add_tail(_device_obj.link, _obj_list);
+   efi_console_register();
+#ifdef CONFIG_PARTITIONS
+   efi_disk_register();
+#endif
+#ifdef CONFIG_LCD
+   efi_gop_register();
+#endif
+#ifdef CONFIG_NET
+   void *nethandle = loaded_image_info.device_handle;
+   efi_net_register();
+
+   if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6))
+   loaded_image_info.device_handle = nethandle;
+   else
+   loaded_image_info.device_handle = bootefi_device_path;
+#endif
+#ifdef CONFIG_GENERATE_SMBIOS_TABLE
+   efi_smbios_register();
+#endif
+
+   /* Initialize EFI runtime services */
+   efi_reset_system_init();
+   efi_get_time_init();
+}
+
 static void *copy_fdt(void *fdt)
 {
u64 fdt_size = fdt_totalsize(fdt);
@@ -223,32 +256,8 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
return -ENOENT;
 
/* Initialize and populate EFI object list */
-   INIT_LIST_HEAD(_obj_list);
-   list_add_tail(_image_info_obj.link, _obj_list);
-   list_add_tail(_device_obj.link, _obj_list);
-   efi_console_register();
-#ifdef CONFIG_PARTITIONS
-   efi_disk_register();
-#endif
-#ifdef CONFIG_LCD
-   efi_gop_register();
-#endif
-#ifdef CONFIG_NET
-   void *nethandle = loaded_image_info.device_handle;
-   efi_net_register();
-
-   if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6))
-   loaded_image_info.device_handle = nethandle;
-   else
-   loaded_image_info.device_handle = bootefi_device_path;
-#endif
-#ifdef CONFIG_GENERATE_SMBIOS_TABLE
-   efi_smbios_register();
-#endif
-
-   /* Initialize EFI runtime services */
-   efi_reset_system_init();
-   efi_get_time_init();
+   if (!efi_obj_list_initalized)
+   efi_init_obj_list();
 
/* Call our payload! */
debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
-- 
2.13.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] efi_loader: parameter types for CreateEvent, SetTimer

2017-07-19 Thread Heinrich Schuchardt
The first argument 'type' of CreateEvent is an 32bit unsigned
integer bitmap and not an enum.

The second argument 'type' of SetTimer take values of an
enum which is called EFI_TIMER_DELAY in the UEFI standard.
To avoid confusion rename efi_event_type to efi_timer_delay.

Reported-by: Alexander Graf 
Signed-off-by: Heinrich Schuchardt 
---
 include/efi_api.h |  9 +
 include/efi_loader.h  |  8 
 lib/efi_loader/efi_boottime.c | 11 ++-
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index d52eea4086..8f881d2903 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -22,7 +22,7 @@
 #endif
 
 /* Types and defines for EFI CreateEvent */
-enum efi_event_type {
+enum efi_timer_delay {
EFI_TIMER_STOP = 0,
EFI_TIMER_PERIODIC = 1,
EFI_TIMER_RELATIVE = 2
@@ -59,14 +59,15 @@ struct efi_boot_services {
efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
efi_status_t (EFIAPI *free_pool)(void *);
 
-   efi_status_t (EFIAPI *create_event)(enum efi_event_type type,
+   efi_status_t (EFIAPI *create_event)(uint32_t type,
UINTN notify_tpl,
void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
void *notify_context, struct efi_event **event);
-   efi_status_t (EFIAPI *set_timer)(struct efi_event *event, int type,
-   uint64_t trigger_time);
+   efi_status_t (EFIAPI *set_timer)(struct efi_event *event,
+enum efi_timer_delay type,
+uint64_t trigger_time);
efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events,
struct efi_event **event, unsigned long *index);
efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2abb6b87e1..70dc73bbbc 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -76,13 +76,13 @@ struct efi_object {
  * @signaled:  The notify function was already called
  */
 struct efi_event {
-   u32 type;
+   uint32_t type;
UINTN notify_tpl;
void (EFIAPI *notify_function)(struct efi_event *event, void *context);
void *notify_context;
u64 trigger_next;
u64 trigger_time;
-   enum efi_event_type trigger_type;
+   enum efi_timer_delay trigger_type;
int signaled;
 };
 
@@ -119,13 +119,13 @@ void efi_runtime_relocate(ulong offset, struct 
efi_mem_desc *map);
 /* Call this to set the current device name */
 void efi_set_bootdev(const char *dev, const char *devnr, const char *path);
 /* Call this to create an event */
-efi_status_t efi_create_event(enum efi_event_type type, UINTN notify_tpl,
+efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,
  void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
  void *notify_context, struct efi_event **event);
 /* Call this to set a timer */
-efi_status_t efi_set_timer(struct efi_event *event, int type,
+efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,
   uint64_t trigger_time);
 /* Call this to signal an event */
 void efi_signal_event(struct efi_event *event);
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index ecd8c8fc71..468d14fda3 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -213,7 +213,7 @@ static efi_status_t EFIAPI efi_free_pool_ext(void *buffer)
  */
 static struct efi_event efi_events[16];
 
-efi_status_t efi_create_event(enum efi_event_type type, UINTN notify_tpl,
+efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,
  void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
@@ -248,7 +248,7 @@ efi_status_t efi_create_event(enum efi_event_type type, 
UINTN notify_tpl,
 }
 
 static efi_status_t EFIAPI efi_create_event_ext(
-   enum efi_event_type type, UINTN notify_tpl,
+   uint32_t type, UINTN notify_tpl,
void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
@@ -286,7 +286,7 @@ void efi_timer_check(void)
WATCHDOG_RESET();
 }
 
-efi_status_t efi_set_timer(struct efi_event *event, int type,
+efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,
   uint64_t trigger_time)
 {
   

Re: [U-Boot] How to update Espressobin (U-Boot) firmware?

2017-07-19 Thread Andre Przywara
Hi,

On 19/07/17 17:58, Andreas Färber wrote:
> Hi,
> 
> Am 19.07.2017 um 18:50 schrieb Andre Przywara:
>> On 19/07/17 17:37, Kostya Porotchkin wrote:
>>> I probably have to build and try the SATA image as the next step.
>>
>> Yeah, that was my plan for tonight as well, since this would allow me to
>> experiment safely with the generated image.
>>
>> Oh, BTW: Chain-loading mainline U-Boot worked quite nicely and I could
>> launch the generic debian-testing installer via EFI boot. The only issue
>> was that I was using the U-Boot DT directly, which isn't enough for the
>> kernel (missing clocks and interrupts). I will try to send some patches
>> to bring the U-Boot DT in sync with the kernel one. If this is in place,
>> one could simply attach some (UEFI enabled) USB pen drive and it should
>> start without further ado (given a newer U-Boot in the SPI flash with
>> EFI support).
> 
> Which devices have you successfully enumerated on mainline U-Boot? Does
> SATA work for you? I had reported an endless reset on another board. USB
> was not quite working either last time I tried on the other board -
> either the initial scan or a reset had similar symptoms to SATA.

I was using USB (2.0), that worked with origin/master. I haven't tested
SATA yet, but will try tonight and let you know.

Cheers,
Andre.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] How to update Espressobin (U-Boot) firmware?

2017-07-19 Thread Andreas Färber
Hi,

Am 19.07.2017 um 18:50 schrieb Andre Przywara:
> On 19/07/17 17:37, Kostya Porotchkin wrote:
>> I probably have to build and try the SATA image as the next step.
> 
> Yeah, that was my plan for tonight as well, since this would allow me to
> experiment safely with the generated image.
> 
> Oh, BTW: Chain-loading mainline U-Boot worked quite nicely and I could
> launch the generic debian-testing installer via EFI boot. The only issue
> was that I was using the U-Boot DT directly, which isn't enough for the
> kernel (missing clocks and interrupts). I will try to send some patches
> to bring the U-Boot DT in sync with the kernel one. If this is in place,
> one could simply attach some (UEFI enabled) USB pen drive and it should
> start without further ado (given a newer U-Boot in the SPI flash with
> EFI support).

Which devices have you successfully enumerated on mainline U-Boot? Does
SATA work for you? I had reported an endless reset on another board. USB
was not quite working either last time I tried on the other board -
either the initial scan or a reset had similar symptoms to SATA.

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] dm: core: don't fail to iterate if first one fails to probe

2017-07-19 Thread Rob Clark
On Thu, Jul 13, 2017 at 3:10 PM, Simon Glass  wrote:
> Hi Rob,
>
> On 21 June 2017 at 04:52, Rob Clark  wrote:
>> On Wed, Jun 21, 2017 at 6:23 AM, Peter Robinson  wrote:
>>> On Tue, Jun 20, 2017 at 10:49 PM, Rob Clark  wrote:
 efi_disk_register() would try to iterate all the blk devices.  But if
 the first one in the list failed to probe, uclass_first_device() would
 return NULL and no attempt would be made to register the remaining
 devices.  Also uclass_next_device() needs the same fix.
>>>
>>> This looks related/similar to the "efi_loader: disk: iterate only over
>>> valid block devices" patch [1]
>>>
>>
>> hmm, I don't see uclass_first_device_check() which I guess must be
>> part of another in-flight patch?  I don't mind too much *how* we fix
>> it, as long as it works.  (Although it seems more sensible to just
>> make uclass_first_device()/etc dtrt rather than introducing another
>> function that actually works properly.. but that is only my $0.02)
>
> That patch is now in mainline. It was delayed for a release as I did
> not get any reviews and so wasn't sure if it was needed.
>
> I believe the common case is wanting to stop on error, since it means
> something is wrong. The case of continuing onto another device when
> the first one fails is unusual. We should always check return codes
> and return errors when something is wrong.
>
> I believe this case is happening because the device is removable and
> therefore returns an error. Is that right? If so then we should return
> a single error, such as -ENOMEDIUM so that the caller can ignore that
> error, or consider it OK.

yes, iirc, the first one ended up being sd-card (which was removed)..
I'll have to check if driver is properly returning -ENOMEDIUM.  In
which case maybe the right thing to do is for the iterators skip over
just that single error code, since it isn't really an "unusual" error.

BR,
-R

> In general, though, errors should not be ignored.
>
> Regards,
> Simon
>
> [...]
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] How to update Espressobin (U-Boot) firmware?

2017-07-19 Thread Andre Przywara
Hi,

On 19/07/17 17:37, Kostya Porotchkin wrote:
> Hi, Andre,
> 
> Looks like I had enough time for trying the entire process today.
> Please see my steps below.

Thanks very much. As I suspected it seems that I missed:
export WTP=/work/community/A3700-utils-marvell
before building ATF, so the ATF build system couldn't find the tools to
assemble the image. It looks like this should avoid my steps 4-6 and
indeed simplifies the process.

> The UART download tool seems to be missed in the "tools" folder.
> I will ask if it possible to put the binary version somewhere until we got 
> the new release with sources.

Thanks, that would be very nice.

> I probably have to build and try the SATA image as the next step.

Yeah, that was my plan for tonight as well, since this would allow me to
experiment safely with the generated image.

Oh, BTW: Chain-loading mainline U-Boot worked quite nicely and I could
launch the generic debian-testing installer via EFI boot. The only issue
was that I was using the U-Boot DT directly, which isn't enough for the
kernel (missing clocks and interrupts). I will try to send some patches
to bring the U-Boot DT in sync with the kernel one. If this is in place,
one could simply attach some (UEFI enabled) USB pen drive and it should
start without further ado (given a newer U-Boot in the SPI flash with
EFI support).

Thanks again!

Cheers,
Andre.

> BTW It was more complicated than I expected, probably since I usually only 
> run the step 4.
> Enjoy!
> 
> Regards
> Kosta
> 
> #
> # 1. Get sources from the GIT
> #
> 
> mkdir /work/community && cd /work/community
> 
> git clone g...@github.com:MarvellEmbeddedProcessors/atf-marvell.git -b 
> atf-v1.3-armada-17.06
> git clone 
> https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell.git - b 
> A3700_utils-armada-17.06
> git clone g...@github.com:MarvellEmbeddedProcessors/u-boot-marvell.git -b 
> u-boot-2017.03-armada-17.06
> 
> ##
> # 2. TBB tool build - not sure if this step is needed
> # or the build will be triggered by ATF build
> # However I preferred to build it separately - this should
> # be done only once anyway.
> ##
> 
> wget https://www.cryptopp.com/cryptopp565.zip
> cd /work/community/A3700-utils-marvell/wtptp_tool/src/TBB_Linux && makedir -p 
> lib/cryptpp565
> cd lib/cryptpp565 && unzip /work/community/cryptopp565.zip
> 
> make -f GNUmakefile && cd ../../
> make -f TBB_linux.mak LIBDIR=`pwd`/lib/cryptpp565
> 
> ##
> # 3. WTMI binary build
> ##
> 
> cd /work/community/A3700-utils-marvell/wtmi
> make
> 
> ###
> # 4. Build the u-boot, ATF and the flash image
> ###
> 
> cd /work/community/u-boot-marvell
> 
> export 
> CROSS_COMPILE=/opt/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
> export BL33=`pwd`/u-boot.bin
> export ATF_DIR=/work/community/atf-marvell
> export WTP=/work/community/A3700-utils-marvell
> export WTMI_IMG=/work/community/A3700-utils-marvell/wtmi/build/wtmi.bin
> 
> make mrproper && make mvebu_espressobin-88f3720_defconfig && make
> 
> make -C ${ATF_DIR} distclean && make -C ${ATF_DIR} DDR_TOPOLOGY=0 
> BOOTDEV=SPINOR USE_COHERENT_MEM=0 LOG_LEVEL=20 PLAT=a3700 all fip
> 
> ##
> # The resulting images are in ${ATF_DIR}/build/a3700/release
> # The "flash-image.bin" is the image for the boot source device
> # (SPI NOR flash for the above example)
> # The "uart-images.tgz" archive contains separate image
> # components for UART download.
> ##
> 
> 
> Regards
> Kosta
> 
>> -Original Message-
>> From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Kostya
>> Porotchkin
>> Sent: Wednesday, July 19, 2017 18:48
>> To: Andre Przywara
>> Cc: Thomas Petazzoni; Benjamin (Guodan) Huang; Marc Zyngier; U-Boot;
>> Stefan Roese; Andreas Färber
>> Subject: [EXT] Re: [U-Boot] How to update Espressobin (U-Boot) firmware?
>>
>> External Email
>>
>> --
>> Hi, Andre,
>>
>>> -Original Message-
>>> From: Andre Przywara [mailto:andre.przyw...@arm.com]
>>> Sent: Wednesday, July 19, 2017 18:19
>>> To: Kostya Porotchkin
>>> Cc: Stefan Roese; Marc Zyngier; Thomas Petazzoni; Gregory CLEMENT;
>>> Antoine Tenart; Andreas Färber; U-Boot; Benjamin (Guodan) Huang
>>> Subject: Re: How to update Espressobin (U-Boot) firmware?
>>>
>>> Hi Kosta,
>>>
>>> thanks again for the instructions, though I feel the road there is
>>> still a bit bumpy and has some potholes ;-)
>>>
>> [Konstantin Porotchkin] Until the WIKI instructions are ready, I will
>> try to follow the entire build process out of Github sources and post
>> you my 

Re: [U-Boot] [PATCH 0/5] db410c: updates for grub + gfxterm

2017-07-19 Thread Rob Clark
On Thu, Jul 6, 2017 at 8:02 AM, Mateusz Kulikowski
 wrote:
> Hi Rob,
>
> On 25.06.2017 01:05, Rob Clark wrote:
>> In particular, support for display setup by lk.  This introduces a
>> simplefb display driver that uses the framebuffer fdt node populated
>> by the firmware[1] for u-boot display support (and, at least for
>> what I am working on, more interestingly, EFI GOP support).
> [...]
>
>> A few related patches so that on db410c we actually use the fdt
>> passed by lk (and so that dm/core is clever enough to notice fdt
>> nodes under "chosen"), config updates, and related fixes.
> [...]
>
> I finally had time to look at patches (this and the earlier series).
>
> Enabling the output is pretty cool - I thought of that myself some time ago.
>
> Question: Do you have non-standard partition layout?
> I have flashed most recent 96boards debian image, but my device doesn't
> have splash partition. (It initializes screen properly, just doesn't display 
> anything)

yes, I have a modified version of bootloader package from linaro:

https://people.freedesktop.org/~robclark/tmp/dragonboard410c_bootloader_emmc_linux-79-u-boot.tgz

I split the boot partition (which was originally big enough for
kernel+initrd which is somewhat larger than u-boot.img) to make a
splash partition.  I probably should write up instructions for how to
do that and generate the splash.img (but it isn't too hard to find
with a bit of googling)..

It isn't the latest lk + u-boot, on the lk side I have some fixes I
still need to push to make it deal properly with #address/size-cells
and a few other misc things.  (And on the u-boot side, adding a
reserved-memory node in the dragonboard410c.dts)..

> Question2: Are you sure you have included all the patches?
>
> I've applied this series (also included patches from 2017-06-20), but u-boot
> doesn't parse device tree properly and things like usb cease to work -
> both with your and official lk:
>
> 
>
> U-Boot 2017.07-rc3-00015-ga2592ee (Jul 06 2017 - 13:48:40 +0200)
> Qualcomm-DragonBoard 410C
>
> DRAM:  986 MiB
> MMC:   sdhci@07824000: 0, sdhci@07864000: 1
> Using default environment
>
> In:serial
> Out:   serial
> Err:   serial
> Failed to find PMIC pon node. Check device tree
> Net:   Net Initialization Skipped
> No ethernet found.
> Hit any key to stop autoboot:  0
>
> 
>
>
> On the other hand it works properly with your pre-built binary [1].
>
> I assume the difference may be that you have added proper (instead of fake) 
> device
> tree into mkbootimg - is that the case?
>

I've (mostly) been using the dragonboard410c.dtb from u-boot build,
since there seem to be some small problems in the other direction..
u-boot isn't completely compatible with upstream linux dtb.

I did find a few things that were only working after I shifted to
CONFIG_OF_BOARD because I hadn't done a clean build (ie. still picking
up old .dtb)

I'm working on cleaning up things, and I'll try to write up some
better instructions and push things to github branch this afternoon,
to make it a bit more reproducible

BR,
-R

>
> Thanks,
> Mateusz
>
>
>
>>
>> [1] https://github.com/robclark/lk/commits/db410c-display
>>
>> Rob Clark (5):
>>   board/db410c: use fdt passed from lk
>>   dm: core: also parse chosen node
>>   video: simplefb
>>   efi_loader: gop: fixes for CONFIG_DM_VIDEO without CONFIG_LCD
>>   configs: db410c: config updates
>>
>>  arch/arm/Kconfig |  2 +-
>>  board/qualcomm/dragonboard410c/dragonboard410c.c | 16 ++
>>  cmd/bootefi.c|  2 +-
>>  configs/dragonboard410c_defconfig|  7 +++
>>  drivers/core/root.c  | 22 +++-
>>  drivers/video/Kconfig| 10 
>>  drivers/video/Makefile   |  2 +-
>>  drivers/video/simplefb.c | 68 
>> 
>>  lib/efi_loader/Makefile  |  1 +
>>  lib/efi_loader/efi_gop.c |  7 ++-
>>  10 files changed, 132 insertions(+), 5 deletions(-)
>>  create mode 100644 drivers/video/simplefb.c
>>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC] efi: variable support

2017-07-19 Thread Rob Clark
On Wed, Jul 12, 2017 at 8:57 AM, Alexander Graf  wrote:
>
>
> On 25.06.17 00:29, Rob Clark wrote:
>>
>> Mapping from EFI variables to grub variables.  Still almost as many
>> TODOs as lines of code, but just figured I'd send out an early version
>> for comments.
>>
>> I was thinking of it as a useful way for u-boot to pass values to grub
>> (although grub is still missing a way for grub scripts to retrieve
>> UEFI variables).
>>
>> The rough idea is to encode GUID + variable name plus "efi_" prefix
>> (to avoid unintended u-boot variables leaking into the UEFI world).
>> And then encode the type (and attributes?) in the string value of the
>> variable.  Ie. something like:
>>
>>setenv efi_8be4df6193ca11d2aa0d00e098032b8c_OsIndicationsSupported
>> (u64)0
>
>
> That's a pretty nice idea altogether, I agree. I don't think the goal you
> have in mind is good though.
>
> I don't really think we should ever allow grub to override the device tree
> files - unless for development purposes. The reason we are in the dt mess we
> are in today is because it's too easy. People associate device trees with
> kernels, not hardware. That's just plain wrong: device trees describe
> hardware, not Linux interfaces.

I kinda wish I could agree with you, but it breaks down quickly when
you start getting into more complex SoC's.  There is enough that we
simply haven't figured out how to model properly in dt.  5yrs from now
I might agree with you ;-)

It might mostly sorta work most of the time if u-boot finds the most
recent dtb (which at least in fedora would mean parsing all the
dtb-x.y.z directory names and figuring out which is newest)

and btw, as someone who works on kernel to the "development purposes"
is an important use-case to me..  and generally it isn't a good idea
to make kernel developer's boot process significantly different from
end users, or you'll just end up in a state where things constantly
work for developers and are broken for distros ;-)

> As for real variable support (for example to boot using a native EFI boot
> order), I think this approach can work. But before committing to a specific
> path to take, I'd like to see a full solution that allows us to maintain
> these variables consistently in runtime services too, as that's required for
> the boot order.

persisting variables, especially after we exit boot-services will
be... interesting.

Rough idea is move env_htab into __efi_runtime_data and some simple
accessors into __efi_runtime.  I think we'll need some board support
to saveenv after a variable is written.  It seems tricky depending on
where the variables are stored (ie. if they are on same eMMC that
linux thinks it owns).

In some cases it might make sense for u-boot to own eMMC (and hide it
from linux) and keep grub and rest of distro media on sd-card /
usb-disk / etc.  I'm not entirely sure how that would work from
kconfig option standpoint, and it would mean that we start adding
drivers and a bunch more in the efi_runtime section.  (And then how to
deal w/ dynamically allocated memory, etc)

BR,
-R

> So far my thinking was that maybe we could push all u-boot variables into
> EL3. That way we could still call into the same space during Linux
> execution. However of course only if there is separate storage to put those
> variables into...
>
>
> Alex
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] How to update Espressobin (U-Boot) firmware?

2017-07-19 Thread Kostya Porotchkin
Hi, Andre,

Looks like I had enough time for trying the entire process today.
Please see my steps below.
The UART download tool seems to be missed in the "tools" folder.
I will ask if it possible to put the binary version somewhere until we got the 
new release with sources.
I probably have to build and try the SATA image as the next step.

BTW It was more complicated than I expected, probably since I usually only run 
the step 4.
Enjoy!

Regards
Kosta

#
# 1. Get sources from the GIT
#

mkdir /work/community && cd /work/community

git clone g...@github.com:MarvellEmbeddedProcessors/atf-marvell.git -b 
atf-v1.3-armada-17.06
git clone https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell.git 
- b A3700_utils-armada-17.06
git clone g...@github.com:MarvellEmbeddedProcessors/u-boot-marvell.git -b 
u-boot-2017.03-armada-17.06

##
# 2. TBB tool build - not sure if this step is needed
# or the build will be triggered by ATF build
# However I preferred to build it separately - this should
# be done only once anyway.
##

wget https://www.cryptopp.com/cryptopp565.zip
cd /work/community/A3700-utils-marvell/wtptp_tool/src/TBB_Linux && makedir -p 
lib/cryptpp565
cd lib/cryptpp565 && unzip /work/community/cryptopp565.zip

make -f GNUmakefile && cd ../../
make -f TBB_linux.mak LIBDIR=`pwd`/lib/cryptpp565

##
# 3. WTMI binary build
##

cd /work/community/A3700-utils-marvell/wtmi
make

###
# 4. Build the u-boot, ATF and the flash image
###

cd /work/community/u-boot-marvell

export 
CROSS_COMPILE=/opt/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export BL33=`pwd`/u-boot.bin
export ATF_DIR=/work/community/atf-marvell
export WTP=/work/community/A3700-utils-marvell
export WTMI_IMG=/work/community/A3700-utils-marvell/wtmi/build/wtmi.bin

make mrproper && make mvebu_espressobin-88f3720_defconfig && make

make -C ${ATF_DIR} distclean && make -C ${ATF_DIR} DDR_TOPOLOGY=0 
BOOTDEV=SPINOR USE_COHERENT_MEM=0 LOG_LEVEL=20 PLAT=a3700 all fip

##
# The resulting images are in ${ATF_DIR}/build/a3700/release
# The "flash-image.bin" is the image for the boot source device
# (SPI NOR flash for the above example)
# The "uart-images.tgz" archive contains separate image
# components for UART download.
##


Regards
Kosta

> -Original Message-
> From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Kostya
> Porotchkin
> Sent: Wednesday, July 19, 2017 18:48
> To: Andre Przywara
> Cc: Thomas Petazzoni; Benjamin (Guodan) Huang; Marc Zyngier; U-Boot;
> Stefan Roese; Andreas Färber
> Subject: [EXT] Re: [U-Boot] How to update Espressobin (U-Boot) firmware?
> 
> External Email
> 
> --
> Hi, Andre,
> 
> > -Original Message-
> > From: Andre Przywara [mailto:andre.przyw...@arm.com]
> > Sent: Wednesday, July 19, 2017 18:19
> > To: Kostya Porotchkin
> > Cc: Stefan Roese; Marc Zyngier; Thomas Petazzoni; Gregory CLEMENT;
> > Antoine Tenart; Andreas Färber; U-Boot; Benjamin (Guodan) Huang
> > Subject: Re: How to update Espressobin (U-Boot) firmware?
> >
> > Hi Kosta,
> >
> > thanks again for the instructions, though I feel the road there is
> > still a bit bumpy and has some potholes ;-)
> >
> [Konstantin Porotchkin] Until the WIKI instructions are ready, I will
> try to follow the entire build process out of Github sources and post
> you my results here.
> > Here is what I did:
> > 1) build u-boot.bin
> > 2) build wtmi.bin (from the utils repo)
> > 3) build ATF
> > $ make USE_COHERENT_MEM=0 DEBUG=1 LOG_LEVEL=20 DDR_TOPOLOGY=2
> > BOOTDEV=SPINOR WTMI_IMG=/path/to/wtmi.bin PLAT=a3700 all fip This
> > breaks after having created fip.bin. I concatenated bl1.bin (padded to
> > 128K) and fip.bin to atf.bin manually.
> > 4) create the image description file (in the utils repo):
> > ./buildtim.sh 0 SPINOR ./untrusted ./ CPU_800_DDR_800 2 0 1 ntim.txt
> > 5) fixup the filenames in the generated text file (wtmi.bin and
> > atf.bin)
> > 6) create the image (utils repo):
> > ./wtptp_tool/linux/TBB_linux -m 1 -r ntim.txt -V
> >
> > From staring at the SPI dump in a hexeditor, I take it that:
> > a) TIM_ATF.bin goes to 0
> > b) wtmi.bin goes to 0x4000
> > c) atf.bin goes to 0x15000
> >
> > Is that about right? Is it that doimage from the ATF repo is supposed
> > to glue this together (step 4-6), which for some reason doesn't work
> > for me?
> [Konstantin Porotchkin] It should not be THAT complex. You suppose to
> run few build commands and get the flash image ready with almost no
> effort. I am mostly working with another SoC family (A8K) 

Re: [U-Boot] [PATCH 4/5] efi_loader: gop: fixes for CONFIG_DM_VIDEO without CONFIG_LCD

2017-07-19 Thread Rob Clark
On Tue, Jul 18, 2017 at 11:06 AM, Alexander Graf  wrote:
> On 07/18/2017 04:54 PM, Simon Glass wrote:
>>
>> Hi Alex,
>>
>> On 18 July 2017 at 07:47, Alexander Graf  wrote:
>>>
>>> On 07/18/2017 04:00 PM, Simon Glass wrote:

 Hi,

 On 12 July 2017 at 05:52, Alexander Graf  wrote:
>
>
> On 25.06.17 01:05, Rob Clark wrote:
>>
>> Signed-off-by: Rob Clark 
>> Cc: Alexander Graf 
>
>
> Looks reasonable to me, but could probably use a commit message ;).
> Also
> please make sure to CC Simon on all things DM.
>
 Can we drop the CONFIG_LCD support entirely? This is legacy code at
 this point. What boards use it?
>>>
>>>
>>> Sounds like someone would first need to convert a bunch of boards :).
>>>
>>> $ for i in $(grep CONFIG_LCD configs/* | cut -d : -f 1); do grep -q
>>> DM_VIDEO
>>> $i || echo $i; done
>>> configs/at91sam9261ek_dataflash_cs0_defconfig
>>> configs/at91sam9261ek_dataflash_cs3_defconfig
>>> configs/at91sam9261ek_nandflash_defconfig
>>> configs/at91sam9263ek_dataflash_cs0_defconfig
>>> configs/at91sam9263ek_dataflash_defconfig
>>> configs/at91sam9263ek_nandflash_defconfig
>>> configs/at91sam9263ek_norflash_boot_defconfig
>>> configs/at91sam9263ek_norflash_defconfig
>>> configs/at91sam9g10ek_dataflash_cs0_defconfig
>>> configs/at91sam9g10ek_dataflash_cs3_defconfig
>>> configs/at91sam9g10ek_nandflash_defconfig
>>> configs/at91sam9m10g45ek_mmc_defconfig
>>> configs/at91sam9m10g45ek_nandflash_defconfig
>>> configs/at91sam9n12ek_mmc_defconfig
>>> configs/at91sam9n12ek_nandflash_defconfig
>>> configs/at91sam9n12ek_spiflash_defconfig
>>> configs/at91sam9rlek_dataflash_defconfig
>>> configs/at91sam9rlek_mmc_defconfig
>>> configs/at91sam9rlek_nandflash_defconfig
>>> configs/at91sam9x5ek_dataflash_defconfig
>>> configs/at91sam9x5ek_mmc_defconfig
>>> configs/at91sam9x5ek_nandflash_defconfig
>>> configs/at91sam9x5ek_spiflash_defconfig
>>> configs/brppt1_mmc_defconfig
>>> configs/brppt1_nand_defconfig
>>> configs/brppt1_spi_defconfig
>>> configs/brxre1_defconfig
>>> configs/cm_t3517_defconfig
>>> configs/cm_t35_defconfig
>>> configs/picosam9g45_defconfig
>>> configs/pm9261_defconfig
>>> configs/pm9263_defconfig
>>> configs/sama5d36ek_cmp_mmc_defconfig
>>> configs/sama5d36ek_cmp_nandflash_defconfig
>>> configs/sama5d36ek_cmp_spiflash_defconfig
>>> configs/sama5d3xek_mmc_defconfig
>>> configs/sama5d3xek_nandflash_defconfig
>>> configs/sama5d3xek_spiflash_defconfig
>>> configs/sama5d4ek_mmc_defconfig
>>> configs/sama5d4ek_nandflash_defconfig
>>> configs/sama5d4ek_spiflash_defconfig
>>> configs/zipitz2_defconfig
>>
>> Not really. I suspect none of those uses EFI_LOADER
>
>
> Why not? I really don't want to limit EFI_LOADER to something I consider
> good. It's supposed to be the *one* interface that just works for everyone.
>
>> There is video driver for atmel which is most of the boards in that
>> list, but we can disable EFI_LOADER until they are converted.
>
>
> No, I won't disable EFI_LOADER on any board because it's not converted. I'd
> rather add support to EFI_LOADER to support more boards that are not
> converted to DM ;).
>
>> We should avoid adding new features to legacy code paths as it makes
>> DM conversion harder and less likely to complete.
>
>
> I agree, but the solution is not to disable EFI_LOADER, it's to convert
> boards.
>

So what is the conclusion on this patch?  I can re-send with a commit
msg (although there is not much to say beyond $subject)..  I kinda
think we should merge this for now, unless dropping CONFIG_LCD is
imminent in which case I can re-work it to drop the CONFIG_LCD and add
CONFIG_DM_VIDEO.. EFI_LOADER should definitely support the non-legacy
case and probably should not remove the legacy case until it does not
exist anymore.

btw, I had a bit of time today to rebase my u-boot patches and start
cleaning up some of the other patches I have for (re)posting.. so
expect some more patches soon(ish)

BR,
-R
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] How to update Espressobin (U-Boot) firmware?

2017-07-19 Thread Kostya Porotchkin
Hi, Andre,

> -Original Message-
> From: Andre Przywara [mailto:andre.przyw...@arm.com]
> Sent: Wednesday, July 19, 2017 18:19
> To: Kostya Porotchkin
> Cc: Stefan Roese; Marc Zyngier; Thomas Petazzoni; Gregory CLEMENT;
> Antoine Tenart; Andreas Färber; U-Boot; Benjamin (Guodan) Huang
> Subject: Re: How to update Espressobin (U-Boot) firmware?
> 
> Hi Kosta,
> 
> thanks again for the instructions, though I feel the road there is still
> a bit bumpy and has some potholes ;-)
> 
[Konstantin Porotchkin] Until the WIKI instructions are ready, I will try to 
follow the entire build process out of Github sources and post you my results 
here.
> Here is what I did:
> 1) build u-boot.bin
> 2) build wtmi.bin (from the utils repo)
> 3) build ATF
> $ make USE_COHERENT_MEM=0 DEBUG=1 LOG_LEVEL=20 DDR_TOPOLOGY=2
> BOOTDEV=SPINOR WTMI_IMG=/path/to/wtmi.bin PLAT=a3700 all fip This breaks
> after having created fip.bin. I concatenated bl1.bin (padded to 128K)
> and fip.bin to atf.bin manually.
> 4) create the image description file (in the utils repo):
> ./buildtim.sh 0 SPINOR ./untrusted ./ CPU_800_DDR_800 2 0 1 ntim.txt
> 5) fixup the filenames in the generated text file (wtmi.bin and atf.bin)
> 6) create the image (utils repo):
> ./wtptp_tool/linux/TBB_linux -m 1 -r ntim.txt -V
> 
> From staring at the SPI dump in a hexeditor, I take it that:
> a) TIM_ATF.bin goes to 0
> b) wtmi.bin goes to 0x4000
> c) atf.bin goes to 0x15000
> 
> Is that about right? Is it that doimage from the ATF repo is supposed to
> glue this together (step 4-6), which for some reason doesn't work for
> me?
[Konstantin Porotchkin] It should not be THAT complex. You suppose to run few 
build commands and get the flash image ready with almost no effort. I am mostly 
working with another SoC family (A8K) and need to try this build by my own for 
refreshing the entire process in my memory.
If Benjamin (included in this thread) does not have the build recipe already, I 
will give you my compilation steps tomorrow.
> 
> Another issue seems to be that the UART download tool seems to be closed
> source only and only available from the Marvell "Extranet" under NDA?
[Konstantin Porotchkin] I think it's not an NDA issue. If the UART download 
tool currently not available in a source form, it probably will be supplied in 
August SW release (17.08). Anyway, I believe if this tool is missing, we can 
share it in the binary form as a temporary solution. I will update you about it 
after my build test.
> 
> From looking at the output of the "h" command in UART mode I guess this
> tools is just a glorious wrapper around spoon-feeding the generated
> binaries in 32-bit chunks into the respective SRAM regions, then execute
> them? Possibly also doing all those register setups (via MMIO) described
> in the ntim.txt/TIM_ATF.bin file?
> Which doesn't look too complicated to hack an Open Source tool for.
> Or is this tool actually available somewhere (either as source or as a
> binary)?
[Konstantin Porotchkin] The UART download tool is working with the SoC service 
CPU (Cortex-M3), which runs the BootROM. So the BootROM verifies the 
information received over the serial line and executes all required 
initializations. Some memory regions and registers are not accessible or cannot 
be modified by the application CPU, so only the service CPU can do the job.

Regards
Kosta
> 
> Cheers,
> Andre.
> 
> 
> On 18/07/17 16:32, Kostya Porotchkin wrote:
> > Hi, Andre,
> >
> >> -Original Message-
> >> From: Andre Przywara [mailto:andre.przyw...@arm.com]
> >> Sent: Tuesday, July 18, 2017 18:24
> >> To: Kostya Porotchkin
> >> Cc: Stefan Roese; Marc Zyngier; Thomas Petazzoni; Gregory CLEMENT;
> >> Antoine Tenart; Andreas Färber; U-Boot; Benjamin (Guodan) Huang
> >> Subject: Re: [EXT] How to update Espressobin (U-Boot) firmware?
> >>
> >> Hi Kosta,
> >>
> >> On 18/07/17 16:13, Kostya Porotchkin wrote:
> >>> The A37xx SoC does not support boot from SD.
> >>
> >> Ah!
> >>
> >>> Only boot from eMMC is supported, however your board probably only
> >>> has
> >> soldering pads for the eMMC and not eMMC chip installed.
> >>> If you want to play with the bootloader without jeopardizing your
> >>> SPI
> >> image, you have to use either UART or SATA boot mode.
> >>
> >> Does SATA boot work like SD boot, where the boot image starts at
> >> sector 1? And it needs to be flagged as a SATA boot image, right?
> > [Konstantin Porotchkin] Correct. You can put it on LBA-1 or LBA-34 if
> you use GPT.
> > Just remember, this image is very special. It's actually a multipart
> > image that we merge into a single blob for easier usage with the u-
> boot "bubt" command.
> >
> >>
> >>> For the boot image build you will need to obtain the u-boot, ATF and
> >> the image building tools sources.
> >>> https://github.com/MarvellEmbeddedProcessors/atf-marvell/tree/atf-v1
> >>> .3
> >>> -armada-17.06
> >>> https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell/tre
> >>> e/
> >>> 

Re: [U-Boot] [PATCH v2] usb: fix usb_stor_read/write on DM

2017-07-19 Thread Masahiro Yamada
2017-07-15 21:57 GMT+09:00 Marek Vasut :
> On 07/15/2017 01:30 AM, Benoît Thébaudeau wrote:
>> On Sat, Jul 15, 2017 at 12:06 AM, Marek Vasut  wrote:
>>> On 07/14/2017 11:46 PM, Benoît Thébaudeau wrote:
 On Fri, Jul 14, 2017 at 1:50 PM, Marek Vasut  wrote:
> On 07/14/2017 01:03 PM, Masahiro Yamada wrote:
>> 2017-07-14 19:07 GMT+09:00 Marek Vasut :
>>> On 07/14/2017 04:31 AM, Masahiro Yamada wrote:
 Prior to DM, we could not enable different types of USB controllers
 at the same time.  DM was supposed to loosen the limitation.  It is
 true that we can compile drivers, but they do not work.

 For example, if EHCI is enabled, xHCI fails as follows:

   => usb read 8200 0 2000

   USB read: device 0 block # 0, count 8192 ... WARN halted endpoint, 
 queueing URB anyway.
   Unexpected XHCI event TRB, skipping... (3fb54010 0001 1300 
 01008401)
   BUG: failure at drivers/usb/host/xhci-ring.c:489/abort_td()!
   BUG!
   ### ERROR ### Please RESET the board ###

 The cause of the error seems the following code:

   #ifdef CONFIG_USB_EHCI_HCD
   /*
* The U-Boot EHCI driver can handle any transfer length as long as 
 there is
* enough free heap space left, but the SCSI READ(10) and WRITE(10) 
 commands are
* limited to 65535 blocks.
*/
   #define USB_MAX_XFER_BLK65535
   #else
   #define USB_MAX_XFER_BLK20
   #endif

 To fix the problem, choose the chunk size at run-time for CONFIG_BLK.
>>>
>>> What happens if CONFIG_BLK is not set ?
>>
>> USB_MAX_XFER_BLK is chosen.
>
> And can we fix that even for non-CONFIG_BLK ?
>
>>> Why is it 20 for XHCI anyway ?
>>
>> You are the maintainer.
>> (I hope) you have better knowledge with this.
>
> Heh, way to deflect the question. I seem to remember some discussion
> about the DMA (?) limitation on XHCI, but I'd have to dig through the ML
> archives myself.
>
>> Looks like the following commit was picked up by you.
>
> 5 years ago, way before DM was what it is today .

 And even way before the introduction of XHCI into U-Boot, which means
 that this 20 was targeting OHCI or proprietary HCDs, not XHCI.
 USB_MAX_READ_BLK was already set to 20 in the initial revision of
 usb_storage.c. As I said in the commit message, this 20 was certainly
 not optimal for these non-EHCI HCDs, but it restored the previous
 (i.e. pre-5dd95cf) behavior for these HCDs instead of using the 5 * 4
 KiB code, which was specific to ehci-hcd.c at that time. Without
 knowing the rationale for the legacy 20 blocks, the safest approach
 for non-EHCI HCDs was to use this value in order to avoid breaking a
 platform or something. Looking at ohci-hcd.c, it limits the transfer
 size to (N_URB_TD - 2) * 4 KiB, with N_URB_TD set to 48, so the
 maximum number of transfers would depend on the MSC block size.
 dwc2.c, isp116x-hcd.c, r8a66597-hcd.c, and sl811-hcd.c do not seem to
 have any limit caused by these drivers. The limit with the current
 XHCI code seems to be 64 * 64 KiB. So, nowadays, USB_MAX_XFER_BLK
 could be set to 65535 for all HCDs but OHCI and XHCI, which require
 specific rules depending on the MSC block size.
>>>
>>> For whatever reason, something tells me that setting the block size to
>>> 64k for XHCI broke things, but I cannot locate the thread. But there's
>>> something in the back of my head ...
>>
>> Indeed: according to what I said above, USB_MAX_XFER_BLK cannot be set
>> to 65535 for XHCI. With an MSC block size of blksz = 512 bytes /
>> block, USB_MAX_XFER_BLK can be set to at most 1 segment *
>> (TRBS_PER_SEGMENT = 64 TRBs / segment) * (TRB_MAX_BUFF_SIZE = 65536
>> bytes / TRB) / blksz = 8192 blocks for XHCI. And for OHCI, the limit
>> is (N_URB_TD - 2 = 46 TDs) * (4096 bytes / TD) / blksz = 368 blocks.
>> The buffer alignment may also have to be taken into account to adjust
>> these values, which would require a USB_MAX_XFER_BLK(host_if, start,
>> blksz) macro or function. USB_MAX_XFER_BLK can however be set to 65535
>> regardless of blksz for all the other HCDs (i.e. EHCI, dwc2.c,
>> isp116x-hcd.c, r8a66597-hcd.c, and sl811-hcd.c).
>
> That's probably what I was looking for, thanks.
>


So, how shall we handle this?

If somebody can fix this in a correct way,
I am happy to hand over this.



-- 
Best Regards
Masahiro Yamada
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] A80 (CubieBoard4) u-boot - what to inject in boot0 area?

2017-07-19 Thread Chen-Yu Tsai
On Wed, Jul 19, 2017 at 11:03 PM, Konrad Rzeszutek Wilk
 wrote:
> On Tue, Jul 18, 2017 at 11:22:00AM +0800, Chen-Yu Tsai wrote:
>> "Hi,
>>
>> On Tue, Jul 18, 2017 at 10:40 AM, Konrad Rzeszutek Wilk
>>  wrote:
>> > Hey,
>> >
>> > I am trying to install an U-boot from the upstream repo as it looks to 
>> > have most (if not all?)
>> > of the features needed for the A80 board (Cubieboard4).
>> >
>> > I've built the uboot just fine (using the default 
>> > ./configs/Cubieboard4_defconfig)
>> > ..
>> > ./tools/mkimage -A arm -T firmware -C none -O u-boot -a 0x2a00 -e 0 -n 
>> > "U-Boot 2017.07-00217-ge14b116 for sunxi board" -d u-boot.bin u-boot.img
>> > Image Name:   U-Boot 2017.07-00217-ge14b116 fo
>> > Created:  Wed Jul 12 22:11:53 2017
>> > Image Type:   ARM U-Boot Firmware (uncompressed)
>> > Data Size:355711 Bytes = 347.37 KiB = 0.34 MiB
>> > Load Address: 2a00
>> > Entry Point:  
>> >
>> > And now I am trying to load it on the SD card and load it
>> > on a Cubieboard4, but it just hangs.
>> >
>> > If I use from the CC-A80-binaries[*1] git repo the "sdcard-fwbuild.sh"
>> > and put the two resulting binaries on the SD card it boots fine.
>> >
>> > But naturally the u-boot that is on the mentioned repo is from 2011
>> > and I would like a more recent version.
>> >
>> > If I try to use the CC-A80-binaries[*1] git repo and the 
>> > "sdcard-fwbuild.sh"
>> > with the upstream u-boot it complains very loudly - and the resulting
>> > binary is not created.
>> >
>> > I figured out that it must be due to the header which as the magic
>> > string of 'uboot' (which in [*2] is in 
>> > arch/arm/cpu/armv7/sun9iw1/spare_head.c)
>> >
>> > In u-boot upstream I can set CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
>> > which I did, but now I am struggling to figure out what I am
>> > suppose to put in there. Any ideas? Is there an tool to fill this
>> > area out? And more importantly, am I on the right track or is
>> > there something else that I a missing?
>> >
>> > I did look at board/sunxi/README.sunxi64 and it explained about the boot0
>> > but that talks about A53 boards I have an A15 (armv7) - and
>> > 'arm-trusted-firmware' is all geared towards armv8.
>> >
>> > Hints of what I should do next?
>>
>> With ARMv7 Allwinner SoCs and mainline U-boot, boot0 is replaced with
>> U-boot SPL. The build process should generate a "u-boot-sunxi-with-spl.bin"
>> file, which is the SPL combined with U-boot proper at the correct offsets.
>> Just write that as you would the image built from "sdcard-fwbuild.sh",
>> that is at an offset of 8192 bytes on the SD card.
>
> Awesome! Next snag - I am hitting an issue with trying to boot Xen with
> it. Specifically I have:
>
>
> U-Boot SPL 2017.07-00217-ge14b1169c0 (Jul 18 2017 - 09:27:24)
> DRAM: 2048 MiB
> Trying to boot from MMC1
>
>
> U-Boot 2017.07-00217-ge14b1169c0 (Jul 18 2017 - 09:27:24 -0400) Allwinner 
> Technology
>
> CPU:   Allwinner A80 (SUN9I)
> Model: Cubietech Cubieboard4
> DRAM:  2 GiB
> MMC:   SUNXI SD/MMC: 0, SUNXI SD/MMC: 1
> *** Warning - bad CRC, using default environment
>
> In:serial@0700
> Out:   serial@0700
> Err:   serial@0700
>
>
> U-Boot 2017.07-00217-ge14b1169c0 (Jul 18 2017 - 09:27:24 -0400) Allwinner 
> Technology
>
> CPU:   Allwinner A80 (SUN9I)
> Model: Cubietech Cubieboard4
> DRAM:  2 GiB
> MMC:   SUNXI SD/MMC: 0, SUNXI SD/MMC: 1
> *** Warning - bad CRC, using default environment
>
> In:serial@0700
> Out:   serial@0700
> Err:   serial@0700
> Net:   No ethernet found.
> starting USB...
> No controllers found
> Hit any key to stop autoboot:  2 1 0
> switch to partitions #0, OK
> mmc0 is current device
> Scanning mmc 0:1...
> Found U-Boot script /boot.scr
> reading /boot.scr
> 1687 bytes read in 19 ms (85.9 KiB/s)
> ## Executing script at 2310
> libfdt fdt_check_header(): FDT_ERR_BADMAGIC
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> No FDT memory address configured. Please configure
> the FDT address via "fdt addr " command.
> Aborting!
> reading /xen
> 851976 bytes read in 121 ms (6.7 MiB/s)
> reading /zImage.dtb
> 16825 bytes read in 27 ms (608.4 KiB/s)
> reading /zImage
> 10233696 bytes read in 1153 ms (8.5 MiB/s)
> ## Flattened Device Tree blob at bec0

Re: [U-Boot] How to update Espressobin (U-Boot) firmware?

2017-07-19 Thread Andre Przywara
Hi Kosta,

thanks again for the instructions, though I feel the road there is still
a bit bumpy and has some potholes ;-)

Here is what I did:
1) build u-boot.bin
2) build wtmi.bin (from the utils repo)
3) build ATF
$ make USE_COHERENT_MEM=0 DEBUG=1 LOG_LEVEL=20 DDR_TOPOLOGY=2
BOOTDEV=SPINOR WTMI_IMG=/path/to/wtmi.bin PLAT=a3700 all fip
This breaks after having created fip.bin. I concatenated bl1.bin (padded
to 128K) and fip.bin to atf.bin manually.
4) create the image description file (in the utils repo):
./buildtim.sh 0 SPINOR ./untrusted ./ CPU_800_DDR_800 2 0 1 ntim.txt
5) fixup the filenames in the generated text file (wtmi.bin and atf.bin)
6) create the image (utils repo):
./wtptp_tool/linux/TBB_linux -m 1 -r ntim.txt -V

From staring at the SPI dump in a hexeditor, I take it that:
a) TIM_ATF.bin goes to 0
b) wtmi.bin goes to 0x4000
c) atf.bin goes to 0x15000

Is that about right? Is it that doimage from the ATF repo is supposed to
glue this together (step 4-6), which for some reason doesn't work for me?

Another issue seems to be that the UART download tool seems to be closed
source only and only available from the Marvell "Extranet" under NDA?

From looking at the output of the "h" command in UART mode I guess this
tools is just a glorious wrapper around spoon-feeding the generated
binaries in 32-bit chunks into the respective SRAM regions, then execute
them? Possibly also doing all those register setups (via MMIO) described
in the ntim.txt/TIM_ATF.bin file?
Which doesn't look too complicated to hack an Open Source tool for.
Or is this tool actually available somewhere (either as source or as a
binary)?

Cheers,
Andre.


On 18/07/17 16:32, Kostya Porotchkin wrote:
> Hi, Andre,
> 
>> -Original Message-
>> From: Andre Przywara [mailto:andre.przyw...@arm.com]
>> Sent: Tuesday, July 18, 2017 18:24
>> To: Kostya Porotchkin
>> Cc: Stefan Roese; Marc Zyngier; Thomas Petazzoni; Gregory CLEMENT;
>> Antoine Tenart; Andreas Färber; U-Boot; Benjamin (Guodan) Huang
>> Subject: Re: [EXT] How to update Espressobin (U-Boot) firmware?
>>
>> Hi Kosta,
>>
>> On 18/07/17 16:13, Kostya Porotchkin wrote:
>>> The A37xx SoC does not support boot from SD.
>>
>> Ah!
>>
>>> Only boot from eMMC is supported, however your board probably only has
>> soldering pads for the eMMC and not eMMC chip installed.
>>> If you want to play with the bootloader without jeopardizing your SPI
>> image, you have to use either UART or SATA boot mode.
>>
>> Does SATA boot work like SD boot, where the boot image starts at sector
>> 1? And it needs to be flagged as a SATA boot image, right?
> [Konstantin Porotchkin] Correct. You can put it on LBA-1 or LBA-34 if you use 
> GPT.
> Just remember, this image is very special. It's actually a multipart image
> that we merge into a single blob for easier usage with the u-boot "bubt" 
> command.
> 
>>
>>> For the boot image build you will need to obtain the u-boot, ATF and
>> the image building tools sources.
>>> https://github.com/MarvellEmbeddedProcessors/atf-marvell/tree/atf-v1.3
>>> -armada-17.06
>>> https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell/tree/
>>> A3700_utils-armada-17.06
>>> https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/tree/u-boo
>>> t-2017.03-armada-17.06
>>>
>>> The "utils" git contains also the UART download tool.
>>> It uses a proprietary download protocol and not xmodem one as in KW
>> case.
>>> The flash image structure on this platform also differs from KW, so
>> please do not try to directly burn a "bin" or "kw" file created by the
>> u-boot build system.
>>> The ATF git from above already contains the required changes in the
>> Makefile for running the additional steps of the final flash image
>> formatting.
>>> Additionally, the boot image contains a boot device information in its
>> header, so you cannot move SPI flash image to another boot device.
>>>
>>> For the boot loader build instructions please check the following
>> documents:
>>> https://github.com/MarvellEmbeddedProcessors/atf-marvell/blob/atf-v1.3
>>> -17.04/docs/marvell/build.txt
>>> https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/blob/u-boo
>>> t-2017.03-armada-17.06/doc/mvebu/build.txt
>>>
>>> UART boot details:
>>> https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/blob/u-boo
>>> t-2017.03-armada-17.06/doc/mvebu/uart_boot.txt
>>
>> Thanks a ton for those links and information, that was exactly what I
>> was looking for!
>> Do you mind if I (later ;-) write up those steps in a document which we
>> merge into the repo?
>> Something like [1], which proved useful in the past just to point people
>> to - that would save you some typing as well ;-)
> [Konstantin Porotchkin] Sure, any additional source of information would be 
> great.
> I just notified the Espressobin WIKI team about urgent need for this type of 
> document and for an alternative boot source usage example.
> Hope the new WIKI entry will be ready shortly.
> 
> Regards
> Kosta
>>
>> Cheers,
>> 

Re: [U-Boot] A80 (CubieBoard4) u-boot - what to inject in boot0 area?

2017-07-19 Thread Konrad Rzeszutek Wilk
On Tue, Jul 18, 2017 at 11:22:00AM +0800, Chen-Yu Tsai wrote:
> "Hi,
> 
> On Tue, Jul 18, 2017 at 10:40 AM, Konrad Rzeszutek Wilk
>  wrote:
> > Hey,
> >
> > I am trying to install an U-boot from the upstream repo as it looks to have 
> > most (if not all?)
> > of the features needed for the A80 board (Cubieboard4).
> >
> > I've built the uboot just fine (using the default 
> > ./configs/Cubieboard4_defconfig)
> > ..
> > ./tools/mkimage -A arm -T firmware -C none -O u-boot -a 0x2a00 -e 0 -n 
> > "U-Boot 2017.07-00217-ge14b116 for sunxi board" -d u-boot.bin u-boot.img
> > Image Name:   U-Boot 2017.07-00217-ge14b116 fo
> > Created:  Wed Jul 12 22:11:53 2017
> > Image Type:   ARM U-Boot Firmware (uncompressed)
> > Data Size:355711 Bytes = 347.37 KiB = 0.34 MiB
> > Load Address: 2a00
> > Entry Point:  
> >
> > And now I am trying to load it on the SD card and load it
> > on a Cubieboard4, but it just hangs.
> >
> > If I use from the CC-A80-binaries[*1] git repo the "sdcard-fwbuild.sh"
> > and put the two resulting binaries on the SD card it boots fine.
> >
> > But naturally the u-boot that is on the mentioned repo is from 2011
> > and I would like a more recent version.
> >
> > If I try to use the CC-A80-binaries[*1] git repo and the "sdcard-fwbuild.sh"
> > with the upstream u-boot it complains very loudly - and the resulting
> > binary is not created.
> >
> > I figured out that it must be due to the header which as the magic
> > string of 'uboot' (which in [*2] is in 
> > arch/arm/cpu/armv7/sun9iw1/spare_head.c)
> >
> > In u-boot upstream I can set CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
> > which I did, but now I am struggling to figure out what I am
> > suppose to put in there. Any ideas? Is there an tool to fill this
> > area out? And more importantly, am I on the right track or is
> > there something else that I a missing?
> >
> > I did look at board/sunxi/README.sunxi64 and it explained about the boot0
> > but that talks about A53 boards I have an A15 (armv7) - and
> > 'arm-trusted-firmware' is all geared towards armv8.
> >
> > Hints of what I should do next?
> 
> With ARMv7 Allwinner SoCs and mainline U-boot, boot0 is replaced with
> U-boot SPL. The build process should generate a "u-boot-sunxi-with-spl.bin"
> file, which is the SPL combined with U-boot proper at the correct offsets.
> Just write that as you would the image built from "sdcard-fwbuild.sh",
> that is at an offset of 8192 bytes on the SD card.

Awesome! Next snag - I am hitting an issue with trying to boot Xen with
it. Specifically I have:


U-Boot SPL 2017.07-00217-ge14b1169c0 (Jul 18 2017 - 09:27:24)
DRAM: 2048 MiB
Trying to boot from MMC1


U-Boot 2017.07-00217-ge14b1169c0 (Jul 18 2017 - 09:27:24 -0400) Allwinner 
Technology

CPU:   Allwinner A80 (SUN9I)
Model: Cubietech Cubieboard4
DRAM:  2 GiB
MMC:   SUNXI SD/MMC: 0, SUNXI SD/MMC: 1
*** Warning - bad CRC, using default environment

In:serial@0700
Out:   serial@0700
Err:   serial@0700


U-Boot 2017.07-00217-ge14b1169c0 (Jul 18 2017 - 09:27:24 -0400) Allwinner 
Technology

CPU:   Allwinner A80 (SUN9I)
Model: Cubietech Cubieboard4
DRAM:  2 GiB
MMC:   SUNXI SD/MMC: 0, SUNXI SD/MMC: 1
*** Warning - bad CRC, using default environment

In:serial@0700
Out:   serial@0700
Err:   serial@0700
Net:   No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot:  2  1  0 
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
reading /boot.scr
1687 bytes read in 19 ms (85.9 KiB/s)
## Executing script at 2310
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr " command.
Aborting!
reading /xen
851976 bytes read in 121 ms (6.7 MiB/s)
reading /zImage.dtb
16825 bytes read in 27 ms (608.4 KiB/s)
reading /zImage
10233696 bytes read in 1153 ms (8.5 MiB/s)
## Flattened Device Tree blob at bec0
   Booting using the fdt blob at 0xbec0
   Using Device Tree in place at bec0, end bec071b8

Starting kernel ...

- UART enabled -
- CPU  booting -
- Xen must be entered in NS Hyp mode -
- Please update the bootloader -
- Boot failed -


I couldn't see anything in uboot 

[U-Boot] [PATCH 4/4] dfu: add common function to initiate transaction

2017-07-19 Thread Patrick Delaunay
- 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 
---
the boolean 'read' is only used to avoid r_left initialization
with call get_medium_size()

So the patch don't change the current dynamic
but for my point of view it should removed

 drivers/dfu/dfu.c | 72 ++-
 1 file changed, 34 insertions(+), 38 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 63a5a44..f6281f4 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -171,8 +171,8 @@ void dfu_transaction_cleanup(struct dfu_entity *dfu)
dfu->crc = 0;
dfu->offset = 0;
dfu->i_blk_seq_num = 0;
-   dfu->i_buf_start = dfu_buf;
-   dfu->i_buf_end = dfu_buf;
+   dfu->i_buf_start = dfu_get_buf(dfu);
+   dfu->i_buf_end = dfu->i_buf_start;
dfu->i_buf = dfu->i_buf_start;
dfu->r_left = 0;
dfu->b_left = 0;
@@ -181,6 +181,32 @@ void dfu_transaction_cleanup(struct dfu_entity *dfu)
dfu->inited = 0;
 }
 
+int dfu_transaction_initiate(struct dfu_entity *dfu, bool read)
+{
+   int ret = 0;
+
+   if (dfu->inited)
+   return 0;
+
+   dfu_transaction_cleanup(dfu);
+
+   if (dfu->i_buf_start == NULL)
+   return -ENOMEM;
+
+   dfu->i_buf_end = dfu->i_buf_start + dfu_get_buf_size();
+
+   if (read) {
+   ret = dfu->get_medium_size(dfu, >r_left);
+   if (ret < 0)
+   return ret;
+   debug("%s: %s %lld [B]\n", __func__, dfu->name, dfu->r_left);
+   }
+
+   dfu->inited = 1;
+
+   return 0;
+}
+
 int dfu_flush(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
 {
int ret = 0;
@@ -209,20 +235,9 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
  __func__, dfu->name, buf, size, blk_seq_num, dfu->offset,
  (unsigned long)(dfu->i_buf - dfu->i_buf_start));
 
-   if (!dfu->inited) {
-   /* initial state */
-   dfu->crc = 0;
-   dfu->offset = 0;
-   dfu->bad_skip = 0;
-   dfu->i_blk_seq_num = 0;
-   dfu->i_buf_start = dfu_get_buf(dfu);
-   if (dfu->i_buf_start == NULL)
-   return -ENOMEM;
-   dfu->i_buf_end = dfu_get_buf(dfu) + dfu_buf_size;
-   dfu->i_buf = dfu->i_buf_start;
-
-   dfu->inited = 1;
-   }
+   ret = dfu_transaction_initiate(dfu, false);
+   if (ret < 0)
+   return ret;
 
if (dfu->i_blk_seq_num != blk_seq_num) {
printf("%s: Wrong sequence number! [%d] [%d]\n",
@@ -338,28 +353,9 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
debug("%s: name: %s buf: 0x%p size: 0x%x p_num: 0x%x i_buf: 0x%p\n",
   __func__, dfu->name, buf, size, blk_seq_num, dfu->i_buf);
 
-   if (!dfu->inited) {
-   dfu->i_buf_start = dfu_get_buf(dfu);
-   if (dfu->i_buf_start == NULL)
-   return -ENOMEM;
-
-   ret = dfu->get_medium_size(dfu, >r_left);
-   if (ret < 0)
-   return ret;
-
-   debug("%s: %s %lld [B]\n", __func__, dfu->name, dfu->r_left);
-
-   dfu->i_blk_seq_num = 0;
-   dfu->crc = 0;
-   dfu->offset = 0;
-   dfu->i_buf_end = dfu_get_buf(dfu) + dfu_buf_size;
-   dfu->i_buf = dfu->i_buf_start;
-   dfu->b_left = 0;
-
-   dfu->bad_skip = 0;
-
-   dfu->inited = 1;
-   }
+   ret = dfu_transaction_initiate(dfu, true);
+   if (ret < 0)
+   return ret;
 
if (dfu->i_blk_seq_num != blk_seq_num) {
printf("%s: Wrong sequence number! [%d] [%d]\n",
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/4] dfu: factorize transaction cleanup

2017-07-19 Thread Patrick Delaunay
rename cleanup function, as now called by read

Signed-off-by: Patrick Delaunay 
---

 drivers/dfu/dfu.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 0f1ab0d..63a5a44 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -165,7 +165,7 @@ static int dfu_write_buffer_drain(struct dfu_entity *dfu)
return ret;
 }
 
-void dfu_write_transaction_cleanup(struct dfu_entity *dfu)
+void dfu_transaction_cleanup(struct dfu_entity *dfu)
 {
/* clear everything */
dfu->crc = 0;
@@ -174,6 +174,10 @@ void dfu_write_transaction_cleanup(struct dfu_entity *dfu)
dfu->i_buf_start = dfu_buf;
dfu->i_buf_end = dfu_buf;
dfu->i_buf = dfu->i_buf_start;
+   dfu->r_left = 0;
+   dfu->b_left = 0;
+   dfu->bad_skip = 0;
+
dfu->inited = 0;
 }
 
@@ -192,7 +196,7 @@ int dfu_flush(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
printf("\nDFU complete %s: 0x%08x\n", dfu_hash_algo->name,
   dfu->crc);
 
-   dfu_write_transaction_cleanup(dfu);
+   dfu_transaction_cleanup(dfu);
 
return ret;
 }
@@ -223,7 +227,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
if (dfu->i_blk_seq_num != blk_seq_num) {
printf("%s: Wrong sequence number! [%d] [%d]\n",
   __func__, dfu->i_blk_seq_num, blk_seq_num);
-   dfu_write_transaction_cleanup(dfu);
+   dfu_transaction_cleanup(dfu);
return -1;
}
 
@@ -247,7 +251,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
if ((dfu->i_buf + size) > dfu->i_buf_end) {
ret = dfu_write_buffer_drain(dfu);
if (ret) {
-   dfu_write_transaction_cleanup(dfu);
+   dfu_transaction_cleanup(dfu);
return ret;
}
}
@@ -256,7 +260,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
if ((dfu->i_buf + size) > dfu->i_buf_end) {
error("Buffer overflow! (0x%p + 0x%x > 0x%p)\n", dfu->i_buf,
  size, dfu->i_buf_end);
-   dfu_write_transaction_cleanup(dfu);
+   dfu_transaction_cleanup(dfu);
return -1;
}
 
@@ -267,7 +271,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
if (size == 0 || (dfu->i_buf + size) > dfu->i_buf_end) {
ret = dfu_write_buffer_drain(dfu);
if (ret) {
-   dfu_write_transaction_cleanup(dfu);
+   dfu_transaction_cleanup(dfu);
return ret;
}
}
@@ -377,17 +381,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
  dfu_hash_algo->name, dfu->crc);
puts("\nUPLOAD ... done\nCtrl+C to exit ...\n");
 
-   dfu->i_blk_seq_num = 0;
-   dfu->crc = 0;
-   dfu->offset = 0;
-   dfu->i_buf_start = dfu_buf;
-   dfu->i_buf_end = dfu_buf;
-   dfu->i_buf = dfu->i_buf_start;
-   dfu->b_left = 0;
-
-   dfu->bad_skip = 0;
-
-   dfu->inited = 0;
+   dfu_transaction_cleanup(dfu);
}
 
return ret;
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/4] dfu: allow dfu read on partition greater than 2GB

2017-07-19 Thread Patrick Delaunay
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 = 0x8000
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 
---

 drivers/dfu/dfu.c  |  6 +++---
 drivers/dfu/dfu_mmc.c  | 12 ++--
 drivers/dfu/dfu_nand.c |  6 --
 drivers/dfu/dfu_ram.c  |  6 --
 drivers/dfu/dfu_sf.c   |  6 --
 include/dfu.h  |  2 +-
 6 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index ceb33e3..c777016 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -339,9 +339,9 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
if (dfu->i_buf_start == NULL)
return -ENOMEM;
 
-   dfu->r_left = dfu->get_medium_size(dfu);
-   if (dfu->r_left < 0)
-   return dfu->r_left;
+   ret = dfu->get_medium_size(dfu, >r_left);
+   if (ret < 0)
+   return ret;
 
debug("%s: %s %ld [B]\n", __func__, dfu->name, dfu->r_left);
 
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 926ccbd..d918f95 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -209,23 +209,23 @@ int dfu_flush_medium_mmc(struct dfu_entity *dfu)
return ret;
 }
 
-long dfu_get_medium_size_mmc(struct dfu_entity *dfu)
+int dfu_get_medium_size_mmc(struct dfu_entity *dfu, long *size)
 {
int ret;
-   long len;
 
switch (dfu->layout) {
case DFU_RAW_ADDR:
-   return dfu->data.mmc.lba_size * dfu->data.mmc.lba_blk_size;
+   *size = dfu->data.mmc.lba_size * dfu->data.mmc.lba_blk_size;
+   return 0;
case DFU_FS_FAT:
case DFU_FS_EXT4:
dfu_file_buf_filled = -1;
-   ret = mmc_file_op(DFU_OP_SIZE, dfu, NULL, );
+   ret = mmc_file_op(DFU_OP_SIZE, dfu, NULL, size);
if (ret < 0)
return ret;
-   if (len > CONFIG_SYS_DFU_MAX_FILE_SIZE)
+   if (*size > CONFIG_SYS_DFU_MAX_FILE_SIZE)
return -1;
-   return len;
+   return 0;
default:
printf("%s: Layout (%s) not (yet) supported!\n", __func__,
   dfu_get_layout(dfu->layout));
diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
index 97cd608..ed4ceb7 100644
--- a/drivers/dfu/dfu_nand.c
+++ b/drivers/dfu/dfu_nand.c
@@ -114,9 +114,11 @@ static int dfu_write_medium_nand(struct dfu_entity *dfu,
return ret;
 }
 
-long dfu_get_medium_size_nand(struct dfu_entity *dfu)
+int dfu_get_medium_size_nand(struct dfu_entity *dfu, long *size)
 {
-   return dfu->data.nand.size;
+   *size = dfu->data.nand.size;
+
+   return 0;
 }
 
 static int dfu_read_medium_nand(struct dfu_entity *dfu, u64 offset, void *buf,
diff --git a/drivers/dfu/dfu_ram.c b/drivers/dfu/dfu_ram.c
index c1b0021..b95cb9f 100644
--- a/drivers/dfu/dfu_ram.c
+++ b/drivers/dfu/dfu_ram.c
@@ -41,9 +41,11 @@ static int dfu_write_medium_ram(struct dfu_entity *dfu, u64 
offset,
return dfu_transfer_medium_ram(DFU_OP_WRITE, dfu, offset, buf, len);
 }
 
-long dfu_get_medium_size_ram(struct dfu_entity *dfu)
+int dfu_get_medium_size_ram(struct dfu_entity *dfu, long *size)
 {
-   return dfu->data.ram.size;
+   *size = dfu->data.ram.size;
+
+   return 0;
 }
 
 static int dfu_read_medium_ram(struct dfu_entity *dfu, u64 offset,
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index b6d5fe2..2b26f2c 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -12,9 +12,11 @@
 #include 
 #include 
 
-static long dfu_get_medium_size_sf(struct dfu_entity *dfu)
+static int dfu_get_medium_size_sf(struct dfu_entity *dfu, long *size)
 {
-   return dfu->data.sf.size;
+   *size = dfu->data.sf.size;
+
+   return 0;
 }
 
 static int dfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf,
diff --git a/include/dfu.h b/include/dfu.h
index f39d3f1..5b621b5 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -110,7 +110,7 @@ struct dfu_entity {
struct sf_internal_data sf;
} data;
 
-   long (*get_medium_size)(struct dfu_entity *dfu);
+   int (*get_medium_size)(struct dfu_entity *dfu, long *size);
 
int (*read_medium)(struct dfu_entity *dfu,
u64 offset, void *buf, long *len);
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/4] dfu: remove limitation on partition size

2017-07-19 Thread Patrick Delaunay
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 
---

 drivers/dfu/dfu.c  |  2 +-
 drivers/dfu/dfu_mmc.c  | 10 +-
 drivers/dfu/dfu_nand.c |  2 +-
 drivers/dfu/dfu_ram.c  |  2 +-
 drivers/dfu/dfu_sf.c   |  2 +-
 include/dfu.h  |  4 ++--
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index c777016..0f1ab0d 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -343,7 +343,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
if (ret < 0)
return ret;
 
-   debug("%s: %s %ld [B]\n", __func__, dfu->name, dfu->r_left);
+   debug("%s: %s %lld [B]\n", __func__, dfu->name, dfu->r_left);
 
dfu->i_blk_seq_num = 0;
dfu->crc = 0;
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index d918f95..bb23e7f 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -17,7 +17,7 @@
 #include 
 
 static unsigned char *dfu_file_buf;
-static long dfu_file_buf_len;
+static u64 dfu_file_buf_len;
 static long dfu_file_buf_filled;
 
 static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
@@ -107,7 +107,7 @@ static int mmc_file_buffer(struct dfu_entity *dfu, void 
*buf, long *len)
 }
 
 static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,
-   void *buf, long *len)
+   void *buf, u64 *len)
 {
const char *fsname, *opname;
char cmd_buf[DFU_CMD_BUF_SIZE];
@@ -150,7 +150,7 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity 
*dfu,
sprintf(cmd_buf + strlen(cmd_buf), " %s", dfu->name);
 
if (op == DFU_OP_WRITE)
-   sprintf(cmd_buf + strlen(cmd_buf), " %lx", *len);
+   sprintf(cmd_buf + strlen(cmd_buf), " %llx", *len);
 
debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
 
@@ -209,7 +209,7 @@ int dfu_flush_medium_mmc(struct dfu_entity *dfu)
return ret;
 }
 
-int dfu_get_medium_size_mmc(struct dfu_entity *dfu, long *size)
+int dfu_get_medium_size_mmc(struct dfu_entity *dfu, u64 *size)
 {
int ret;
 
@@ -237,7 +237,7 @@ static int mmc_file_unbuffer(struct dfu_entity *dfu, u64 
offset, void *buf,
 long *len)
 {
int ret;
-   long file_len;
+   u64 file_len;
 
if (dfu_file_buf_filled == -1) {
ret = mmc_file_op(DFU_OP_READ, dfu, dfu_file_buf, _len);
diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
index ed4ceb7..6dc9ff7 100644
--- a/drivers/dfu/dfu_nand.c
+++ b/drivers/dfu/dfu_nand.c
@@ -114,7 +114,7 @@ static int dfu_write_medium_nand(struct dfu_entity *dfu,
return ret;
 }
 
-int dfu_get_medium_size_nand(struct dfu_entity *dfu, long *size)
+int dfu_get_medium_size_nand(struct dfu_entity *dfu, u64 *size)
 {
*size = dfu->data.nand.size;
 
diff --git a/drivers/dfu/dfu_ram.c b/drivers/dfu/dfu_ram.c
index b95cb9f..6e3f531 100644
--- a/drivers/dfu/dfu_ram.c
+++ b/drivers/dfu/dfu_ram.c
@@ -41,7 +41,7 @@ static int dfu_write_medium_ram(struct dfu_entity *dfu, u64 
offset,
return dfu_transfer_medium_ram(DFU_OP_WRITE, dfu, offset, buf, len);
 }
 
-int dfu_get_medium_size_ram(struct dfu_entity *dfu, long *size)
+int dfu_get_medium_size_ram(struct dfu_entity *dfu, u64 *size)
 {
*size = dfu->data.ram.size;
 
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index 2b26f2c..2d2586d 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 
-static int dfu_get_medium_size_sf(struct dfu_entity *dfu, long *size)
+static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)
 {
*size = dfu->data.sf.size;
 
diff --git a/include/dfu.h b/include/dfu.h
index 5b621b5..7e322d9 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -110,7 +110,7 @@ struct dfu_entity {
struct sf_internal_data sf;
} data;
 
-   int (*get_medium_size)(struct dfu_entity *dfu, long *size);
+   int (*get_medium_size)(struct dfu_entity *dfu, u64 *size);
 
int (*read_medium)(struct dfu_entity *dfu,
u64 offset, void *buf, long *len);
@@ -132,7 +132,7 @@ struct dfu_entity {
u8 *i_buf;
u8 *i_buf_start;
u8 *i_buf_end;
-   long r_left;
+   u64 r_left;
long b_left;
 
u32 bad_skip;   /* for nand use */
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 0/4] dfu: remove limitation on partition size

2017-07-19 Thread Patrick Delaunay

I discover some limitation on DFU stack when I play on my ARM board
with DFU for my external SDCARD : 16GB

It is mainly caused by the 'long' type (32 bits on ARMv7)
used for size in dfu.c

I solve the issue with the 2 first patches of this serie
- manage size and result correctly in get_medium_size()
- change size to u64

The 2 next patch of the serie are not directly related to the issue.
It is a cleanup and code factorization of dfu.c code



Patrick Delaunay (4):
  dfu: allow dfu read on partition greater than 2GB
  dfu: remove limitation on partition size
  dfu: factorize transaction cleanup
  dfu: add common function to initiate transaction

 drivers/dfu/dfu.c  | 100 ++---
 drivers/dfu/dfu_mmc.c  |  20 +-
 drivers/dfu/dfu_nand.c |   6 ++-
 drivers/dfu/dfu_ram.c  |   6 ++-
 drivers/dfu/dfu_sf.c   |   6 ++-
 include/dfu.h  |   4 +-
 6 files changed, 69 insertions(+), 73 deletions(-)

-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 00/15] usb: hub: Support USB 3.0 hubs

2017-07-19 Thread Marek Vasut
On 07/19/2017 03:51 PM, Bin Meng wrote:
> This series is a follow-up series to previous series [1] that adds
> support for USB 3.0 hubs.
> 
> USB 3.0 hubs have slightly different hub descriptor format, as well
> as different port status bit positions. These needs to be properly
> handled by U-Boot USB core stack codes. xHCI driver has also been
> updated to correctly set up context structures that are required
> for devices behind a 3.0 hub to work.
> 
> Besides USB 3.0 hubs support, this series also adds support for low
> speed/full speed devices connected behind a high speed hub with the
> xHC controller. It turns out the 'Transaction Translator' part in
> the xHC data structure is missing.
> 
> Note there is one error during testing USB keyboard when
> CONFIG_USB_KEYBOARD is on.
> 
>   "Failed to get keyboard state from device 413c:2105"
> 
> The enumeration process did pass and the error was thrown in the
> USB keyboard driver. This was due to the interrupt transfer is
> still not supported by xHCI driver, as of today.
> 
> This series is available at u-boot-x86/xhci-working2 for testing.
> 
> [1] https://lists.denx.de/pipermail/u-boot/2017-June/296166.html

Applied to u-boot-usb/master, thanks.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 06/15] usb: hub: Translate USB 3.0 hub port status into old version

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/usb_hub.c | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index a8c2f56..b0ff159 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -112,9 +112,40 @@ static int usb_get_hub_status(struct usb_device *dev, void 
*data)
 
 int usb_get_port_status(struct usb_device *dev, int port, void *data)
 {
-   return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+   int ret;
+
+   ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port,
data, sizeof(struct usb_port_status), USB_CNTL_TIMEOUT);
+
+#ifdef CONFIG_DM_USB
+   if (ret < 0)
+   return ret;
+
+   /*
+* Translate the USB 3.0 hub port status field into the old version
+* that U-Boot understands. Do this only when the hub is not root hub.
+* For root hub, the port status field has already been translated
+* in the host controller driver (see xhci_submit_root() in xhci.c).
+*
+* Note: this only supports driver model.
+*/
+
+   if (!usb_hub_is_root_hub(dev->dev) && usb_hub_is_superspeed(dev)) {
+   struct usb_port_status *status = (struct usb_port_status *)data;
+   u16 tmp = (status->wPortStatus) & USB_SS_PORT_STAT_MASK;
+
+   if (status->wPortStatus & USB_SS_PORT_STAT_POWER)
+   tmp |= USB_PORT_STAT_POWER;
+   if ((status->wPortStatus & USB_SS_PORT_STAT_SPEED) ==
+   USB_SS_PORT_STAT_SPEED_5GBPS)
+   tmp |= USB_PORT_STAT_SUPER_SPEED;
+
+   status->wPortStatus = tmp;
+   }
+#endif
+
+   return ret;
 }
 
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 07/15] usb: hub: Support 'set hub depth' request for USB 3.0 hubs

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 

---

Changes in v3: None
Changes in v2:
- change to use 'packets' in the comments

 common/usb_hub.c   | 52 
 include/usb.h  |  1 +
 include/usb_defs.h |  3 +++
 3 files changed, 56 insertions(+)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index b0ff159..18c366a 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -75,6 +75,16 @@ bool usb_hub_is_root_hub(struct udevice *hub)
 
return false;
 }
+
+static int usb_set_hub_depth(struct usb_device *dev, int depth)
+{
+   if (depth < 0 || depth > 4)
+   return -EINVAL;
+
+   return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+   USB_REQ_SET_HUB_DEPTH, USB_DIR_OUT | USB_RT_HUB,
+   depth, 0, NULL, 0, USB_CNTL_TIMEOUT);
+}
 #endif
 
 static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size)
@@ -726,6 +736,48 @@ static int usb_hub_configure(struct usb_device *dev)
debug("%sover-current condition exists\n",
  (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \
  "" : "no ");
+
+#ifdef CONFIG_DM_USB
+   /*
+* A maximum of seven tiers are allowed in a USB topology, and the
+* root hub occupies the first tier. The last tier ends with a normal
+* USB device. USB 3.0 hubs use a 20-bit field called 'route string'
+* to route packets to the designated downstream port. The 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.
+*/
+   if (usb_hub_is_root_hub(dev->dev)) {
+   hub->hub_depth = -1;
+   } else {
+   struct udevice *hdev;
+   int depth = 0;
+
+   hdev = dev->dev->parent;
+   while (!usb_hub_is_root_hub(hdev)) {
+   depth++;
+   hdev = hdev->parent;
+   }
+
+   hub->hub_depth = depth;
+
+   if (usb_hub_is_superspeed(dev)) {
+   debug("set hub (%p) depth to %d\n", dev, depth);
+   /*
+* This request sets the value that the hub uses to
+* determine the index into the 'route string index'
+* for this hub.
+*/
+   ret = usb_set_hub_depth(dev, depth);
+   if (ret < 0) {
+   debug("%s: failed to set hub depth (%lX)\n",
+ __func__, dev->status);
+   return ret;
+   }
+   }
+   }
+#endif
+
usb_hub_power_on(hub);
 
/*
diff --git a/include/usb.h b/include/usb.h
index 64dfa84..f71da52 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -570,6 +570,7 @@ struct usb_hub_device {
ulong connect_timeout;  /* Device connection timeout in ms */
ulong query_delay;  /* Device query delay in ms */
int overcurrent_count[USB_MAXCHILDREN]; /* Over-current counter */
+   int hub_depth;  /* USB 3.0 hub depth */
 };
 
 #ifdef CONFIG_DM_USB
diff --git a/include/usb_defs.h b/include/usb_defs.h
index 6b4385a..273337f 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -306,6 +306,9 @@
 /* Mask for wIndex in get/set port feature */
 #define USB_HUB_PORT_MASK  0xf
 
+/* Hub class request codes */
+#define USB_REQ_SET_HUB_DEPTH  0x0c
+
 /*
  * CBI style
  */
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 0/3] power: Add a driver to handle the PBIAS cell of the TI SOCs

2017-07-19 Thread Jean-Jacques Hiblot
In the TI SOCs a PBIAS cell exists to provide a bias voltage to the MMC1
IO cells. Without this bias voltage these I/O cells can not function
properly. This bias voltage is either 1.8v or 3.0v.

The first patch adds 2 functions to the DM core: to count strings in a
stringlist and get a string from a stringlist based on its position in the
list.
The second patch implements the support for this PBIAS cell as a regulator
driver.
The last patch is here to allow the binding of the driver. In the DTS of the
dra7x and am57x platforms, the pbias entry is a child of a syscon.


changes since v1:
 - add new functions to get strings from a stringlist in DM core
 - use the dev_read_*() API to access the DT
 - automatically select the PBIAS driver if DM_REGULATOR, DM_MMC and
   MMC_OMAP_HS are set.
 - removed the patch touching the DRA7 and AM57 config files.
 

Jean-Jacques Hiblot (3):
  dm: core: Add functions to get strings and the string count from a
stringlist
  regulator: pbias: Add PBIAS regulator for proper voltage switching on
MMC1
  dm: syscon: scan sub-nodes of the syscon node

 drivers/core/read.c   |  11 ++
 drivers/core/syscon-uclass.c  |   1 +
 drivers/mmc/Kconfig   |   1 +
 drivers/power/regulator/Kconfig   |  10 +
 drivers/power/regulator/Makefile  |   1 +
 drivers/power/regulator/pbias_regulator.c | 302 ++
 include/dm/read.h |  36 
 7 files changed, 362 insertions(+)
 create mode 100644 drivers/power/regulator/pbias_regulator.c

-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 00/18] usb: xhci: Fix USB xHCI support on Intel platform

2017-07-19 Thread Marek Vasut
On 07/19/2017 03:49 PM, Bin Meng wrote:
> Currently U-Boot xHCI driver does not work on Intel BayTrail SoC based
> boards that have USB 3.0 ports. Trying to do a 'usb start' simply hangs
> the board. This series fixes a bunch of xHCI driver issues to make it
> work on Intel's platform.
> 
> Issues identified in the U-Boot xHCI driver are really spec violations,
> but apparently other xHCI IPs found on ARM SoCs (mainly Synopsis IP?)
> are quite tolerant with these spec violations, or IOW those IPs don't
> respect the xHCI spec. While it comes to Intel platform, it just breaks.
> 
> Note xHCI interrupt transfer is still not supported in this series, as
> it has been there since the original commit of xHCI support for years.
> 
> Tested on Intel MinnowMax board with the following USB devices:
> - Dell USB 1.1 keyboard
> - Dell USB 1.1 mouse
> - Netac USB 2.0 flash disk
> - JetFlash USB 3.0 flash disk
> - GenesysLogic 4-port USB 3.0 hub, with an integrated Realtek USB
>   ethernet chipset connected to one of its downstream port
> 
> Testing were performed on both ports (2.0 port and 3.0 port), and both
> ports are connected to xHCI (configure MinnowMax to enable xHCI).
> 
> Testing results:
> - DELL USB 1.1 keyboard and mouse can be enumerated on both ports
> - USB 2.0 and 3.0 flash disks work fine (enumerated, read/write) on
>   both ports
> - GenesysLogic USB 3.0 hub can be enumerated on 2.0 port as a 2.0
>   hub, and the integrated Realtek USB ethernet chipset enumerated as
>   well. USB 2.0 and 3.0 flash disks connected via the hub can be
>   enumerated, but DELL USB 1.1 keyboard and mouse cannot.
> - GenesysLogic USB 3.0 hub can be enumerated on 3.0 port as a 3.0 hub,
>   but the integrated Realtek USB ethernet chipset cannot be enumerated.
>   None of devices connected via the hub can be enumerated. U-Boot xHCI
>   driver just throws BUG_ON() on the event TRB handling.
> 
> This indicates that USB 3.0 hub support in U-Boot is seriously broken.
> So far this series tries to fix some of the issues identified, but the
> USB 3.0 hub is still not working. This will be left as future work.
> 
> The USB 3.0 hub work includes: port status translation, USB 3.0 newly
> added "Set Hub Depth" request support, xHCI codes update to fill in
> hub description fields in the input slot context when issuing commands
> to xHC, etc.
> 
> This series is available at u-boot-x86/xhci-working for testing.

Applied to u-boot-usb/master, thanks

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 03/15] usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 

---

Changes in v3: None
Changes in v2:
- trim down the ifdefs by adding usb_get_hub_device() and limit
  ifdefs only in that function

 common/usb_hub.c  | 27 ++-
 drivers/usb/host/usb-uclass.c |  2 --
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index a46d26a..37b358b 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -55,9 +55,6 @@ struct usb_device_scan {
struct list_head list;
 };
 
-/* TODO(s...@chromium.org): Remove this when CONFIG_DM_USB is defined */
-static struct usb_hub_device hub_dev[USB_MAX_HUB];
-static int usb_hub_index;
 static LIST_HEAD(usb_scan_list);
 
 __weak void usb_hub_reset_devices(int port)
@@ -164,6 +161,10 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
  max(100, (int)pgood_delay) + 1000);
 }
 
+#ifndef CONFIG_DM_USB
+static struct usb_hub_device hub_dev[USB_MAX_HUB];
+static int usb_hub_index;
+
 void usb_hub_reset(void)
 {
usb_hub_index = 0;
@@ -180,6 +181,7 @@ static struct usb_hub_device *usb_hub_allocate(void)
printf("ERROR: USB_MAX_HUB (%d) reached\n", USB_MAX_HUB);
return NULL;
 }
+#endif
 
 #define MAX_TRIES 5
 
@@ -543,6 +545,20 @@ out:
return ret;
 }
 
+static struct usb_hub_device *usb_get_hub_device(struct usb_device *dev)
+{
+   struct usb_hub_device *hub;
+
+#ifndef CONFIG_DM_USB
+   /* "allocate" Hub device */
+   hub = usb_hub_allocate();
+#else
+   hub = dev_get_uclass_priv(dev->dev);
+#endif
+
+   return hub;
+}
+
 static int usb_hub_configure(struct usb_device *dev)
 {
int i, length;
@@ -554,11 +570,11 @@ static int usb_hub_configure(struct usb_device *dev)
__maybe_unused struct usb_hub_status *hubsts;
int ret;
 
-   /* "allocate" Hub device */
-   hub = usb_hub_allocate();
+   hub = usb_get_hub_device(dev);
if (hub == NULL)
return -ENOMEM;
hub->pusb_dev = dev;
+
/* Get the the hub descriptor */
ret = usb_get_hub_descriptor(dev, buffer, 4);
if (ret < 0) {
@@ -792,6 +808,7 @@ UCLASS_DRIVER(usb_hub) = {
.child_pre_probe= usb_child_pre_probe,
.per_child_auto_alloc_size = sizeof(struct usb_device),
.per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata),
+   .per_device_auto_alloc_size = sizeof(struct usb_hub_device),
 };
 
 static const struct usb_device_id hub_id_table[] = {
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index efc5d4e..d8d74bd 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -177,7 +177,6 @@ int usb_stop(void)
 #ifdef CONFIG_USB_STORAGE
usb_stor_reset();
 #endif
-   usb_hub_reset();
uc_priv->companion_device_count = 0;
usb_started = 0;
 
@@ -230,7 +229,6 @@ int usb_init(void)
int ret;
 
asynch_allowed = 1;
-   usb_hub_reset();
 
ret = uclass_get(UCLASS_USB, );
if (ret)
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/3] dm: core: Add functions to get strings and the string count from a stringlist

2017-07-19 Thread Jean-Jacques Hiblot
dev_read_string_count() is used to get the number of strings in a
stringlist.
dev_read_string_index() is used to get a string in the stringlist based on
its position in the list.

Signed-off-by: Jean-Jacques Hiblot 
---

 not present in the v1 of this series
 
 drivers/core/read.c | 11 +++
 include/dm/read.h   | 36 
 2 files changed, 47 insertions(+)

diff --git a/drivers/core/read.c b/drivers/core/read.c
index eafe727..cb4c45e 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -74,6 +74,17 @@ int dev_read_stringlist_search(struct udevice *dev, const 
char *property,
return ofnode_stringlist_search(dev_ofnode(dev), property, string);
 }
 
+int dev_read_string_index(struct udevice *dev, const char *propname, int index,
+   const char **outp)
+{
+   return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp);
+}
+
+int dev_read_string_count(struct udevice *dev, const char *propname)
+{
+   return ofnode_read_string_count(dev_ofnode(dev), propname);
+}
+
 int dev_read_phandle_with_args(struct udevice *dev, const char *list_name,
const char *cells_name, int cell_count,
int index,
diff --git a/include/dm/read.h b/include/dm/read.h
index b86a2f5..4ef99cb 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -166,6 +166,29 @@ int dev_read_stringlist_search(struct udevice *dev, const 
char *property,
  const char *string);
 
 /**
+ * dev_read_string_index() - obtain an indexed string from a string list
+ *
+ * @dev: device to examine
+ * @propname: name of the property containing the string list
+ * @index: index of the string to return
+ * @out: return location for the string
+ *
+ * @return:
+ *   length of string, if found or -ve error value if not found
+ */
+int dev_read_string_index(struct udevice *dev, const char *propname, int index,
+   const char **outp);
+
+/**
+ * dev_read_string_count() - find the number of strings in a string list
+ *
+ * @dev: device to examine
+ * @propname: name of the property containing the string list
+ * @return:
+ *   number of strings in the list, or -ve error value if not found
+ */
+int dev_read_string_count(struct udevice *dev, const char *propname);
+/**
  * dev_read_phandle_with_args() - Find a node pointed by phandle in a list
  *
  * This function is useful to parse lists of phandles and their arguments.
@@ -407,6 +430,19 @@ static inline int dev_read_stringlist_search(struct 
udevice *dev,
return ofnode_stringlist_search(dev_ofnode(dev), propname, string);
 }
 
+static inline int dev_read_string_index(struct udevice *dev,
+   const char *propname, int index,
+   const char **outp)
+{
+   return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp);
+}
+
+static inline int dev_read_string_count(struct udevice *dev,
+   const char *propname)
+{
+   return ofnode_read_string_count(dev_ofnode(dev), propname);
+}
+
 static inline int dev_read_phandle_with_args(struct udevice *dev,
const char *list_name, const char *cells_name, int cell_count,
int index, struct ofnode_phandle_args *out_args)
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 08/15] usb: xhci: Change xhci_setup_addressable_virt_dev() signature

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci-mem.c | 6 --
 drivers/usb/host/xhci.c | 3 +--
 drivers/usb/host/xhci.h | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 12e277a..9aa3092 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -713,14 +713,16 @@ void xhci_slot_copy(struct xhci_ctrl *ctrl, struct 
xhci_container_ctx *in_ctx,
  * @param udev pointer to the Device Data Structure
  * @return returns negative value on failure else 0 on success
  */
-void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, int slot_id,
-int speed, int hop_portnr)
+void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
+struct usb_device *udev, int hop_portnr)
 {
struct xhci_virt_device *virt_dev;
struct xhci_ep_ctx *ep0_ctx;
struct xhci_slot_ctx *slot_ctx;
u32 port_num = 0;
u64 trb_64 = 0;
+   int slot_id = udev->slot_id;
+   int speed = udev->speed;
 
virt_dev = ctrl->devs[slot_id];
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 0c88980..336613f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -415,8 +415,7 @@ static int xhci_address_device(struct usb_device *udev, int 
root_portnr)
 * so setting up the slot context.
 */
debug("Setting up addressable devices %p\n", ctrl->dcbaa);
-   xhci_setup_addressable_virt_dev(ctrl, udev->slot_id, udev->speed,
-   root_portnr);
+   xhci_setup_addressable_virt_dev(ctrl, udev, root_portnr);
 
ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index b9602ba..cdce67c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1247,8 +1247,8 @@ void xhci_endpoint_copy(struct xhci_ctrl *ctrl,
 void xhci_slot_copy(struct xhci_ctrl *ctrl,
struct xhci_container_ctx *in_ctx,
struct xhci_container_ctx *out_ctx);
-void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, int slot_id,
-int speed, int hop_portnr);
+void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
+struct usb_device *udev, int hop_portnr);
 void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr,
u32 slot_id, u32 ep_index, trb_type cmd);
 void xhci_acknowledge_event(struct xhci_ctrl *ctrl);
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 04/15] usb: hub: Remove hub_port_reset()

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 

---

Changes in v3: None
Changes in v2:
- new patch to "remove hub_port_reset()"

 common/usb_hub.c | 25 +
 include/usb.h| 18 --
 2 files changed, 13 insertions(+), 30 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 37b358b..086b155 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -207,8 +207,18 @@ static inline char *portspeed(int portstatus)
return speed_str;
 }
 
-int legacy_hub_port_reset(struct usb_device *dev, int port,
-   unsigned short *portstat)
+/**
+ * usb_hub_port_reset() - reset a port given its usb_device pointer
+ *
+ * Reset a hub port and see if a device is present on that port, providing
+ * sufficient time for it to show itself. The port status is returned.
+ *
+ * @dev:   USB device to reset
+ * @port:  Port number to reset (note ports are numbered from 0 here)
+ * @portstat:  Returns port status
+ */
+static int usb_hub_port_reset(struct usb_device *dev, int port,
+ unsigned short *portstat)
 {
int err, tries;
ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1);
@@ -281,15 +291,6 @@ int legacy_hub_port_reset(struct usb_device *dev, int port,
return 0;
 }
 
-#ifdef CONFIG_DM_USB
-int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat)
-{
-   struct usb_device *udev = dev_get_parent_priv(dev);
-
-   return legacy_hub_port_reset(udev, port, portstat);
-}
-#endif
-
 int usb_hub_port_connect_change(struct usb_device *dev, int port)
 {
ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1);
@@ -323,7 +324,7 @@ int usb_hub_port_connect_change(struct usb_device *dev, int 
port)
}
 
/* Reset the port */
-   ret = legacy_hub_port_reset(dev, port, );
+   ret = usb_hub_port_reset(dev, port, );
if (ret < 0) {
if (ret != -ENXIO)
printf("cannot reset port %i!?\n", port + 1);
diff --git a/include/usb.h b/include/usb.h
index eb82cc2..a266677 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -871,24 +871,6 @@ bool usb_device_has_child_on_port(struct usb_device 
*parent, int port);
 int usb_hub_probe(struct usb_device *dev, int ifnum);
 void usb_hub_reset(void);
 
-/**
- * legacy_hub_port_reset() - reset a port given its usb_device pointer
- *
- * Reset a hub port and see if a device is present on that port, providing
- * sufficient time for it to show itself. The port status is returned.
- *
- * With driver model this moves to hub_port_reset() and is passed a struct
- * udevice.
- *
- * @dev:   USB device to reset
- * @port:  Port number to reset (note ports are numbered from 0 here)
- * @portstat:  Returns port status
- */
-int legacy_hub_port_reset(struct usb_device *dev, int port,
- unsigned short *portstat);
-
-int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat);
-
 /*
  * usb_find_usb2_hub_address_port() - Get hub address and port for TT setting
  *
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/3] regulator: pbias: Add PBIAS regulator for proper voltage switching on MMC1

2017-07-19 Thread Jean-Jacques Hiblot
In the TI SOCs a PBIAS cell exists to provide a bias voltage to the MMC1
IO cells. Without this bias voltage these I/O cells can not function
properly. The PBIAS cell is controlled by software.

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Tom Rini 
Reviewed-by: Simon Glass 
---

changes since v1:
 - automatically select the PBIAS driver if DM_REGULATOR, DM_MMC and
   MMC_OMAP_HS are set
 - use the dev_read_*() API to access the DT

 drivers/mmc/Kconfig   |   1 +
 drivers/power/regulator/Kconfig   |  10 +
 drivers/power/regulator/Makefile  |   1 +
 drivers/power/regulator/pbias_regulator.c | 302 ++
 4 files changed, 314 insertions(+)
 create mode 100644 drivers/power/regulator/pbias_regulator.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 588e118..63e1122 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -158,6 +158,7 @@ config MMC_PCI
 config MMC_OMAP_HS
bool "TI OMAP High Speed Multimedia Card Interface support"
select DM_MMC_OPS if DM_MMC
+   select DM_REGULATOR_PBIAS if DM_MMC && DM_REGULATOR
help
  This selects the TI OMAP High Speed Multimedia card Interface.
  If you have an omap2plus board with a Multimedia Card slot,
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index f213487..f4ed3cc 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -142,6 +142,16 @@ config DM_REGULATOR_PALMAS
features for REGULATOR PALMAS and the family of PALMAS PMICs.
The driver implements get/set api for: value and enable.
 
+config DM_REGULATOR_PBIAS
+   bool "Enable driver for PBIAS regulator"
+   ---help---
+   This enables implementation of driver-model regulator uclass
+   features for pseudo-regulator PBIAS found in the OMAP SOCs.
+   This pseudo-regulator is used to provide a BIAS voltage to MMC1
+   signal pads and must be configured properly during a voltage switch.
+   Voltage switching is required by some operating modes of SDcards and
+   eMMC.
+
 config DM_REGULATOR_LP873X
bool "Enable driver for LP873X PMIC regulators"
 depends on PMIC_LP873X
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index ce14d08..75d611a 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -17,5 +17,6 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
 obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
diff --git a/drivers/power/regulator/pbias_regulator.c 
b/drivers/power/regulator/pbias_regulator.c
new file mode 100644
index 000..303eca9
--- /dev/null
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -0,0 +1,302 @@
+/*
+ * (C) Copyright 2016 Texas Instruments Incorporated, 
+ * Jean-Jacques Hiblot 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct pbias_reg_info {
+   u32 enable;
+   u32 enable_mask;
+   u32 disable_val;
+   u32 vmode;
+   unsigned int enable_time;
+   char *name;
+};
+
+struct pbias_priv {
+   struct regmap *regmap;
+   int offset;
+};
+
+static const struct pmic_child_info pmic_children_info[] = {
+   { .prefix = "pbias", .driver = "pbias_regulator"},
+   { },
+};
+
+static int pbias_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+   uint32_t val = *(uint32_t *)buff;
+
+   if (len != 4)
+   return -EINVAL;
+
+   return regmap_write(priv->regmap, priv->offset, val);
+}
+
+static int pbias_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+
+   if (len != 4)
+   return -EINVAL;
+
+   return regmap_read(priv->regmap, priv->offset, (uint32_t *)buff);
+}
+
+static int pbias_ofdata_to_platdata(struct udevice *dev)
+{
+   struct pbias_priv *priv = dev_get_priv(dev);
+   struct udevice *syscon;
+   struct regmap *regmap;
+   struct resource res;
+   int err;
+
+   err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
+  "syscon", );
+   if (err) {
+   error("%s: unable to find syscon device (%d)\n", __func__,
+ err);
+   return err;
+   }
+
+   regmap = syscon_get_regmap(syscon);
+   if 

Re: [U-Boot] [PATCH v7 3/5] drivers: phy: Set phy->dev to NULL when generic_phy_get_by_index() fails

2017-07-19 Thread Jean-Jacques Hiblot


On 18/07/2017 11:38, patrice.chot...@st.com wrote:

From: Patrice Chotard 

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 
Signed-off-by: Patrice Chotard 
Reviewed-by: Simon Glass 
---
v7: _ none
v6: _ none
v5: _ none
v4: _ ensure that phy->dev is set to NULL in case of
generic_phy_get_by_index() fails


  drivers/phy/phy-uclass.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index d8b8d58..68e518f 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -45,6 +45,7 @@ int generic_phy_get_by_index(struct udevice *dev, int index,
debug("%s(dev=%p, index=%d, phy=%p)\n", __func__, dev, index, phy);
  
  	assert(phy);

+   phy->dev = NULL;
ret = dev_read_phandle_with_args(dev, "phys", "#phy-cells", 0, index,
 );
if (ret) {


Reviewed-by: Jean-Jacques Hiblot 

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 3/3] dm: syscon: scan sub-nodes of the syscon node

2017-07-19 Thread Jean-Jacques Hiblot
This allow to probe devices that are defined under a syscon node

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Simon Glass 
---

no changes since v1

 drivers/core/syscon-uclass.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
index 2148469..b06ca6a 100644
--- a/drivers/core/syscon-uclass.c
+++ b/drivers/core/syscon-uclass.c
@@ -104,5 +104,6 @@ static const struct udevice_id generic_syscon_ids[] = {
 U_BOOT_DRIVER(generic_syscon) = {
.name   = "syscon",
.id = UCLASS_SYSCON,
+   .bind   = dm_scan_fdt_dev,
.of_match = generic_syscon_ids,
 };
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 4/5] drivers: phy: add generic_phy_valid() method

2017-07-19 Thread Jean-Jacques Hiblot


On 18/07/2017 11:38, patrice.chot...@st.com wrote:

From: Patrice Chotard 

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

Signed-off-by: Patrice Chotard 
---
v7: _ declare bool generic_phy_valid(struct phy *phy) as static inline
v6: _ none
v5: _ none
v4: _ none


  include/generic-phy.h | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/include/generic-phy.h b/include/generic-phy.h
index 762704c..58cd2b2 100644
--- a/include/generic-phy.h
+++ b/include/generic-phy.h
@@ -220,4 +220,15 @@ int generic_phy_get_by_index(struct udevice *user, int 
index,
  int generic_phy_get_by_name(struct udevice *user, const char *phy_name,
struct phy *phy);
  
+/**

+ * generic_phy_valid() - check if PHY port is valid
+ *
+ * @phy:   the PHY port to check
+ * @return TRUE if valid, or FALSE
+ */
+static inline bool generic_phy_valid(struct phy *phy)
+{
+   return phy->dev != NULL;
+}
+
  #endif /*__GENERIC_PHY_H */


Reviewed-by: Jean-Jacques Hiblot 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 14/18] configs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 

---

Changes in v4:
- remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in poplar.h

Changes in v3: None
Changes in v2: None

 arch/arm/include/asm/ehci-omap.h| 4 
 include/configs/MPC8572DS.h | 1 -
 include/configs/cm_t54.h| 1 -
 include/configs/corvus.h| 3 ---
 include/configs/duovero.h   | 2 --
 include/configs/exynos5-common.h| 2 --
 include/configs/ma5d4evk.h  | 1 -
 include/configs/mcx.h   | 1 -
 include/configs/mvebu_armada-37xx.h | 7 +--
 include/configs/mvebu_armada-8k.h   | 7 +--
 include/configs/mx35pdk.h   | 1 -
 include/configs/odroid.h| 1 -
 include/configs/omap3_beagle.h  | 1 -
 include/configs/omap3_overo.h   | 1 -
 include/configs/omap4_panda.h   | 2 --
 include/configs/omap5_uevm.h| 1 -
 include/configs/picosam9g45.h   | 3 ---
 include/configs/poplar.h| 1 -
 include/configs/sama5d2_ptc.h   | 4 
 include/configs/snapper9g45.h   | 3 ---
 include/configs/sunxi-common.h  | 1 -
 include/configs/tam3517-common.h| 1 -
 include/configs/tao3530.h   | 1 -
 include/configs/tegra114-common.h   | 1 -
 include/configs/tegra124-common.h   | 1 -
 include/configs/tegra20-common.h| 1 -
 include/configs/tegra210-common.h   | 1 -
 include/configs/tegra30-common.h| 1 -
 include/configs/vinco.h | 6 --
 include/configs/x86-common.h| 1 -
 scripts/config_whitelist.txt| 1 -
 31 files changed, 2 insertions(+), 61 deletions(-)

diff --git a/arch/arm/include/asm/ehci-omap.h b/arch/arm/include/asm/ehci-omap.h
index 5a53e40..9dbb2c4 100644
--- a/arch/arm/include/asm/ehci-omap.h
+++ b/arch/arm/include/asm/ehci-omap.h
@@ -19,11 +19,7 @@ enum usbhs_omap_port_mode {
OMAP_EHCI_PORT_MODE_HSIC,
 };
 
-#ifdef CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS
-#define OMAP_HS_USB_PORTS  CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS
-#else
 #define OMAP_HS_USB_PORTS  3
-#endif
 
 #define is_ehci_phy_mode(x)((x) == OMAP_EHCI_PORT_MODE_PHY)
 #define is_ehci_tll_mode(x)((x) == OMAP_EHCI_PORT_MODE_TLL)
diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h
index d8e0dfd..8eb40a6 100644
--- a/include/configs/MPC8572DS.h
+++ b/include/configs/MPC8572DS.h
@@ -561,7 +561,6 @@
 #define CONFIG_USB_EHCI_PCI
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
 #define CONFIG_PCI_EHCI_DEVICE 0
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2
 #endif
 
 #undef CONFIG_WATCHDOG /* watchdog disabled */
diff --git a/include/configs/cm_t54.h b/include/configs/cm_t54.h
index 3647573..6a4ba39 100644
--- a/include/configs/cm_t54.h
+++ b/include/configs/cm_t54.h
@@ -57,7 +57,6 @@
 #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
CONFIG_SYS_SCSI_MAX_LUN)
 /* USB UHH support options */
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
 
 #define CONFIG_OMAP_EHCI_PHY2_RESET_GPIO   76 /* HSIC2 HUB #RESET */
diff --git a/include/configs/corvus.h b/include/configs/corvus.h
index 8b8b122..d4bb9ef 100644
--- a/include/configs/corvus.h
+++ b/include/configs/corvus.h
@@ -94,9 +94,6 @@
 #define CONFIG_NET_RETRY_COUNT 20
 #define CONFIG_AT91_WANTS_COMMON_PHY
 
-/* USB */
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2
-
 /* USB DFU support */
 #define CONFIG_CMD_MTDPARTS
 #define CONFIG_MTD_DEVICE
diff --git a/include/configs/duovero.h b/include/configs/duovero.h
index f142231..49875ff 100644
--- a/include/configs/duovero.h
+++ b/include/configs/duovero.h
@@ -25,8 +25,6 @@
 #define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
 
 /* USB UHH support options */
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
-
 #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 1
 #define CONFIG_OMAP_EHCI_PHY2_RESET_GPIO 62
 
diff --git a/include/configs/exynos5-common.h b/include/configs/exynos5-common.h
index 7cb3278..3b73bbc 100644
--- a/include/configs/exynos5-common.h
+++ b/include/configs/exynos5-common.h
@@ -134,8 +134,6 @@
 /* Enable Time Command */
 
 /* USB */
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
-
 #define CONFIG_USB_HOST_ETHER
 #define CONFIG_USB_ETHER_ASIX
 #define CONFIG_USB_ETHER_SMSC95XX
diff --git a/include/configs/ma5d4evk.h b/include/configs/ma5d4evk.h
index 82aee15..95b2573 100644
--- a/include/configs/ma5d4evk.h
+++ b/include/configs/ma5d4evk.h
@@ -97,7 +97,6 @@
  * USB
  */
 #ifdef CONFIG_CMD_USB
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
 
 /* USB device */
 #define CONFIG_USB_ETHER
diff --git a/include/configs/mcx.h b/include/configs/mcx.h
index 0c237a5..0c5becd 100644
--- a/include/configs/mcx.h
+++ b/include/configs/mcx.h
@@ -74,7 +74,6 

[U-Boot] [PATCH v3 13/15] usb: xhci: Implement update_hub_device() operation

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 

---

Changes in v3: None
Changes in v2:
- fix several nits in the commit message
- add a comment for 666 in TT think time

 drivers/usb/host/xhci.c | 59 +
 1 file changed, 59 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 336613f..9b82ee5 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1170,6 +1170,64 @@ static int xhci_alloc_device(struct udevice *dev, struct 
usb_device *udev)
return _xhci_alloc_device(udev);
 }
 
+static int xhci_update_hub_device(struct udevice *dev, struct usb_device *udev)
+{
+   struct xhci_ctrl *ctrl = dev_get_priv(dev);
+   struct usb_hub_device *hub = dev_get_uclass_priv(udev->dev);
+   struct xhci_virt_device *virt_dev;
+   struct xhci_input_control_ctx *ctrl_ctx;
+   struct xhci_container_ctx *out_ctx;
+   struct xhci_container_ctx *in_ctx;
+   struct xhci_slot_ctx *slot_ctx;
+   int slot_id = udev->slot_id;
+   unsigned think_time;
+
+   debug("%s: dev='%s', udev=%p\n", __func__, dev->name, udev);
+
+   /* Ignore root hubs */
+   if (usb_hub_is_root_hub(udev->dev))
+   return 0;
+
+   virt_dev = ctrl->devs[slot_id];
+   BUG_ON(!virt_dev);
+
+   out_ctx = virt_dev->out_ctx;
+   in_ctx = virt_dev->in_ctx;
+
+   ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
+   /* Initialize the input context control */
+   ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG);
+   ctrl_ctx->drop_flags = 0;
+
+   xhci_inval_cache((uintptr_t)out_ctx->bytes, out_ctx->size);
+
+   /* slot context */
+   xhci_slot_copy(ctrl, in_ctx, out_ctx);
+   slot_ctx = xhci_get_slot_ctx(ctrl, in_ctx);
+
+   /* Update hub related fields */
+   slot_ctx->dev_info |= cpu_to_le32(DEV_HUB);
+   if (hub->tt.multi && udev->speed == USB_SPEED_HIGH)
+   slot_ctx->dev_info |= cpu_to_le32(DEV_MTT);
+   slot_ctx->dev_info2 |= cpu_to_le32(XHCI_MAX_PORTS(udev->maxchild));
+   /*
+* Set TT think time - convert from ns to FS bit times.
+* Note 8 FS bit times == (8 bits / 1200 bps) ~= 666ns
+*
+* 0 =  8 FS bit times, 1 = 16 FS bit times,
+* 2 = 24 FS bit times, 3 = 32 FS bit times.
+*
+* This field shall be 0 if the device is not a high-spped hub.
+*/
+   think_time = hub->tt.think_time;
+   if (think_time != 0)
+   think_time = (think_time / 666) - 1;
+   if (udev->speed == USB_SPEED_HIGH)
+   slot_ctx->tt_info |= cpu_to_le32(TT_THINK_TIME(think_time));
+
+   return xhci_configure_endpoints(udev, false);
+}
+
 int xhci_register(struct udevice *dev, struct xhci_hccr *hccr,
  struct xhci_hcor *hcor)
 {
@@ -1222,6 +1280,7 @@ struct dm_usb_ops xhci_usb_ops = {
.bulk = xhci_submit_bulk_msg,
.interrupt = xhci_submit_int_msg,
.alloc_device = xhci_alloc_device,
+   .update_hub_device = xhci_update_hub_device,
 };
 
 #endif
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 09/18] usb: hub: Add 3.0 hub port status mask of 2.0 hub

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 include/usb_defs.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/usb_defs.h b/include/usb_defs.h
index 608a0ca..6b4385a 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -262,12 +262,17 @@
 
 /*
  * Changes to wPortStatus bit field in USB 3.0
- * See USB 3.0 spec Table 10-11
+ * See USB 3.0 spec Table 10-10
  */
 #define USB_SS_PORT_STAT_LINK_STATE0x01e0
 #define USB_SS_PORT_STAT_POWER 0x0200
 #define USB_SS_PORT_STAT_SPEED 0x1c00
 #define USB_SS_PORT_STAT_SPEED_5GBPS   0x
+/* Bits that are the same from USB 2.0 */
+#define USB_SS_PORT_STAT_MASK  (USB_PORT_STAT_CONNECTION | \
+USB_PORT_STAT_ENABLE | \
+USB_PORT_STAT_OVERCURRENT | \
+USB_PORT_STAT_RESET)
 
 /* wPortChange bits */
 #define USB_PORT_STAT_C_CONNECTION  0x0001
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 05/15] usb: hub: Add a new API to test if a hub device is root hub

2017-07-19 Thread Bin Meng
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 

---

Changes in v3: None
Changes in v2:
- squash the xchi is_root_port() changes into previous commit

 common/usb_hub.c| 10 ++
 drivers/usb/host/xhci.c | 24 ++--
 include/usb.h   |  8 
 3 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 086b155..a8c2f56 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -67,6 +67,16 @@ static inline bool usb_hub_is_superspeed(struct usb_device 
*hdev)
return hdev->descriptor.bDeviceProtocol == 3;
 }
 
+#ifdef CONFIG_DM_USB
+bool usb_hub_is_root_hub(struct udevice *hub)
+{
+   if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB)
+   return true;
+
+   return false;
+}
+#endif
+
 static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size)
 {
unsigned short dtype = USB_DT_HUB;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 62ab62b..0c88980 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1116,26 +1116,6 @@ int usb_lowlevel_stop(int index)
 #endif /* CONFIG_DM_USB */
 
 #ifdef CONFIG_DM_USB
-/*
-static struct usb_device *get_usb_device(struct udevice *dev)
-{
-   struct usb_device *udev;
-
-   if (device_get_uclass_id(dev) == UCLASS_USB)
-   udev = dev_get_uclass_priv(dev);
-   else
-   udev = dev_get_parent_priv(dev);
-
-   return udev;
-}
-*/
-static bool is_root_hub(struct udevice *dev)
-{
-   if (device_get_uclass_id(dev->parent) != UCLASS_USB_HUB)
-   return true;
-
-   return false;
-}
 
 static int xhci_submit_control_msg(struct udevice *dev, struct usb_device 
*udev,
   unsigned long pipe, void *buffer, int length,
@@ -1150,10 +1130,10 @@ static int xhci_submit_control_msg(struct udevice *dev, 
struct usb_device *udev,
hub = udev->dev;
if (device_get_uclass_id(hub) == UCLASS_USB_HUB) {
/* Figure out our port number on the root hub */
-   if (is_root_hub(hub)) {
+   if (usb_hub_is_root_hub(hub)) {
root_portnr = udev->portnr;
} else {
-   while (!is_root_hub(hub->parent))
+   while (!usb_hub_is_root_hub(hub->parent))
hub = hub->parent;
uhop = dev_get_parent_priv(hub);
root_portnr = uhop->portnr;
diff --git a/include/usb.h b/include/usb.h
index a266677..64dfa84 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -776,6 +776,14 @@ int usb_setup_device(struct usb_device *dev, bool do_read,
 struct usb_device *parent);
 
 /**
+ * usb_hub_is_root_hub() - Test whether a hub device is root hub or not
+ *
+ * @hub:   USB hub device to test
+ * @return:true if the hub device is root hub, false otherwise.
+ */
+bool usb_hub_is_root_hub(struct udevice *hub);
+
+/**
  * usb_hub_scan() - Scan a hub and find its devices
  *
  * @hub:   Hub device to scan
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 11/15] dm: usb: Add a new USB controller operation 'update_hub_device'

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 drivers/usb/host/usb-uclass.c | 11 +++
 include/usb.h | 21 -
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index d8d74bd..0b8a501 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -139,6 +139,17 @@ int usb_reset_root_port(struct usb_device *udev)
return ops->reset_root_port(bus, udev);
 }
 
+int usb_update_hub_device(struct usb_device *udev)
+{
+   struct udevice *bus = udev->controller_dev;
+   struct dm_usb_ops *ops = usb_get_ops(bus);
+
+   if (!ops->update_hub_device)
+   return -ENOSYS;
+
+   return ops->update_hub_device(bus, udev);
+}
+
 int usb_stop(void)
 {
struct udevice *bus;
diff --git a/include/usb.h b/include/usb.h
index 58b4549..fad0401 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -758,6 +758,14 @@ struct dm_usb_ops {
 * reset_root_port() - Reset usb root port
 */
int (*reset_root_port)(struct udevice *bus, struct usb_device *udev);
+
+   /**
+* update_hub_device() - Update HCD's internal representation of hub
+*
+* After a hub descriptor is fetched, notify HCD so that its internal
+* representation of this hub can be updated (xHCI)
+*/
+   int (*update_hub_device)(struct udevice *bus, struct usb_device *udev);
 };
 
 #define usb_get_ops(dev)   ((struct dm_usb_ops *)(dev)->driver->ops)
@@ -931,6 +939,17 @@ int usb_new_device(struct usb_device *dev);
 int usb_alloc_device(struct usb_device *dev);
 
 /**
+ * update_hub_device() - Update HCD's internal representation of hub
+ *
+ * After a hub descriptor is fetched, notify HCD so that its internal
+ * representation of this hub can be updated.
+ *
+ * @dev:   Hub device
+ * @return 0 if OK, -ve on error
+ */
+int usb_update_hub_device(struct usb_device *dev);
+
+/**
  * usb_emul_setup_device() - Set up a new USB device emulation
  *
  * This is normally called when a new emulation device is bound. It tells
@@ -943,7 +962,7 @@ int usb_alloc_device(struct usb_device *dev);
  * @desc_list: List of points or USB descriptors, terminated by NULL.
  * The first entry must be struct usb_device_descriptor,
  * and others follow on after that.
- * @return 0 if OK, -ve on error
+ * @return 0 if OK, -ENOSYS if not implemented, other -ve on error
  */
 int usb_emul_setup_device(struct udevice *dev, int maxpacketsize,
  struct usb_string *strings, void **desc_list);
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 12/15] usb: hub: Call usb_update_hub_device() after hub descriptor is fetched

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/usb_hub.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index bbb1155..70bc6e2 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -789,6 +789,17 @@ static int usb_hub_configure(struct usb_device *dev)
 
 #ifdef CONFIG_DM_USB
/*
+* Update USB host controller's internal representation of this hub
+* after the hub descriptor is fetched.
+*/
+   ret = usb_update_hub_device(dev);
+   if (ret < 0 && ret != -ENOSYS) {
+   debug("%s: failed to update hub device for HCD (%x)\n",
+ __func__, ret);
+   return ret;
+   }
+
+   /*
 * A maximum of seven tiers are allowed in a USB topology, and the
 * root hub occupies the first tier. The last tier ends with a normal
 * USB device. USB 3.0 hubs use a 20-bit field called 'route string'
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 15/15] usb: xhci: Enable TT to support LS/FS devices behind a HS hub

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci-mem.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index c02059e..d5eab3a 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -783,6 +783,20 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl 
*ctrl,
BUG();
}
 
+#ifdef CONFIG_DM_USB
+   /* Set up TT fields to support FS/LS devices */
+   if (speed == USB_SPEED_LOW || speed == USB_SPEED_FULL) {
+   dev = dev_get_parent_priv(udev->dev);
+   if (dev->speed == USB_SPEED_HIGH) {
+   hub = dev_get_uclass_priv(udev->dev);
+   if (hub->tt.multi)
+   slot_ctx->dev_info |= cpu_to_le32(DEV_MTT);
+   slot_ctx->tt_info |= cpu_to_le32(TT_PORT(udev->portnr));
+   slot_ctx->tt_info |= cpu_to_le32(TT_SLOT(dev->slot_id));
+   }
+   }
+#endif
+
port_num = hop_portnr;
debug("port_num = %d\n", port_num);
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 16/18] usb: xhci: Convert CONFIG_USB_XHCI_PCI to Kconfig

2017-07-19 Thread Bin Meng
Add CONFIG_USB_XHCI_PCI as a Kconfig option.

Signed-off-by: Bin Meng 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 

---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Update description to use "PCI-based"
- Remove CONFIG_USB_XHCI_PCI from config_whitelist.txt

 drivers/usb/host/Kconfig | 6 ++
 scripts/config_whitelist.txt | 1 -
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index bc2c1f1..9edc589 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -31,6 +31,12 @@ config USB_XHCI_MVEBU
  SoCs, which includes Armada8K, Armada3700 and other Armada
  family SoCs.
 
+config USB_XHCI_PCI
+   bool "Support for PCI-based xHCI USB controller"
+   default y if X86
+   help
+ Enables support for the PCI-based xHCI controller.
+
 config USB_XHCI_ROCKCHIP
bool "Support for Rockchip on-chip xHCI USB controller"
depends on ARCH_ROCKCHIP
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 72b7a6c..d7d3add 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -5204,7 +5204,6 @@ CONFIG_USB_XHCI_EXYNOS
 CONFIG_USB_XHCI_FSL
 CONFIG_USB_XHCI_KEYSTONE
 CONFIG_USB_XHCI_OMAP
-CONFIG_USB_XHCI_PCI
 CONFIG_USER_LOWLEVEL_INIT
 CONFIG_USE_FDT
 CONFIG_USE_INTERRUPT
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 09/15] usb: xhci: Program 'route string' in the input slot context

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 

---
Test logs: two USB 3.0 hubs (one tier2, one tier3)
=> usb tree
USB device tree:
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Hub (5 Gb/s, 0mA)
  | |  GenesysLogic USB3.0 Hub
  | |
  | +-4  Hub (5 Gb/s, 0mA)
  | | |  VIA Labs, Inc.  USB3.0 Hub
  | | |
  | | +-7  Mass Storage (5 Gb/s, 76mA)
  | |  JetFlash Mass Storage Device 16Q6ZPH20GF3E8UQ
  | |
  | +-8  Vendor specific (5 Gb/s, 36mA)
  |  Realtek USB 10/100/1000 LAN 00E04C680977
  |
  +-3  Hub (480 Mb/s, 100mA)
|  GenesysLogic USB2.0 Hub
|
+-5  Mass Storage (480 Mb/s, 200mA)
|Netac OnlyDisk FF00ECB608001526
|
+-6  Hub (480 Mb/s, 0mA)
 VIA Labs, Inc.  USB2.0 Hub

Changes in v3:
- fix build warnings for non-DM configuration

Changes in v2:
- handle port number is greater than 15 in route string

 drivers/usb/host/xhci-mem.c | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 9aa3092..c02059e 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -723,6 +723,11 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl 
*ctrl,
u64 trb_64 = 0;
int slot_id = udev->slot_id;
int speed = udev->speed;
+   int route = 0;
+#ifdef CONFIG_DM_USB
+   struct usb_device *dev = udev;
+   struct usb_hub_device *hub;
+#endif
 
virt_dev = ctrl->devs[slot_id];
 
@@ -733,7 +738,32 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl 
*ctrl,
slot_ctx = xhci_get_slot_ctx(ctrl, virt_dev->in_ctx);
 
/* Only the control endpoint is valid - one endpoint context */
-   slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | 0);
+   slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1));
+
+#ifdef CONFIG_DM_USB
+   /* Calculate the route string for this device */
+   port_num = dev->portnr;
+   while (!usb_hub_is_root_hub(dev->dev)) {
+   hub = dev_get_uclass_priv(dev->dev);
+   /*
+* Each hub in the topology is expected to have no more than
+* 15 ports in order for the route string of a device to be
+* unique. SuperSpeed hubs are restricted to only having 15
+* ports, but FS/LS/HS hubs are not. The xHCI specification
+* says that if the port number the device is greater than 15,
+* that portion of the route string shall be set to 15.
+*/
+   if (port_num > 15)
+   port_num = 15;
+   route |= port_num << (hub->hub_depth * 4);
+   dev = dev_get_parent_priv(dev->dev);
+   port_num = dev->portnr;
+   dev = dev_get_parent_priv(dev->dev->parent);
+   }
+
+   debug("route string %x\n", route);
+#endif
+   slot_ctx->dev_info |= route;
 
switch (speed) {
case USB_SPEED_SUPER:
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 02/15] usb: xhci-pci: Clean up the driver a little bit

2017-07-19 Thread Bin Meng
This cleans up the driver a little bit.

Signed-off-by: Bin Meng 
Reviewed-by: Simon Glass 

---

Changes in v3: None
Changes in v2:
- nuke xhci_pci_remove() altogether

 drivers/usb/host/xhci-pci.c | 21 ++---
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 5ad8452..e4a0ef4 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -8,16 +8,10 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
-
 #include "xhci.h"
 
-struct xhci_pci_priv {
-   struct xhci_ctrl ctrl;  /* Needs to come first in this struct! */
-};
-
 static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
  struct xhci_hcor **ret_hcor)
 {
@@ -53,17 +47,6 @@ static int xhci_pci_probe(struct udevice *dev)
return xhci_register(dev, hccr, hcor);
 }
 
-static int xhci_pci_remove(struct udevice *dev)
-{
-   int ret;
-
-   ret = xhci_deregister(dev);
-   if (ret)
-   return ret;
-
-   return 0;
-}
-
 static const struct udevice_id xhci_pci_ids[] = {
{ .compatible = "xhci-pci" },
{ }
@@ -73,11 +56,11 @@ U_BOOT_DRIVER(xhci_pci) = {
.name   = "xhci_pci",
.id = UCLASS_USB,
.probe = xhci_pci_probe,
-   .remove = xhci_pci_remove,
+   .remove = xhci_deregister,
.of_match = xhci_pci_ids,
.ops= _usb_ops,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
-   .priv_auto_alloc_size = sizeof(struct xhci_pci_priv),
+   .priv_auto_alloc_size = sizeof(struct xhci_ctrl),
.flags  = DM_FLAG_ALLOC_PRIV_DMA,
 };
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 14/15] usb: xhci: Correct TT_SLOT and TT_PORT macros

2017-07-19 Thread Bin Meng
These two macros really need a parameter to make them useful.

Signed-off-by: Bin Meng 
Reviewed-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index cdce67c..a497d9d 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -548,12 +548,12 @@ struct xhci_slot_ctx {
  * The Slot ID of the hub that isolates the high speed signaling from
  * this low or full-speed device.  '0' if attached to root hub port.
  */
-#define TT_SLOT(0xff)
+#define TT_SLOT(p) (((p) & 0xff) << 0)
 /*
  * The number of the downstream facing port of the high-speed hub
  * '0' if the device is not low or full speed.
  */
-#define TT_PORT(0xff << 8)
+#define TT_PORT(p) (((p) & 0xff) << 8)
 #define TT_THINK_TIME(p)   (((p) & 0x3) << 16)
 
 /* dev_state bitmasks */
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 00/15] usb: hub: Support USB 3.0 hubs

2017-07-19 Thread Bin Meng
This series is a follow-up series to previous series [1] that adds
support for USB 3.0 hubs.

USB 3.0 hubs have slightly different hub descriptor format, as well
as different port status bit positions. These needs to be properly
handled by U-Boot USB core stack codes. xHCI driver has also been
updated to correctly set up context structures that are required
for devices behind a 3.0 hub to work.

Besides USB 3.0 hubs support, this series also adds support for low
speed/full speed devices connected behind a high speed hub with the
xHC controller. It turns out the 'Transaction Translator' part in
the xHC data structure is missing.

Note there is one error during testing USB keyboard when
CONFIG_USB_KEYBOARD is on.

  "Failed to get keyboard state from device 413c:2105"

The enumeration process did pass and the error was thrown in the
USB keyboard driver. This was due to the interrupt transfer is
still not supported by xHCI driver, as of today.

This series is available at u-boot-x86/xhci-working2 for testing.

[1] https://lists.denx.de/pipermail/u-boot/2017-June/296166.html

Changes in v3:
- fix build warnings for non-DM configuration

Changes in v2:
- update the xhci-pci driver Kconfig to make it depend on DM_USB
- nuke xhci_pci_remove() altogether
- trim down the ifdefs by adding usb_get_hub_device() and limit
  ifdefs only in that function
- new patch to "remove hub_port_reset()"
- squash the xchi is_root_port() changes into previous commit
- change to use 'packets' in the comments
- handle port number is greater than 15 in route string
- fix several nits in the commit message
- add a comment for 666 in TT think time

Bin Meng (15):
  usb: xhci-pci: Drop non-DM version of xhci-pci driver
  usb: xhci-pci: Clean up the driver a little bit
  usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv
  usb: hub: Remove hub_port_reset()
  usb: hub: Add a new API to test if a hub device is root hub
  usb: hub: Translate USB 3.0 hub port status into old version
  usb: hub: Support 'set hub depth' request for USB 3.0 hubs
  usb: xhci: Change xhci_setup_addressable_virt_dev() signature
  usb: xhci: Program 'route string' in the input slot context
  usb: hub: Parse and save TT details from device descriptor
  dm: usb: Add a new USB controller operation 'update_hub_device'
  usb: hub: Call usb_update_hub_device() after hub descriptor is fetched
  usb: xhci: Implement update_hub_device() operation
  usb: xhci: Correct TT_SLOT and TT_PORT macros
  usb: xhci: Enable TT to support LS/FS devices behind a HS hub

 common/usb_hub.c  | 208 ++
 drivers/usb/host/Kconfig  |   1 +
 drivers/usb/host/usb-uclass.c |  13 ++-
 drivers/usb/host/xhci-mem.c   |  52 ++-
 drivers/usb/host/xhci-pci.c   |  73 +--
 drivers/usb/host/xhci.c   |  86 -
 drivers/usb/host/xhci.h   |   8 +-
 include/usb.h |  64 +
 include/usb_defs.h|  15 +++
 9 files changed, 379 insertions(+), 141 deletions(-)

-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 15/18] usb: cmd: Print actual packet size for super speed devices

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 

---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Change to use uint and also 'normal' variable name packet_size.

 cmd/usb.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cmd/usb.c b/cmd/usb.c
index 4fa456e..992d414 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -150,6 +150,8 @@ static void usb_display_string(struct usb_device *dev, int 
index)
 
 static void usb_display_desc(struct usb_device *dev)
 {
+   uint packet_size = dev->descriptor.bMaxPacketSize0;
+
if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
printf("%d: %s,  USB Revision %x.%x\n", dev->devnum,
usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass),
@@ -171,9 +173,10 @@ static void usb_display_desc(struct usb_device *dev)
   usb_get_class_desc(
dev->config.if_desc[0].desc.bInterfaceClass));
}
+   if (dev->descriptor.bcdUSB >= cpu_to_le16(0x0300))
+   packet_size = 1 << packet_size;
printf(" - PacketSize: %d  Configurations: %d\n",
-   dev->descriptor.bMaxPacketSize0,
-   dev->descriptor.bNumConfigurations);
+   packet_size, dev->descriptor.bNumConfigurations);
printf(" - Vendor: 0x%04x  Product 0x%04x Version %d.%d\n",
dev->descriptor.idVendor, dev->descriptor.idProduct,
(dev->descriptor.bcdDevice>>8) & 0xff,
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 11/18] usb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci.c | 8 +---
 drivers/usb/host/xhci.h | 4 +---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d5a1b34..62ab62b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -668,12 +668,14 @@ static int xhci_submit_root(struct usb_device *udev, 
unsigned long pipe,
uint32_t reg;
volatile uint32_t *status_reg;
struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
+   struct xhci_hccr *hccr = ctrl->hccr;
struct xhci_hcor *hcor = ctrl->hcor;
+   int max_ports = HCS_MAX_PORTS(xhci_readl(>cr_hcsparams1));
 
if ((req->requesttype & USB_RT_PORT) &&
-   le16_to_cpu(req->index) > CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS) {
-   printf("The request port(%d) is not configured\n",
-   le16_to_cpu(req->index) - 1);
+   le16_to_cpu(req->index) > max_ports) {
+   printf("The request port(%d) exceeds maximum port number\n",
+  le16_to_cpu(req->index) - 1);
return -EINVAL;
}
 
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 3cf08e4..b9602ba 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -172,9 +172,7 @@ struct xhci_hcor {
volatile uint64_t or_dcbaap;
volatile uint32_t or_config;
volatile uint32_t reserved_2[241];
-   struct xhci_hcor_port_regs portregs[CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS];
-
-   uint32_t reserved_4[CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS * 254];
+   struct xhci_hcor_port_regs portregs[MAX_HC_PORTS];
 };
 
 /* USBCMD - USB command - command bitmasks */
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 10/15] usb: hub: Parse and save TT details from device descriptor

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/usb_hub.c   | 50 ++
 include/usb.h  | 16 
 include/usb_defs.h | 12 
 3 files changed, 78 insertions(+)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 18c366a..bbb1155 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -700,6 +700,56 @@ static int usb_hub_configure(struct usb_device *dev)
break;
}
 
+   switch (dev->descriptor.bDeviceProtocol) {
+   case USB_HUB_PR_FS:
+   break;
+   case USB_HUB_PR_HS_SINGLE_TT:
+   debug("Single TT\n");
+   break;
+   case USB_HUB_PR_HS_MULTI_TT:
+   ret = usb_set_interface(dev, 0, 1);
+   if (ret == 0) {
+   debug("TT per port\n");
+   hub->tt.multi = true;
+   } else {
+   debug("Using single TT (err %d)\n", ret);
+   }
+   break;
+   case USB_HUB_PR_SS:
+   /* USB 3.0 hubs don't have a TT */
+   break;
+   default:
+   debug("Unrecognized hub protocol %d\n",
+ dev->descriptor.bDeviceProtocol);
+   break;
+   }
+
+   /* Note 8 FS bit times == (8 bits / 1200 bps) ~= 666ns */
+   switch (hubCharacteristics & HUB_CHAR_) {
+   case HUB__8_BITS:
+   if (dev->descriptor.bDeviceProtocol != 0) {
+   hub->tt.think_time = 666;
+   debug("TT requires at most %d FS bit times (%d ns)\n",
+ 8, hub->tt.think_time);
+   }
+   break;
+   case HUB__16_BITS:
+   hub->tt.think_time = 666 * 2;
+   debug("TT requires at most %d FS bit times (%d ns)\n",
+ 16, hub->tt.think_time);
+   break;
+   case HUB__24_BITS:
+   hub->tt.think_time = 666 * 3;
+   debug("TT requires at most %d FS bit times (%d ns)\n",
+ 24, hub->tt.think_time);
+   break;
+   case HUB__32_BITS:
+   hub->tt.think_time = 666 * 4;
+   debug("TT requires at most %d FS bit times (%d ns)\n",
+ 32, hub->tt.think_time);
+   break;
+   }
+
debug("power on to power good time: %dms\n",
  descriptor->bPwrOn2PwrGood * 2);
debug("hub controller current requirement: %dmA\n",
diff --git a/include/usb.h b/include/usb.h
index f71da52..58b4549 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -537,6 +537,21 @@ struct usb_hub_status {
unsigned short wHubChange;
 } __attribute__ ((packed));
 
+/*
+ * Hub Device descriptor
+ * USB Hub class device protocols
+ */
+#define USB_HUB_PR_FS  0 /* Full speed hub */
+#define USB_HUB_PR_HS_NO_TT0 /* Hi-speed hub without TT */
+#define USB_HUB_PR_HS_SINGLE_TT1 /* Hi-speed hub with single TT */
+#define USB_HUB_PR_HS_MULTI_TT 2 /* Hi-speed hub with multiple TT */
+#define USB_HUB_PR_SS  3 /* Super speed hub */
+
+/* Transaction Translator Think Times, in bits */
+#define HUB__8_BITS0x00
+#define HUB__16_BITS   0x20
+#define HUB__24_BITS   0x40
+#define HUB__32_BITS   0x60
 
 /* Hub descriptor */
 struct usb_hub_descriptor {
@@ -571,6 +586,7 @@ struct usb_hub_device {
ulong query_delay;  /* Device query delay in ms */
int overcurrent_count[USB_MAXCHILDREN]; /* Over-current counter */
int hub_depth;  /* USB 3.0 hub depth */
+   struct usb_tt tt;   /* Transaction Translator */
 };
 
 #ifdef CONFIG_DM_USB
diff --git a/include/usb_defs.h b/include/usb_defs.h
index 273337f..b7f2ead 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -293,6 +293,7 @@
 #define HUB_CHAR_LPSM   0x0003
 #define HUB_CHAR_COMPOUND   0x0004
 #define HUB_CHAR_OCPM   0x0018
+#define HUB_CHAR_   0x0060 /* TT Think Time mask */
 
 /*
  * Hub Status & Hub Change bit masks
@@ -310,6 +311,17 @@
 #define USB_REQ_SET_HUB_DEPTH  0x0c
 
 /*
+ * As of USB 2.0, full/low speed devices are segregated into trees.
+ * One type grows from USB 1.1 host controllers (OHCI, UHCI etc).
+ * The other type grows from high speed hubs when they connect to
+ * full/low speed devices using "Transaction Translators" (TTs).
+ */

[U-Boot] [PATCH v4 07/18] usb: hub: Revise wLength for 'get port status' request

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/usb_hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 48831b5..83c6767 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -107,7 +107,7 @@ int usb_get_port_status(struct usb_device *dev, int port, 
void *data)
 {
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port,
-   data, sizeof(struct usb_hub_status), USB_CNTL_TIMEOUT);
+   data, sizeof(struct usb_port_status), USB_CNTL_TIMEOUT);
 }
 
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 01/15] usb: xhci-pci: Drop non-DM version of xhci-pci driver

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 

---

Changes in v3: None
Changes in v2:
- update the xhci-pci driver Kconfig to make it depend on DM_USB

 drivers/usb/host/Kconfig|  1 +
 drivers/usb/host/xhci-pci.c | 52 -
 2 files changed, 1 insertion(+), 52 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 9edc589..67ad72b 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -33,6 +33,7 @@ config USB_XHCI_MVEBU
 
 config USB_XHCI_PCI
bool "Support for PCI-based xHCI USB controller"
+   depends on DM_USB
default y if X86
help
  Enables support for the PCI-based xHCI controller.
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 63daaa6..5ad8452 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -14,56 +14,6 @@
 
 #include "xhci.h"
 
-#ifndef CONFIG_DM_USB
-
-/*
- * Create the appropriate control structures to manage a new XHCI host
- * controller.
- */
-int xhci_hcd_init(int index, struct xhci_hccr **ret_hccr,
- struct xhci_hcor **ret_hcor)
-{
-   struct xhci_hccr *hccr;
-   struct xhci_hcor *hcor;
-   pci_dev_t pdev;
-   uint32_t cmd;
-   int len;
-
-   pdev = pci_find_class(PCI_CLASS_SERIAL_USB_XHCI, index);
-   if (pdev < 0) {
-   printf("XHCI host controller not found\n");
-   return -1;
-   }
-
-   hccr = (struct xhci_hccr *)pci_map_bar(pdev,
-   PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
-   len = HC_LENGTH(xhci_readl(>cr_capbase));
-   hcor = (struct xhci_hcor *)((uint32_t)hccr + len);
-
-   debug("XHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n",
- (uint32_t)hccr, (uint32_t)hcor, len);
-
-   *ret_hccr = hccr;
-   *ret_hcor = hcor;
-
-   /* enable busmaster */
-   pci_read_config_dword(pdev, PCI_COMMAND, );
-   cmd |= PCI_COMMAND_MASTER;
-   pci_write_config_dword(pdev, PCI_COMMAND, cmd);
-
-   return 0;
-}
-
-/*
- * Destroy the appropriate control structures corresponding * to the XHCI host
- * controller
- */
-void xhci_hcd_stop(int index)
-{
-}
-
-#else
-
 struct xhci_pci_priv {
struct xhci_ctrl ctrl;  /* Needs to come first in this struct! */
 };
@@ -137,5 +87,3 @@ static struct pci_device_id xhci_pci_supported[] = {
 };
 
 U_BOOT_PCI_DEVICE(xhci_pci, xhci_pci_supported);
-
-#endif /* CONFIG_DM_USB */
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 12/18] configs: Remove CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS in all boards

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 include/configs/am43xx_evm.h | 1 -
 include/configs/am57xx_evm.h | 1 -
 include/configs/cl-som-am57x.h   | 1 -
 include/configs/cm_t43.h | 1 -
 include/configs/dra7xx_evm.h | 1 -
 include/configs/ds414.h  | 1 -
 include/configs/exynos5-common.h | 1 -
 include/configs/ls1012afrdm.h| 1 -
 include/configs/ls1012aqds.h | 1 -
 include/configs/ls1012ardb.h | 1 -
 include/configs/ls1021aiot.h | 1 -
 include/configs/ls1021aqds.h | 1 -
 include/configs/ls1021atwr.h | 1 -
 include/configs/ls1043aqds.h | 1 -
 include/configs/ls1043ardb.h | 1 -
 include/configs/ls1046aqds.h | 1 -
 include/configs/ls1046ardb.h | 1 -
 include/configs/ls2080aqds.h | 1 -
 include/configs/ls2080ardb.h | 1 -
 include/configs/mvebu_armada-37xx.h  | 4 +---
 include/configs/mvebu_armada-8k.h| 4 +---
 include/configs/rk3328_common.h  | 2 --
 include/configs/rk3399_common.h  | 3 ---
 include/configs/ti_armv7_keystone2.h | 1 -
 include/configs/uniphier.h   | 3 ---
 include/configs/xilinx_zynqmp.h  | 2 --
 scripts/config_whitelist.txt | 1 -
 27 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index 1d8e39c..4278878 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -83,7 +83,6 @@
 #if defined(CONFIG_SPL_USB_HOST_SUPPORT) || !defined(CONFIG_SPL_BUILD)
 #define CONFIG_SYS_USB_FAT_BOOT_PARTITION  1
 #define CONFIG_USB_XHCI_OMAP
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
 
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_AM437X_USB2PHY2_HOST
diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
index 98ce6c5..2f59111 100644
--- a/include/configs/am57xx_evm.h
+++ b/include/configs/am57xx_evm.h
@@ -93,7 +93,6 @@
 
 /* USB xHCI HOST */
 #define CONFIG_USB_XHCI_OMAP
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
 
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_OMAP_USB3PHY1_HOST
diff --git a/include/configs/cl-som-am57x.h b/include/configs/cl-som-am57x.h
index a04f4cd..02adac5 100644
--- a/include/configs/cl-som-am57x.h
+++ b/include/configs/cl-som-am57x.h
@@ -84,7 +84,6 @@
 
 /* USB xHCI HOST */
 #define CONFIG_USB_XHCI_OMAP
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
 
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_OMAP_USB3PHY1_HOST
diff --git a/include/configs/cm_t43.h b/include/configs/cm_t43.h
index 7b5ca0d..ad6f6ce 100644
--- a/include/configs/cm_t43.h
+++ b/include/configs/cm_t43.h
@@ -60,7 +60,6 @@
 
 /* USB support */
 #define CONFIG_USB_XHCI_OMAP
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_AM437X_USB2PHY2_HOST
 
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index d2f7c7c..102c986 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -156,7 +156,6 @@
 
 /* USB xHCI HOST */
 #define CONFIG_USB_XHCI_OMAP
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
 
 #define CONFIG_OMAP_USB_PHY
 #define CONFIG_OMAP_USB2PHY2_HOST
diff --git a/include/configs/ds414.h b/include/configs/ds414.h
index aaba5d8..b0846ef 100644
--- a/include/configs/ds414.h
+++ b/include/configs/ds414.h
@@ -69,7 +69,6 @@
 #if 0
 #undef CONFIG_DM_USB
 #define CONFIG_USB_XHCI_PCI
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
 #endif
 
 #if !defined(CONFIG_USB_XHCI_HCD)
diff --git a/include/configs/exynos5-common.h b/include/configs/exynos5-common.h
index 378219d..7cb3278 100644
--- a/include/configs/exynos5-common.h
+++ b/include/configs/exynos5-common.h
@@ -135,7 +135,6 @@
 
 /* USB */
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2
 
 #define CONFIG_USB_HOST_ETHER
 #define CONFIG_USB_ETHER_ASIX
diff --git a/include/configs/ls1012afrdm.h b/include/configs/ls1012afrdm.h
index f6f88e8..6b1ba57 100644
--- a/include/configs/ls1012afrdm.h
+++ b/include/configs/ls1012afrdm.h
@@ -39,7 +39,6 @@
 #ifdef CONFIG_HAS_FSL_XHCI_USB
 #define CONFIG_USB_XHCI_FSL
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS  2
 #endif
 
 #define CONFIG_CMD_MEMINFO
diff --git a/include/configs/ls1012aqds.h b/include/configs/ls1012aqds.h
index 9e6c7a7..bebb0df 100644
--- a/include/configs/ls1012aqds.h
+++ b/include/configs/ls1012aqds.h
@@ -124,7 +124,6 @@
 #ifdef CONFIG_HAS_FSL_XHCI_USB
 #define CONFIG_USB_XHCI_FSL
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
-#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS  2
 #endif
 
 /*  MMC  */
diff --git a/include/configs/ls1012ardb.h 

[U-Boot] [PATCH v4 13/18] usb: ehci: Get rid of CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/ehci-hcd.c | 10 +++---
 drivers/usb/host/ehci.h |  7 +++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 40ac3a6..3243c1d 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -148,9 +148,12 @@ static void ehci_powerup_fixup(struct ehci_ctrl *ctrl, 
uint32_t *status_reg,
 
 static uint32_t *ehci_get_portsc_register(struct ehci_ctrl *ctrl, int port)
 {
-   if (port < 0 || port >= CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) {
+   int max_ports = HCS_N_PORTS(ehci_readl(>hccr->cr_hcsparams));
+
+   if (port < 0 || port >= max_ports) {
/* Printing the message would cause a scan failure! */
-   debug("The request port(%u) is not configured\n", port);
+   debug("The request port(%u) exceeds maximum port number\n",
+ port);
return NULL;
}
 
@@ -205,6 +208,7 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl)
 {
int i, ret = 0;
uint32_t cmd, reg;
+   int max_ports = HCS_N_PORTS(ehci_readl(>hccr->cr_hcsparams));
 
if (!ctrl || !ctrl->hcor)
return -EINVAL;
@@ -219,7 +223,7 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl)
100 * 1000);
 
if (!ret) {
-   for (i = 0; i < CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS; i++) {
+   for (i = 0; i < max_ports; i++) {
reg = ehci_readl(>hcor->or_portsc[i]);
reg |= EHCI_PS_SUSP;
ehci_writel(>hcor->or_portsc[i], reg);
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 2ab830d..7c39bec 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -11,9 +11,8 @@
 
 #include 
 
-#if !defined(CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS)
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2
-#endif
+/* Section 2.2.3 - N_PORTS */
+#define MAX_HC_PORTS   15
 
 /*
  * Register Space.
@@ -62,7 +61,7 @@ struct ehci_hcor {
uint32_t _reserved_1_[6];
uint32_t or_configflag;
 #define FLAG_CF(1 << 0)/* true:  we'll support "high 
speed" */
-   uint32_t or_portsc[CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS];
+   uint32_t or_portsc[MAX_HC_PORTS];
 #define PORTSC_PSPD(x) (((x) >> 26) & 0x3)
 #define PORTSC_PSPD_FS 0x0
 #define PORTSC_PSPD_LS 0x1
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 18/18] x86: minnowmax: Enable USB xHCI support

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 

---

Changes in v4:
- Rebase on u-boot-usb/master

Changes in v3:
- Rebase on u-boot/master

Changes in v2:
- Drop two x86 patches that were already applied to u-boot-x86

 arch/x86/dts/minnowmax.dts  | 3 +++
 configs/minnowmax_defconfig | 1 +
 2 files changed, 4 insertions(+)

diff --git a/arch/x86/dts/minnowmax.dts b/arch/x86/dts/minnowmax.dts
index 4c0a8fe..a0ad03c 100644
--- a/arch/x86/dts/minnowmax.dts
+++ b/arch/x86/dts/minnowmax.dts
@@ -272,6 +272,9 @@
fsp,enable-spi;
fsp,enable-sata;
fsp,sata-mode = ;
+#ifdef CONFIG_USB_XHCI_HCD
+   fsp,enable-xhci;
+#endif
fsp,lpe-mode = ;
fsp,lpss-sio-mode = ;
fsp,enable-dma0;
diff --git a/configs/minnowmax_defconfig b/configs/minnowmax_defconfig
index a64a0a3..72dea82 100644
--- a/configs/minnowmax_defconfig
+++ b/configs/minnowmax_defconfig
@@ -69,6 +69,7 @@ CONFIG_ICH_SPI=y
 CONFIG_TIMER=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
+CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_DM_VIDEO=y
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 17/18] x86: minnowmax: Add a environment variable for USB power-on delay

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 include/configs/minnowmax.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/configs/minnowmax.h b/include/configs/minnowmax.h
index ae95485..6ea607d 100644
--- a/include/configs/minnowmax.h
+++ b/include/configs/minnowmax.h
@@ -20,7 +20,8 @@
 
 #define CONFIG_STD_DEVICES_SETTINGS"stdin=usbkbd,serial\0" \
"stdout=vidconsole,serial\0" \
-   "stderr=vidconsole,serial\0"
+   "stderr=vidconsole,serial\0" \
+   "usb_pgood_delay=40\0"
 
 #define CONFIG_SCSI_DEV_LIST   \
{PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VALLEYVIEW_SATA}, \
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 10/18] usb: xhci: Change MAX_HC_PORTS to 255

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 32dd611..3cf08e4 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -30,7 +30,7 @@
 /* Max number of USB devices for any host controller - limit in section 6.1 */
 #define MAX_HC_SLOTS256
 /* Section 5.3.3 - MaxPorts */
-#define MAX_HC_PORTS127
+#define MAX_HC_PORTS255
 
 /* Up to 16 ms to halt an HC */
 #define XHCI_MAX_HALT_USEC (16*1000)
@@ -102,8 +102,8 @@ struct xhci_hccr {
 #define HCS_MAX_INTRS(p)   (((p) >> 8) & 0x7ff)
 /* bits 24:31, Max Ports - max value is 0x7F = 127 ports */
 #define HCS_MAX_PORTS_SHIFT24
-#define HCS_MAX_PORTS_MASK (0x7f << HCS_MAX_PORTS_SHIFT)
-#define HCS_MAX_PORTS(p)   (((p) >> 24) & 0x7f)
+#define HCS_MAX_PORTS_MASK (0xff << HCS_MAX_PORTS_SHIFT)
+#define HCS_MAX_PORTS(p)   (((p) >> 24) & 0xff)
 
 /* HCSPARAMS2 - hcs_params2 - bitmasks */
 /* bits 0:3, frames or uframes that SW needs to queue transactions
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 05/18] usb: hub: Update handling connect status/change in usb_scan_port()

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
Tested-by: Dinh Nguyen 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/usb_hub.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index d135526..4fe0daa 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -405,8 +405,15 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)
portchange = le16_to_cpu(portsts->wPortChange);
debug("Port %d Status %X Change %X\n", i + 1, portstatus, portchange);
 
-   /* No connection change happened, wait a bit more. */
-   if (!(portchange & USB_PORT_STAT_C_CONNECTION)) {
+   /*
+* No connection change happened, wait a bit more.
+*
+* For some situation, the hub reports no connection change but a
+* device is connected to the port (eg: CCS bit is set but CSC is not
+* in the PORTSC register of a root hub), ignore such case.
+*/
+   if (!(portchange & USB_PORT_STAT_C_CONNECTION) &&
+   !(portstatus & USB_PORT_STAT_CONNECTION)) {
if (get_timer(0) >= hub->connect_timeout) {
debug("devnum=%d port=%d: timeout\n",
  dev->devnum, i + 1);
@@ -418,10 +425,6 @@ static int usb_scan_port(struct usb_device_scan *usb_scan)
return 0;
}
 
-   /* Test if the connection came up, and if not exit */
-   if (!(portstatus & USB_PORT_STAT_CONNECTION))
-   return 0;
-
/* A new USB device is ready at this point */
debug("devnum=%d port=%d: USB dev found\n", dev->devnum, i + 1);
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 08/18] usb: hub: Change USB hub descriptor to match USB 3.0 hubs

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/usb_hub.c   | 12 +++-
 drivers/usb/emul/sandbox_hub.c |  7 ++-
 drivers/usb/host/ehci-hcd.c|  4 ++--
 drivers/usb/host/xhci.c|  4 ++--
 include/usb.h  | 18 ++
 5 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 83c6767..a46d26a 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -583,17 +583,19 @@ static int usb_hub_configure(struct usb_device *dev)
>wHubCharacteristics)),
>desc.wHubCharacteristics);
/* set the bitmap */
-   bitmap = (unsigned char *)>desc.DeviceRemovable[0];
+   bitmap = (unsigned char *)>desc.u.hs.DeviceRemovable[0];
/* devices not removable by default */
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8);
-   bitmap = (unsigned char *)>desc.PortPowerCtrlMask[0];
+   bitmap = (unsigned char *)>desc.u.hs.PortPowerCtrlMask[0];
memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */
 
for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
-   hub->desc.DeviceRemovable[i] = descriptor->DeviceRemovable[i];
+   hub->desc.u.hs.DeviceRemovable[i] =
+   descriptor->u.hs.DeviceRemovable[i];
 
for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
-   hub->desc.PortPowerCtrlMask[i] = 
descriptor->PortPowerCtrlMask[i];
+   hub->desc.u.hs.PortPowerCtrlMask[i] =
+   descriptor->u.hs.PortPowerCtrlMask[i];
 
dev->maxchild = descriptor->bNbrPorts;
debug("%d ports detected\n", dev->maxchild);
@@ -637,7 +639,7 @@ static int usb_hub_configure(struct usb_device *dev)
 
for (i = 0; i < dev->maxchild; i++)
debug("port %d is%s removable\n", i + 1,
- hub->desc.DeviceRemovable[(i + 1) / 8] & \
+ hub->desc.u.hs.DeviceRemovable[(i + 1) / 8] & \
  (1 << ((i + 1) % 8)) ? " not" : "");
 
if (sizeof(struct usb_hub_status) > USB_BUFSIZ) {
diff --git a/drivers/usb/emul/sandbox_hub.c b/drivers/usb/emul/sandbox_hub.c
index 9ffda9c..1432858 100644
--- a/drivers/usb/emul/sandbox_hub.c
+++ b/drivers/usb/emul/sandbox_hub.c
@@ -96,7 +96,12 @@ static struct usb_hub_descriptor hub_desc = {
1 << 7),
.bPwrOn2PwrGood = 2,
.bHubContrCurrent   = 5,
-   .DeviceRemovable= {0, 0xff}, /* all ports removeable */
+   {
+   {
+   /* all ports removeable */
+   .DeviceRemovable= {0, 0xff}
+   }
+   }
 #if SANDBOX_NUM_PORTS > 8
 #error "This code sets up an incorrect mask"
 #endif
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index f08709d..40ac3a6 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -52,8 +52,8 @@ static struct descriptor {
0,  /* wHubCharacteristics */
10, /* bPwrOn2PwrGood */
0,  /* bHubCntrCurrent */
-   {}, /* Device removable */
-   {}  /* at most 7 ports! XXX */
+   {   /* Device removable */
+   }   /* at most 7 ports! XXX */
},
{
0x12,   /* bLength */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 59ee476..d5a1b34 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -50,8 +50,8 @@ static struct descriptor {
cpu_to_le16(0x8), /* wHubCharacteristics */
10, /* bPwrOn2PwrGood */
0,  /* bHubCntrCurrent */
-   {}, /* Device removable */
-   {}  /* at most 7 ports! XXX */
+   {   /* Device removable */
+   }   /* at most 7 ports! XXX */
},
{
0x12,   /* bLength */
diff --git a/include/usb.h b/include/usb.h
index 62f051f..eb82cc2 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -546,10 +546,20 @@ struct usb_hub_descriptor {
unsigned short wHubCharacteristics;
unsigned char  bPwrOn2PwrGood;
unsigned char  bHubContrCurrent;
-   unsigned char  DeviceRemovable[(USB_MAXCHILDREN+1+7)/8];
-   

[U-Boot] [PATCH v4 06/18] usb: hub: Send correct wValue to get hub descriptor of a USB 3.0 hub

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/usb_hub.c| 12 +++-
 drivers/usb/host/xhci.c |  1 +
 include/usb_defs.h  |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 4fe0daa..48831b5 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -65,11 +65,21 @@ __weak void usb_hub_reset_devices(int port)
return;
 }
 
+static inline bool usb_hub_is_superspeed(struct usb_device *hdev)
+{
+   return hdev->descriptor.bDeviceProtocol == 3;
+}
+
 static int usb_get_hub_descriptor(struct usb_device *dev, void *data, int size)
 {
+   unsigned short dtype = USB_DT_HUB;
+
+   if (usb_hub_is_superspeed(dev))
+   dtype = USB_DT_SS_HUB;
+
return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
-   USB_DT_HUB << 8, 0, data, size, USB_CNTL_TIMEOUT);
+   dtype << 8, 0, data, size, USB_CNTL_TIMEOUT);
 }
 
 static int usb_clear_port_feature(struct usb_device *dev, int port, int 
feature)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 95a0fba..59ee476 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -727,6 +727,7 @@ static int xhci_submit_root(struct usb_device *udev, 
unsigned long pipe,
case USB_REQ_GET_DESCRIPTOR | ((USB_DIR_IN | USB_RT_HUB) << 8):
switch (le16_to_cpu(req->value) >> 8) {
case USB_DT_HUB:
+   case USB_DT_SS_HUB:
debug("USB_DT_HUB config\n");
srcptr = 
srclen = 0x8;
diff --git a/include/usb_defs.h b/include/usb_defs.h
index 8214ba9..608a0ca 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -93,6 +93,7 @@
 #define USB_DT_REPORT   (USB_TYPE_CLASS | 0x02)
 #define USB_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)
 #define USB_DT_HUB  (USB_TYPE_CLASS | 0x09)
+#define USB_DT_SS_HUB   (USB_TYPE_CLASS | 0x0a)
 
 /* Descriptor sizes per descriptor type */
 #define USB_DT_DEVICE_SIZE  18
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 02/18] usb: xhci: Correct command TRB 4th dword initialization

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci-ring.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 2675a8f..579e670 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -280,8 +280,15 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, 
u32 slot_id,
fields[0] = lower_32_bits(val_64);
fields[1] = upper_32_bits(val_64);
fields[2] = 0;
-   fields[3] = TRB_TYPE(cmd) | EP_ID_FOR_TRB(ep_index) |
-   SLOT_ID_FOR_TRB(slot_id) | ctrl->cmd_ring->cycle_state;
+   fields[3] = TRB_TYPE(cmd) | SLOT_ID_FOR_TRB(slot_id) |
+   ctrl->cmd_ring->cycle_state;
+
+   /*
+* Only 'reset endpoint', 'stop endpoint' and 'set TR dequeue pointer'
+* commands need endpoint id encoded.
+*/
+   if (cmd >= TRB_RESET_EP && cmd <= TRB_SET_DEQ)
+   fields[3] |= EP_ID_FOR_TRB(ep_index);
 
queue_trb(ctrl, ctrl->cmd_ring, false, fields);
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 03/18] usb: xhci: Initialize scratchpad buffer array and scratchpad buffers

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci-mem.c | 87 +
 drivers/usb/host/xhci.h | 10 --
 2 files changed, 95 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 62db51d..12e277a 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -96,6 +96,25 @@ static void xhci_ring_free(struct xhci_ring *ring)
 }
 
 /**
+ * Free the scratchpad buffer array and scratchpad buffers
+ *
+ * @ctrl   host controller data structure
+ * @return none
+ */
+static void xhci_scratchpad_free(struct xhci_ctrl *ctrl)
+{
+   if (!ctrl->scratchpad)
+   return;
+
+   ctrl->dcbaa->dev_context_ptrs[0] = 0;
+
+   free((void *)(uintptr_t)ctrl->scratchpad->sp_array[0]);
+   free(ctrl->scratchpad->sp_array);
+   free(ctrl->scratchpad);
+   ctrl->scratchpad = NULL;
+}
+
+/**
  * frees the "xhci_container_ctx" pointer passed
  *
  * @param ptr  pointer to "xhci_container_ctx" to be freed
@@ -155,6 +174,7 @@ void xhci_cleanup(struct xhci_ctrl *ctrl)
 {
xhci_ring_free(ctrl->event_ring);
xhci_ring_free(ctrl->cmd_ring);
+   xhci_scratchpad_free(ctrl);
xhci_free_virt_devices(ctrl);
free(ctrl->erst.entries);
free(ctrl->dcbaa);
@@ -320,6 +340,70 @@ struct xhci_ring *xhci_ring_alloc(unsigned int num_segs, 
bool link_trbs)
 }
 
 /**
+ * Set up the scratchpad buffer array and scratchpad buffers
+ *
+ * @ctrl   host controller data structure
+ * @return -ENOMEM if buffer allocation fails, 0 on success
+ */
+static int xhci_scratchpad_alloc(struct xhci_ctrl *ctrl)
+{
+   struct xhci_hccr *hccr = ctrl->hccr;
+   struct xhci_hcor *hcor = ctrl->hcor;
+   struct xhci_scratchpad *scratchpad;
+   int num_sp;
+   uint32_t page_size;
+   void *buf;
+   int i;
+
+   num_sp = HCS_MAX_SCRATCHPAD(xhci_readl(>cr_hcsparams2));
+   if (!num_sp)
+   return 0;
+
+   scratchpad = malloc(sizeof(*scratchpad));
+   if (!scratchpad)
+   goto fail_sp;
+   ctrl->scratchpad = scratchpad;
+
+   scratchpad->sp_array = xhci_malloc(num_sp * sizeof(u64));
+   if (!scratchpad->sp_array)
+   goto fail_sp2;
+   ctrl->dcbaa->dev_context_ptrs[0] =
+   cpu_to_le64((uintptr_t)scratchpad->sp_array);
+
+   page_size = xhci_readl(>or_pagesize) & 0x;
+   for (i = 0; i < 16; i++) {
+   if ((0x1 & page_size) != 0)
+   break;
+   page_size = page_size >> 1;
+   }
+   BUG_ON(i == 16);
+
+   page_size = 1 << (i + 12);
+   buf = memalign(page_size, num_sp * page_size);
+   if (!buf)
+   goto fail_sp3;
+   memset(buf, '\0', num_sp * page_size);
+   xhci_flush_cache((uintptr_t)buf, num_sp * page_size);
+
+   for (i = 0; i < num_sp; i++) {
+   uintptr_t ptr = (uintptr_t)buf + i * page_size;
+   scratchpad->sp_array[i] = cpu_to_le64(ptr);
+   }
+
+   return 0;
+
+fail_sp3:
+   free(scratchpad->sp_array);
+
+fail_sp2:
+   free(scratchpad);
+   ctrl->scratchpad = NULL;
+
+fail_sp:
+   return -ENOMEM;
+}
+
+/**
  * Allocates the Container context
  *
  * @param ctrl Host controller data structure
@@ -499,6 +583,9 @@ int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr 
*hccr,
 
xhci_writeq(>ir_set->erst_base, val_64);
 
+   /* set up the scratchpad buffer array and scratchpad buffers */
+   xhci_scratchpad_alloc(ctrl);
+
/* initializing the virtual devices to NULL */
for (i = 0; i < MAX_HC_SLOTS; ++i)
ctrl->devs[i] = NULL;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 431afd8..32dd611 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -111,9 +111,10 @@ struct xhci_hccr {
 #define HCS_IST(p) (((p) >> 0) & 0xf)
 /* bits 4:7, max number of Event Ring segments */
 #define HCS_ERST_MAX(p)(((p) >> 4) & 0xf)
+/* bits 21:25 Hi 5 bits of Scratchpad buffers SW must allocate for the HW */
 /* bit 26 Scratchpad restore - for save/restore HW state - not used yet */
-/* 

[U-Boot] [PATCH v4 01/18] usb: xhci: Remove incorrect comments for struct xhci_container_ctx

2017-07-19 Thread Bin Meng
There is no member called 'dma' in struct xhci_container_ctx. Remove
the comments that mentions it.

Signed-off-by: Bin Meng 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 2afa386..431afd8 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -482,10 +482,9 @@ struct xhci_protocol_caps {
  * @type: Type of context.  Used to calculated offsets to contained contexts.
  * @size: Size of the context data
  * @bytes: The raw context data given to HW
- * @dma: dma address of the bytes
  *
  * Represents either a Device or Input context.  Holds a pointer to the raw
- * memory used for the context (bytes) and dma address of it (dma).
+ * memory used for the context (bytes).
  */
 struct xhci_container_ctx {
unsigned type;
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 04/18] usb: xhci: Add input slot context in xhci_set_configuration()

2017-07-19 Thread Bin Meng
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 
Reviewed-by: Simon Glass 
Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index bd8f4c4..95a0fba 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -332,8 +332,8 @@ static int xhci_set_configuration(struct usb_device *udev)
ifdesc = >config.if_desc[0];
 
ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
-   /* Zero the input context control */
-   ctrl_ctx->add_flags = 0;
+   /* Initialize the input context control */
+   ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG);
ctrl_ctx->drop_flags = 0;
 
/* EP_FLAG gives values 1 & 4 for EP1OUT and EP2IN */
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 00/18] usb: xhci: Fix USB xHCI support on Intel platform

2017-07-19 Thread Bin Meng
Currently U-Boot xHCI driver does not work on Intel BayTrail SoC based
boards that have USB 3.0 ports. Trying to do a 'usb start' simply hangs
the board. This series fixes a bunch of xHCI driver issues to make it
work on Intel's platform.

Issues identified in the U-Boot xHCI driver are really spec violations,
but apparently other xHCI IPs found on ARM SoCs (mainly Synopsis IP?)
are quite tolerant with these spec violations, or IOW those IPs don't
respect the xHCI spec. While it comes to Intel platform, it just breaks.

Note xHCI interrupt transfer is still not supported in this series, as
it has been there since the original commit of xHCI support for years.

Tested on Intel MinnowMax board with the following USB devices:
- Dell USB 1.1 keyboard
- Dell USB 1.1 mouse
- Netac USB 2.0 flash disk
- JetFlash USB 3.0 flash disk
- GenesysLogic 4-port USB 3.0 hub, with an integrated Realtek USB
  ethernet chipset connected to one of its downstream port

Testing were performed on both ports (2.0 port and 3.0 port), and both
ports are connected to xHCI (configure MinnowMax to enable xHCI).

Testing results:
- DELL USB 1.1 keyboard and mouse can be enumerated on both ports
- USB 2.0 and 3.0 flash disks work fine (enumerated, read/write) on
  both ports
- GenesysLogic USB 3.0 hub can be enumerated on 2.0 port as a 2.0
  hub, and the integrated Realtek USB ethernet chipset enumerated as
  well. USB 2.0 and 3.0 flash disks connected via the hub can be
  enumerated, but DELL USB 1.1 keyboard and mouse cannot.
- GenesysLogic USB 3.0 hub can be enumerated on 3.0 port as a 3.0 hub,
  but the integrated Realtek USB ethernet chipset cannot be enumerated.
  None of devices connected via the hub can be enumerated. U-Boot xHCI
  driver just throws BUG_ON() on the event TRB handling.

This indicates that USB 3.0 hub support in U-Boot is seriously broken.
So far this series tries to fix some of the issues identified, but the
USB 3.0 hub is still not working. This will be left as future work.

The USB 3.0 hub work includes: port status translation, USB 3.0 newly
added "Set Hub Depth" request support, xHCI codes update to fill in
hub description fields in the input slot context when issuing commands
to xHC, etc.

This series is available at u-boot-x86/xhci-working for testing.

Changes in v4:
- remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in poplar.h
- Rebase on u-boot-usb/master

Changes in v3:
- Rebase on u-boot/master

Changes in v2:
- Change to use uint and also 'normal' variable name packet_size.
- Update description to use "PCI-based"
- Remove CONFIG_USB_XHCI_PCI from config_whitelist.txt
- Drop two x86 patches that were already applied to u-boot-x86

Bin Meng (18):
  usb: xhci: Remove incorrect comments for struct xhci_container_ctx
  usb: xhci: Correct command TRB 4th dword initialization
  usb: xhci: Initialize scratchpad buffer array and scratchpad buffers
  usb: xhci: Add input slot context in xhci_set_configuration()
  usb: hub: Update handling connect status/change in usb_scan_port()
  usb: hub: Send correct wValue to get hub descriptor of a USB 3.0 hub
  usb: hub: Revise wLength for 'get port status' request
  usb: hub: Change USB hub descriptor to match USB 3.0 hubs
  usb: hub: Add 3.0 hub port status mask of 2.0 hub
  usb: xhci: Change MAX_HC_PORTS to 255
  usb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS
  configs: Remove CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS in all boards
  usb: ehci: Get rid of CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS
  configs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards
  usb: cmd: Print actual packet size for super speed devices
  usb: xhci: Convert CONFIG_USB_XHCI_PCI to Kconfig
  x86: minnowmax: Add a environment variable for USB power-on delay
  x86: minnowmax: Enable USB xHCI support

 arch/arm/include/asm/ehci-omap.h |  4 --
 arch/x86/dts/minnowmax.dts   |  3 ++
 cmd/usb.c|  7 ++-
 common/usb_hub.c | 41 +++--
 configs/minnowmax_defconfig  |  1 +
 drivers/usb/emul/sandbox_hub.c   |  7 ++-
 drivers/usb/host/Kconfig |  6 +++
 drivers/usb/host/ehci-hcd.c  | 14 +++---
 drivers/usb/host/ehci.h  |  7 ++-
 drivers/usb/host/xhci-mem.c  | 87 
 drivers/usb/host/xhci-ring.c | 11 -
 drivers/usb/host/xhci.c  | 17 ---
 drivers/usb/host/xhci.h  | 23 +-
 include/configs/MPC8572DS.h  |  1 -
 include/configs/am43xx_evm.h |  1 -
 include/configs/am57xx_evm.h |  1 -
 include/configs/cl-som-am57x.h   |  1 -
 include/configs/cm_t43.h |  1 -
 include/configs/cm_t54.h |  1 -
 include/configs/corvus.h |  3 --
 include/configs/dra7xx_evm.h |  1 -
 include/configs/ds414.h  |  1 -
 include/configs/duovero.h|  2 -
 include/configs/exynos5-common.h |  3 --
 include/configs/ls1012afrdm.h|  1 -
 

Re: [U-Boot] [PATCH 1/1] common: Move CONFIG_BOOTARGS to Kconfig

2017-07-19 Thread Sam Protsenko
On 18 July 2017 at 22:43, Tom Rini  wrote:
> On Mon, Jul 17, 2017 at 04:44:55PM +0300, Sam Protsenko wrote:
>
>> Also introduce CONFIG_USE_BOOTARGS option so we can control if
>> CONFIG_BOOTARGS defined at all.
>>
>> Signed-off-by: Sam Protsenko 
> [snip]
>> +config USE_BOOTARGS
>> + bool "Enable boot arguments"
>> + default n
>
> n is default, we don't need this.
>

Noted. Will fix it in PATCH v2.

> [snip]
>> diff --git a/configs/P1020MBG-PC_36BIT_SDCARD_defconfig 
>> b/configs/P1020MBG-PC_36BIT_SDCARD_defconfig
>> index e297a0da5b..88a795b42e 100644
>> --- a/configs/P1020MBG-PC_36BIT_SDCARD_defconfig
>> +++ b/configs/P1020MBG-PC_36BIT_SDCARD_defconfig
>> @@ -13,6 +13,7 @@ CONFIG_OF_BOARD_SETUP=y
>>  CONFIG_OF_STDOUT_VIA_ALIAS=y
>>  CONFIG_SYS_EXTRA_OPTIONS="SDCARD"
>>  CONFIG_BOOTDELAY=10
>> +CONFIG_USE_BOOTARGS=y
>>  CONFIG_BOARD_EARLY_INIT_F=y
>>  CONFIG_SPL=y
>>  CONFIG_SPL_ENV_SUPPORT=y
>
> This is the first of a number of examples where USE_BOOTARGS is set to y
> but there's no BOOTARGS set.  That doesn't make sense.
>

By doing this I tried to achieve exactly the same behavior like it was
done before this patch. I.e. having empty "bootargs=" variable defined
in the environment (just so buildman doesn't bark a lot). I can remove
those lines, if you like.


> Looking at it a
> bit more in detail, the conversion didn't happen right in cases where we
> have:
> #define CONFIG_BOOTARGS SOME_OTHER_DEFINE.
>

Why exactly? Can you show some corresponding example?

> That may become tricky.  I'm going to post a horrible hack to help,
> shortly.
>

Please link it here when it's done. Also I'd like to hear some details
about it (what is not right and how to use your hack to overcome it).

Thanks.

> --
> Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Pull request: u-boot-mips

2017-07-19 Thread Tom Rini
On Wed, Jul 19, 2017 at 01:59:16PM +0100, Paul Burton wrote:
> Hi Tom,
> 
> On Tuesday, 18 July 2017 02:07:59 BST Tom Rini wrote:
> > On Thu, Jul 13, 2017 at 10:58:47AM -0700, Paul Burton wrote:
> > > Hi Daniel & Tom,
> > > 
> > > On Thursday, 13 July 2017 03:51:00 PDT Daniel Schwierzeck wrote:
> > > > Hi Paul,
> > > > 
> > > > 2017-07-13 2:33 GMT+02:00 Tom Rini :
> > > > > On Wed, Jul 12, 2017 at 04:57:42PM -0400, Tom Rini wrote:
> > > > >> On Wed, Jul 12, 2017 at 10:32:29PM +0200, Daniel Schwierzeck wrote:
> > > > >> > Hi Tom,
> > > > >> > 
> > > > >> > This supports dynamic relocation on MIPS without the need for
> > > > >> > building
> > > > >> > a
> > > > >> > position-independent executable. This notably reduces the code size
> > > > >> > for
> > > > >> > all MIPS boards.
> > > > >> > 
> > > > >> > The following changes since commit
> > > 
> > > d85ca029f257b53a96da6c2fb421e78a003a9943:
> > > > >> >   Prepare v2017.07 (2017-07-10 13:07:38 -0400)
> > > > >> > 
> > > > >> > are available in the git repository at:
> > > > >> >   git://git.denx.de/u-boot-mips.git master
> > > > >> > 
> > > > >> > for you to fetch changes up to
> > > 
> > > f653dcd5720c4135607211f7304283d7a8ec3b8a:
> > > > >> >   MIPS: bootm: Fix broken boot_env_legacy codepath (2017-07-12
> > > > >> >   22:10:42
> > > > >> >   +0200)>>
> > > > >> 
> > > > >> I'm seeing:
> > > > >>   mips:  +   tplink_wdr4300
> > > > >> 
> > > > >> +(tplink_wdr4300)pfx##hdr32[idx].field = _val;   \
> > > > >> +(tplink_wdr4300)  ^
> > > > >> +(tplink_wdr4300) ../tools/mips-relocs.c:51:11: note: ?_val? was
> > > > >> declared
> > > > >> here +(tplink_wdr4300)   uint64_t _val;  \
> > > > >> +(tplink_wdr4300)^
> > > > >> +(tplink_wdr4300) ../tools/mips-relocs.c:88:2: note: in expansion of
> > > > >> macro ?set_hdr_field? +(tplink_wdr4300)   set_hdr_field(p, idx,
> > > > >> field,
> > > > >> val)
> > > > >> +(tplink_wdr4300)   ^
> > > > >> +(tplink_wdr4300) ../tools/mips-relocs.c:408:3: note: in expansion of
> > > > >> macro ?set_phdr_field? +(tplink_wdr4300)set_phdr_field(i,
> > > > >> p_filesz,
> > > > >> load_sz);
> > > > >> +(tplink_wdr4300)^~
> > > > >> w+(tplink_wdr4300) ../tools/mips-relocs.c: In function ?main?:
> > > > >> w+(tplink_wdr4300) ../tools/mips-relocs.c:77:25: warning: ?_val? may
> > > > >> be
> > > > >> used uninitialized in this function [-Wmaybe-uninitialized]
> > > > >> 
> > > > >> for what I suspect is going to be all MIPS.  Host tools here are
> > > > >> gcc-6.3.
> > > > > 
> > > > > Yeah, this is all MIPS boards.  Please fix, thanks!
> > > > 
> > > > Paul, could you send a follow-up patch to fix this? Thanks.
> > > 
> > > Sure. I'm on gcc 7.1.1 which doesn't show this issue. Is the following
> > > sufficient to fix this for you Tom? I can submit it as a proper patch if
> > > you like & it works out.
> > 
> > Oh?  That it doesn't show up with a newer compiler is interesting...
> 
> Yeah, I imagine gcc got smarter at recognising that the path it was 
> complaining about is never actually taken.
> 
> > > Thanks,
> > > 
> > > Paul
> > > 
> > > diff --git a/tools/mips-relocs.c b/tools/mips-relocs.c
> > > index b690fa53c4..75d532546b 100644
> > > --- a/tools/mips-relocs.c
> > > +++ b/tools/mips-relocs.c
> > > @@ -69,6 +69,9 @@
> > > 
> > > case 8: \
> > > 
> > > _val = is_be ? htobe64(val) : htole64(val); \
> > > break;  \
> > > 
> > > +   default:\
> > > +   __builtin_unreachable();\
> > > +   break;  \
> > > 
> > > }   \
> > 
> > I'm not a huge fan of adding builtin calls like this.  Is there some
> > other way to restructure the code perhaps, while still being clear?
> > Thanks!
> 
> An alternative would be to assign _val = 0 to silence the warning, and 
> probably call abort() or assert(0) or something similar in that path. Would 
> that be preferrable to you?

Yeah, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Pull request: u-boot-mips

2017-07-19 Thread Paul Burton
Hi Tom,

On Tuesday, 18 July 2017 02:07:59 BST Tom Rini wrote:
> On Thu, Jul 13, 2017 at 10:58:47AM -0700, Paul Burton wrote:
> > Hi Daniel & Tom,
> > 
> > On Thursday, 13 July 2017 03:51:00 PDT Daniel Schwierzeck wrote:
> > > Hi Paul,
> > > 
> > > 2017-07-13 2:33 GMT+02:00 Tom Rini :
> > > > On Wed, Jul 12, 2017 at 04:57:42PM -0400, Tom Rini wrote:
> > > >> On Wed, Jul 12, 2017 at 10:32:29PM +0200, Daniel Schwierzeck wrote:
> > > >> > Hi Tom,
> > > >> > 
> > > >> > This supports dynamic relocation on MIPS without the need for
> > > >> > building
> > > >> > a
> > > >> > position-independent executable. This notably reduces the code size
> > > >> > for
> > > >> > all MIPS boards.
> > > >> > 
> > > >> > The following changes since commit
> > 
> > d85ca029f257b53a96da6c2fb421e78a003a9943:
> > > >> >   Prepare v2017.07 (2017-07-10 13:07:38 -0400)
> > > >> > 
> > > >> > are available in the git repository at:
> > > >> >   git://git.denx.de/u-boot-mips.git master
> > > >> > 
> > > >> > for you to fetch changes up to
> > 
> > f653dcd5720c4135607211f7304283d7a8ec3b8a:
> > > >> >   MIPS: bootm: Fix broken boot_env_legacy codepath (2017-07-12
> > > >> >   22:10:42
> > > >> >   +0200)>>
> > > >> 
> > > >> I'm seeing:
> > > >>   mips:  +   tplink_wdr4300
> > > >> 
> > > >> +(tplink_wdr4300)pfx##hdr32[idx].field = _val;   \
> > > >> +(tplink_wdr4300)  ^
> > > >> +(tplink_wdr4300) ../tools/mips-relocs.c:51:11: note: ?_val? was
> > > >> declared
> > > >> here +(tplink_wdr4300)   uint64_t _val;  \
> > > >> +(tplink_wdr4300)^
> > > >> +(tplink_wdr4300) ../tools/mips-relocs.c:88:2: note: in expansion of
> > > >> macro ?set_hdr_field? +(tplink_wdr4300)   set_hdr_field(p, idx,
> > > >> field,
> > > >> val)
> > > >> +(tplink_wdr4300)   ^
> > > >> +(tplink_wdr4300) ../tools/mips-relocs.c:408:3: note: in expansion of
> > > >> macro ?set_phdr_field? +(tplink_wdr4300)set_phdr_field(i,
> > > >> p_filesz,
> > > >> load_sz);
> > > >> +(tplink_wdr4300)^~
> > > >> w+(tplink_wdr4300) ../tools/mips-relocs.c: In function ?main?:
> > > >> w+(tplink_wdr4300) ../tools/mips-relocs.c:77:25: warning: ?_val? may
> > > >> be
> > > >> used uninitialized in this function [-Wmaybe-uninitialized]
> > > >> 
> > > >> for what I suspect is going to be all MIPS.  Host tools here are
> > > >> gcc-6.3.
> > > > 
> > > > Yeah, this is all MIPS boards.  Please fix, thanks!
> > > 
> > > Paul, could you send a follow-up patch to fix this? Thanks.
> > 
> > Sure. I'm on gcc 7.1.1 which doesn't show this issue. Is the following
> > sufficient to fix this for you Tom? I can submit it as a proper patch if
> > you like & it works out.
> 
> Oh?  That it doesn't show up with a newer compiler is interesting...

Yeah, I imagine gcc got smarter at recognising that the path it was 
complaining about is never actually taken.

> > Thanks,
> > 
> > Paul
> > 
> > diff --git a/tools/mips-relocs.c b/tools/mips-relocs.c
> > index b690fa53c4..75d532546b 100644
> > --- a/tools/mips-relocs.c
> > +++ b/tools/mips-relocs.c
> > @@ -69,6 +69,9 @@
> > 
> > case 8: \
> > 
> > _val = is_be ? htobe64(val) : htole64(val); \
> > break;  \
> > 
> > +   default:\
> > +   __builtin_unreachable();\
> > +   break;  \
> > 
> > }   \
> 
> I'm not a huge fan of adding builtin calls like this.  Is there some
> other way to restructure the code perhaps, while still being clear?
> Thanks!

An alternative would be to assign _val = 0 to silence the warning, and 
probably call abort() or assert(0) or something similar in that path. Would 
that be preferrable to you?

Thanks,
Paul

signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/4] power: pwm_regulator: fix the pwm_set_config parameter order

2017-07-19 Thread Philipp Tomsich
> The rkpwm reg order has fixed by below patch:
> e3ef41d rockchip: pwm: fix the register layout for the PWM controller
> 
> We need to correct the parameter order for pwm_set_config() to make
> the pwm regulator works correctly.
> 
> Signed-off-by: Kever Yang 
> ---
> 
>  drivers/power/regulator/pwm_regulator.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Acked-by: Philipp Tomsich 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/2] rockchip: dts: rk3399-puma: put EFI partition entries at 2MB

2017-07-19 Thread Philipp Tomsich
> When creating a EFI/GUID partition map for the RK3399-Q7 through
> U-Boot, the partition entries should be places at a 1MB offset from
> the start of the device to give us space for the environment (at 16KB
> on SD/MMC devices), the SPL stage (at 32KB on SD/MMC devices) and the
> image payload (at 256KB on SD/MMC devices).
> 
> This change sets this up through the u-boot,efi-partition-entries-offset
> /config property in the RK3399-Q7 DTSI.
> 
> Signed-off-by: Philipp Tomsich 
> ---
> 
>  arch/arm/dts/rk3399-puma.dtsi | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Philipp Tomsich 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 3/4] power: pwm_regulator: remove redundance code

2017-07-19 Thread Philipp Tomsich
> The regulator_enable() should be called from upper layer like
> regulators_enable_boot_on(), remove it from pwm regulator driver.
> 
> Signed-off-by: Kever Yang 
> ---
> 
>  drivers/power/regulator/pwm_regulator.c | 8 +---
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 

Acked-by: Philipp Tomsich 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 4/4] rockchip: pwm: add mask for config setting

2017-07-19 Thread Philipp Tomsich
> Use mask to clear old setting before direct set the new config,
> or else there it will mess up the config when it's not the same
> with default value.
> Fixs: 3851059 rockchip: Setup default PWM flags
> 
> Signed-off-by: Kever Yang 
> ---
> 
>  arch/arm/include/asm/arch-rockchip/pwm.h | 2 ++
>  drivers/pwm/rk_pwm.c | 1 +
>  2 files changed, 3 insertions(+)
> 

Acked-by: Philipp Tomsich 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/2] rockchip: dts: rk3399-puma: put environment (in MMC/SD configurations) before SPL

2017-07-19 Thread Philipp Tomsich
> As our SPL stage can grow quite large (80KB+ are not unusual) on the
> RK3399-Q7, the default setting for the environment location (in
> include/configs/rockchip-common.h) can overlap our SPL.
> 
> This change finally makes use of the 'u-boot,mmc-env-offset' DTS
> property to override the environment location and put it at 16KB into
> the device, which is right before the SPL (located at 32KB).
> 
> Signed-off-by: Philipp Tomsich 
> ---
> 
>  arch/arm/dts/rk3399-puma.dtsi | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

Acked-by: Philipp Tomsich 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/4] rockchip: dts: correct vdd_log setting for firefly-rk3399

2017-07-19 Thread Philipp Tomsich
> Add regulator-init-microvolt for driver to init the regulator,
> and the min output value is not 80mV for the PWM2 io domain has
> changed to VCC3V0 instead of VCC1V8 in rockchip evb, we need to
> correct it with the value measured when PWM2 output HIGH.
> 
> Signed-off-by: Kever Yang 
> ---
> 
>  arch/arm/dts/rk3399-firefly.dts | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

Acked-by: Philipp Tomsich 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/2] rockchip: dts: rk3399-puma: put EFI partition entries at 2MB

2017-07-19 Thread Philipp Tomsich
When creating a EFI/GUID partition map for the RK3399-Q7 through
U-Boot, the partition entries should be places at a 1MB offset from
the start of the device to give us space for the environment (at 16KB
on SD/MMC devices), the SPL stage (at 32KB on SD/MMC devices) and the
image payload (at 256KB on SD/MMC devices).

This change sets this up through the u-boot,efi-partition-entries-offset
/config property in the RK3399-Q7 DTSI.

Signed-off-by: Philipp Tomsich 
---

 arch/arm/dts/rk3399-puma.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi
index 0491886..dd1baea 100644
--- a/arch/arm/dts/rk3399-puma.dtsi
+++ b/arch/arm/dts/rk3399-puma.dtsi
@@ -14,6 +14,7 @@
config {
u-boot,spl-payload-offset = <0x4>; /* @ 256KB */
u-boot,mmc-env-offset = <0x4000>;  /* @  16KB */
+   u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */
u-boot,boot-led = "module_led";
};
 
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   >