[U-Boot] [PATCH 4/4] powerpc/t2080qds: enable eSDHC peripheral clock support for kernel
Enable eSDHC peripheral clock support for kernel, and linux will use SD clock generated by peripheral clock instead of platform clock. Signed-off-by: Yangbo Lu Cc: York Sun --- include/configs/T208xQDS.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h index 8d6918a..ea8f89a 100644 --- a/include/configs/T208xQDS.h +++ b/include/configs/T208xQDS.h @@ -757,6 +757,7 @@ unsigned long get_board_ddr_clk(void); #ifdef CONFIG_MMC #define CONFIG_CMD_MMC #define CONFIG_FSL_ESDHC +#define define CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK #define CONFIG_SYS_FSL_ESDHC_ADDR CONFIG_SYS_MPC85xx_ESDHC_ADDR #define CONFIG_SYS_FSL_ESDHC_BROKEN_TIMEOUT #define CONFIG_SYS_FSL_MMC_HAS_CAPBLT_VS33 -- 2.1.0.27.g96db324 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/4] powerpc/t2080qds: enable eSDHC adapter card type identification
Enable eSDHC adapter card type identification and this will do some corresponding operations and set 'adapter-type' property for device tree according SDHC Card ID. Signed-off-by: Yangbo Lu Cc: York Sun --- include/configs/T208xQDS.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h index ff6d2c1..8d6918a 100644 --- a/include/configs/T208xQDS.h +++ b/include/configs/T208xQDS.h @@ -764,6 +764,7 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT #define CONFIG_DOS_PARTITION +#define CONFIG_FSL_ESDHC_ADAPTER_IDENT #endif -- 2.1.0.27.g96db324 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 3/4] mmc: fsl_esdhc: Add peripheral clock support for kernel
The SD clock could be generated by platform clock or peripheral clock for some platforms. This patch adds peripheral clock support for kernel for T1024/T1040/T2080. To enable it, define CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK. Signed-off-by: Yangbo Lu Cc: York Sun --- arch/powerpc/cpu/mpc85xx/speed.c | 49 ++- arch/powerpc/include/asm/config_mpc85xx.h | 10 +-- drivers/mmc/fsl_esdhc.c | 5 include/e500.h| 1 + 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/speed.c b/arch/powerpc/cpu/mpc85xx/speed.c index 7e69873..79202bb 100644 --- a/arch/powerpc/cpu/mpc85xx/speed.c +++ b/arch/powerpc/cpu/mpc85xx/speed.c @@ -69,7 +69,8 @@ void get_sys_info(sys_info_t *sys_info) [14] = 4, /* CC4 PPL / 4 */ }; uint i, freq_c_pll[CONFIG_SYS_FSL_NUM_CC_PLLS]; -#if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) +#if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) || \ + defined(CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK) uint rcw_tmp; #endif uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS]; @@ -313,6 +314,48 @@ void get_sys_info(sys_info_t *sys_info) #endif #endif +#ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK +#if defined(CONFIG_PPC_T2080) +#define ESDHC_CLK_SEL 0x0007 +#define ESDHC_CLK_SHIFT0 +#define ESDHC_CLK_RCWSR15 +#else /* Support T1040 T1024 by now */ +#define ESDHC_CLK_SEL 0xe000 +#define ESDHC_CLK_SHIFT29 +#define ESDHC_CLK_RCWSR7 +#endif + rcw_tmp = in_be32(&gur->rcwsr[ESDHC_CLK_RCWSR]); + switch ((rcw_tmp & ESDHC_CLK_SEL) >> ESDHC_CLK_SHIFT) { + case 1: + sys_info->freq_sdhc = freq_c_pll[CONFIG_SYS_SDHC_CLK]; + break; + case 2: + sys_info->freq_sdhc = freq_c_pll[CONFIG_SYS_SDHC_CLK] / 2; + break; + case 3: + sys_info->freq_sdhc = freq_c_pll[CONFIG_SYS_SDHC_CLK] / 3; + break; +#if defined(CONFIG_SYS_SDHC_CLK_2_PLL) + case 4: + sys_info->freq_sdhc = freq_c_pll[CONFIG_SYS_SDHC_CLK] / 4; + break; +#if defined(CONFIG_PPC_T2080) + case 5: + sys_info->freq_sdhc = freq_c_pll[1 - CONFIG_SYS_SDHC_CLK]; + break; +#endif + case 6: + sys_info->freq_sdhc = freq_c_pll[1 - CONFIG_SYS_SDHC_CLK] / 2; + break; + case 7: + sys_info->freq_sdhc = freq_c_pll[1 - CONFIG_SYS_SDHC_CLK] / 3; + break; +#endif + default: + sys_info->freq_sdhc = 0; + printf("Error: Unknown SDHC peripheral clock select!\n"); + } +#endif #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { @@ -520,12 +563,16 @@ int get_clocks (void) gd->arch.i2c2_clk = gd->arch.i2c1_clk; #if defined(CONFIG_FSL_ESDHC) +#ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK + gd->arch.sdhc_clk = sys_info.freq_sdhc / 2; +#else #if defined(CONFIG_MPC8569) || defined(CONFIG_P1010) ||\ defined(CONFIG_P1014) gd->arch.sdhc_clk = gd->bus_clk; #else gd->arch.sdhc_clk = gd->bus_clk / 2; #endif +#endif #endif /* defined(CONFIG_FSL_ESDHC) */ #if defined(CONFIG_CPM2) diff --git a/arch/powerpc/include/asm/config_mpc85xx.h b/arch/powerpc/include/asm/config_mpc85xx.h index 01b0905..24c593b 100644 --- a/arch/powerpc/include/asm/config_mpc85xx.h +++ b/arch/powerpc/include/asm/config_mpc85xx.h @@ -757,7 +757,6 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022) #endif #define CONFIG_SYS_FSL_NUM_CC_PLLS 2 #define CONFIG_SYS_FSL_CLUSTER_CLOCKS { 1, 1, 1, 1 } -#define CONFIG_SYS_SDHC_CLOCK 0 #define CONFIG_SYS_FSL_NUM_LAWS16 #define CONFIG_SYS_FSL_SRDS_1 #define CONFIG_SYS_FSL_SEC_COMPAT 5 @@ -773,6 +772,9 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022) #define CONFIG_SYS_FMAN_V3 #define CONFIG_FM_PLAT_CLK_DIV 1 #define CONFIG_SYS_FM1_CLK CONFIG_FM_PLAT_CLK_DIV +#define CONFIG_SYS_SDHC_CLK0/* Select SDHC CLK begining from PLL1 + per rcw field value */ +#define CONFIG_SYS_SDHC_CLK_2_PLL /* Select SDHC CLK from 2 PLLs */ #define CONFIG_SYS_FM_MURAM_SIZE 0x3 #define CONFIG_SYS_FSL_SINGLE_SOURCE_CLK #define CONFIG_SYS_FSL_TBCLK_DIV 16 @@ -805,7 +807,6 @@ defined(CONFIG_PPC_T1014) || defined(CONFIG_PPC_T1013) #endif #define CONFIG_SYS_FSL_NUM_CC_PLL 2 #define CONFIG_SYS_FSL_CLUSTER_CLOCKS { 1, 1, 1, 1 } -#define CONFIG_SYS_SDHC_CLOCK 0 #define CONFIG_SYS_FSL_NUM_LAWS16 #define CONFIG_SYS_FSL_SRDS_1 #define CONFIG_SYS_FSL_SEC_COMPAT 5 @@ -818,6 +819,8 @@ defined(CONFIG_PPC_T1014) || defined(CONFIG_PPC_T1013) #define CONFIG_SYS_FSL_DDR_VER FSL_DDR_VER_5_0 #define CONFIG_SYS_FSL_IFC
[U-Boot] [PATCH 1/4] mmc: fsl_esdhc: Add adapter card type identification support
Add adapter card type identification support by reading FPGA STAT_PRES1 register SDHC Card ID[0:2] bits. To use this function, define CONFIG_FSL_ESDHC_ADAPTER_IDENT. Signed-off-by: Yangbo Lu Cc: York Sun --- arch/powerpc/include/asm/global_data.h | 3 +++ board/freescale/common/qixis.h | 14 + drivers/mmc/fsl_esdhc.c| 38 +- drivers/mmc/mmc.c | 6 ++ drivers/mmc/mmc_private.h | 3 +++ include/fsl_esdhc.h| 4 6 files changed, 67 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/global_data.h b/arch/powerpc/include/asm/global_data.h index c57d9c0..4090975 100644 --- a/arch/powerpc/include/asm/global_data.h +++ b/arch/powerpc/include/asm/global_data.h @@ -15,6 +15,9 @@ struct arch_global_data { #if defined(CONFIG_FSL_ESDHC) u32 sdhc_clk; +#if defined(CONFIG_FSL_ESDHC_ADAPTER_IDENT) + u8 sdhc_adapter; +#endif #endif #if defined(CONFIG_8xx) unsigned long brg_clk; diff --git a/board/freescale/common/qixis.h b/board/freescale/common/qixis.h index 52d2021..51ce9c3 100644 --- a/board/freescale/common/qixis.h +++ b/board/freescale/common/qixis.h @@ -115,4 +115,18 @@ void qixis_write_i2c(unsigned int reg, u8 value); qixis_write_i2c(offsetof(struct qixis, reg), value) #endif +/* Use for SDHC adapter card type identification and operation */ +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT +#define QIXIS_SDID_MASK 0x07 +#define QIXIS_ESDHC_ADAPTER_TYPE_EMMC45 0x1/* eMMC Card Rev4.5 */ +#define QIXIS_ESDHC_ADAPTER_TYPE_SDMMC_LEGACY 0x2/* SD/MMC Legacy Card */ +#define QIXIS_ESDHC_ADAPTER_TYPE_EMMC44 0x3/* eMMC Card Rev4.4 */ +#define QIXIS_ESDHC_ADAPTER_TYPE_RSV0x4/* Reserved */ +#define QIXIS_ESDHC_ADAPTER_TYPE_MMC0x5/* MMC Card */ +#define QIXIS_ESDHC_ADAPTER_TYPE_SD 0x6/* SD Card Rev2.0 3.0 */ +#define QIXIS_ESDHC_NO_ADAPTER 0x7/* No Card is Present*/ +#define QIXIS_SDCLKIN 0x08 +#define QIXIS_SDCLKOUT 0x02 +#endif + #endif diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index f5d2ccb..355cada 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -643,6 +643,39 @@ int fsl_esdhc_mmc_init(bd_t *bis) return fsl_esdhc_initialize(bis, cfg); } +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT +void mmc_adapter_card_type_ident(void) +{ + u8 card_id; + u8 value; + + card_id = QIXIS_READ(present) & QIXIS_SDID_MASK; + gd->arch.sdhc_adapter = card_id; + + switch (card_id) { + case QIXIS_ESDHC_ADAPTER_TYPE_EMMC45: + break; + case QIXIS_ESDHC_ADAPTER_TYPE_SDMMC_LEGACY: + break; + case QIXIS_ESDHC_ADAPTER_TYPE_EMMC44: + value = QIXIS_READ(brdcfg[5]); + value |= (QIXIS_SDCLKIN | QIXIS_SDCLKOUT); + QIXIS_WRITE(brdcfg[5], value); + break; + case QIXIS_ESDHC_ADAPTER_TYPE_RSV: + break; + case QIXIS_ESDHC_ADAPTER_TYPE_MMC: + break; + case QIXIS_ESDHC_ADAPTER_TYPE_SD: + break; + case QIXIS_ESDHC_NO_ADAPTER: + break; + default: + break; + } +} +#endif + #ifdef CONFIG_OF_LIBFDT void fdt_fixup_esdhc(void *blob, bd_t *bd) { @@ -658,7 +691,10 @@ void fdt_fixup_esdhc(void *blob, bd_t *bd) do_fixup_by_compat_u32(blob, compat, "clock-frequency", gd->arch.sdhc_clk, 1); - +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT + do_fixup_by_compat_u32(blob, compat, "adapter-type", + (u32)(gd->arch.sdhc_adapter), 1); +#endif do_fixup_by_compat(blob, compat, "status", "okay", 4 + 1, 1); } diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index a13769e..dc32aec 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1588,6 +1588,9 @@ int mmc_start_init(struct mmc *mmc) if (mmc->has_init) return 0; +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT + mmc_adapter_card_type_ident(); +#endif board_mmc_power_init(); /* made sure it's not NULL earlier */ @@ -1739,6 +1742,9 @@ static void do_preinit(void) list_for_each(entry, &mmc_devices) { m = list_entry(entry, struct mmc, link); +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT + mmc_set_preinit(m, 1); +#endif if (m->preinit) mmc_start_init(m); } diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h index 16dcf9f..447a700 100644 --- a/drivers/mmc/mmc_private.h +++ b/drivers/mmc/mmc_private.h @@ -16,6 +16,9 @@ extern int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data); extern int mmc_send_status(struct mmc *mmc, int timeout); ext
[U-Boot] [PATCH v2 1/2] ARM: tegra: get rid of colibri_t20-common
As a preparatory step to renaming the board folder as well first get rid of the colibri_t20-common after having integrated it into colibri_t20_iris for now. While at it also migrate to using NVIDIA's common.mk magic. Signed-off-by: Marcel Ziswiler --- .../colibri_t20-common/colibri_t20-common.c| 35 -- .../colibri_t20-common/colibri_t20-common.h| 7 board/toradex/colibri_t20_iris/Makefile| 4 +-- board/toradex/colibri_t20_iris/colibri_t20_iris.c | 42 +++--- 4 files changed, 31 insertions(+), 57 deletions(-) delete mode 100644 board/toradex/colibri_t20-common/colibri_t20-common.c delete mode 100644 board/toradex/colibri_t20-common/colibri_t20-common.h diff --git a/board/toradex/colibri_t20-common/colibri_t20-common.c b/board/toradex/colibri_t20-common/colibri_t20-common.c deleted file mode 100644 index 58a9916..000 --- a/board/toradex/colibri_t20-common/colibri_t20-common.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2012 Lucas Stach - * - * SPDX-License-Identifier:GPL-2.0+ - */ - -#include -#include -#include -#include -#include - -#include "colibri_t20-common.h" - -#ifdef CONFIG_USB_EHCI_TEGRA -void colibri_t20_common_pin_mux_usb(void) -{ - /* module internal USB bus to connect ethernet chipset */ - funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI); - /* ULPI reference clock output */ - pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4); - pinmux_tristate_disable(PMUX_PINGRP_CDEV2); - /* PHY reset GPIO */ - pinmux_tristate_disable(PMUX_PINGRP_UAC); - /* VBus GPIO */ - pinmux_tristate_disable(PMUX_PINGRP_DTE); -} -#endif - -#ifdef CONFIG_TEGRA_NAND -void pin_mux_nand(void) -{ - funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT); -} -#endif diff --git a/board/toradex/colibri_t20-common/colibri_t20-common.h b/board/toradex/colibri_t20-common/colibri_t20-common.h deleted file mode 100644 index 1fe53f6..000 --- a/board/toradex/colibri_t20-common/colibri_t20-common.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright (C) 2012 Lucas Stach - * - * SPDX-License-Identifier:GPL-2.0+ - */ - -void colibri_t20_common_pin_mux_usb(void); diff --git a/board/toradex/colibri_t20_iris/Makefile b/board/toradex/colibri_t20_iris/Makefile index ebeac70..f286aec 100644 --- a/board/toradex/colibri_t20_iris/Makefile +++ b/board/toradex/colibri_t20_iris/Makefile @@ -4,6 +4,6 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y := ../../nvidia/common/board.o -obj-y += ../colibri_t20-common/colibri_t20-common.o +include $(srctree)/board/nvidia/common/common.mk + obj-y += colibri_t20_iris.o diff --git a/board/toradex/colibri_t20_iris/colibri_t20_iris.c b/board/toradex/colibri_t20_iris/colibri_t20_iris.c index 49c74f3..4656094 100644 --- a/board/toradex/colibri_t20_iris/colibri_t20_iris.c +++ b/board/toradex/colibri_t20_iris/colibri_t20_iris.c @@ -5,23 +5,11 @@ */ #include -#include #include #include #include #include - -#include "../colibri_t20-common/colibri_t20-common.h" - -#ifdef CONFIG_USB_EHCI_TEGRA -void pin_mux_usb(void) -{ - colibri_t20_common_pin_mux_usb(); - - /* USB 1 aka Tegra USB port 3 VBus*/ - pinmux_tristate_disable(PMUX_PINGRP_SPIG); -} -#endif +#include #ifdef CONFIG_TEGRA_MMC /* @@ -34,3 +22,31 @@ void pin_mux_mmc(void) pinmux_tristate_disable(PMUX_PINGRP_GMB); } #endif + +#ifdef CONFIG_TEGRA_NAND +void pin_mux_nand(void) +{ + funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT); +} +#endif + +#ifdef CONFIG_USB_EHCI_TEGRA +void pin_mux_usb(void) +{ + /* module internal USB bus to connect ethernet chipset */ + funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI); + + /* ULPI reference clock output */ + pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4); + pinmux_tristate_disable(PMUX_PINGRP_CDEV2); + + /* PHY reset GPIO */ + pinmux_tristate_disable(PMUX_PINGRP_UAC); + + /* VBus GPIO */ + pinmux_tristate_disable(PMUX_PINGRP_DTE); + + /* USB 1 aka Tegra USB port 3 VBus */ + pinmux_tristate_disable(PMUX_PINGRP_SPIG); +} +#endif -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 2/2] ARM: tegra: rename colibri_t20 board/configuration/device-tree
In accordance with our other modules supported by U-Boot and as agreed upon for Apalis/Colibri T30 get rid of the carrier board in the board/ configuration/device-tree naming. While at it also bring the prompt more in line with our other products. Signed-off-by: Marcel Ziswiler --- arch/arm/dts/Makefile| 2 +- .../dts/{tegra20-colibri_t20_iris.dts => tegra20-colibri.dts}| 0 arch/arm/mach-tegra/tegra20/Kconfig | 4 ++-- board/toradex/{colibri_t20_iris => colibri_t20}/Kconfig | 6 +++--- board/toradex/{colibri_t20_iris => colibri_t20}/MAINTAINERS | 9 + board/toradex/{colibri_t20_iris => colibri_t20}/Makefile | 2 +- .../colibri_t20_iris.c => colibri_t20/colibri_t20.c} | 0 configs/{colibri_t20_iris_defconfig => colibri_t20_defconfig}| 4 ++-- include/configs/{colibri_t20_iris.h => colibri_t20.h}| 6 +++--- tools/buildman/README| 2 +- 10 files changed, 18 insertions(+), 17 deletions(-) rename arch/arm/dts/{tegra20-colibri_t20_iris.dts => tegra20-colibri.dts} (100%) rename board/toradex/{colibri_t20_iris => colibri_t20}/Kconfig (51%) rename board/toradex/{colibri_t20_iris => colibri_t20}/MAINTAINERS (24%) rename board/toradex/{colibri_t20_iris => colibri_t20}/Makefile (81%) rename board/toradex/{colibri_t20_iris/colibri_t20_iris.c => colibri_t20/colibri_t20.c} (100%) rename configs/{colibri_t20_iris_defconfig => colibri_t20_defconfig} (34%) rename include/configs/{colibri_t20_iris.h => colibri_t20.h} (89%) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index cbe5b86..f897e6d 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -24,7 +24,7 @@ dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \ tegra20-trimslice.dtb \ tegra20-ventana.dtb \ tegra20-whistler.dtb \ - tegra20-colibri_t20_iris.dtb \ + tegra20-colibri.dtb \ tegra30-apalis.dtb \ tegra30-beaver.dtb \ tegra30-cardhu.dtb \ diff --git a/arch/arm/dts/tegra20-colibri_t20_iris.dts b/arch/arm/dts/tegra20-colibri.dts similarity index 100% rename from arch/arm/dts/tegra20-colibri_t20_iris.dts rename to arch/arm/dts/tegra20-colibri.dts diff --git a/arch/arm/mach-tegra/tegra20/Kconfig b/arch/arm/mach-tegra/tegra20/Kconfig index a354e2a..7f09f81 100644 --- a/arch/arm/mach-tegra/tegra20/Kconfig +++ b/arch/arm/mach-tegra/tegra20/Kconfig @@ -30,7 +30,7 @@ config TARGET_VENTANA config TARGET_WHISTLER bool "NVIDIA Tegra20 Whistler evaluation board" -config TARGET_COLIBRI_T20_IRIS +config TARGET_COLIBRI_T20 bool "Toradex Colibri T20 board" endchoice @@ -47,6 +47,6 @@ source "board/avionic-design/tec/Kconfig" source "board/compulab/trimslice/Kconfig" source "board/nvidia/ventana/Kconfig" source "board/nvidia/whistler/Kconfig" -source "board/toradex/colibri_t20_iris/Kconfig" +source "board/toradex/colibri_t20/Kconfig" endif diff --git a/board/toradex/colibri_t20_iris/Kconfig b/board/toradex/colibri_t20/Kconfig similarity index 51% rename from board/toradex/colibri_t20_iris/Kconfig rename to board/toradex/colibri_t20/Kconfig index 4bf7278..7f373b2 100644 --- a/board/toradex/colibri_t20_iris/Kconfig +++ b/board/toradex/colibri_t20/Kconfig @@ -1,12 +1,12 @@ -if TARGET_COLIBRI_T20_IRIS +if TARGET_COLIBRI_T20 config SYS_BOARD - default "colibri_t20_iris" + default "colibri_t20" config SYS_VENDOR default "toradex" config SYS_CONFIG_NAME - default "colibri_t20_iris" + default "colibri_t20" endif diff --git a/board/toradex/colibri_t20_iris/MAINTAINERS b/board/toradex/colibri_t20/MAINTAINERS similarity index 24% rename from board/toradex/colibri_t20_iris/MAINTAINERS rename to board/toradex/colibri_t20/MAINTAINERS index c68955b..b251c00 100644 --- a/board/toradex/colibri_t20_iris/MAINTAINERS +++ b/board/toradex/colibri_t20/MAINTAINERS @@ -1,6 +1,7 @@ -COLIBRI_T20_IRIS BOARD +COLIBRI_T20 M: Lucas Stach S: Maintained -F: board/toradex/colibri_t20_iris/ -F: include/configs/colibri_t20_iris.h -F: configs/colibri_t20_iris_defconfig +F: board/toradex/colibri_t20/ +F: include/configs/colibri_t20.h +F: configs/colibri_t20_defconfig +F: arch/arm/dts/tegra20-colibri.dtb diff --git a/board/toradex/colibri_t20_iris/Makefile b/board/toradex/colibri_t20/Makefile similarity index 81% rename from board/toradex/colibri_t20_iris/Makefile rename to board/toradex/colibri_t20/Makefile index f286aec..86f78d9 100644 --- a/board/toradex/colibri_t20_iris/Makefile +++ b/board/toradex/colibri_t20/Makefile @@ -6,4 +6,4 @@ include $(srctree)/board/nvidia/common/common.mk -obj-y += colibri_t20_iris.o +obj-y += colibri_t20.o diff --git a/board/toradex/colibri_t20_iris/colibri_t20_iris.c b/board/toradex/colibri_t20/colibri_t20.c similarity index 100% rename from board/toradex/colibri_t20_iris/colibri_t20_iris.c rename to bo
[U-Boot] [PATCH v2 0/2] rename colibri_t20
In accordance with our other modules supported by U-Boot and as agreed upon for Apalis/Colibri T30 [1] get rid of the carrier board post fix in the board/configuration/device-tree naming. [1] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/192041 Changes in v2: - squashed it all together into two patches as suggested by Stephen in order to avoid any intermediate breakage and "git bisect" issues - added my previously missing signed-off-by Marcel Ziswiler (2): ARM: tegra: get rid of colibri_t20-common ARM: tegra: rename colibri_t20 board/configuration/device-tree arch/arm/dts/Makefile | 2 +- ...20-colibri_t20_iris.dts => tegra20-colibri.dts} | 0 arch/arm/mach-tegra/tegra20/Kconfig| 4 +-- .../colibri_t20-common/colibri_t20-common.c| 35 - .../colibri_t20-common/colibri_t20-common.h| 7 - .../{colibri_t20_iris => colibri_t20}/Kconfig | 6 ++-- .../{colibri_t20_iris => colibri_t20}/MAINTAINERS | 9 +++--- .../{colibri_t20_iris => colibri_t20}/Makefile | 6 ++-- .../colibri_t20.c} | 33 +++- ...ri_t20_iris_defconfig => colibri_t20_defconfig} | 4 +-- .../configs/{colibri_t20_iris.h => colibri_t20.h} | 6 ++-- tools/buildman/README | 2 +- 12 files changed, 45 insertions(+), 105 deletions(-) rename arch/arm/dts/{tegra20-colibri_t20_iris.dts => tegra20-colibri.dts} (100%) delete mode 100644 board/toradex/colibri_t20-common/colibri_t20-common.c delete mode 100644 board/toradex/colibri_t20-common/colibri_t20-common.h rename board/toradex/{colibri_t20_iris => colibri_t20}/Kconfig (51%) rename board/toradex/{colibri_t20_iris => colibri_t20}/MAINTAINERS (24%) rename board/toradex/{colibri_t20_iris => colibri_t20}/Makefile (39%) rename board/toradex/{colibri_t20_iris/colibri_t20_iris.c => colibri_t20/colibri_t20.c} (65%) rename configs/{colibri_t20_iris_defconfig => colibri_t20_defconfig} (34%) rename include/configs/{colibri_t20_iris.h => colibri_t20.h} (89%) -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 4/4] common/lcd_console: introduce display/framebuffer rotation
On 2015-03-25 17:24, Nikita Kiryanov wrote: Hi Hannes, Hi Nikita, This is almost an Acked-By from me, just a few final comments: Perfect, i think with v4 we can finish the thing :-) On 03/19/2015 10:37 AM, Hannes Petermaier wrote: diff --git a/README b/README index b0124d6..c649de1 100644 --- a/README +++ b/README @@ -1947,6 +1947,28 @@ CBFS (Coreboot Filesystem) support the console jump but can help speed up operation when scrolling is slow. +CONFIG_LCD_ROTATION + +Sometimes, for example if the display is mounted in portrait +mode or even if it mounted landscape but rotated by 180degree, s/if it/if it's/ +we need to rotate our content of the display respectively the s/respectively the/relative to the/ +framebuffer, so that user can read the messages who are printed s/who are printed/which are printed/ +out. +For this we introduce the feature called "CONFIG_LCD_ROTATION", +this may be defined in the board-configuration if needed. After +this the lcd_console will be initialized with a given rotation "this may be defined in the board-configuration if needed" This is true for all config options in general, no need to mention this. Also, "For this we introduce" is good for a commit message, but doesn't look good once committed. How about just "Once CONFIG_LCD_ROTATION is defined, the lcd_console will be..." +from "vl_rot" out of "vidinfo_t" which is provided by the board +specific code. +The value for vl_rot is coded as following (matching to +fbcon=rotate: linux-kernel commandline): +0 = no rotation respectively 0 degree +1 = 90 degree rotation +2 = 180 degree rotation +3 = 270 degree rotation + +If CONFIG_LCD_ROTATION is not defined, the console will be +initialized with 0degree rotation. + CONFIG_LCD_BMP_RLE8 Support drawing of RLE8-compressed bitmaps on the LCD. [...] +static void console_calc_rowcol(struct console_t *pcons) +{ +pcons->cols = pcons->lcdsizex / VIDEO_FONT_WIDTH; +#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) +pcons->rows = (pcons->lcdsizey - BMP_LOGO_HEIGHT); +pcons->rows /= VIDEO_FONT_HEIGHT; +#else +pcons->rows = pcons->lcdsizey / VIDEO_FONT_HEIGHT; +#endif +} Okay, i will fixup the description in v4 ... maybe these troubles are coming from, lets say, sub-optimal english-language practise :-) In original i speak german. [...] @@ -235,4 +253,3 @@ U_BOOT_CMD( "print string on lcd-framebuffer", "" ); - Looks like part of the cleanup from the previous series slipped through... Okay, i will remove it. +static void console_calc_rowcol_rot(struct console_t *pcons) +{ +u32 cols, rows; + +if (pcons->lcdrot == 1 || pcons->lcdrot == 3) { +cols = pcons->lcdsizey; +rows = pcons->lcdsizex; +} else { +cols = pcons->lcdsizex; +rows = pcons->lcdsizey; +} + +pcons->cols = cols / VIDEO_FONT_WIDTH; +#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) +pcons->rows = (rows - BMP_LOGO_HEIGHT); +pcons->rows /= VIDEO_FONT_HEIGHT; +#else +pcons->rows = rows / VIDEO_FONT_HEIGHT; +#endif This duplication with console_calc_rowcol() exists because the lcdsizey and lcdsizex data is expected by the functions to be already in pcons. If you change console_calc_rowcol() to accept both variables as additional arguments, then console_calc_rowcol() could be reused in console_calc_rowcol_rot() and we'll get rid of the code duplication. I'm not sure about what is more uggly or better. To avoid this duplication and use one function i have to make this function non-static and make a mix of rotation-code into lcd_console.c - i wouldn't prefer this. Maybe the actual way of this (little) duplication is the beautiful one and gives most readability of the code. what do you mean about? best regards, Hannes ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 57/80] dm: usb: tegra: Remove the port_addr_clear_csc variable
> -Original Message- > From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Simon Glass > Sent: Thursday, March 26, 2015 2:23 AM > To: U-Boot Mailing List > Cc: Marek Vasut; Stephen Warren; Vivek Gautam; Tom Warren > Subject: [U-Boot] [PATCH v2 57/80] dm: usb: tegra: Remove the > port_addr_clear_csc variable > > This variable is a bit of a hack. We can obtain the same information from the > normal device config. This will fit better with driver model, where global > variables > are best avoided. > > Signed-off-by: Simon Glass > --- > > Changes in v2: None > > drivers/usb/host/ehci-tegra.c | 6 +- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c > index 38333c7..464f55d 100644 > --- a/drivers/usb/host/ehci-tegra.c > +++ b/drivers/usb/host/ehci-tegra.c > @@ -87,8 +87,6 @@ struct fdt_usb { > > static struct fdt_usb port[USB_PORTS_MAX]; /* List of valid USB ports */ > static unsigned port_count; /* Number of available ports */ > -/* Port that needs to clear CSC after Port Reset */ -static u32 > port_addr_clear_csc; > > /* > * This table has USB timing parameters for each Oscillator frequency we @@ > -206,7 +204,7 @@ static void tegra_ehci_powerup_fixup(struct ehci_ctrl *ctrl, if (controller->has_hostpc) > *reg |= EHCI_PS_PE; > > - if (((u32)status_reg & TEGRA_USB_ADDR_MASK) != port_addr_clear_csc) > + if (!config->has_legacy_mode) > return; How do we get config (config->has_legacy_mode) for in this function? If you read ehci_set_usbmode, "config" comes from "config = &port[index];". Or "config" is an input argument like set_up_vbus(struct fdt_usb *config, ...) But for ehci_powerup_fixup, I don't see a way for us to get "config". > /* For EHCI_PS_CSC to be cleared in ehci_hcd.c */ --nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Driver model Ethernet issue
Hi Joe, I think moving the packet processing into the uclass was a good idea, but I did not think it through. If you look at the designware driver, when it receives a packet it processes it and then retires that buffer for later reuse. The few others I have looked at are similar. We can't retire it in the recv() method since the packet is still needed at that point, and may be overwritten by a new packet if we retire its buffer space. I am wondering if we should have a new method, like: int free_pkt(struct udevice *dev, uchar *packet, int len) which is called by the uclass after the packet is processed (assuming that recv() returns a packet). It would pass the packet pointer and length to the driver. This would allow the driver to do what it needs to do. What do you think? I'd like to figure this out and send v2 of the sunxi Ethernet conversion. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] u-boot: OpenRD Ultimate fails to build
Hi Vagrant, Le 21/03/2015 15:53, Vagrant Cascadian a écrit : > It seems that OpenRD Ultimate with u-boot 2015.04-rc3 and newer no > longer builds from source, both in Debian and with mainline git. It > appears to have overgrown the size limits set for it: Looks like the NAND partition map had to be changed to give more space for u-boot. Take care also that the MMC/SDIO kirkwood driver has been renamed and is now mainline (MVEBU_MMC). Default define is in SheevaPlug config file. guruplug_mvfs_and_mmc.diff and openrd-mmc.diff still refer to an old driver. These 2 patches may both been removed. Guruplug has no need of the kirkwood MMC driver, cause the MMC/uSD slot they get is an USB hardware. OpenRD and derivatives must use the newer (MVEBU_MMC) driver. Enjoy Gérald ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 v1] sf: probe: Add support Atmel AT45DB series devices special commands
Hi Haikun, On 3/26/2015 10:39 AM, Wang Haikun-B53464 wrote: On 3/25/2015 10:10 PM, Fan Peng-B51431 wrote: Hi Haikun, On 3/25/2015 8:35 PM, Haikun Wang wrote: From: Haikun Wang Atmel AT45DB series devices commands is different from common spi flash commands. This patch add support for AT45DB special commands. Add a flag AT45DB_CMD to control whether use those commands. Signed-off-by: Haikun Wang --- Changes in v1: None drivers/mtd/spi/sf_internal.h | 7 +++ drivers/mtd/spi/sf_ops.c | 2 +- drivers/mtd/spi/sf_probe.c| 10 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 785f7a9..234af21 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -43,6 +43,7 @@ enum { SST_BP = 1 << 3, SST_WP = 1 << 4, WR_QPP = 1 << 5, + AT45DB_CMD = 1 << 6, }; #define SST_WR (SST_BP | SST_WP) @@ -106,6 +107,12 @@ enum { #define SPI_FLASH_PAGE_ERASE_TIMEOUT(5 * CONFIG_SYS_HZ) #define SPI_FLASH_SECTOR_ERASE_TIMEOUT (10 * CONFIG_SYS_HZ) +/* Atmel AT45DB specific */ +#define CMD_ATMEL_PAGE_PROGRAM 0x82 Why not use 0x2 to align with current mtd/spi framework? I didn't find the program command '0x2' in AT45DB021D datasheet. My fault. 0x2h is supported by AT45DB021E, but not AT45DB021D. You can use 0x82. Do you ever use it in AT45DB flash chip? I used a similar chip AT45DB021E, not AT45DB021D. And I have a local patch for this chip. +#define CMD_ATMEL_READ_STATUS 0xd7 +#define CMD_ATMEL_FLAG_STATUS 0xd7 +#define CMD_ATMEL_BLK_ERASE0x50 + /* SST specific */ #ifdef CONFIG_SPI_FLASH_SST # define CMD_SST_BP 0x02/* Byte Program */ diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 34bc54e..27ce5f9 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -165,7 +165,7 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout) u8 poll_bit = STATUS_WIP; u8 cmd = flash->poll_cmd; - if (cmd == CMD_FLAG_STATUS) { + if (cmd == CMD_FLAG_STATUS || cmd == CMD_ATMEL_FLAG_STATUS) { poll_bit = STATUS_PEC; check_status = poll_bit; } diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 4103723..2ccddf2 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -226,6 +226,16 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode, flash->poll_cmd = CMD_FLAG_STATUS; #endif +#ifdef CONFIG_SPI_FLASH_ATMEL + if (params->flags & AT45DB_CMD) { + flash->poll_cmd = CMD_ATMEL_READ_STATUS; + flash->write_cmd = CMD_ATMEL_PAGE_PROGRAM; + /* use block-erase command, eight pages */ + flash->erase_cmd = CMD_ATMEL_BLK_ERASE; + flash->erase_size = flash->page_size * 8; + } +#endif + The SPI Flash's default page size is 264 bytes, but mtd/spi framework supports 256 and 512 bytes for one page. In your patch, you does not handle such case, can your driver works as expected? Fine, I know mtd/spi framework doesn't support page-size of 264bytes. In fact we change the chip's page-size to 256bytes before using it. If others use a same chip, he/she has no idea about this. It is a big work to adjust the framework support 264bytes. No big work, just send a configuration command to the chip. So how about add a check here, if the chip has a page-size of 264bytes, we just return an error. This AT45XXD chip's page size can only be configured once. you can check the status register, BIT 0's meaning is PAGE SIZE is 256 or 264. If the page size is 264, you can configure the chip to 256 seeing "11.1 Programming the Configuration Register". If the page size is already 256, no need to configure it again. You can added related function in sf_ops.c and invoke this function in sf_probe.c when probe. you can take the following piece of code as a reference as you like, it works for AT45DB021E. About read status, I suppose you can use the FLAG_STATUS to get the correct value. #if defined(CONFIG_SPI_FLASH_ATMEL) /* * For the AT45DB021E, there are an extra eight bytes * of memory in each page for a total of an extra 8KB * (64-Kbits) of user-accessible memory. * In order to be compatible with spi framework, we use 256bytes. */ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc) { u8 data[3]; u8 cmd; int ret; ret = spi_flash_cmd_read_status(flash, &data[0]); if (ret < 0) return ret; /* * PAGE SIZE Page Size, bit 0. * 0 Device is configured for standard DataFlash page size (264 bytes). * 1 Device is configured for “power of 2” binary page size (256 bytes). */ if (wc == SPI_FLASH_PAGE_256) {
Re: [U-Boot] [PATCH 1/2 v1] sf: probe: Add support Atmel AT45DB series devices special commands
On 3/25/2015 10:10 PM, Fan Peng-B51431 wrote: > Hi Haikun, > > On 3/25/2015 8:35 PM, Haikun Wang wrote: >> From: Haikun Wang >> >> Atmel AT45DB series devices commands is different from common spi flash >> commands. This patch add support for AT45DB special commands. >> Add a flag AT45DB_CMD to control whether use those commands. >> >> Signed-off-by: Haikun Wang >> --- >> >> Changes in v1: None >> >>drivers/mtd/spi/sf_internal.h | 7 +++ >>drivers/mtd/spi/sf_ops.c | 2 +- >>drivers/mtd/spi/sf_probe.c| 10 ++ >>3 files changed, 18 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h >> index 785f7a9..234af21 100644 >> --- a/drivers/mtd/spi/sf_internal.h >> +++ b/drivers/mtd/spi/sf_internal.h >> @@ -43,6 +43,7 @@ enum { >> SST_BP = 1 << 3, >> SST_WP = 1 << 4, >> WR_QPP = 1 << 5, >> +AT45DB_CMD = 1 << 6, >>}; >> >>#define SST_WR(SST_BP | SST_WP) >> @@ -106,6 +107,12 @@ enum { >>#define SPI_FLASH_PAGE_ERASE_TIMEOUT (5 * CONFIG_SYS_HZ) >>#define SPI_FLASH_SECTOR_ERASE_TIMEOUT(10 * CONFIG_SYS_HZ) >> >> +/* Atmel AT45DB specific */ >> +#define CMD_ATMEL_PAGE_PROGRAM 0x82 > Why not use 0x2 to align with current mtd/spi framework? I didn't find the program command '0x2' in AT45DB021D datasheet. Do you ever use it in AT45DB flash chip? >> +#define CMD_ATMEL_READ_STATUS 0xd7 >> +#define CMD_ATMEL_FLAG_STATUS 0xd7 >> +#define CMD_ATMEL_BLK_ERASE 0x50 >> + >>/* SST specific */ >>#ifdef CONFIG_SPI_FLASH_SST >># define CMD_SST_BP 0x02/* Byte Program */ >> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c >> index 34bc54e..27ce5f9 100644 >> --- a/drivers/mtd/spi/sf_ops.c >> +++ b/drivers/mtd/spi/sf_ops.c >> @@ -165,7 +165,7 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, >> unsigned long timeout) >> u8 poll_bit = STATUS_WIP; >> u8 cmd = flash->poll_cmd; >> >> -if (cmd == CMD_FLAG_STATUS) { >> +if (cmd == CMD_FLAG_STATUS || cmd == CMD_ATMEL_FLAG_STATUS) { >> poll_bit = STATUS_PEC; >> check_status = poll_bit; >> } >> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c >> index 4103723..2ccddf2 100644 >> --- a/drivers/mtd/spi/sf_probe.c >> +++ b/drivers/mtd/spi/sf_probe.c >> @@ -226,6 +226,16 @@ static int spi_flash_validate_params(struct spi_slave >> *spi, u8 *idcode, >> flash->poll_cmd = CMD_FLAG_STATUS; >>#endif >> >> +#ifdef CONFIG_SPI_FLASH_ATMEL >> +if (params->flags & AT45DB_CMD) { >> +flash->poll_cmd = CMD_ATMEL_READ_STATUS; >> +flash->write_cmd = CMD_ATMEL_PAGE_PROGRAM; >> +/* use block-erase command, eight pages */ >> +flash->erase_cmd = CMD_ATMEL_BLK_ERASE; >> +flash->erase_size = flash->page_size * 8; >> +} >> +#endif >> + > The SPI Flash's default page size is 264 bytes, but mtd/spi framework > supports 256 and 512 bytes for one page. In your patch, you does not > handle such case, can your driver works as expected? Fine, I know mtd/spi framework doesn't support page-size of 264bytes. In fact we change the chip's page-size to 256bytes before using it. It is a big work to adjust the framework support 264bytes. So how about add a check here, if the chip has a page-size of 264bytes, we just return an error. Or I will add a AT45DB special flash driver under Driver Model. -- Best regards, Wang Haikun >> /* Configure the BAR - discover bank cmds and read current bank */ >>#ifdef CONFIG_SPI_FLASH_BAR >> u8 curr_bank = 0; > Regards, > Peng. > ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2 v1] sf: Update AT45DB021D flash chip parameters
On 3/25/2015 10:11 PM, Fan Peng-B51431 wrote: > Hi Haikun, > > On 3/25/2015 8:36 PM, Haikun Wang wrote: >> From: Haikun Wang >> >> AT45DB021D flash size is 1024*page_size, page_size is 256bytes or 264bytes. >> In current params_table its size is 64*1024*8, recorrect it. >> Add AT45DB_CMD flag for AT45DB021D. >> >> Signed-off-by: Haikun Wang >> --- >> >> Changes in v1: None >> >>drivers/mtd/spi/sf_params.c | 3 ++- >>1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mtd/spi/sf_params.c b/drivers/mtd/spi/sf_params.c >> index c12e8c6..c6b68f8 100644 >> --- a/drivers/mtd/spi/sf_params.c >> +++ b/drivers/mtd/spi/sf_params.c >> @@ -16,7 +16,8 @@ >>const struct spi_flash_params spi_flash_params_table[] = { >>#ifdef CONFIG_SPI_FLASH_ATMEL /* ATMEL */ >> {"AT45DB011D", 0x1f2200, 0x0, 64 * 1024, 4, RD_NORM, >> SECT_4K}, >> -{"AT45DB021D", 0x1f2300, 0x0, 64 * 1024, 8, RD_NORM, >> SECT_4K}, >> +{"AT45DB021D", 0x1f2300, 0x0, 64 * 1024, 4, >> + RD_NORM, AT45DB_CMD}, > It's sector size is 32K, count is 8, right? Fine, will update next version. -- Best regards, Wang Haikun >> {"AT45DB041D", 0x1f2400, 0x0, 64 * 1024, 8, RD_NORM, >> SECT_4K}, >> {"AT45DB081D", 0x1f2500, 0x0, 64 * 1024,16, RD_NORM, >> SECT_4K}, >> {"AT45DB161D", 0x1f2600, 0x0, 64 * 1024,32, RD_NORM, >> SECT_4K}, > Regards, > Peng. > ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2] Exynos: Clock: Fix exynos5_get_periph_rate for I2C.
On 19 March 2015 at 11:06, Guillaume Gardet wrote: > Ping. > > Guillaume > > > Le 11/03/2015 10:34, Guillaume GARDET a écrit : > >> Commit 2e82e9252695a612ab0cbf40fa0c7368515f6506 'Exynos: Clock: Cleanup >> soc_get_periph_rate' introduced a bug in I2C config. This patch makes >> cros_ec >> keyboard working again on Samsung Chromebook (snow). >> >> Changes in V2: reorder lines as requested by Joonyoung Shim. >> >> Signed-off-by: Guillaume GARDET >> Cc: Akshay Saraswat >> Cc: Minkyu Kang >> Cc: Joonyoung Shim >> >> --- >> arch/arm/cpu/armv7/exynos/clock.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm/cpu/armv7/exynos/clock.c >> b/arch/arm/cpu/armv7/exynos/clock.c >> index c6455c2..2984867 100644 >> --- a/arch/arm/cpu/armv7/exynos/clock.c >> +++ b/arch/arm/cpu/armv7/exynos/clock.c >> @@ -423,8 +423,8 @@ static unsigned long exynos5_get_periph_rate(int >> peripheral) >> case PERIPH_ID_I2C6: >> case PERIPH_ID_I2C7: >> src = EXYNOS_SRC_MPLL; >> - div = readl(&clk->div_top0); >> - sub_div = readl(&clk->div_top1); >> + div = readl(&clk->div_top1); >> + sub_div = readl(&clk->div_top0); >> break; >> default: >> debug("%s: invalid peripheral %d", __func__, peripheral); Tested on snow. Reviewed-by: Simon Glass Tested-by: Simon Glass ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2] ARM: tegra: update colibri_t20 configuration
Bring the Colibri T20 configuration in-line with Apalis/Colibri T30. Signed-off-by: Marcel Ziswiler --- Changes in v2: - added my previously missing signed-off-by include/configs/colibri_t20.h | 31 +++ 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/include/configs/colibri_t20.h b/include/configs/colibri_t20.h index e80e9ed..c17f245 100644 --- a/include/configs/colibri_t20.h +++ b/include/configs/colibri_t20.h @@ -14,9 +14,12 @@ #define CONFIG_TEGRA_BOARD_STRING "Toradex Colibri T20" /* Board-specific serial config */ +#define CONFIG_SERIAL_MULTI #define CONFIG_TEGRA_ENABLE_UARTA #define CONFIG_TEGRA_UARTA_SDIO1 -#define CONFIG_SYS_NS16550_COM1NV_PA_APB_UARTA_BASE +#define CONFIG_SYS_NS16550_COM1NV_PA_APB_UARTA_BASE + +#define CONFIG_MACH_TYPE MACH_TYPE_COLIBRI_T20 /* SD/MMC support */ #define CONFIG_MMC @@ -29,17 +32,17 @@ #define CONFIG_USB_EHCI_TEGRA #define CONFIG_USB_ULPI #define CONFIG_USB_ULPI_VIEWPORT -#define CONFIG_USB_STORAGE #define CONFIG_USB_MAX_CONTROLLER_COUNT 3 +#define CONFIG_USB_STORAGE #define CONFIG_CMD_USB /* USB networking support */ #define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX + +/* General networking support */ #define CONFIG_CMD_NET #define CONFIG_CMD_DHCP -#define CONFIG_CMD_NFS -#define CONFIG_CMD_PING /* NAND support */ #define CONFIG_CMD_NAND @@ -56,6 +59,26 @@ #define CONFIG_CMD_BDI #define CONFIG_CMD_CACHE +/* Miscellaneous commands */ +#define CONFIG_CMD_SETEXPR +#define CONFIG_FAT_WRITE + +/* Increase console I/O buffer size */ +#undef CONFIG_SYS_CBSIZE +#define CONFIG_SYS_CBSIZE 1024 + +/* Increase arguments buffer size */ +#undef CONFIG_SYS_BARGSIZE +#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE + +/* Increase print buffer size */ +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16) + +/* Increase maximum number of arguments */ +#undef CONFIG_SYS_MAXARGS +#define CONFIG_SYS_MAXARGS 32 + +#include "tegra-common-usb-gadget.h" #include "tegra-common-post.h" #endif /* __CONFIG_H */ -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2] ARM: tegra: fix colibri_t20 asix reset
Fix ASIX USB to Ethernet chip reset. Signed-off-by: Marcel Ziswiler --- Changes in v2: - added my previously missing signed-off-by board/toradex/colibri_t20/colibri_t20.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c index 4656094..5d8bdec 100644 --- a/board/toradex/colibri_t20/colibri_t20.c +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -46,7 +46,14 @@ void pin_mux_usb(void) /* VBus GPIO */ pinmux_tristate_disable(PMUX_PINGRP_DTE); - /* USB 1 aka Tegra USB port 3 VBus */ + /* Reset ASIX using LAN_RESET */ + gpio_request(GPIO_PV4, "LAN_RESET"); + gpio_direction_output(GPIO_PV4, 0); + pinmux_tristate_disable(PMUX_PINGRP_GPV); + udelay(5); + gpio_set_value(GPIO_PV4, 1); + + /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */ pinmux_tristate_disable(PMUX_PINGRP_SPIG); } #endif -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2] ARM: tegra: fix colibri_t20 machine type
A while ago I got Russell to change the machine type of our Colibri T20 from COLIBRI_TEGRA2 to COLIBRI_T20 which at least in parts is also reflected in his machine registry: http://www.arm.linux.org.uk/developer/machines/list.php?id=3323 For us it is really very beneficial to actually still be able to boot downstream L4T kernel with its working hardware accelerated graphics/multimedia stack albeit it being proprietary/closed-source. Signed-off-by: Marcel Ziswiler Acked-by: Stephen Warren --- Changes in v2: - clarified commit message based on Stephen's comments - added my previously missing signed-off-by arch/arm/include/asm/mach-types.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/mach-types.h b/arch/arm/include/asm/mach-types.h index d4a447b..c424a22 100644 --- a/arch/arm/include/asm/mach-types.h +++ b/arch/arm/include/asm/mach-types.h @@ -936,7 +936,7 @@ extern unsigned int __machine_arch_type; #define MACH_TYPE_CWME9210 3320 #define MACH_TYPE_CWME9210JS 3321 #define MACH_TYPE_PGS_SITARA 3322 -#define MACH_TYPE_COLIBRI_TEGRA2 3323 +#define MACH_TYPE_COLIBRI_T20 3323 #define MACH_TYPE_W21 3324 #define MACH_TYPE_POLYSAT1 3325 #define MACH_TYPE_DATAWAY 3326 @@ -12197,16 +12197,16 @@ extern unsigned int __machine_arch_type; # define machine_is_pgs_v1() (0) #endif -#ifdef CONFIG_MACH_COLIBRI_TEGRA2 +#ifdef CONFIG_MACH_COLIBRI_T20 # ifdef machine_arch_type # undef machine_arch_type # define machine_arch_type__machine_arch_type # else -# define machine_arch_typeMACH_TYPE_COLIBRI_TEGRA2 +# define machine_arch_typeMACH_TYPE_COLIBRI_T20 # endif -# define machine_is_colibri_tegra2() (machine_arch_type == MACH_TYPE_COLIBRI_TEGRA2) +# define machine_is_colibri_t20() (machine_arch_type == MACH_TYPE_COLIBRI_T20) #else -# define machine_is_colibri_tegra2() (0) +# define machine_is_colibri_t20() (0) #endif #ifdef CONFIG_MACH_W21 -- 1.9.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] ARM: tegra: fix colibri_t20 machine type
On Mon, 2015-03-23 at 13:37 -0600, Stephen Warren wrote: > Only "half" of the references there seem to be updated; there are still > some mentions of e.g. CONFIG_MACH_COLIBRI_TEGRA2, > MACH_TYPE_COLIBRI_TEGRA2. Perhaps it's still in flux? Ah, yes. Now I remember. Some stuff can't easily be changed from within that web interface but as Russell actually anyway got rid of most machine IDs in the mainline kernel I decided to just leave it. For us it is really very beneficial to actually still be able to boot downstream L4T kernel with its working hardware accelerated graphics/multimedia stack albeit it being proprietary/closed-source. > Even so, this change seems fine since it does better represent the name > of the board. > > Acked-by: Stephen Warren Thanks. I will resubmit as I forgot to even add my signed-of-by (;-p). ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] Exynos: Clock: Fix exynos5_get_periph_rate for I2C.
Hi Minkyu, On 24 March 2015 at 01:45, Minkyu Kang wrote: > hi, > > On 20 March 2015 at 02:06, Guillaume Gardet > wrote: > >> Ping. >> >> Guillaume >> >> >> Le 11/03/2015 10:34, Guillaume GARDET a écrit : >> >> Commit 2e82e9252695a612ab0cbf40fa0c7368515f6506 'Exynos: Clock: Cleanup >>> soc_get_periph_rate' introduced a bug in I2C config. This patch makes >>> cros_ec >>> keyboard working again on Samsung Chromebook (snow). >>> >>> Changes in V2: reorder lines as requested by Joonyoung Shim. >>> >>> Signed-off-by: Guillaume GARDET >> > >>> Cc: Akshay Saraswat >> > >>> Cc: Minkyu Kang >> > >>> Cc: Joonyoung Shim >> > >>> >>> --- >>> arch/arm/cpu/armv7/exynos/clock.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/arch/arm/cpu/armv7/exynos/clock.c >>> b/arch/arm/cpu/armv7/exynos/clock.c >>> index c6455c2..2984867 100644 >>> --- a/arch/arm/cpu/armv7/exynos/clock.c >>> +++ b/arch/arm/cpu/armv7/exynos/clock.c >>> @@ -423,8 +423,8 @@ static unsigned long exynos5_get_periph_rate(int >>> peripheral) >>> case PERIPH_ID_I2C6: >>> case PERIPH_ID_I2C7: >>> src = EXYNOS_SRC_MPLL; >>> - div = readl(&clk->div_top0); >>> - sub_div = readl(&clk->div_top1); >>> + div = readl(&clk->div_top1); >>> + sub_div = readl(&clk->div_top0); >>> break; >>> default: >>> debug("%s: invalid peripheral %d", __func__, peripheral); >>> >> >> ___ >> U-Boot mailing list >> U-Boot@lists.denx.de >> >> http://lists.denx.de/mailman/listinfo/u-boot >> > > This patch will be merged at next week! Great! Also where are we with the peach Pi display series? Can that go in also? Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 04/40] fdt: Add functions to retrieve strings
Hi Thierry, On 8 September 2014 at 09:02, Simon Glass wrote: > Applied to u-boot-fdt/next, thanks! Did you submit these patches to dtc upstream? I don't see them applied. Regards, SImon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Please pull u-boot-dm
Hi Tom, The following changes since commit b81bdf62e0cf9b5c64d30284d01658a851f142f7: bav335x: Update defconfigs and fix typo in EEPROM config format (2015-03-24 10:56:35 -0400) are available in the git repository at: http://git.denx.de/u-boot-dm.git for you to fetch changes up to 891ee87e2b4586012ce5bacd9149177f61de4ad5: dm: serial: remove bogus include (2015-03-25 16:33:27 -0600) Masahiro Yamada (1): dm: serial: remove bogus include drivers/serial/serial-uclass.c | 2 -- 1 file changed, 2 deletions(-) Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] dm: serial: remove bogus include
On 20 March 2015 at 17:52, Simon Glass wrote: > On 20 March 2015 at 09:24, Tom Rini wrote: >> On Fri, Mar 20, 2015 at 01:24:45PM +0900, Masahiro Yamada wrote: >> >>> Serial-uclass should be generically implemented without depending >>> a particular hardware. Fortunately, nothing in include/ns16550.h is >>> referenced from drivers/serial/serial-uclass.c, so remove this bogus >>> include. >>> >>> Signed-off-by: Masahiro Yamada >> >> Reviewed-by: Tom Rini > > Acked-by: Simon Glass Applied to u-boot-dm, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] x86: galileo: Enable saving environment in SPI flash
On 12 March 2015 at 19:40, Bin Meng wrote: > Hi Simon, > > On Fri, Mar 13, 2015 at 6:15 AM, Simon Glass wrote: >> On 11 March 2015 at 02:22, Bin Meng wrote: >>> Saving U-Boot's environment in SPI flash on Intel Galileo board. >>> >>> Signed-off-by: Bin Meng >>> --- >>> >>> include/configs/galileo.h | 8 >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/include/configs/galileo.h b/include/configs/galileo.h >>> index 65a2c3e..288acf3 100644 >>> --- a/include/configs/galileo.h >>> +++ b/include/configs/galileo.h >>> @@ -62,4 +62,12 @@ >>> #define CONFIG_DW_ALTDESCRIPTOR >>> #define CONFIG_PHYLIB >>> >>> +/* Environment configuration */ >>> +#undef CONFIG_ENV_IS_NOWHERE >>> +#undef CONFIG_ENV_SIZE >>> +#define CONFIG_ENV_IS_IN_SPI_FLASH >>> +#define CONFIG_ENV_SIZE0x1000 >>> +#define CONFIG_ENV_SECT_SIZE 0x1000 >>> +#define CONFIG_ENV_OFFSET 0 >>> + >>> #endif /* __CONFIG_H */ >>> -- >>> 1.8.2.1 >>> >> >> Acked-by: Simon Glass >> >> I wonder at what point we should move some of this to x86-common.h? > > I believe we can only put > > #define CONFIG_ENV_IS_IN_SPI_FLASH > > in x86-common.h and leave others still in the board file due to they > are spi flash/board-specific. Yes that sounds right. Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 4/4] x86: crownbay: Enable Intel Topcliff GMAC support
On 20 March 2015 at 13:18, Joe Hershberger wrote: > On Fri, Mar 20, 2015 at 4:12 AM, Bin Meng wrote: >> >> Intel Crown Bay board has one ethernet port connected from Intel >> Topcliff PCH. Enable it in the board configuration. >> >> Signed-off-by: Bin Meng >> >> --- > > Reviewed-by: Joe Hershberger Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/4] net: Add ethernet FCS length macro in net.h
On 20 March 2015 at 13:18, Joe Hershberger wrote: > On Fri, Mar 20, 2015 at 4:12 AM, Bin Meng wrote: >> >> Some ethernet drivers use their own version of ethernet FCS length >> macro which is really common. We define ETH_FCS_LEN in net.h and >> replace those custom versions in various places. >> >> Signed-off-by: Bin Meng >> --- > > Acked-by: Joe Hershberger I'll pick this up to get this board into better shape. Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] x86: quark: Enable on-chip ethernet controllers
On 12 March 2015 at 16:13, Simon Glass wrote: > Hi Bin, > > On 10 March 2015 at 20:25, Bin Meng wrote: >> Intel Quark SoC integrates two 10/100 ethernet controllers which can >> be connected to an external RMII PHY. The MAC IP is from Designware. >> Enable this support with the existing U-Boot Designware MAC driver >> so that the ethernet port on Intel Galileo board can be used. >> >> Signed-off-by: Bin Meng >> --- >> >> arch/x86/cpu/quark/quark.c | 19 +++ >> include/configs/galileo.h | 5 + >> 2 files changed, 24 insertions(+) Since this only affects this new board we may as well apply it now. Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] serial atag tag in devicetree ?
Le mardi 24 mars 2015 à 09:01 +0100, Hans de Goede a écrit : > Hi, > > On 24-03-15 00:12, Rob Herring wrote: > > On Mon, Mar 23, 2015 at 6:30 AM, Hans de Goede wrote: > >> Hi, > >> > >> > >> On 22-03-15 22:01, Rob Herring wrote: > > > > >>> There is already "serial-number" (a string) which exists for > >>> OpenFirmware. Also, "copyright" corresponds to vendor/manufacturer > >>> string. Both of these are supported by lshw already. > >> > >> > >> Ok, so if I understand you correctly then you're saying that we > >> should set a "serial-number" string property at the dt root level > >> and that this may contain pretty much anything, e.g. in the > >> sunxi case the full 128 bit SID in hex. > > > > Right. > > > >> Is the use of the "serial-number" string property already documented > >> somewhere? If not I'll submit a kernel patch to document it. > > > > Not that I'm aware of. It is something that predates our documentation > > requirements. It could be in OpenFirmware specs. Documenting it in the > > DT bindings does not hurt. > > Ok. > > >> And for older kernels we should not set any serial atag (u-boot > >> always sets it, so this leaves it at 0) and old kernel users are > >> out of luck wrt getting to the serial ? > > > > If there is sufficient reason to support this on old kernels you could. > > One problem with supporting this for older kernels is that if a non 0 > serial gets shown in /proc/cpuinfo with older atag booted kernels, we > should really show the same number in /proc/cpuinfo which means adding > code to the kernel to get the devicetree "serial-number" string property > and somehow put that into the 64 bits which we have in /proc/cpuinfo, > but given that the "serial-number" string could be hex or decimal or > what ever and > 64 bits that will likely require a platform specific > solution. All doable, but the question then becomes is this worth the > effort ? After investigating a bit more, I found out that the USB serial number is expected to be a string of 32 bytes, so a 128 bit numeric serial doesn't fit (it takes 32 bytes for the hex representation of 128 bits, so there is no room left for the terminating null byte), hence it makes sense to keep a 64 bit limitation for the serial number, if users are going to rely on it as USB serial string. Moreover, it seems that Android devices are mostly used 64 bit numbers for serial numbers/ I was initially going to suggest that we set it in stone that serial must be 64 numeric bits (as it was in the ATAGs days) and that bootloaders would pass it that way to the kernel through device tree (with two 32 bits numeric integers), but Hans talked me out of it. I just want to expose the situation (especially the USB and Android thing) here to double-check that everyone still is convinced that a string approach in device tree is best (which is fine with me). This way, users that still want to use the serial passed through device tree as a USB serial number will have to use a string of 32 bits, including the null terminating byte (which is what I'll suggest for sunxi by using only 64 bits for the serial number). Also, I suggest that we show that serial-number string as-is in cpuinfo as well and instead make a string out of the serial ATAG in the kernel prior to showing it in cpuinfo (as opposed to translating the string coming from device tree to a numeric value that cpuinfo will end up showing as a string at the end of the day). Thus, the serial number coming from device tree will still be shown in cpuinfo as well and no ABI gets broken. If you're all okay with this, I'll be sending patches to both U-Boot and Linux to start documenting/implementing this. -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: http://www.replicant.us/ Blog: http://blog.replicant.us/ Wiki/tracker/forums: http://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] x86: crownbay: Enable saving environment in SPI flash
On 12 March 2015 at 16:15, Simon Glass wrote: > On 11 March 2015 at 02:22, Bin Meng wrote: >> Saving U-Boot's environment in SPI flash on Intel CrownBay board. >> >> Signed-off-by: Bin Meng >> --- >> >> include/configs/crownbay.h | 8 >> 1 file changed, 8 insertions(+) >> >> diff --git a/include/configs/crownbay.h b/include/configs/crownbay.h >> index b927b1c..4a74f82 100644 >> --- a/include/configs/crownbay.h >> +++ b/include/configs/crownbay.h >> @@ -56,4 +56,12 @@ >> #undef CONFIG_VIDEO >> #undef CONFIG_CFB_CONSOLE >> >> +/* Environment configuration */ >> +#undef CONFIG_ENV_IS_NOWHERE >> +#undef CONFIG_ENV_SIZE >> +#define CONFIG_ENV_IS_IN_SPI_FLASH >> +#define CONFIG_ENV_SIZE0x1000 >> +#define CONFIG_ENV_SECT_SIZE 0x1000 >> +#define CONFIG_ENV_OFFSET 0 >> + >> #endif /* __CONFIG_H */ >> -- >> 1.8.2.1 >> > > Acked-by: Simon Glass Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/4] net: Add Intel Topcliff GMAC driver
On 23 March 2015 at 22:54, Bin Meng wrote: > Hi Simon, > > On Tue, Mar 24, 2015 at 12:18 PM, Simon Glass wrote: >> Hi Bin, >> >> On Mar 23, 2015 7:24 PM, "Bin Meng" wrote: >>> >>> Hi Simon, >>> >>> On Tue, Mar 24, 2015 at 5:57 AM, Simon Glass wrote: >>> > Hi Bin, >>> > >>> > On 20 March 2015 at 13:18, Joe Hershberger >>> > wrote: >>> >> On Fri, Mar 20, 2015 at 4:12 AM, Bin Meng wrote: >>> >>> >>> >>> Add a new driver for the Gigabit Ethernet MAC found on Intel Topcliff >>> >>> Platform Controller Hub. Tested under 10/100 half/full duplex and 1000 >>> >>> full duplex modes using ping and tftpboot commands. >>> >>> >>> >>> Signed-off-by: Bin Meng >>> >>> --- >>> >> >>> >> Acked-by: Joe Hershberger >>> > >>> > Do you think this could be converted to driver model? >>> > >>> > E.g., see this: >>> > >>> > http://patchwork.ozlabs.org/patch/444846/ >>> >>> Yes, I plan to do the conversion in the future as a separate patch. If >>> possible to catch up the train for the v2015.04 release, are you going >>> to apply this series now? >> >> I was planning to do this later. Do you want it in this release? I suppose >> that would be ok because it is a new board. >> > > Yep, given the series look OK and no rework will be needed, I would > like to add it to this release if time permits. And maybe along with > my other patches before (quark)? > > Regards, > Bin Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] x86: Add queensbay fsp patch information in README.x86
On 5 March 2015 at 12:48, Simon Glass wrote: > On 4 March 2015 at 20:21, Bin Meng wrote: >> The FSP release version 001 for Intel Queensbay has a bug which >> could cause random endless loop during the FspInit call. This bug >> was published by Intel although Intel did not describe any details. >> Describe this information in the x86 doc so that U-Boot Queensbay >> support is invulnerable. >> >> Signed-off-by: Bin Meng >> --- >> >> doc/README.x86 | 7 +++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/doc/README.x86 b/doc/README.x86 >> index fb87682..0355d1c 100644 >> --- a/doc/README.x86 >> +++ b/doc/README.x86 >> @@ -105,6 +105,13 @@ in this FSP package too. >> Rename the first one to fsp.bin and second one to cmc.bin and put them in >> the >> board directory. >> >> +Note the FSP release version 001 has a bug which could cause random endless >> +loop during the FspInit call. This bug was published by Intel although Intel >> +did not describe any details. We need manually apply the patch to the FSP >> +binary using any hex editor (eg: bvi). Go to the offset 0x1fcd8 of the FSP >> +binary, change the following five bytes values from orginally E8 42 FF FF FF >> +to B8 00 80 0B 00. >> + >> Now you can build U-Boot and obtain u-boot.rom >> >> $ make crownbay_defconfig >> -- >> 1.8.2.1 >> > > Acked-by: Simon Glass Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/4] net: Update README.drivers.eth to mention latest APIs
On 20 March 2015 at 13:18, Joe Hershberger wrote: > On Fri, Mar 20, 2015 at 4:12 AM, Bin Meng wrote: >> >> README.drivers.eth still refers to the deprecated miiphy_register(). >> Update the doc to mention new APIs mdio_alloc() and mdio_register(). >> >> Signed-off-by: Bin Meng >> --- > > Acked-by: Joe Hershberger Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] fdtdec: Improve fdtdec_get_pci_bdf() documentation
On 5 March 2015 at 12:48, Simon Glass wrote: > On 4 March 2015 at 00:08, Bin Meng wrote: >> Add the description that how the compatible property is involved in >> the fdtdec_get_pci_bdf() documentation. >> >> Signed-off-by: Bin Meng >> --- >> >> include/fdtdec.h | 5 - >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/include/fdtdec.h b/include/fdtdec.h >> index 1bc70db..eef78a7 100644 >> --- a/include/fdtdec.h >> +++ b/include/fdtdec.h >> @@ -346,7 +346,10 @@ int fdtdec_get_pci_vendev(const void *blob, int node, >> >> /** >> * Look at the pci address of a device node that represents a PCI device >> - * and parse the bus, device and function number from it. >> + * and parse the bus, device and function number from it. For some cases >> + * like the bus number encoded in reg property is not correct after pci >> + * enumeration, this function looks through the node's compatible strings >> + * to get these numbers extracted instead. >> * >> * @param blob FDT blob >> * @param node node to examine >> -- >> 1.8.2.1 >> > > Acked-by: Simon Glass Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arch/x86/cpu/quark/mrc.c: Switch to U_BOOT_DATE / U_BOOT_TIME
On 19 February 2015 at 11:26, Simon Glass wrote: > On 19 February 2015 at 04:58, Tom Rini wrote: >> >> Using __DATE__ and __TIME__ results in an error due to -Werror=date-time >> with gcc-4.9 (__DATE__ / __TIME__ might prevent reproducible builds) so >> switch these over to U_BOOT_DATE / U_BOOT_TIME >> >> Cc: Bin Meng >> Cc: Simon Glass >> Signed-off-by: Tom Rini >> --- >> arch/x86/cpu/quark/mrc.c |3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) > > Acked-by: Simon Glass Applied to u-boot-x86, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Please pull u-boot-x86.git
Hi Tom, These are improvements to a new board and some code clean-ups that I requested, so I think it is probably reasonable to take these now. The following changes since commit b81bdf62e0cf9b5c64d30284d01658a851f142f7: bav335x: Update defconfigs and fix typo in EEPROM config format (2015-03-24 10:56:35 -0400) are available in the git repository at: http://git.denx.de/u-boot-x86.git for you to fetch changes up to 6f1eba49a558421e3fcb06ab0addc12b9a3804c6: x86: Add ramboot and nfsboot commands in x86-common.h (2015-03-24 21:22:38 -0600) Bin Meng (11): x86: quark: MRC codes clean up fdtdec: Improve fdtdec_get_pci_bdf() documentation x86: Add queensbay fsp patch information in README.x86 x86: quark: Enable on-chip ethernet controllers net: Add ethernet FCS length macro in net.h net: Update README.drivers.eth to mention latest APIs net: Add Intel Topcliff GMAC driver x86: crownbay: Enable Intel Topcliff GMAC support x86: crownbay: Enable saving environment in SPI flash x86: galileo: Enable saving environment in SPI flash x86: Add ramboot and nfsboot commands in x86-common.h Tom Rini (1): arch/x86/cpu/quark/mrc.c: Switch to U_BOOT_DATE / U_BOOT_TIME arch/x86/cpu/quark/hte.c | 74 arch/x86/cpu/quark/hte.h |4 +- arch/x86/cpu/quark/mrc.c | 15 +- arch/x86/cpu/quark/mrc_util.c | 326 arch/x86/cpu/quark/mrc_util.h | 34 arch/x86/cpu/quark/quark.c| 19 ++ arch/x86/cpu/quark/smc.c | 1205 --- arch/x86/cpu/quark/smc.h | 349 ++- doc/README.drivers.eth| 51 +++-- doc/README.x86|7 + drivers/net/Makefile |1 + drivers/net/e1000.h |7 +- drivers/net/pch_gbe.c | 466 ++ drivers/net/pch_gbe.h | 300 ++ drivers/usb/gadget/ether.c|1 - drivers/usb/gadget/rndis.c|1 - include/configs/crownbay.h| 12 ++ include/configs/galileo.h | 13 ++ include/configs/x86-common.h | 31 +++- include/fdtdec.h |5 +- include/net.h |2 + include/netdev.h |4 + include/usb_ether.h |1 - 23 files changed, 1852 insertions(+), 1076 deletions(-) create mode 100644 drivers/net/pch_gbe.c create mode 100644 drivers/net/pch_gbe.h Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 14/28] drivers/fsl-mc: Changed MC firmware loading for new boot architecture
On Tue, 24 Mar 2015 21:32:56 -0500 Stuart Yoder wrote: > Kim, why is this being taken off-list? Adding it back. Also, please don't top-post. > I think it is premature to start focusing on saving single digit > milliseconds in u-boot. The 35 second boot time you are seeing on > some ls2085 boards is due to the fact that the MC was running with > it's CPU caches off until a few weeks ago. DDR is still running at > the slowest speed, which will affect the MC's performance. It's still > early in hardware bringup and things are not even stable yet. > > I'm still convinced that the MC itself probably has significant > performance work. > > The 1ms delay used polling for MC to boot has nothing to do with DPL > size. DPL processing is a separate, later initialization step. We're > just waiting for the MC to initialize here. The MC boot time > shouldn't vary. My visual reading watching things boot is that the MC > boot takes a few hundred milliseconds. I don't see what's wrong with > a 1 ms polling delay here. > > On a system with the MC running with caches on, u-boot took 20 seconds > to boot. The MC took about 5 seconds of that, most of that in DPL > processing. > > We would welcome help analyzing u-boot boot time and where the time is > going. But, seriously, saving 1 ms is not going to help at all. I did a quick experiment and saved ~50ms when setting both udelays down to 50, which, sure, isn't a big deal given it's out of the order of 10sec, but it's something, and, like I said, development time for our users can be seriously helped if MC initialization were omitted from the main u-boot boot sequence, and occurred only when necessary, i.e., when users want to use one of the DP net interfaces. Most of the time when we boot today, we don't use DP net interfaces, so MC init - with or without DPL processing - is just a waste of our time! Thanks, Kim > Thanks, > Stuart > > > > On Tue, Mar 24, 2015 at 10:35 AM, Kim Phillips > wrote: > > On Tue, 24 Mar 2015 10:14:39 -0500 > > Rivera Jose-B46482 wrote: > > > >> > From: Kim Phillips [mailto:kim.phill...@freescale.com] > >> > Sent: Monday, March 23, 2015 5:06 PM > >> > > >> > On Mon, 23 Mar 2015 16:15:56 -0500 > >> > Rivera Jose-B46482 wrote: > >> > > >> > > > From: Kim Phillips [mailto:kim.phill...@freescale.com] > >> > > > Sent: Monday, March 23, 2015 3:34 PM > >> > > > > >> > > > On Mon, 23 Mar 2015 15:06:11 -0500 > >> > > > Rivera Jose-B46482 wrote: > >> > > > > >> > > > > > From: Kim Phillips [mailto:kim.phill...@freescale.com] > >> > > > > > Sent: Thursday, March 19, 2015 12:53 PM > >> > > > > > > >> > > > > > On Thu, 19 Mar 2015 09:45:45 -0700 York Sun > >> > > > > > wrote: > >> > > > > > > >> > > > > > > From: "J. German Rivera" > >> > > > > > > > >> > > > > > > Changed MC firmware loading to comply with the new MC boot > >> > > > > > architecture. > >> > > > > > > Flush D-cache hierarchy after loading MC images. Add > >> > > > > > > environment variables "mcboottimeout" for MC boot timeout in > >> > > > > > > milliseconds, "mcmemsize" for MC DRAM block size. Check MC > >> > > > > > > boot status before calling flib functions. > >> > > > > > > >> > > > > > Can we just assign actual and/or optimal values for > >> > 'mcboottimeout' > >> > > > > > and 'mcmemsize' instead of making them environment variables? > >> > > > > > > >> > > > > Having environment variables gives us the flexibility if these > >> > > > > values need to be changed for a given customer configuration. The > >> > > > > actual > >> > > > > >> > > > what defines a 'customer configuration,' and how does that manifest > >> > > > itself at u-boot boot time? > >> > > A DPL (data path layout - a device-tree-like structure describing The > >> > > DPAA2 objects created at boot time and their connections) > >> > > > >> > > > Is it the amount of time it takes to load (and execute?) firmare? > >> > > Yes, bigger DPLs take longer to process by the MC. > >> > > > >> > > > Why isn't customer-specific firmware being loaded via linux? All > >> > > > u-boot needs is basic networking, pretty static > >> > > > setup: fixed numbers for both memsize & timeout. > >> > > This is not customer-specific firmware. What is customer-specific is > >> > just the DPL. > >> > > In order to have networking in u-boot, we need to load the MC firmware > >> > > in u-boot, For cases in which the target system has only DPAA2-based > >> > network interfaces. > >> > > >> > ok, for that case, when time comes for u-boot to do some DPAA2 networking > >> > arrives (i.e., we shouldn't have to be loading firmware at board boot- > >> > time), then we should load a minimal DPL for the number of singular, non- > >> > virtual/switch, etc., interfaces for that board just to tftp: this > >> > shouldn't be a big DPL at all, and its time complexity is fixed. > >> > > >> It is up to the customer to decide what kind of DPL they want to have. > > > > true, but in this case the 'customer' is the average upstream u-boo
Re: [U-Boot] [PATCH v2 3/3] config_distro_bootcmd.h: Prefer booting from bootable paritions
On Wed, Feb 25, 2015 at 11:23:52PM +0100, Sjoerd Simons wrote: > List bootable partitions and only scan those for bootable files, falling > back to partition 1 if there are no bootable partitions > > Signed-off-by: Sjoerd Simons > Reviewed-by: Hans de Goede Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions
On Wed, Feb 25, 2015 at 11:23:50PM +0100, Sjoerd Simons wrote: > Add an optional -bootable parameter to the part list commands to only > put the list of bootable partitions in the environment variable > > Signed-off-by: Sjoerd Simons Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 2/3] config_cmd_default.h: Add 'env exists' command
On Wed, Feb 25, 2015 at 11:23:51PM +0100, Sjoerd Simons wrote: > env exists allows scripts to query whether an environment variable > exists. Enable by default as it adds only a trivial amount of code and > can be useful in scripts. > > Signed-off-by: Sjoerd Simons > Reviewed-by: Hans de Goede Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/13] ARM: UniPhier: enable CONFIG_SPL_DM with some clean-ups
Hi Masahiro, On 24 March 2015 at 22:08, Masahiro Yamada wrote: > Hi Simon, > > > 2015-03-24 7:47 GMT+09:00 Simon Glass : >> Hi Masahiro, >> >> On 23 March 2015 at 09:19, Masahiro Yamada >> wrote: >>> 2015-03-23 0:07 GMT+09:00 Masahiro Yamada : Masahiro Yamada (13): ARM: UniPhier: include PH1-LD4 Makefile from PH1-sLD8 ARM: UniPhier: move platform devices to SPL ARM: UniPhier: move UART pin settings to SPL ARM: UniPhier: enable CONFIG_PANIC_HANG ARM: UniPhier: enable Driver Model and UART on SPL ARM: UniPhier: use CONFIG_SPL_STACK to define SPL stack pointer ARM: UniPhier: add CONFIG_SPL_MAX_FOOTPRINT ARM: UniPhier: move init stack area just below TEXT_BASE ARM: UniPhier: add empty lowlevel_init to U-boot proper ARM: UniPhier: fix typos in comments ARM: UniPhier: optimize kicking secondary CPUs code ARM: UniPhier: disable L2 cache by lowlevel_init of U-Boot proper ARM: UniPhier: remove unnecessary ifdef conditional >>> >>> >>> Applied to u-boot-uniphier/master. >> >> Great! Also you could look at my series here: >> >> http://lists.denx.de/pipermail/u-boot/2015-February/206581.html >> >> The device tree method is not good, I think we need a tool that chops >> the device tree down automatically for SPL. But otherwise, the support >> is there for device tree in SPL. > > Amazing! > It is very nice that OF_CONTROL can be available with such small > memory footprint. > > I can use 64KB for SPL on my boards, so it will surely work for me. > I will check it out! > > Thanks for your hard work all the time! Thanks! Yes it has worked out well. It is still overhead but it is tolerable overhead for most modern platforms, I think. I look forward to hearing what you find. Re the tool, I think we need something like: fdtsubset -a serial0 -a /gpio which looks up the alias 'serial0' and the /gpio node and creates a device tree subset containing just enough to allow that to work. I did a more general-purpose 'fdtgrep' tool along those lines a long time ago but it was not accepted to dtc. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] config: peach: Correct memory layout environment settings
On Wed, Mar 25, 2015 at 08:54:16PM +0100, Sjoerd Simons wrote: > On Wed, 2015-03-25 at 12:58 -0400, Tom Rini wrote: > > On Wed, Mar 25, 2015 at 09:32:45AM +0100, Sjoerd Simons wrote: > > > On Wed, 2015-03-25 at 01:11 -0400, Tom Rini wrote: > > > > On Mon, Mar 23, 2015 at 03:04:48PM -0600, Simon Glass wrote: > > > > > Hi Sjoerd, > > > > > > > > > > On 12 March 2015 at 15:33, Sjoerd Simons > > > > > wrote: > > > > > > The peach boards have their SDRAM start address at 0x2000 > > > > > > instead of > > > > > > 0x4000 which seems common for all other exynos5 based boards. > > > > > > This > > > > > > means the layout set in exynos5-common.h causes the kernel be loaded > > > > > > more then 128MB (at 0x4200) away from memory start which breaks > > > > > > booting kernels with CONFIG_AUTO_ZRELADDR > > > > > > > > > > > > Define a custom MEM_LAYOUT_ENV_SETTINGS for both peach boards which > > > > > > uses > > > > > > the same offsets from start of memory as the common exynos5 > > > > > > settings. > > > > > > > > > > > > This fixes booting via bootz and PXE > > > > > > > > > > > > Signed-off-by: Sjoerd Simons > > > > > > --- > > > > > > include/configs/peach-pi.h | 8 > > > > > > include/configs/peach-pit.h | 8 > > > > > > 2 files changed, 16 insertions(+) > > > > > > > > > > > > diff --git a/include/configs/peach-pi.h b/include/configs/peach-pi.h > > > > > > index f04f061..e3cb09e 100644 > > > > > > --- a/include/configs/peach-pi.h > > > > > > +++ b/include/configs/peach-pi.h > > > > > > @@ -16,6 +16,14 @@ > > > > > > #define CONFIG_ENV_OFFSET (FLASH_SIZE - CONFIG_BL2_SIZE) > > > > > > #define CONFIG_SPI_BOOTING > > > > > > > > > > > > +#define MEM_LAYOUT_ENV_SETTINGS \ > > > > > > + "bootm_size=0x1000\0" \ > > > > > > + "kernel_addr_r=0x2200\0" \ > > > > > > + "fdt_addr_r=0x2300\0" \ > > > > > > + "ramdisk_addr_r=0x2330\0" \ > > > > > > + "scriptaddr=0x3000\0" \ > > > > > > + "pxefile_addr_r=0x3100\0" > > > > > > + > > > > > > #include > > > > > > #include > > > > > > > > > > > > diff --git a/include/configs/peach-pit.h > > > > > > b/include/configs/peach-pit.h > > > > > > index b5efbdc..3ee42ef 100644 > > > > > > --- a/include/configs/peach-pit.h > > > > > > +++ b/include/configs/peach-pit.h > > > > > > @@ -16,6 +16,14 @@ > > > > > > #define CONFIG_ENV_OFFSET (FLASH_SIZE - CONFIG_BL2_SIZE) > > > > > > #define CONFIG_SPI_BOOTING > > > > > > > > > > > > +#define MEM_LAYOUT_ENV_SETTINGS \ > > > > > > + "bootm_size=0x1000\0" \ > > > > > > + "kernel_addr_r=0x2200\0" \ > > > > > > + "fdt_addr_r=0x2300\0" \ > > > > > > + "ramdisk_addr_r=0x2330\0" \ > > > > > > + "scriptaddr=0x3000\0" \ > > > > > > + "pxefile_addr_r=0x3100\0" > > > > > > + > > > > > > #include > > > > > > #include > > > > > > > > > > It would be great if we could have this in the device tree. > > > > > > > > I understand what you're thinking but this is environment. And really > > > > this is not board specific, this is SoC family specific which is why the > > > > similar part for TI stuff is in ti_armv7_common.h :) > > > > > > Exynos 5 has the same in exynos5-common.h, however for whatever reason > > > the peach pi/pit boards are different then other exynos board supported > > > by u-boot thusfar. So in this case, this information _is_ board specific > > > not platform specific. > > > > Oh I missed that early on, sorry. But... > > > > Why not change things around a bit to enable CONFIG_CMD_SETEXPR and then > > have MEM_LAYOUT_ENV_SETTINGS just set the exynos5_ddr_base and then > > setexpr kernel_addr_r $exynos5_ddr_base + 0x200 > > and similar in the generic part. > > Partially because i didn't know the setexpr command and partially > because i wanted a minimally disruptive patch that can hopefully still > make it for 2015.4. For the first part I forgot it existed until this morning so that's OK :) > I think doing the above would also require tweaking the distro_boot_cmd > code to integrate it nicely. I'm agreeable to taking this now to fix things if we promise to clean it up ASAP after the release (since we can do that without breaking the visible portion I think). -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/5 v2] dm: ls1021a: Bring in ls1021a dts files from linux kernel
On 25 March 2015 at 06:23, Haikun Wang wrote: > From: haikun > > Bring in required device tree files for ls1021a from Linux. > These are initially unchanged and have a number of pieces not needed by > U-Boot. > > Signed-off-by: Haikun Wang > --- > > Changes in v2: > - Use CONFIG_LS102XA in arch/arm/dts/Makefile > > Changes in v1: None > > arch/arm/dts/Makefile| 3 + > arch/arm/dts/ls1021a-qds.dts | 201 +++ > arch/arm/dts/ls1021a-twr.dts | 88 ++ > arch/arm/dts/ls1021a.dtsi| 370 > +++ > 4 files changed, 662 insertions(+) > create mode 100644 arch/arm/dts/ls1021a-qds.dts > create mode 100644 arch/arm/dts/ls1021a-twr.dts > create mode 100644 arch/arm/dts/ls1021a.dtsi Acked-by: Simon Glass ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3] arm: mx5: Add support for USB armory board
Hi Stefano, On Wed, Mar 25, 2015 at 09:48:36AM +0100, Stefano Babic wrote: > Hi Andrej, > > On 24/03/2015 14:26, and...@inversepath.com wrote: > > From: Andrej Rosano > > > > Add support for Inverse Path USB armory board, an open source > > flash-drive sized computer based on Freescale i.MX53 SoC. > > > > http://inversepath.com/usbarmory > > > > Signed-off-by: Andrej Rosano > > Cc: Stefano Babic > > Cc: Chris Kuethe > > Cc: Fabio Estevam > > Cc: Vagrant Cascadian > > --- > > Changes for v3: > > - Add config_distro support > > > > Changes for v2: > > - Fix double print_cpuinfo() call > > - Fix CONFIG_BOOTCOMMAND typo > > - Fix CONFIG_SYS_FSL_ESDHC_NUM to 1 > > > > arch/arm/Kconfig |5 + > > board/inversepath/usbarmory/Kconfig | 15 + > > board/inversepath/usbarmory/MAINTAINERS |6 + > > board/inversepath/usbarmory/Makefile | 10 + > > board/inversepath/usbarmory/imximage.cfg | 82 ++ > > board/inversepath/usbarmory/usbarmory.c | 439 > > ++ > > configs/usbarmory_defconfig |3 + > > include/configs/usbarmory.h | 127 + > > 8 files changed, 687 insertions(+) > > create mode 100644 board/inversepath/usbarmory/Kconfig > > create mode 100644 board/inversepath/usbarmory/MAINTAINERS > > create mode 100644 board/inversepath/usbarmory/Makefile > > create mode 100644 board/inversepath/usbarmory/imximage.cfg > > create mode 100644 board/inversepath/usbarmory/usbarmory.c > > create mode 100644 configs/usbarmory_defconfig > > create mode 100644 include/configs/usbarmory.h > > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > > index b9ebee1..a490084 100644 > > --- a/arch/arm/Kconfig > > +++ b/arch/arm/Kconfig > > @@ -462,6 +462,10 @@ config TARGET_MX53SMD > > bool "Support mx53smd" > > select CPU_V7 > > > > +config TARGET_USBARMORY > > + bool "Support USB armory" > > + select CPU_V7 > > + > > I recently merged Boris Brezillon's patches to move new boards outside > arm/Kconfig. Patches were related to MX6, but the same mechanism can be > reused for MX5/MX53. It should be better to have the same and bew boards > should not change arm/Kconfig. That generates conflicts by merging > different architecture. > > Can you take a look at it and move USB armory to that approach ? Sure. > > > > config TARGET_MX51_EFIKAMX > > bool "Support mx51_efikamx" > > select CPU_V7 > > @@ -819,6 +823,7 @@ source "board/h2200/Kconfig" > > source "board/hale/tt01/Kconfig" > > source "board/icpdas/lp8x4x/Kconfig" > > source "board/imx31_phycore/Kconfig" > > +source "board/inversepath/usbarmory/Kconfig" > > source "board/isee/igep0033/Kconfig" > > source "board/jornada/Kconfig" > > source "board/karo/tx25/Kconfig" > > diff --git a/board/inversepath/usbarmory/Kconfig > > b/board/inversepath/usbarmory/Kconfig > > new file mode 100644 > > index 000..254b6c9 > > --- /dev/null > > +++ b/board/inversepath/usbarmory/Kconfig > > @@ -0,0 +1,15 @@ > > +if TARGET_USBARMORY > > + > > +config SYS_BOARD > > + default "usbarmory" > > + > > +config SYS_VENDOR > > + default "inversepath" > > + > > +config SYS_SOC > > + default "mx5" > > + > > +config SYS_CONFIG_NAME > > + default "usbarmory" > > + > > +endif > > diff --git a/board/inversepath/usbarmory/MAINTAINERS > > b/board/inversepath/usbarmory/MAINTAINERS > > new file mode 100644 > > index 000..71a3dd4 > > --- /dev/null > > +++ b/board/inversepath/usbarmory/MAINTAINERS > > @@ -0,0 +1,6 @@ > > +USBARMORY BOARD > > +M: Andrej Rosano > > +S: Maintained > > +F: board/inversepath/usbarmory/ > > +F: include/configs/usbarmory.h > > +F: configs/usbarmory_defconfig > > diff --git a/board/inversepath/usbarmory/Makefile > > b/board/inversepath/usbarmory/Makefile > > new file mode 100644 > > index 000..9b8bd80 > > --- /dev/null > > +++ b/board/inversepath/usbarmory/Makefile > > @@ -0,0 +1,10 @@ > > +# > > +# USB armory MkI board Makefile > > +# http://inversepath.com/usbarmory > > +# > > +# Copyright (C) 2015, Inverse Path > > +# Andrej Rosano > > +# > > +# SPDX-License-Identifier:|GPL-2.0+ > > + > > +obj-y := usbarmory.o > > diff --git a/board/inversepath/usbarmory/imximage.cfg > > b/board/inversepath/usbarmory/imximage.cfg > > new file mode 100644 > > index 000..392d2f9 > > --- /dev/null > > +++ b/board/inversepath/usbarmory/imximage.cfg > > @@ -0,0 +1,82 @@ > > +/* > > + * USB armory MkI board imximage configuration > > + * http://inversepath.com/usbarmory > > + * > > + * Copyright (C) 2015, Inverse Path > > + * Andrej Rosano > > + * > > + * SPDX-License-Identifier:|GPL-2.0+ > > + */ > > + > > +IMAGE_VERSION 2 > > +BOOT_FROM sd > > + > > + > > +/* IOMUX */ > > + > > +DATA 4 0x53fa86f4 0x /* GRP_DDRMODE_CTL */ > > +DATA 4 0x53fa8714 0x /* GRP_DDRMODE */ > > +DATA 4 0x53fa86fc 0x /* GRP_DDRPKE */ > > +DATA 4 0x53fa8724 0x0400 /* GRP_DDR_TYPE*/ > > + > >
Re: [U-Boot] [PATCH v3] arm: mx5: Add support for USB armory board
On 2015-03-25, Stefano Babic wrote: >> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig >> index b9ebee1..a490084 100644 >> --- a/arch/arm/Kconfig >> +++ b/arch/arm/Kconfig >> @@ -462,6 +462,10 @@ config TARGET_MX53SMD >> bool "Support mx53smd" >> select CPU_V7 >> >> +config TARGET_USBARMORY >> +bool "Support USB armory" >> +select CPU_V7 >> + > > I recently merged Boris Brezillon's patches to move new boards outside > arm/Kconfig. Patches were related to MX6, but the same mechanism can be > reused for MX5/MX53. It should be better to have the same and bew boards > should not change arm/Kconfig. That generates conflicts by merging > different architecture. > > Can you take a look at it and move USB armory to that approach ? I've got an updated patch for this based on u-boot-imx; would you like a separate patch for the mx5 changes, or should it be included as part of the usbarmory series? live well, vagrant signature.asc Description: PGP signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] config: peach: Correct memory layout environment settings
On Wed, 2015-03-25 at 12:58 -0400, Tom Rini wrote: > On Wed, Mar 25, 2015 at 09:32:45AM +0100, Sjoerd Simons wrote: > > On Wed, 2015-03-25 at 01:11 -0400, Tom Rini wrote: > > > On Mon, Mar 23, 2015 at 03:04:48PM -0600, Simon Glass wrote: > > > > Hi Sjoerd, > > > > > > > > On 12 March 2015 at 15:33, Sjoerd Simons > > > > wrote: > > > > > The peach boards have their SDRAM start address at 0x2000 instead > > > > > of > > > > > 0x4000 which seems common for all other exynos5 based boards. This > > > > > means the layout set in exynos5-common.h causes the kernel be loaded > > > > > more then 128MB (at 0x4200) away from memory start which breaks > > > > > booting kernels with CONFIG_AUTO_ZRELADDR > > > > > > > > > > Define a custom MEM_LAYOUT_ENV_SETTINGS for both peach boards which > > > > > uses > > > > > the same offsets from start of memory as the common exynos5 settings. > > > > > > > > > > This fixes booting via bootz and PXE > > > > > > > > > > Signed-off-by: Sjoerd Simons > > > > > --- > > > > > include/configs/peach-pi.h | 8 > > > > > include/configs/peach-pit.h | 8 > > > > > 2 files changed, 16 insertions(+) > > > > > > > > > > diff --git a/include/configs/peach-pi.h b/include/configs/peach-pi.h > > > > > index f04f061..e3cb09e 100644 > > > > > --- a/include/configs/peach-pi.h > > > > > +++ b/include/configs/peach-pi.h > > > > > @@ -16,6 +16,14 @@ > > > > > #define CONFIG_ENV_OFFSET (FLASH_SIZE - CONFIG_BL2_SIZE) > > > > > #define CONFIG_SPI_BOOTING > > > > > > > > > > +#define MEM_LAYOUT_ENV_SETTINGS \ > > > > > + "bootm_size=0x1000\0" \ > > > > > + "kernel_addr_r=0x2200\0" \ > > > > > + "fdt_addr_r=0x2300\0" \ > > > > > + "ramdisk_addr_r=0x2330\0" \ > > > > > + "scriptaddr=0x3000\0" \ > > > > > + "pxefile_addr_r=0x3100\0" > > > > > + > > > > > #include > > > > > #include > > > > > > > > > > diff --git a/include/configs/peach-pit.h b/include/configs/peach-pit.h > > > > > index b5efbdc..3ee42ef 100644 > > > > > --- a/include/configs/peach-pit.h > > > > > +++ b/include/configs/peach-pit.h > > > > > @@ -16,6 +16,14 @@ > > > > > #define CONFIG_ENV_OFFSET (FLASH_SIZE - CONFIG_BL2_SIZE) > > > > > #define CONFIG_SPI_BOOTING > > > > > > > > > > +#define MEM_LAYOUT_ENV_SETTINGS \ > > > > > + "bootm_size=0x1000\0" \ > > > > > + "kernel_addr_r=0x2200\0" \ > > > > > + "fdt_addr_r=0x2300\0" \ > > > > > + "ramdisk_addr_r=0x2330\0" \ > > > > > + "scriptaddr=0x3000\0" \ > > > > > + "pxefile_addr_r=0x3100\0" > > > > > + > > > > > #include > > > > > #include > > > > > > > > It would be great if we could have this in the device tree. > > > > > > I understand what you're thinking but this is environment. And really > > > this is not board specific, this is SoC family specific which is why the > > > similar part for TI stuff is in ti_armv7_common.h :) > > > > Exynos 5 has the same in exynos5-common.h, however for whatever reason > > the peach pi/pit boards are different then other exynos board supported > > by u-boot thusfar. So in this case, this information _is_ board specific > > not platform specific. > > Oh I missed that early on, sorry. But... > > Why not change things around a bit to enable CONFIG_CMD_SETEXPR and then > have MEM_LAYOUT_ENV_SETTINGS just set the exynos5_ddr_base and then > setexpr kernel_addr_r $exynos5_ddr_base + 0x200 > and similar in the generic part. Partially because i didn't know the setexpr command and partially because i wanted a minimally disruptive patch that can hopefully still make it for 2015.4. I think doing the above would also require tweaking the distro_boot_cmd code to integrate it nicely. > > But even in case of including it in device tree, a default/common > > setting could go into the platforms dtsi with board-specific overrides > > as needed. > > > > One thing i have wondered though, looking at the various boards > > specifying the various memory layour addresses. They all end up being > > relatively similar offset to the base memory address, which makes me > > think it may be possible to calculate these values in the initialisation > > code rather then having to hardcode it in the environment. However, even > > if that's a sensible thing, something for later :) > > ... Yes, we should then take what I just did above and make it even > further wide-spread among boards where we have more than ~512MB DDR or > so :) Sounds like a plan. -- Sjoerd Simons Collabora Ltd. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 15/80] dm: usb: Drop the legacy USB init sequence
This CONFIG is not used anywhere in U-Boot, so drop it. Signed-off-by: Simon Glass --- Changes in v2: None common/usb.c | 26 -- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/common/usb.c b/common/usb.c index f87c6a5..330e6a2 100644 --- a/common/usb.c +++ b/common/usb.c @@ -899,26 +899,8 @@ int usb_new_device(struct usb_device *dev) addr = dev->devnum; dev->devnum = 0; -#ifdef CONFIG_LEGACY_USB_INIT_SEQ - /* this is the old and known way of initializing devices, it is -* different than what Windows and Linux are doing. Windows and Linux -* both retrieve 64 bytes while reading the device descriptor -* Several USB stick devices report ERR: CTL_TIMEOUT, caused by an -* invalid header while reading 8 bytes as device descriptor. */ - dev->descriptor.bMaxPacketSize0 = 8;/* Start off at 8 bytes */ - dev->maxpacketsize = PACKET_SIZE_8; - dev->epmaxpacketin[0] = 8; - dev->epmaxpacketout[0] = 8; - - err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, tmpbuf, 8); - if (err < 8) { - printf("\n USB device not responding, " \ - "giving up (status=%lX)\n", dev->status); - return 1; - } - memcpy(&dev->descriptor, tmpbuf, 8); -#else - /* This is a Windows scheme of initialization sequence, with double + /* +* This is a Windows scheme of initialization sequence, with double * reset of the device (Linux uses the same sequence) * Some equipment is said to work only with such init sequence; this * patch is based on the work by Alan Stern: @@ -929,7 +911,8 @@ int usb_new_device(struct usb_device *dev) struct usb_device *parent = dev->parent; unsigned short portstatus; - /* send 64-byte GET-DEVICE-DESCRIPTOR request. Since the descriptor is + /* +* send 64-byte GET-DEVICE-DESCRIPTOR request. Since the descriptor is * only 18 bytes long, this will terminate with a short packet. But if * the maxpacket size is 8 or 16 the device may be waiting to transmit * some more, or keeps on retransmitting the 8 byte header. */ @@ -972,7 +955,6 @@ int usb_new_device(struct usb_device *dev) } else { usb_reset_root_port(); } -#endif dev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0; dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0; -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 22/80] dm: usb: Add driver model support for hubs
Adjust the existing hub code to support driver model, and add a USB driver for hubs. Signed-off-by: Simon Glass --- Changes in v2: None common/usb_hub.c | 94 +++--- include/dm/uclass-id.h | 1 + 2 files changed, 91 insertions(+), 4 deletions(-) diff --git a/common/usb_hub.c b/common/usb_hub.c index cc22f4b..6933015 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -24,12 +24,16 @@ #include #include +#include #include #include #include #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; #include #ifdef CONFIG_4xx @@ -38,6 +42,7 @@ #define USB_BUFSIZ 512 +/* 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; @@ -148,7 +153,12 @@ int legacy_hub_port_reset(struct usb_device *dev, int port, ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); unsigned short portstatus, portchange; - debug("hub_port_reset: resetting port %d...\n", port); +#ifdef CONFIG_DM_USB + debug("%s: resetting '%s' port %d...\n", __func__, dev->dev->name, + port + 1); +#else + debug("%s: resetting port %d...\n", __func__, port + 1); +#endif for (tries = 0; tries < MAX_TRIES; tries++) { usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET); @@ -206,10 +216,17 @@ 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_parentdata(dev); + + return legacy_hub_port_reset(udev, port, portstat); +} +#endif int usb_hub_port_connect_change(struct usb_device *dev, int port) { - struct usb_device *usb; ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); unsigned short portstatus; int ret, speed; @@ -232,7 +249,8 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port) /* Disconnect any existing devices under this port */ if (((!(portstatus & USB_PORT_STAT_CONNECTION)) && -(!(portstatus & USB_PORT_STAT_ENABLE))) || (dev->children[port])) { +(!(portstatus & USB_PORT_STAT_ENABLE))) || + usb_device_has_child_on_port(dev, port)) { debug("usb_disconnect(&hub->children[port]);\n"); /* Return now if nothing is connected */ if (!(portstatus & USB_PORT_STAT_CONNECTION)) @@ -264,6 +282,13 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port) break; } +#ifdef CONFIG_DM_USB + struct udevice *child; + + ret = usb_scan_device(dev->dev, port + 1, speed, &child); +#else + struct usb_device *usb; + ret = usb_alloc_new_device(dev->controller, &usb); if (ret) { printf("cannot create new device: ret=%d", ret); @@ -280,6 +305,9 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port) /* Woops, disable the port */ usb_free_device(dev->controller); dev->children[port] = NULL; + } +#endif + if (ret < 0) { debug("hub: disabling port %d\n", port + 1); usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_ENABLE); } @@ -427,7 +455,11 @@ static int usb_hub_configure(struct usb_device *dev) int ret; ulong start = get_timer(0); +#ifdef CONFIG_DM_USB + debug("\n\nScanning '%s' port %d\n", dev->dev->name, i + 1); +#else debug("\n\nScanning port %d\n", i + 1); +#endif /* * Wait for (whichever finishes first) * - A maximum of 10 seconds @@ -477,7 +509,7 @@ static int usb_hub_configure(struct usb_device *dev) * them again. Works at least with mouse driver */ if (!(portstatus & USB_PORT_STAT_ENABLE) && (portstatus & USB_PORT_STAT_CONNECTION) && -((dev->children[i]))) { +usb_device_has_child_on_port(dev, i)) { debug("already running port %i " \ "disabled by hub (EMI?), " \ "re-enabling...\n", i + 1); @@ -558,3 +590,57 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) ret = usb_hub_configure(dev); return ret; } + +#ifdef CONFIG_DM_USB +int usb_hub_scan(struct udevice *hub) +{ + struct usb_device *udev = dev_get_parentdata(hub); + + return usb_hub_configure(udev); +} + +static int usb_hub_post_bind(struct udevice *dev) +{ + /* Scan the bus for devices */ + return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); +} + +static int usb_hub_post_probe(struct udevice *de
[U-Boot] [PATCH v2 10/80] dm: gpio: Add an implementation for gpio_get_number()
This has a prototype but no implementation. It returns the global GPIO number given a gpio_desc. It is useful for debugging in some cases. Signed-off-by: Simon Glass --- Changes in v2: None drivers/gpio/gpio-uclass.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index b6e1058..380366f 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -689,6 +689,18 @@ static int gpio_renumber(struct udevice *removed_dev) return 0; } +int gpio_get_number(struct gpio_desc *desc) +{ + struct udevice *dev = desc->dev; + struct gpio_dev_priv *uc_priv; + + if (!dev) + return -1; + uc_priv = dev->uclass_priv; + + return uc_priv->gpio_base + desc->offset; +} + static int gpio_post_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 54/80] dm: usb: dts: sandbox: Add some sample USB devices to sandbox
These allow basic testing of the USB functionality within sandbox. Signed-off-by: Simon Glass --- Changes in v2: None arch/sandbox/dts/sandbox.dts | 40 1 file changed, 40 insertions(+) diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index 7d050d9..03b540c 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -1,5 +1,7 @@ /dts-v1/; +#define USB_CLASS_HUB 9 + / { #address-cells = <1>; #size-cells = <1>; @@ -219,4 +221,42 @@ reg = <0x9000 0x1000>; host-raw-interface = "lo"; }; + + usb@0 { + compatible = "sandbox,usb"; + status = "disabled"; + hub { + compatible = "sandbox,usb-hub"; + #address-cells = <1>; + #size-cells = <0>; + flash-stick { + reg = <0>; + compatible = "sandbox,usb-flash"; + }; + }; + }; + + usb@1 { + compatible = "sandbox,usb"; + hub { + compatible = "usb-hub"; + usb,device-class = ; + hub-emul { + compatible = "sandbox,usb-hub"; + #address-cells = <1>; + #size-cells = <0>; + flash-stick { + reg = <0>; + compatible = "sandbox,usb-flash"; + sandbox,filepath = "flash.bin"; + }; + }; + }; + }; + + usb@2 { + compatible = "sandbox,usb"; + status = "disabled"; + }; + }; -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 52/80] dm: usb: sandbox: Add an emulator for USB hub emulation
All USB controllers need a root hub. Add a sandbox emulation for this so that we can add USB devices to sandbox. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/emul/Makefile | 1 + drivers/usb/emul/sandbox_hub.c | 303 + include/usb_defs.h | 3 + 3 files changed, 307 insertions(+) create mode 100644 drivers/usb/emul/sandbox_hub.c diff --git a/drivers/usb/emul/Makefile b/drivers/usb/emul/Makefile index 1d5acce..8fd83d5 100644 --- a/drivers/usb/emul/Makefile +++ b/drivers/usb/emul/Makefile @@ -6,4 +6,5 @@ # obj-$(CONFIG_USB_EMUL) += sandbox_flash.o +obj-$(CONFIG_USB_EMUL) += sandbox_hub.o obj-$(CONFIG_USB_EMUL) += usb-emul-uclass.o diff --git a/drivers/usb/emul/sandbox_hub.c b/drivers/usb/emul/sandbox_hub.c new file mode 100644 index 000..280c708 --- /dev/null +++ b/drivers/usb/emul/sandbox_hub.c @@ -0,0 +1,303 @@ +/* + * (C) Copyright 2015 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* We only support up to 8 */ +#define SANDBOX_NUM_PORTS 2 + +struct sandbox_hub_platdata { + struct usb_dev_platdata plat; + int port; /* Port number (numbered from 0) */ +}; + +enum { + STRING_MANUFACTURER = 1, + STRING_PRODUCT, + STRING_SERIAL, + + STRING_count, +}; + +static struct usb_string hub_strings[] = { + {STRING_MANUFACTURER, "sandbox"}, + {STRING_PRODUCT,"hub"}, + {STRING_SERIAL, "2345"}, +}; + +static struct usb_device_descriptor hub_device_desc = { + .bLength = sizeof(hub_device_desc), + .bDescriptorType = USB_DT_DEVICE, + + .bcdUSB = __constant_cpu_to_le16(0x0200), + + .bDeviceClass = USB_CLASS_HUB, + .bDeviceSubClass = 0, + .bDeviceProtocol = 0, + + .idVendor = __constant_cpu_to_le16(0x1234), + .idProduct =__constant_cpu_to_le16(0x5678), + .iManufacturer =STRING_MANUFACTURER, + .iProduct = STRING_PRODUCT, + .iSerialNumber =STRING_SERIAL, + .bNumConfigurations = 1, +}; + +static struct usb_config_descriptor hub_config1 = { + .bLength= sizeof(hub_config1), + .bDescriptorType= USB_DT_CONFIG, + + /* wTotalLength is set up by usb-emul-uclass */ + .bNumInterfaces = 1, + .bConfigurationValue= 0, + .iConfiguration = 0, + .bmAttributes = 1 << 7, + .bMaxPower = 50, +}; + +static struct usb_interface_descriptor hub_interface0 = { + .bLength= sizeof(hub_interface0), + .bDescriptorType= USB_DT_INTERFACE, + + .bInterfaceNumber = 0, + .bAlternateSetting = 0, + .bNumEndpoints = 1, + .bInterfaceClass= USB_CLASS_HUB, + .bInterfaceSubClass = 0, + .bInterfaceProtocol = US_PR_CB, + .iInterface = 0, +}; + +static struct usb_endpoint_descriptor hub_endpoint0_in = { + .bLength= USB_DT_ENDPOINT_SIZE, + .bDescriptorType= USB_DT_ENDPOINT, + + .bEndpointAddress = 1 | USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_INT, + .wMaxPacketSize = __constant_cpu_to_le16(1024), + .bInterval = 0, +}; + +static struct usb_hub_descriptor hub_desc = { + .bLength= sizeof(hub_desc), + .bDescriptorType= USB_DT_HUB, + .bNbrPorts = SANDBOX_NUM_PORTS, + .wHubCharacteristics= __constant_cpu_to_le16(1 << 0 | 1 << 3 | + 1 << 7), + .bPwrOn2PwrGood = 2, + .bHubContrCurrent = 5, + .DeviceRemovable= {0, 0xff}, /* all ports removeable */ +#if SANDBOX_NUM_PORTS > 8 +#error "This code sets up an incorrect mask" +#endif +}; + +static void *hub_desc_list[] = { + &hub_device_desc, + &hub_config1, + &hub_interface0, + &hub_endpoint0_in, + &hub_desc, + NULL, +}; + +struct sandbox_hub_priv { + int status[SANDBOX_NUM_PORTS]; + int change[SANDBOX_NUM_PORTS]; +}; + +static struct udevice *hub_find_device(struct udevice *hub, int port) +{ + struct udevice *dev; + + for (device_find_first_child(hub, &dev); +dev; +device_find_next_child(&dev)) { + struct sandbox_hub_platdata *plat; + + plat = dev_get_parent_platdata(dev); + if (plat->port == port) + return dev; + } + + return NULL; +} + +static int clrset_post_state(struct udevice *hub, int port, int clear, int set) +{ + struct sandbox_hub_priv *priv = dev_get_priv(hub); + int *status = &priv->status[
[U-Boot] [PATCH v2 38/80] dm: usb: Refactor EHCI init
Move the bulk of the code in usb_lowlevel_init() into a separate function which will also be used by driver model. Keep the CONFIG options out of this function by providing a tweak flag for Faraday. We need to avoid using CONFIG options in driver model code where possible, since it makes it impossible to use multiple controllers in that code where they have different options. The CONFIG_EHCI_HCD_INIT_AFTER_RESET option is also kept out of the common init function. With driver model the controller will be able to perform this extra init itself after registering with the EHCI layer. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-hcd.c | 117 +--- drivers/usb/host/ehci.h | 6 +++ 2 files changed, 72 insertions(+), 51 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d01e17e..3fa6fe2 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -945,41 +945,19 @@ void *ehci_get_controller_priv(int index) return ehcic[index].priv; } -int usb_lowlevel_stop(int index) -{ - ehci_shutdown(&ehcic[index]); - return ehci_hcd_stop(index); -} - -int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) +static int ehci_common_init(struct ehci_ctrl *ctrl, uint tweaks) { - uint32_t reg; - uint32_t cmd; struct QH *qh_list; struct QH *periodic; + uint32_t reg; + uint32_t cmd; int i; - int rc; - - rc = ehci_hcd_init(index, init, &ehcic[index].hccr, &ehcic[index].hcor); - if (rc) - return rc; - if (init == USB_INIT_DEVICE) - goto done; - - /* EHCI spec section 4.1 */ - if (ehci_reset(index)) - return -1; -#if defined(CONFIG_EHCI_HCD_INIT_AFTER_RESET) - rc = ehci_hcd_init(index, init, &ehcic[index].hccr, &ehcic[index].hcor); - if (rc) - return rc; -#endif /* Set the high address word (aka segment) for 64-bit controller */ - if (ehci_readl(&ehcic[index].hccr->cr_hccparams) & 1) - ehci_writel(&ehcic[index].hcor->or_ctrldssegment, 0); + if (ehci_readl(&ctrl->hccr->cr_hccparams) & 1) + ehci_writel(&ctrl->hcor->or_ctrldssegment, 0); - qh_list = &ehcic[index].qh_list; + qh_list = &ctrl->qh_list; /* Set head of reclaim list */ memset(qh_list, 0, sizeof(*qh_list)); @@ -995,14 +973,14 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) ALIGN_END_ADDR(struct QH, qh_list, 1)); /* Set async. queue head pointer. */ - ehci_writel(&ehcic[index].hcor->or_asynclistaddr, (uint32_t)qh_list); + ehci_writel(&ctrl->hcor->or_asynclistaddr, (uint32_t)qh_list); /* * Set up periodic list * Step 1: Parent QH for all periodic transfers. */ - ehcic[index].periodic_schedules = 0; - periodic = &ehcic[index].periodic_queue; + ctrl->periodic_schedules = 0; + periodic = &ctrl->periodic_queue; memset(periodic, 0, sizeof(*periodic)); periodic->qh_link = cpu_to_hc32(QH_LINK_TERMINATE); periodic->qh_overlay.qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); @@ -1020,25 +998,25 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) * Split Transactions will be spread across microframes using * S-mask and C-mask. */ - if (ehcic[index].periodic_list == NULL) - ehcic[index].periodic_list = memalign(4096, 1024 * 4); + if (ctrl->periodic_list == NULL) + ctrl->periodic_list = memalign(4096, 1024 * 4); - if (!ehcic[index].periodic_list) + if (!ctrl->periodic_list) return -ENOMEM; for (i = 0; i < 1024; i++) { - ehcic[index].periodic_list[i] = cpu_to_hc32((uint32_t)periodic + ctrl->periodic_list[i] = cpu_to_hc32((uint32_t)periodic | QH_LINK_TYPE_QH); } - flush_dcache_range((uint32_t)ehcic[index].periodic_list, - ALIGN_END_ADDR(uint32_t, ehcic[index].periodic_list, + flush_dcache_range((uint32_t)ctrl->periodic_list, + ALIGN_END_ADDR(uint32_t, ctrl->periodic_list, 1024)); /* Set periodic list base address */ - ehci_writel(&ehcic[index].hcor->or_periodiclistbase, - (uint32_t)ehcic[index].periodic_list); + ehci_writel(&ctrl->hcor->or_periodiclistbase, + (uint32_t)ctrl->periodic_list); - reg = ehci_readl(&ehcic[index].hccr->cr_hcsparams); + reg = ehci_readl(&ctrl->hccr->cr_hcsparams); descriptor.hub.bNbrPorts = HCS_N_PORTS(reg); debug("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts); /* Port
[U-Boot] [PATCH v2 45/80] dm: usb: Split out the keyboard probe into its own function
Before adding driver model support, split out code from this over-long function. Signed-off-by: Simon Glass --- Changes in v2: None common/usb_kbd.c | 89 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index ecc3085..e02529f 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -471,59 +471,72 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum) return 1; } +static int probe_usb_keyboard(struct usb_device *dev) +{ + char *stdinname; + struct stdio_dev usb_kbd_dev; + int error; + + /* Try probing the keyboard */ + if (usb_kbd_probe(dev, 0) != 1) + return -ENOENT; + + /* Register the keyboard */ + debug("USB KBD: register.\n"); + memset(&usb_kbd_dev, 0, sizeof(struct stdio_dev)); + strcpy(usb_kbd_dev.name, DEVNAME); + usb_kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; + usb_kbd_dev.getc = usb_kbd_getc; + usb_kbd_dev.tstc = usb_kbd_testc; + usb_kbd_dev.priv = (void *)dev; + error = stdio_register(&usb_kbd_dev); + if (error) + return error; + + stdinname = getenv("stdin"); +#ifdef CONFIG_CONSOLE_MUX + error = iomux_doenv(stdin, stdinname); + if (error) + return error; +#else + /* Check if this is the standard input device. */ + if (strcmp(stdinname, DEVNAME)) + return 1; + + /* Reassign the console */ + if (overwrite_console()) + return 1; + + error = console_assign(stdin, DEVNAME); + if (error) + return error; +#endif + + return 0; +} + /* Search for keyboard and register it if found. */ int drv_usb_kbd_init(void) { - struct stdio_dev usb_kbd_dev; - struct usb_device *dev; - char *stdinname = getenv("stdin"); int error, i; - /* Scan all USB Devices */ + debug("%s: Probing for keyboard\n", __func__);/* Scan all USB Devices */ for (i = 0; i < USB_MAX_DEVICE; i++) { + struct usb_device *dev; + /* Get USB device. */ dev = usb_get_dev_index(i); if (!dev) - return -1; + break; if (dev->devnum == -1) continue; - /* Try probing the keyboard */ - if (usb_kbd_probe(dev, 0) != 1) - continue; - - /* Register the keyboard */ - debug("USB KBD: register.\n"); - memset(&usb_kbd_dev, 0, sizeof(struct stdio_dev)); - strcpy(usb_kbd_dev.name, DEVNAME); - usb_kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; - usb_kbd_dev.getc = usb_kbd_getc; - usb_kbd_dev.tstc = usb_kbd_testc; - usb_kbd_dev.priv = (void *)dev; - error = stdio_register(&usb_kbd_dev); - if (error) - return error; - -#ifdef CONFIG_CONSOLE_MUX - error = iomux_doenv(stdin, stdinname); - if (error) - return error; -#else - /* Check if this is the standard input device. */ - if (strcmp(stdinname, DEVNAME)) - return 1; - - /* Reassign the console */ - if (overwrite_console()) + error = probe_usb_keyboard(dev); + if (!error) return 1; - - error = console_assign(stdin, DEVNAME); - if (error) + if (error && error != -ENOENT) return error; -#endif - - return 1; } /* No USB Keyboard found */ -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 29/80] dm: usb: Move all the EHCI weak functions together and declare them
Put these at the top of the file so they are in one place. Also add function prototypes to the header file to avoid call site mismatches. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-hcd.c | 22 +++--- drivers/usb/host/ehci.h | 6 ++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f1fb190..10a0671 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -143,6 +143,17 @@ __weak void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg) mdelay(50); } +__weak uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port) +{ + if (port < 0 || port >= CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) { + /* Printing the message would cause a scan failure! */ + debug("The request port(%u) is not configured\n", port); + return NULL; + } + + return (uint32_t *)&hcor->or_portsc[port]; +} + static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec) { uint32_t result; @@ -649,17 +660,6 @@ fail: return -1; } -__weak uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port) -{ - if (port < 0 || port >= CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) { - /* Printing the message would cause a scan failure! */ - debug("The request port(%u) is not configured\n", port); - return NULL; - } - - return (uint32_t *)&hcor->or_portsc[port]; -} - int ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer, int length, struct devrequest *req) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 79aecd4..3e5427a 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -250,6 +250,12 @@ struct ehci_ctrl { int ntds; }; +/* Weak functions that drivers can override */ +int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg); +void ehci_set_usbmode(int index); +void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg); +uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port); + /* Low level init functions */ int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 24/80] dm: usb: Fix type problems in usb_stor_get_info()
This function assumes that unsigned long is 32-bits wide, but it is not on 64-bit machines. Use the correct type, and add a few debug() lines also. Signed-off-by: Simon Glass --- Changes in v2: None common/usb_storage.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/common/usb_storage.c b/common/usb_storage.c index 590408a..80ed14a 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -1178,6 +1178,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, iface->desc.bInterfaceClass != USB_CLASS_MASS_STORAGE || iface->desc.bInterfaceSubClass < US_SC_MIN || iface->desc.bInterfaceSubClass > US_SC_MAX) { + debug("Not mass storage\n"); /* if it's not a mass storage, we go no further */ return 0; } @@ -1293,9 +1294,9 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, block_dev_desc_t *dev_desc) { unsigned char perq, modi; - ALLOC_CACHE_ALIGN_BUFFER(unsigned long, cap, 2); + ALLOC_CACHE_ALIGN_BUFFER(uint32_t, cap, 2); ALLOC_CACHE_ALIGN_BUFFER(unsigned char, usb_stor_buf, 36); - unsigned long *capacity, *blksz; + uint32_t *capacity, *blksz; ccb *pccb = &usb_ccb; pccb->pdata = usb_stor_buf; @@ -1304,8 +1305,10 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, pccb->lun = dev_desc->lun; debug(" address %d\n", dev_desc->target); - if (usb_inquiry(pccb, ss)) + if (usb_inquiry(pccb, ss)) { + debug("%s: usb_inquiry() failed\n", __func__); return -1; + } perq = usb_stor_buf[0]; modi = usb_stor_buf[1]; @@ -1315,6 +1318,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, * they would not respond to test_unit_ready . */ if (((perq & 0x1f) == 0x1f) || ((perq & 0x1f) == 0x0d)) { + debug("%s: unknown/unsupported device\n", __func__); return 0; } if ((modi&0x80) == 0x80) { @@ -1352,19 +1356,19 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, cap[1] = 0x200; } ss->flags &= ~USB_READY; - debug("Read Capacity returns: 0x%lx, 0x%lx\n", cap[0], cap[1]); + debug("Read Capacity returns: 0x%x, 0x%x\n", cap[0], cap[1]); #if 0 if (cap[0] > (0x20 * 10)) /* greater than 10 GByte */ cap[0] >>= 16; #endif - cap[0] = cpu_to_be32(cap[0]); - cap[1] = cpu_to_be32(cap[1]); + cap[0] = be32_to_cpu(cap[0]); + cap[1] = be32_to_cpu(cap[1]); /* this assumes bigendian! */ cap[0] += 1; capacity = &cap[0]; blksz = &cap[1]; - debug("Capacity = 0x%lx, blocksz = 0x%lx\n", *capacity, *blksz); + debug("Capacity = 0x%x, blocksz = 0x%x\n", *capacity, *blksz); dev_desc->lba = *capacity; dev_desc->blksz = *blksz; dev_desc->log2blksz = LOG2(dev_desc->blksz); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 12/80] dm: usb: Adjust usb command to prepare for driver model
Use 'udev' instead of 'dev' in a few places, reserving 'dev' for driver model's struct udevice. Also adjust the code in a few minor ways to make it easier to plumb in driver model. Signed-off-by: Simon Glass --- Changes in v2: None common/cmd_usb.c | 51 +-- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 27813f0..085802b 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -254,15 +254,15 @@ static void usb_display_config(struct usb_device *dev) static struct usb_device *usb_find_device(int devnum) { - struct usb_device *dev; + struct usb_device *udev; int d; for (d = 0; d < USB_MAX_DEVICE; d++) { - dev = usb_get_dev_index(d); - if (dev == NULL) + udev = usb_get_dev_index(d); + if (udev == NULL) return NULL; - if (dev->devnum == devnum) - return dev; + if (udev->devnum == devnum) + return udev; } return NULL; @@ -305,8 +305,8 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre) has_child = 1; } /* check if we are the last one */ - last_child = 1; - if (dev->parent != NULL) { + last_child = (dev->parent != NULL); + if (last_child) { for (i = 0; i < dev->parent->maxchild; i++) { /* search for children */ if (dev->parent->children[i] == dev) { @@ -324,7 +324,7 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre) } /* for all children of the parent */ printf("\b+-"); /* correct last child */ - if (last_child) + if (last_child && index) pre[index-1] = ' '; } /* if not root hub */ else @@ -355,7 +355,7 @@ static void usb_show_tree(struct usb_device *dev) { char preamble[32]; - memset(preamble, 0, 32); + memset(preamble, '\0', sizeof(preamble)); usb_show_tree_graph(dev, &preamble[0]); } @@ -466,9 +466,8 @@ static void do_usb_start(void) */ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - + struct usb_device *udev = NULL; int i; - struct usb_device *dev = NULL; extern char usb_started; #ifdef CONFIG_USB_STORAGE block_dev_desc_t *stor_dev; @@ -509,11 +508,11 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (strncmp(argv[1], "tree", 4) == 0) { puts("USB device tree:\n"); for (i = 0; i < USB_MAX_DEVICE; i++) { - dev = usb_get_dev_index(i); - if (dev == NULL) + udev = usb_get_dev_index(i); + if (udev == NULL) break; - if (dev->parent == NULL) - usb_show_tree(dev); + if (udev->parent == NULL) + usb_show_tree(udev); } return 0; } @@ -521,23 +520,23 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int d; if (argc == 2) { for (d = 0; d < USB_MAX_DEVICE; d++) { - dev = usb_get_dev_index(d); - if (dev == NULL) + udev = usb_get_dev_index(d); + if (udev == NULL) break; - usb_display_desc(dev); - usb_display_config(dev); + usb_display_desc(udev); + usb_display_config(udev); } return 0; } else { i = simple_strtoul(argv[2], NULL, 10); printf("config for device %d\n", i); - dev = usb_find_device(i); - if (dev == NULL) { + udev = usb_find_device(i); + if (udev == NULL) { printf("*** No device available ***\n"); return 0; } else { - usb_display_desc(dev); - usb_display_config(dev); + usb_display_desc(udev); + usb_display_config(udev); } } return 0; @@ -546,13 +545,13 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 5)
[U-Boot] [PATCH v2 64/80] dm: usb: xhci: Factor out common init/uninit
Since driver model will want to use most of the same code for XHCI init and uninit, put it in a separate function. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/xhci.c | 85 ++--- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 774c3e6..4d94618 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -936,33 +936,16 @@ static int _xhci_submit_control_msg(struct usb_device *udev, unsigned long pipe, return xhci_ctrl_tx(udev, pipe, setup, length, buffer); } -/** - * Intialises the XHCI host controller - * and allocates the necessary data structures - * - * @param indexindex to the host controller data structure - * @return pointer to the intialised controller - */ -int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) +static int xhci_lowlevel_init(struct xhci_ctrl *ctrl) { + struct xhci_hccr *hccr; + struct xhci_hcor *hcor; uint32_t val; uint32_t val2; uint32_t reg; - struct xhci_hccr *hccr; - struct xhci_hcor *hcor; - struct xhci_ctrl *ctrl; - - if (xhci_hcd_init(index, &hccr, (struct xhci_hcor **)&hcor) != 0) - return -ENODEV; - - if (xhci_reset(hcor) != 0) - return -ENODEV; - - ctrl = &xhcic[index]; - - ctrl->hccr = hccr; - ctrl->hcor = hcor; + hccr = ctrl->hccr; + hcor = ctrl->hcor; /* * Program the Number of Device Slots Enabled field in the CONFIG * register with the max value of slots the HC can handle. @@ -1004,7 +987,20 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) reg = HC_VERSION(xhci_readl(&hccr->cr_capbase)); printf("USB XHCI %x.%02x\n", reg >> 8, reg & 0xff); - *controller = &xhcic[index]; + return 0; +} + +static int xhci_lowlevel_stop(struct xhci_ctrl *ctrl) +{ + u32 temp; + + xhci_reset(ctrl->hcor); + + debug("// Disabling event ring interrupts\n"); + temp = xhci_readl(&ctrl->hcor->or_usbsts); + xhci_writel(&ctrl->hcor->or_usbsts, temp & ~STS_EINT); + temp = xhci_readl(&ctrl->ir_set->irq_pending); + xhci_writel(&ctrl->ir_set->irq_pending, ER_IRQ_DISABLE(temp)); return 0; } @@ -1023,6 +1019,38 @@ int submit_control_msg(struct usb_device *udev, unsigned long pipe, } /** + * Intialises the XHCI host controller + * and allocates the necessary data structures + * + * @param indexindex to the host controller data structure + * @return pointer to the intialised controller + */ +int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) +{ + struct xhci_hccr *hccr; + struct xhci_hcor *hcor; + struct xhci_ctrl *ctrl; + int ret; + + if (xhci_hcd_init(index, &hccr, (struct xhci_hcor **)&hcor) != 0) + return -ENODEV; + + if (xhci_reset(hcor) != 0) + return -ENODEV; + + ctrl = &xhcic[index]; + + ctrl->hccr = hccr; + ctrl->hcor = hcor; + + ret = xhci_lowlevel_init(ctrl); + + *controller = &xhcic[index]; + + return ret; +} + +/** * Stops the XHCI host controller * and cleans up all the related data structures * @@ -1032,18 +1060,9 @@ int submit_control_msg(struct usb_device *udev, unsigned long pipe, int usb_lowlevel_stop(int index) { struct xhci_ctrl *ctrl = (xhcic + index); - u32 temp; - - xhci_reset(ctrl->hcor); - - debug("// Disabling event ring interrupts\n"); - temp = xhci_readl(&ctrl->hcor->or_usbsts); - xhci_writel(&ctrl->hcor->or_usbsts, temp & ~STS_EINT); - temp = xhci_readl(&ctrl->ir_set->irq_pending); - xhci_writel(&ctrl->ir_set->irq_pending, ER_IRQ_DISABLE(temp)); + xhci_lowlevel_stop(ctrl); xhci_hcd_stop(index); - xhci_cleanup(ctrl); return 0; -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 78/80] dm: usb: tegra: Drop legacy USB code
Drop the code that doesn't use driver model for USB. Signed-off-by: Simon Glass --- Changes in v2: None board/nvidia/common/board.c | 3 - drivers/usb/host/ehci-tegra.c | 150 -- include/fdtdec.h | 3 - lib/fdtdec.c | 3 - 4 files changed, 159 deletions(-) diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index a97035c..91bc03b 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -128,9 +128,6 @@ int board_init(void) #ifdef CONFIG_USB_EHCI_TEGRA pin_mux_usb(); -#ifndef CONFIG_DM_USB - usb_process_devicetree(gd->fdt_blob); -#endif #endif #ifdef CONFIG_LCD diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 66e5649..bfa53ed 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -35,12 +35,6 @@ DECLARE_GLOBAL_DATA_PTR; #endif #endif -#ifndef CONFIG_DM_USB -enum { - USB_PORTS_MAX = 3,/* Maximum ports we allow */ -}; -#endif - /* Parameters we need for USB */ enum { PARAM_DIVN, /* PLL FEEDBACK DIVIDer */ @@ -82,9 +76,6 @@ struct fdt_usb { unsigned ulpi:1;/* 1 if port has external ULPI transceiver */ unsigned enabled:1; /* 1 to enable, 0 to disable */ unsigned has_legacy_mode:1; /* 1 if this port has legacy mode */ -#ifndef CONFIG_DM_USB - unsigned initialized:1; /* has this port already been initialized? */ -#endif enum usb_ctlr_type type; enum usb_init_type init_type; enum dr_mode dr_mode; /* dual role mode */ @@ -93,11 +84,6 @@ struct fdt_usb { struct gpio_desc phy_reset_gpio; /* GPIO to reset ULPI phy */ }; -#ifndef CONFIG_DM_USB -static struct fdt_usb port[USB_PORTS_MAX]; /* List of valid USB ports */ -static unsigned port_count;/* Number of available ports */ -#endif - /* * This table has USB timing parameters for each Oscillator frequency we * support. There are four sets of values: @@ -173,8 +159,6 @@ static const u8 utmip_elastic_limit = 16; static const u8 utmip_hs_sync_start_delay = 9; struct fdt_usb_controller { - /* TODO(s...@chromium.org): Remove when we only use driver model */ - int compat; /* flag to determine whether controller supports hostpc register */ u32 has_hostpc:1; const unsigned *pll_parameter; @@ -182,17 +166,14 @@ struct fdt_usb_controller { static struct fdt_usb_controller fdt_usb_controllers[USB_CTRL_COUNT] = { { - .compat = COMPAT_NVIDIA_TEGRA20_USB, .has_hostpc = 0, .pll_parameter = (const unsigned *)T20_usb_pll, }, { - .compat = COMPAT_NVIDIA_TEGRA30_USB, .has_hostpc = 1, .pll_parameter = (const unsigned *)T30_usb_pll, }, { - .compat = COMPAT_NVIDIA_TEGRA114_USB, .has_hostpc = 1, .pll_parameter = (const unsigned *)T114_usb_pll, }, @@ -754,12 +735,6 @@ int usb_common_init(struct fdt_usb *config, enum usb_init_type init) return -1; } -#ifndef CONFIG_DM_USB - /* skip init, if the port is already initialized */ - if (config->initialized && config->init_type == init) - return 0; -#endif - debug("%d, %d\n", config->utmi, config->ulpi); if (config->utmi) ret = init_utmi_usb_controller(config, init); @@ -796,130 +771,6 @@ static const struct ehci_ops tegra_ehci_ops = { .powerup_fixup = tegra_ehci_powerup_fixup, }; -#ifndef CONFIG_DM_USB -/* - * process_usb_nodes() - Process a list of USB nodes, adding them to our list - * of USB ports. - * @blob: fdt blob - * @node_list: list of nodes to process (any <=0 are ignored) - * @count: number of nodes to process - * @id:controller type (enum usb_ctlr_type) - * - * Return: 0 - ok, -1 - error - */ -static int process_usb_nodes(const void *blob, int node_list[], int count, -enum usb_ctlr_type id) -{ - struct fdt_usb config; - int node, i; - int clk_done = 0; - - port_count = 0; - for (i = 0; i < count; i++) { - if (port_count == USB_PORTS_MAX) { - printf("tegrausb: Cannot register more than %d ports\n", - USB_PORTS_MAX); - return -1; - } - - debug("USB %d: ", i); - node = node_list[i]; - if (!node) - continue; - if (fdt_decode_usb(blob, node, &config)) { - debug("Cannot decode USB node %s\n", - fdt_get_name(blob, node, NULL)); - return -1; - } -
[U-Boot] [PATCH v2 77/80] dm: usb: Add tests for the USB uclass
This adds a simple test for probing and a functional test using the flash stick emulator, which tests a large chunk of the USB stack. Signed-off-by: Simon Glass --- Changes in v2: None test/dm/Makefile | 1 + test/dm/test-dm.sh | 3 +++ test/dm/test.dts | 41 + test/dm/usb.c | 50 ++ 4 files changed, 95 insertions(+) create mode 100644 test/dm/usb.c diff --git a/test/dm/Makefile b/test/dm/Makefile index a2e2d23..fd9e29f 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -23,4 +23,5 @@ obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o +obj-$(CONFIG_DM_USB) += usb.o endif diff --git a/test/dm/test-dm.sh b/test/dm/test-dm.sh index 8ebc392..6158f68 100755 --- a/test/dm/test-dm.sh +++ b/test/dm/test-dm.sh @@ -10,5 +10,8 @@ dtc -I dts -O dtb test/dm/test.dts -o test/dm/test.dtb make O=sandbox sandbox_config || die "Cannot configure U-Boot" make O=sandbox -s -j${NUM_CPUS} || die "Cannot build U-Boot" dd if=/dev/zero of=spi.bin bs=1M count=2 +echo -n "this is a test" > testflash.bin +dd if=/dev/zero bs=1M count=4 >>testflash.bin ./sandbox/u-boot -d test/dm/test.dtb -c "dm test" rm spi.bin +rm testflash.bin diff --git a/test/dm/test.dts b/test/dm/test.dts index 0ab0916..d0c40be 100644 --- a/test/dm/test.dts +++ b/test/dm/test.dts @@ -20,6 +20,9 @@ testfdt8 = "/a-test"; eth0 = "/eth@10002000"; eth5 = ð_5; + usb0 = &usb_0; + usb1 = &usb_1; + usb2 = &usb_2; }; uart0: serial { @@ -186,4 +189,42 @@ fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x22>; }; + usb_0: usb@0 { + compatible = "sandbox,usb"; + status = "disabled"; + hub { + compatible = "sandbox,usb-hub"; + #address-cells = <1>; + #size-cells = <0>; + flash-stick { + reg = <0>; + compatible = "sandbox,usb-flash"; + }; + }; + }; + + usb_1: usb@1 { + compatible = "sandbox,usb"; + hub { + compatible = "usb-hub"; + usb,device-class = <9>; + hub-emul { + compatible = "sandbox,usb-hub"; + #address-cells = <1>; + #size-cells = <0>; + flash-stick { + reg = <0>; + compatible = "sandbox,usb-flash"; + sandbox,filepath = "testflash.bin"; + }; + + }; + }; + }; + + usb_2: usb@2 { + compatible = "sandbox,usb"; + status = "disabled"; + }; + }; diff --git a/test/dm/usb.c b/test/dm/usb.c new file mode 100644 index 000..6ea86d7 --- /dev/null +++ b/test/dm/usb.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2015 Google, Inc + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include + +/* Test that sandbox USB works correctly */ +static int dm_test_usb_base(struct dm_test_state *dms) +{ + struct udevice *bus; + + ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_USB, 0, &bus)); + ut_assertok(uclass_get_device(UCLASS_USB, 0, &bus)); + ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_USB, 2, &bus)); + + return 0; +} +DM_TEST(dm_test_usb_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* + * Test that we can use the flash stick. This is more of a functional test. It + * covers scanning the bug, setting up a hub and a flash stick and reading + * data from the flash stick. + */ +static int dm_test_usb_flash(struct dm_test_state *dms) +{ + struct udevice *dev; + block_dev_desc_t *dev_desc; + char cmp[1024]; + + ut_assertok(usb_init()); + ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &dev)); + ut_assertok(get_device("usb", "0", &dev_desc)); + + /* Read a few blocks and look for the string we expect */ + ut_asserteq(512, dev_desc->blksz); + memset(cmp, '\0', sizeof(cmp)); + ut_asserteq(2, dev_desc->block_read(dev_desc->dev, 0, 2, cmp)); + ut_assertok(strcmp(cmp, "this is a test")); + + return 0; +} +DM_TEST(dm_test_usb_flash, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 11/80] dm: usb: Add a uclass for USB controllers
Add a uclass that can represent a USB controller. For now we do not create devices for things attached to the controller. This will be added later. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/Kconfig | 14 ++ drivers/usb/host/Makefile | 4 + drivers/usb/host/usb-uclass.c | 392 ++ drivers/usb/musb-new/musb_uboot.c | 4 +- include/dm/uclass-id.h| 1 + include/usb.h | 285 ++- 6 files changed, 694 insertions(+), 6 deletions(-) create mode 100644 drivers/usb/host/usb-uclass.c diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index b4a9442..a4414ef 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -35,6 +35,20 @@ config USB if USB +config DM_USB + bool "Enable driver model for USB" + depends on USB && DM + help + Enable driver model for USB. The USB interface is then implemented + by the USB uclass. Multiple USB controllers of different types + (XHCI, EHCI) can be attached and used. The 'usb' command works as + normal. OCHI is not supported at present. + + Much of the code is shared but with this option enabled the USB + uclass takes care of device enumeration. USB devices can be + declared with the USB_DEVICE() macro and will be automatically + probed when found on the bus. + source "drivers/usb/host/Kconfig" config USB_STORAGE diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index eb6f34b..9419295 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -5,6 +5,10 @@ # SPDX-License-Identifier: GPL-2.0+ # +ifdef CONFIG_DM_USB +obj-$(CONFIG_CMD_USB) += usb-uclass.o +endif + # ohci obj-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o obj-$(CONFIG_USB_ATMEL) += ohci-at91.o diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c new file mode 100644 index 000..22dcd14 --- /dev/null +++ b/drivers/usb/host/usb-uclass.c @@ -0,0 +1,392 @@ +/* + * (C) Copyright 2015 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +extern bool usb_started; /* flag for the started/stopped USB status */ +static bool asynch_allowed; + +int usb_disable_asynch(int disable) +{ + int old_value = asynch_allowed; + + asynch_allowed = !disable; + return old_value; +} + +int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, + int length, int interval) +{ + struct udevice *bus = udev->controller_dev; + struct dm_usb_ops *ops = usb_get_ops(bus); + + if (!ops->interrupt) + return -ENOSYS; + + return ops->interrupt(bus, udev, pipe, buffer, length, interval); +} + +int submit_control_msg(struct usb_device *udev, unsigned long pipe, + void *buffer, int length, struct devrequest *setup) +{ + struct udevice *bus = udev->controller_dev; + struct dm_usb_ops *ops = usb_get_ops(bus); + + if (!ops->control) + return -ENOSYS; + + return ops->control(bus, udev, pipe, buffer, length, setup); +} + +int submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, + int length) +{ + struct udevice *bus = udev->controller_dev; + struct dm_usb_ops *ops = usb_get_ops(bus); + + if (!ops->bulk) + return -ENOSYS; + + return ops->bulk(bus, udev, pipe, buffer, length); +} + +int usb_alloc_device(struct usb_device *udev) +{ + struct udevice *bus = udev->controller_dev; + struct dm_usb_ops *ops = usb_get_ops(bus); + + /* This is only requird by some controllers - current XHCI */ + if (!ops->alloc_device) + return 0; + + return ops->alloc_device(bus, udev); +} + +int usb_stop(void) +{ + struct udevice *bus; + struct uclass *uc; + int err = 0, ret; + + /* De-activate any devices that have been activated */ + ret = uclass_get(UCLASS_USB, &uc); + if (ret) + return ret; + uclass_foreach_dev(bus, uc) { + ret = device_remove(bus); + if (ret && !err) + err = ret; + } + + usb_stor_reset(); + usb_hub_reset(); + usb_started = 0; + + return err; +} + +static int usb_scan_bus(struct udevice *bus, bool recurse) +{ + struct usb_bus_priv *priv; + struct udevice *dev; + int ret; + + priv = dev_get_uclass_priv(bus); + + assert(recurse);/* TODO: Support non-recusive */ + + ret = usb_scan_device(bus, 0, USB_SPEED_FULL, &dev); + if (ret) + return ret; + + return priv->next_addr; +} + +int usb_init(void) +{ + int controllers_initialized = 0; + struc
[U-Boot] [PATCH v2 67/80] dm: usb: exynos: Adjust XHCI driver to support driver model
Support driver model in the exynos XHCI driver. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/xhci-exynos5.c | 120 +++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-exynos5.c b/drivers/usb/host/xhci-exynos5.c index 3f86fdc..23c7ecc 100644 --- a/drivers/usb/host/xhci-exynos5.c +++ b/drivers/usb/host/xhci-exynos5.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -32,20 +33,76 @@ /* Declare global data pointer */ DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_DM_USB +struct exynos_xhci_platdata { + fdt_addr_t hcd_base; + fdt_addr_t phy_base; + struct gpio_desc vbus_gpio; +}; +#endif + /** * Contains pointers to register base addresses * for the usb controller. */ struct exynos_xhci { +#ifdef CONFIG_DM_USB + struct usb_platdata usb_plat; +#endif + struct xhci_ctrl ctrl; struct exynos_usb3_phy *usb3_phy; struct xhci_hccr *hcd; struct dwc3 *dwc3_reg; +#ifndef CONFIG_DM_USB struct gpio_desc vbus_gpio; +#endif }; +#ifndef CONFIG_DM_USB static struct exynos_xhci exynos; +#endif -#ifdef CONFIG_OF_CONTROL +#ifdef CONFIG_DM_USB +static int xhci_usb_ofdata_to_platdata(struct udevice *dev) +{ + struct exynos_xhci_platdata *plat = dev_get_platdata(dev); + const void *blob = gd->fdt_blob; + unsigned int node; + int depth; + + /* +* Get the base address for XHCI controller from the device node +*/ + plat->hcd_base = fdtdec_get_addr(blob, dev->of_offset, "reg"); + if (plat->hcd_base == FDT_ADDR_T_NONE) { + debug("Can't get the XHCI register base address\n"); + return -ENXIO; + } + + depth = 0; + node = fdtdec_next_compatible_subnode(blob, dev->of_offset, + COMPAT_SAMSUNG_EXYNOS5_USB3_PHY, &depth); + if (node <= 0) { + debug("XHCI: Can't get device node for usb3-phy controller\n"); + return -ENODEV; + } + + /* +* Get the base address for usbphy from the device node +*/ + plat->phy_base = fdtdec_get_addr(blob, node, "reg"); + if (plat->phy_base == FDT_ADDR_T_NONE) { + debug("Can't get the usbphy register address\n"); + return -ENXIO; + } + + /* Vbus gpio */ + gpio_request_by_name(dev, "samsung,vbus-gpio", 0, +&plat->vbus_gpio, GPIOD_IS_OUT); + + return 0; +} +#else static int exynos_usb3_parse_dt(const void *blob, struct exynos_xhci *exynos) { fdt_addr_t addr; @@ -283,6 +340,7 @@ static void exynos_xhci_core_exit(struct exynos_xhci *exynos) exynos5_usb3_phy_exit(exynos->usb3_phy); } +#ifndef CONFIG_DM_USB int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor) { struct exynos_xhci *ctx = &exynos; @@ -326,3 +384,63 @@ void xhci_hcd_stop(int index) exynos_xhci_core_exit(ctx); } +#endif + +#ifdef CONFIG_DM_USB +static int xhci_usb_probe(struct udevice *dev) +{ + struct exynos_xhci_platdata *plat = dev_get_platdata(dev); + struct exynos_xhci *ctx = dev_get_priv(dev); + struct xhci_hcor *hcor; + int ret; + + ctx->hcd = (struct xhci_hccr *)plat->hcd_base; + ctx->usb3_phy = (struct exynos_usb3_phy *)plat->phy_base; + ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET); + hcor = (struct xhci_hcor *)((uint32_t)ctx->hcd + + HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase))); + + /* setup the Vbus gpio here */ + if (dm_gpio_is_valid(&plat->vbus_gpio)) + dm_gpio_set_value(&plat->vbus_gpio, 1); + + ret = exynos_xhci_core_init(ctx); + if (ret) { + puts("XHCI: failed to initialize controller\n"); + return -EINVAL; + } + + return xhci_register(dev, ctx->hcd, hcor); +} + +static int xhci_usb_remove(struct udevice *dev) +{ + struct exynos_xhci *ctx = dev_get_priv(dev); + int ret; + + ret = xhci_deregister(dev); + if (ret) + return ret; + exynos_xhci_core_exit(ctx); + + return 0; +} + +static const struct udevice_id xhci_usb_ids[] = { + { .compatible = "samsung,exynos5250-xhci" }, + { } +}; + +U_BOOT_DRIVER(usb_xhci) = { + .name = "xhci_exynos", + .id = UCLASS_USB, + .of_match = xhci_usb_ids, + .ofdata_to_platdata = xhci_usb_ofdata_to_platdata, + .probe = xhci_usb_probe, + .remove = xhci_usb_remove, + .ops= &xhci_usb_ops, + .platdata_auto_alloc_size = sizeof(struct exynos_xhci_platdata), + .priv_auto_alloc_size = sizeof(struct exynos_xhci), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; +#endif -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de
[U-Boot] [PATCH v2 63/80] dm: usb: xhci: Use explicit parameters for xhci_setup_addressable_virt_dev()
This function should not be delving into struct usb_device. Pass in the parameters it needs directly. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/xhci-mem.c | 19 +++ drivers/usb/host/xhci.c | 29 ++--- drivers/usb/host/xhci.h | 3 ++- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 4644ffa..1b55534 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -625,17 +625,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 usb_device *udev) +void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, int slot_id, +int speed, int hop_portnr) { - struct usb_device *hop = udev; 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; - struct xhci_ctrl *ctrl = udev->controller; - virt_dev = ctrl->devs[udev->slot_id]; + virt_dev = ctrl->devs[slot_id]; BUG_ON(!virt_dev); @@ -646,7 +645,7 @@ void xhci_setup_addressable_virt_dev(struct usb_device *udev) /* Only the control endpoint is valid - one endpoint context */ slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | 0); - switch (udev->speed) { + switch (speed) { case USB_SPEED_SUPER: slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS); break; @@ -664,11 +663,7 @@ void xhci_setup_addressable_virt_dev(struct usb_device *udev) BUG(); } - /* Extract the root hub port number */ - if (hop->parent) - while (hop->parent->parent) - hop = hop->parent; - port_num = hop->portnr; + port_num = hop_portnr; debug("port_num = %d\n", port_num); slot_ctx->dev_info2 |= @@ -678,9 +673,9 @@ void xhci_setup_addressable_virt_dev(struct usb_device *udev) /* Step 4 - ring already allocated */ /* Step 5 */ ep0_ctx->ep_info2 = cpu_to_le32(CTRL_EP << EP_TYPE_SHIFT); - debug("SPEED = %d\n", udev->speed); + debug("SPEED = %d\n", speed); - switch (udev->speed) { + switch (speed) { case USB_SPEED_SUPER: ep0_ctx->ep_info2 |= cpu_to_le32(((512 & MAX_PACKET_MASK) << MAX_PACKET_SHIFT)); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index de006f7..774c3e6 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -384,7 +384,7 @@ static int xhci_set_configuration(struct usb_device *udev) * @param udev pointer to the Device Data Structure * @return 0 if successful else error code on failure */ -static int xhci_address_device(struct usb_device *udev) +static int xhci_address_device(struct usb_device *udev, int root_portnr) { int ret = 0; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); @@ -400,8 +400,9 @@ static int xhci_address_device(struct usb_device *udev) * This is the first Set Address since device plug-in * so setting up the slot context. */ - debug("Setting up addressable devices\n"); - xhci_setup_addressable_virt_dev(udev); + debug("Setting up addressable devices %p\n", ctrl->dcbaa); + xhci_setup_addressable_virt_dev(ctrl, udev->slot_id, udev->speed, + root_portnr); ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx); ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG); @@ -903,11 +904,12 @@ submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, * @param buffer buffer to be read/written based on the request * @param length length of the buffer * @param setupRequest type + * @param root_portnr Root port number that this device is on * @return returns 0 if successful else -1 on failure */ -int -submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, - int length, struct devrequest *setup) +static int _xhci_submit_control_msg(struct usb_device *udev, unsigned long pipe, + void *buffer, int length, + struct devrequest *setup, int root_portnr) { struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); int ret = 0; @@ -921,7 +923,7 @@ submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, return xhci_submit_root(udev, pipe, buffer, setup); if (setup->request == USB_REQ_SET_ADDRESS) - return xhci_address_device(udev); + return xhci_addre
[U-Boot] [PATCH v2 72/80] dm: usb: Add a generic descriptor struct
This is useful for creating lists of descriptors, and is better than using void * for this purpose. Signed-off-by: Simon Glass --- Changes in v2: None include/linux/usb/ch9.h | 5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index 10675b4..822fca0 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -379,6 +379,11 @@ struct usb_endpoint_descriptor { #define USB_DT_ENDPOINT_SIZE 7 #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ +/* Used to access common fields */ +struct usb_generic_descriptor { + __u8 bLength; + __u8 bDescriptorType; +}; /* * Endpoints -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 69/80] dm: usb: exynos: Enable both USB ports on snow
Switch snow over to use both EHCI and XHCI at the same time. Signed-off-by: Simon Glass --- Changes in v2: None include/configs/snow.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/configs/snow.h b/include/configs/snow.h index fe802f2..e024955 100644 --- a/include/configs/snow.h +++ b/include/configs/snow.h @@ -26,7 +26,9 @@ #define CONFIG_ARCH_EARLY_INIT_R #define CONFIG_USB_XHCI +#define CONFIG_USB_EHCI #define CONFIG_USB_XHCI_EXYNOS +#define CONFIG_USB_EHCI_EXYNOS #define CONFIG_SYS_PROMPT "snow # " #define CONFIG_IDENT_STRING" for snow" -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 58/80] dm: usb: tegra: Tidy up error handling and a static function
Try to return useful error numbers where possible. Also avoid swallowing an error number when it is returned by a called function. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-tegra.c | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 464f55d..04653e4 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -266,7 +266,8 @@ static void set_up_vbus(struct fdt_usb *config, enum usb_init_type init) } } -void usbf_reset_controller(struct fdt_usb *config, struct usb_ctlr *usbctlr) +static void usbf_reset_controller(struct fdt_usb *config, + struct usb_ctlr *usbctlr) { /* Reset the USB controller with 2us delay */ reset_periph(config->periph_id, 2); @@ -524,7 +525,7 @@ static int init_utmi_usb_controller(struct fdt_usb *config, udelay(1); } if (!loop_count) - return -1; + return -ETIMEDOUT; /* Disable ICUSB FS/LS transceiver */ clrbits_le32(&usbctlr->icusb_ctrl, IC_ENB1); @@ -567,6 +568,7 @@ static int init_ulpi_usb_controller(struct fdt_usb *config, int loop_count; struct ulpi_viewport ulpi_vp; struct usb_ctlr *usbctlr = config->reg; + int ret; /* set up ULPI reference clock on pllp_out4 */ clock_enable(PERIPH_ID_DEV2_OUT); @@ -612,9 +614,10 @@ static int init_ulpi_usb_controller(struct fdt_usb *config, ulpi_vp.port_num = 0; ulpi_vp.viewport_addr = (u32)&usbctlr->ulpi_viewport; - if (ulpi_init(&ulpi_vp)) { + ret = ulpi_init(&ulpi_vp); + if (ret) { printf("Tegra ULPI viewport init failed\n"); - return -1; + return ret; } ulpi_set_vbus(&ulpi_vp, 1, 1); @@ -631,7 +634,7 @@ static int init_ulpi_usb_controller(struct fdt_usb *config, udelay(1); } if (!loop_count) - return -1; + return -ETIMEDOUT; clrbits_le32(&usbctlr->susp_ctrl, USB_SUSP_CLR); return 0; @@ -642,7 +645,7 @@ static int init_ulpi_usb_controller(struct fdt_usb *config, { printf("No code to set up ULPI controller, please enable" "CONFIG_USB_ULPI and CONFIG_USB_ULPI_VIEWPORT"); - return -1; + return -ENOSYS; } #endif @@ -669,7 +672,7 @@ static int fdt_decode_usb(const void *blob, int node, struct fdt_usb *config) else { debug("%s: Cannot decode dr_mode '%s'\n", __func__, mode); - return -FDT_ERR_NOTFOUND; + return -EINVAL; } } else { config->dr_mode = DR_MODE_HOST; @@ -684,7 +687,7 @@ static int fdt_decode_usb(const void *blob, int node, struct fdt_usb *config) config->periph_id = clock_decode_periph_id(blob, node); if (config->periph_id == PERIPH_ID_NONE) { debug("%s: Missing/invalid peripheral ID\n", __func__); - return -FDT_ERR_NOTFOUND; + return -EINVAL; } gpio_request_by_name_nodev(blob, node, "nvidia,vbus-gpio", 0, &config->vbus_gpio, GPIOD_IS_OUT); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 73/80] dm: usb: Tidy up pipe value decoding
Add a few more shifts/masks to make it easier to decode a pipe value (rather than just building it). We need this for USB device emulation. Signed-off-by: Simon Glass --- Changes in v2: None include/usb_defs.h | 23 +-- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/include/usb_defs.h b/include/usb_defs.h index 27ddc47..8214ba9 100644 --- a/include/usb_defs.h +++ b/include/usb_defs.h @@ -165,12 +165,14 @@ #define USB_TEST_MODE_FORCE_ENABLE 0x05 -/* "pipe" definitions */ - -#define PIPE_ISOCHRONOUS0 -#define PIPE_INTERRUPT 1 -#define PIPE_CONTROL2 -#define PIPE_BULK 3 +/* + * "pipe" definitions, use unsigned so we can compare reliably, since this + * value is shifted up to bits 30/31. + */ +#define PIPE_ISOCHRONOUS0U +#define PIPE_INTERRUPT 1U +#define PIPE_CONTROL2U +#define PIPE_BULK 3U #define PIPE_DEVEP_MASK 0x0007ff00 #define USB_ISOCHRONOUS0 @@ -178,6 +180,15 @@ #define USB_CONTROL2 #define USB_BULK 3 +#define USB_PIPE_TYPE_SHIFT30 +#define USB_PIPE_TYPE_MASK (3 << USB_PIPE_TYPE_SHIFT) + +#define USB_PIPE_DEV_SHIFT 8 +#define USB_PIPE_DEV_MASK (0x7f << USB_PIPE_DEV_SHIFT) + +#define USB_PIPE_EP_SHIFT 15 +#define USB_PIPE_EP_MASK (0xf << USB_PIPE_EP_SHIFT) + /* USB-status codes: */ #define USB_ST_ACTIVE 0x1/* TD is active */ #define USB_ST_STALLED 0x2/* TD is stalled */ -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 50/80] dm: usb: sandbox: Reset emulation devices in usb stop()
These devices must have their addresses removed ready for the next USB bus enumeration. Add this logic to usb_stop(). Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/usb-uclass.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 29ef5d9..714bc0e 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -93,6 +93,17 @@ int usb_stop(void) err = ret; } +#ifdef CONFIG_SANDBOX + struct udevice *dev; + + /* Reset all enulation devices */ + ret = uclass_get(UCLASS_USB_EMUL, &uc); + if (ret) + return ret; + + uclass_foreach_dev(dev, uc) + usb_emul_reset(dev); +#endif usb_stor_reset(); usb_hub_reset(); usb_started = 0; -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 75/80] dm: test: Correct printf() output nit in 'dm uclass'
Neither the hyphen nor the equals sign is needed. Signed-off-by: Simon Glass --- Changes in v2: None test/dm/cmd_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c index 8d531fd..62e065c 100644 --- a/test/dm/cmd_dm.c +++ b/test/dm/cmd_dm.c @@ -79,7 +79,7 @@ static void dm_display_line(struct udevice *dev) dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ', dev->name, (ulong)map_to_sysmem(dev)); if (dev->seq != -1 || dev->req_seq != -1) - printf(", seq-%d, (req=%d)", dev->seq, dev->req_seq); + printf(", seq %d, (req %d)", dev->seq, dev->req_seq); puts("\n"); } -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 51/80] dm: usb: sandbox: Add an emulator for USB flash devices
This emulator supports USB enumeration and allows a local file to be provided as the contents of the emulated flash stick. U-Boot can then use the file as it would a normal device, with all access passing through the usb_stor layer and the USB stack. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/emul/Makefile| 1 + drivers/usb/emul/sandbox_flash.c | 423 +++ include/dm/uclass-id.h | 1 + 3 files changed, 425 insertions(+) create mode 100644 drivers/usb/emul/sandbox_flash.c diff --git a/drivers/usb/emul/Makefile b/drivers/usb/emul/Makefile index f75bbd8..1d5acce 100644 --- a/drivers/usb/emul/Makefile +++ b/drivers/usb/emul/Makefile @@ -5,4 +5,5 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_USB_EMUL) += sandbox_flash.o obj-$(CONFIG_USB_EMUL) += usb-emul-uclass.o diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c new file mode 100644 index 000..6e0808d --- /dev/null +++ b/drivers/usb/emul/sandbox_flash.c @@ -0,0 +1,423 @@ +/* + * (C) Copyright 2015 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* + * This driver emulates a flash stick using the UFI command specification and + * the BBB (bulk/bulk/bulk) protocol. It supports only a single logical unit + * number (LUN 0). + */ + +enum { + SANDBOX_FLASH_EP_OUT= 1,/* endpoints */ + SANDBOX_FLASH_EP_IN = 2, + SANDBOX_FLASH_BLOCK_LEN = 512, +}; + +enum cmd_phase { + PHASE_START, + PHASE_DATA, + PHASE_STATUS, +}; + +/** + * struct sandbox_flash_priv - private state for this driver + * + * @error: true if there is an error condition + * @alloc_len: Allocation length from the last incoming command + * @transfer_len: Transfer length from CBW header + * @read_len: Number of blocks of data left in the current read command + * @tag: Tag value from last command + * @fd:File descriptor of backing file + * @file_size: Size of file in bytes + * @status_buff: Data buffer for outgoing status + * @buff_used: Number of bytes ready to transfer back to host + * @buff: Data buffer for outgoing data + */ +struct sandbox_flash_priv { + bool error; + int alloc_len; + int transfer_len; + int read_len; + enum cmd_phase phase; + u32 tag; + int fd; + loff_t file_size; + struct umass_bbb_csw status; + int buff_used; + u8 buff[512]; +}; + +struct sandbox_flash_plat { + const char *pathname; +}; + +struct scsi_inquiry_resp { + u8 type; + u8 flags; + u8 version; + u8 data_format; + u8 additional_len; + u8 spare[3]; + char vendor[8]; + char product[16]; + char revision[4]; +}; + +struct scsi_read_capacity_resp { + u32 last_block_addr; + u32 block_len; +}; + +struct __packed scsi_read10_req { + u8 cmd; + u8 lun_flags; + u32 lba; + u8 spare; + u16 transfer_len; + u8 spare2[3]; +}; + +enum { + STRINGID_MANUFACTURER = 1, + STRINGID_PRODUCT, + STRINGID_SERIAL, + + STRINGID_COUNT, +}; + +static struct usb_string flash_strings[] = { + {STRINGID_MANUFACTURER, "sandbox"}, + {STRINGID_PRODUCT, "flash"}, + {STRINGID_SERIAL, "2345"}, + {}, +}; + +static struct usb_device_descriptor flash_device_desc = { + .bLength = sizeof(flash_device_desc), + .bDescriptorType = USB_DT_DEVICE, + + .bcdUSB = __constant_cpu_to_le16(0x0200), + + .bDeviceClass = 0, + .bDeviceSubClass = 0, + .bDeviceProtocol = 0, + + .idVendor = __constant_cpu_to_le16(0x1234), + .idProduct =__constant_cpu_to_le16(0x5678), + .iManufacturer =STRINGID_MANUFACTURER, + .iProduct = STRINGID_PRODUCT, + .iSerialNumber =STRINGID_SERIAL, + .bNumConfigurations = 1, +}; + +static struct usb_config_descriptor flash_config0 = { + .bLength= sizeof(flash_config0), + .bDescriptorType= USB_DT_CONFIG, + + /* wTotalLength is set up by usb-emul-uclass */ + .bNumInterfaces = 1, + .bConfigurationValue= 0, + .iConfiguration = 0, + .bmAttributes = 1 << 7, + .bMaxPower = 50, +}; + +static struct usb_interface_descriptor flash_interface0 = { + .bLength= sizeof(flash_interface0), + .bDescriptorType= USB_DT_INTERFACE, + + .bInterfaceNumber = 0, + .bAlternateSetting = 0, + .bNumEndpoints = 2, + .bInterfaceClass= USB_CLASS_MASS_STORAGE, + .bInterfaceSubClass = US_SC_UFI, + .bInterfaceProto
[U-Boot] [PATCH v2 74/80] dm: usb: sandbox: Enable USB
Enable USB emulation and associated features so that USB can be used in sandbox. Signed-off-by: Simon Glass --- Changes in v2: None configs/sandbox_defconfig | 4 include/configs/sandbox.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index e23b959..3f4812c 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -15,3 +15,7 @@ CONFIG_CMD_CROS_EC=y CONFIG_PCI=y CONFIG_DM_PCI=y CONFIG_PCI_SANDBOX=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_EMUL=y +CONFIG_USB_STORAGE=y diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 558ea2c..95cfce6 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -60,6 +60,7 @@ #define CONFIG_CMD_GPT #define CONFIG_PARTITION_UUIDS #define CONFIG_EFI_PARTITION +#define CONFIG_DOS_PARTITION /* * Size of malloc() pool, before and after relocation @@ -200,5 +201,6 @@ #define CONFIG_TPM_TIS_SANDBOX #define CONFIG_CMD_LZMADEC +#define CONFIG_CMD_USB #endif -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 76/80] dm: test: Allow 'dm test' to select a particular test to run
As well as running all tests, it is useful to be able to run a selected test. Signed-off-by: Simon Glass --- Changes in v2: None include/dm/test.h | 7 --- test/dm/cmd_dm.c| 11 --- test/dm/test-main.c | 7 +-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/dm/test.h b/include/dm/test.h index b310e5f..9c4b8d3 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -205,12 +205,13 @@ void dm_leak_check_start(struct dm_test_state *dms); /** - * dm_test_main() - Run all the tests + * dm_test_main() - Run all or one of the tests * - * This runs all available driver model tests + * This runs all available driver model tests, or a selected one * + * @test_name: Name of test to run, or NULL for all * @return 0 if OK, -ve on error */ -int dm_test_main(void); +int dm_test_main(const char *test_name); #endif diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c index 62e065c..2f527e9 100644 --- a/test/dm/cmd_dm.c +++ b/test/dm/cmd_dm.c @@ -113,7 +113,12 @@ static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc, static int do_dm_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - return dm_test_main(); + const char *test_name = NULL; + + if (argc > 0) + test_name = argv[0]; + + return dm_test_main(test_name); } #define TEST_HELP "\ndm test Run tests" #else @@ -133,7 +138,7 @@ static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) cmd_tbl_t *test_cmd; int ret; - if (argc != 2) + if (argc < 2) return CMD_RET_USAGE; test_cmd = find_cmd_tbl(argv[1], test_commands, ARRAY_SIZE(test_commands)); @@ -148,7 +153,7 @@ static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } U_BOOT_CMD( - dm, 2, 1, do_dm, + dm, 3, 1, do_dm, "Driver model low level access", "tree Dump driver model tree ('*' = activated)\n" "dm uclassDump list of instances for each uclass" diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 90ca810..a47bb37 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -65,7 +65,7 @@ static int dm_test_destroy(struct dm_test_state *dms) return 0; } -int dm_test_main(void) +int dm_test_main(const char *test_name) { struct dm_test *tests = ll_entry_start(struct dm_test, dm_test); const int n_ents = ll_entry_count(struct dm_test, dm_test); @@ -83,9 +83,12 @@ int dm_test_main(void) ut_assert(gd->fdt_blob); } - printf("Running %d driver model tests\n", n_ents); + if (!test_name) + printf("Running %d driver model tests\n", n_ents); for (test = tests; test < tests + n_ents; test++) { + if (test_name && strcmp(test_name, test->name)) + continue; printf("Test: %s\n", test->name); ut_assertok(dm_test_init(dms)); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 57/80] dm: usb: tegra: Remove the port_addr_clear_csc variable
This variable is a bit of a hack. We can obtain the same information from the normal device config. This will fit better with driver model, where global variables are best avoided. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-tegra.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 38333c7..464f55d 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -87,8 +87,6 @@ struct fdt_usb { static struct fdt_usb port[USB_PORTS_MAX]; /* List of valid USB ports */ static unsigned port_count;/* Number of available ports */ -/* Port that needs to clear CSC after Port Reset */ -static u32 port_addr_clear_csc; /* * This table has USB timing parameters for each Oscillator frequency we @@ -206,7 +204,7 @@ static void tegra_ehci_powerup_fixup(struct ehci_ctrl *ctrl, if (controller->has_hostpc) *reg |= EHCI_PS_PE; - if (((u32)status_reg & TEGRA_USB_ADDR_MASK) != port_addr_clear_csc) + if (!config->has_legacy_mode) return; /* For EHCI_PS_CSC to be cleared in ehci_hcd.c */ if (ehci_readl(status_reg) & EHCI_PS_CSC) @@ -683,8 +681,6 @@ static int fdt_decode_usb(const void *blob, int node, struct fdt_usb *config) config->enabled = fdtdec_get_is_enabled(blob, node); config->has_legacy_mode = fdtdec_get_bool(blob, node, "nvidia,has-legacy-mode"); - if (config->has_legacy_mode) - port_addr_clear_csc = (u32) config->reg; config->periph_id = clock_decode_periph_id(blob, node); if (config->periph_id == PERIPH_ID_NONE) { debug("%s: Missing/invalid peripheral ID\n", __func__); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 60/80] dm: usb: tegra: Add driver model support to tegra EHCI
Update this driver with driver model support for USB. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-tegra.c | 83 +++ 1 file changed, 83 insertions(+) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 940a583..66e5649 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -20,6 +21,8 @@ #include "ehci.h" +DECLARE_GLOBAL_DATA_PTR; + #define USB1_ADDR_MASK 0x #define HOSTPC1_DEVLC 0x84 @@ -32,9 +35,11 @@ #endif #endif +#ifndef CONFIG_DM_USB enum { USB_PORTS_MAX = 3,/* Maximum ports we allow */ }; +#endif /* Parameters we need for USB */ enum { @@ -71,12 +76,15 @@ enum usb_ctlr_type { /* Information about a USB port */ struct fdt_usb { + struct ehci_ctrl ehci; struct usb_ctlr *reg; /* address of registers in physical memory */ unsigned utmi:1;/* 1 if port has external tranceiver, else 0 */ unsigned ulpi:1;/* 1 if port has external ULPI transceiver */ unsigned enabled:1; /* 1 to enable, 0 to disable */ unsigned has_legacy_mode:1; /* 1 if this port has legacy mode */ +#ifndef CONFIG_DM_USB unsigned initialized:1; /* has this port already been initialized? */ +#endif enum usb_ctlr_type type; enum usb_init_type init_type; enum dr_mode dr_mode; /* dual role mode */ @@ -85,8 +93,10 @@ struct fdt_usb { struct gpio_desc phy_reset_gpio; /* GPIO to reset ULPI phy */ }; +#ifndef CONFIG_DM_USB static struct fdt_usb port[USB_PORTS_MAX]; /* List of valid USB ports */ static unsigned port_count;/* Number of available ports */ +#endif /* * This table has USB timing parameters for each Oscillator frequency we @@ -163,6 +173,7 @@ static const u8 utmip_elastic_limit = 16; static const u8 utmip_hs_sync_start_delay = 9; struct fdt_usb_controller { + /* TODO(s...@chromium.org): Remove when we only use driver model */ int compat; /* flag to determine whether controller supports hostpc register */ u32 has_hostpc:1; @@ -785,6 +796,7 @@ static const struct ehci_ops tegra_ehci_ops = { .powerup_fixup = tegra_ehci_powerup_fixup, }; +#ifndef CONFIG_DM_USB /* * process_usb_nodes() - Process a list of USB nodes, adding them to our list * of USB ports. @@ -905,3 +917,74 @@ int ehci_hcd_stop(int index) return 0; } +#endif /* !CONFIG_DM_USB */ + +#ifdef CONFIG_DM_USB +static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +{ + struct fdt_usb *priv = dev_get_priv(dev); + int ret; + + ret = fdt_decode_usb(gd->fdt_blob, dev->of_offset, priv); + if (ret) + return ret; + + priv->type = dev_get_driver_data(dev); + + return 0; +} + +static int ehci_usb_probe(struct udevice *dev) +{ + struct usb_platdata *plat = dev_get_platdata(dev); + struct fdt_usb *priv = dev_get_priv(dev); + struct ehci_hccr *hccr; + struct ehci_hcor *hcor; + static bool clk_done; + int ret; + + ret = usb_common_init(priv, plat->init_type); + if (ret) + return ret; + hccr = (struct ehci_hccr *)&priv->reg->cap_length; + hcor = (struct ehci_hcor *)&priv->reg->usb_cmd; + if (!clk_done) { + config_clock(get_pll_timing(&fdt_usb_controllers[priv->type])); + clk_done = true; + } + + return ehci_register(dev, hccr, hcor, &tegra_ehci_ops, 0, +plat->init_type); +} + +static int ehci_usb_remove(struct udevice *dev) +{ + int ret; + + ret = ehci_deregister(dev); + if (ret) + return ret; + + return 0; +} + +static const struct udevice_id ehci_usb_ids[] = { + { .compatible = "nvidia,tegra20-ehci", .data = USB_CTLR_T20 }, + { .compatible = "nvidia,tegra30-ehci", .data = USB_CTLR_T30 }, + { .compatible = "nvidia,tegra114-ehci", .data = USB_CTLR_T114 }, + { } +}; + +U_BOOT_DRIVER(usb_ehci) = { + .name = "ehci_tegra", + .id = UCLASS_USB, + .of_match = ehci_usb_ids, + .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .probe = ehci_usb_probe, + .remove = ehci_usb_remove, + .ops= &ehci_usb_ops, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct fdt_usb), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; +#endif -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 79/80] dm: usb: exynos: Drop legacy USB code
Drop the code that doesn't use driver model for USB. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-exynos.c | 117 drivers/usb/host/xhci-exynos5.c | 108 - include/fdtdec.h| 2 - lib/fdtdec.c| 2 - 4 files changed, 229 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 86cf631..18e9251 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -25,14 +25,12 @@ /* Declare global data pointer */ DECLARE_GLOBAL_DATA_PTR; -#ifdef CONFIG_DM_USB struct exynos_ehci_platdata { struct usb_platdata usb_plat; fdt_addr_t hcd_base; fdt_addr_t phy_base; struct gpio_desc vbus_gpio; }; -#endif /** * Contains pointers to register base addresses @@ -42,16 +40,8 @@ struct exynos_ehci { struct ehci_ctrl ctrl; struct exynos_usb_phy *usb; struct ehci_hccr *hcd; -#ifndef CONFIG_DM_USB - struct gpio_desc vbus_gpio; -#endif }; -#ifndef CONFIG_DM_USB -static struct exynos_ehci exynos; -#endif - -#ifdef CONFIG_DM_USB static int ehci_usb_ofdata_to_platdata(struct udevice *dev) { struct exynos_ehci_platdata *plat = dev_get_platdata(dev); @@ -91,55 +81,6 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) return 0; } -#else -static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos) -{ - fdt_addr_t addr; - unsigned int node; - int depth; - - node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS_EHCI); - if (node <= 0) { - debug("EHCI: Can't get device node for ehci\n"); - return -ENODEV; - } - - /* -* Get the base address for EHCI controller from the device node -*/ - addr = fdtdec_get_addr(blob, node, "reg"); - if (addr == FDT_ADDR_T_NONE) { - debug("Can't get the EHCI register address\n"); - return -ENXIO; - } - - exynos->hcd = (struct ehci_hccr *)addr; - - /* Vbus gpio */ - gpio_request_by_name_nodev(blob, node, "samsung,vbus-gpio", 0, - &exynos->vbus_gpio, GPIOD_IS_OUT); - - depth = 0; - node = fdtdec_next_compatible_subnode(blob, node, - COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth); - if (node <= 0) { - debug("EHCI: Can't get device node for usb-phy controller\n"); - return -ENODEV; - } - - /* -* Get the base address for usbphy from the device node -*/ - exynos->usb = (struct exynos_usb_phy *)fdtdec_get_addr(blob, node, - "reg"); - if (exynos->usb == NULL) { - debug("Can't get the usbphy register address\n"); - return -ENXIO; - } - - return 0; -} -#endif static void exynos5_setup_usb_phy(struct exynos_usb_phy *usb) { @@ -270,63 +211,6 @@ static void reset_usb_phy(struct exynos_usb_phy *usb) set_usbhost_phy_ctrl(POWER_USB_HOST_PHY_CTRL_DISABLE); } -#ifndef CONFIG_DM_USB -/* - * EHCI-initialization - * Create the appropriate control structures to manage - * a new EHCI host controller. - */ -int ehci_hcd_init(int index, enum usb_init_type init, - struct ehci_hccr **hccr, struct ehci_hcor **hcor) -{ - struct exynos_ehci *ctx = &exynos; - -#ifdef CONFIG_OF_CONTROL - if (exynos_usb_parse_dt(gd->fdt_blob, ctx)) { - debug("Unable to parse device tree for ehci-exynos\n"); - return -ENODEV; - } -#else - ctx->usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy(); - ctx->hcd = (struct ehci_hccr *)samsung_get_base_usb_ehci(); -#endif - -#ifdef CONFIG_OF_CONTROL - /* setup the Vbus gpio here */ - if (dm_gpio_is_valid(&ctx->vbus_gpio)) - dm_gpio_set_value(&ctx->vbus_gpio, 1); -#endif - - setup_usb_phy(ctx->usb); - - board_usb_init(index, init); - - *hccr = ctx->hcd; - *hcor = (struct ehci_hcor *)((uint32_t) *hccr - + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); - - debug("Exynos5-ehci: init hccr %x and hcor %x hc_length %d\n", - (uint32_t)*hccr, (uint32_t)*hcor, - (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); - - return 0; -} - -/* - * Destroy the appropriate control structures corresponding - * the EHCI host controller. - */ -int ehci_hcd_stop(int index) -{ - struct exynos_ehci *ctx = &exynos; - - reset_usb_phy(ctx->usb); - - return 0; -} -#endif - -#ifdef CONFIG_DM_USB static int ehci_usb_probe(struct udevice *dev) { struct exynos_ehci_platdata *plat = dev_get_platdata(dev); @@ -377,4 +261,3 @@ U_BOOT_DRIVER(usb_ehci) = { .platdata_auto_alloc_size
[U-Boot] [PATCH v2 71/80] dm: usb: tegra: Move to driver model for USB
Move Tegra boards over to driver model for USB EHCI. There are a few things that are no-longer needed (e.g. in fdtdec.h) but these will be cleaned up in a later patch to be applied one we are confident this change is fully tested. Signed-off-by: Simon Glass --- Changes in v2: None arch/arm/mach-tegra/Kconfig | 3 +++ board/nvidia/common/board.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig index fccfd79..3625035 100644 --- a/arch/arm/mach-tegra/Kconfig +++ b/arch/arm/mach-tegra/Kconfig @@ -47,6 +47,9 @@ config DM_I2C config DM_GPIO default y +config DM_USB + default y + source "arch/arm/mach-tegra/tegra20/Kconfig" source "arch/arm/mach-tegra/tegra30/Kconfig" source "arch/arm/mach-tegra/tegra114/Kconfig" diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 018dddb..a97035c 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -128,8 +128,10 @@ int board_init(void) #ifdef CONFIG_USB_EHCI_TEGRA pin_mux_usb(); +#ifndef CONFIG_DM_USB usb_process_devicetree(gd->fdt_blob); #endif +#endif #ifdef CONFIG_LCD tegra_lcd_check_next_stage(gd->fdt_blob, 0); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 70/80] dm: usb: exynos: Enable both EHCI and XHCI on snow
Since we can support both controllers now, enable this in the device tree. Signed-off-by: Simon Glass --- Changes in v2: None arch/arm/dts/exynos5250-snow.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts index d6777ee..668961a 100644 --- a/arch/arm/dts/exynos5250-snow.dts +++ b/arch/arm/dts/exynos5250-snow.dts @@ -133,6 +133,7 @@ ehci@1211 { samsung,vbus-gpio = <&gpx1 1 GPIO_ACTIVE_HIGH>; + status = "okay"; }; xhci@1200 { -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 80/80] dm: usb: Add a README for driver model
Add some documentation describing how USB is implemented with USB. This might make things easier for people to understand. Signed-off-by: Simon Glass --- Changes in v2: - Rewrite and expand series to support driver model fully doc/driver-model/usb-info.txt | 415 ++ 1 file changed, 415 insertions(+) create mode 100644 doc/driver-model/usb-info.txt diff --git a/doc/driver-model/usb-info.txt b/doc/driver-model/usb-info.txt new file mode 100644 index 000..3762b6c --- /dev/null +++ b/doc/driver-model/usb-info.txt @@ -0,0 +1,415 @@ +How USB works with driver model +=== + +Introduction + + +Driver model USB support makes use of existing features but changes how +drivers are found. This document provides some information intended to help +understand how things work with USB in U-Boot when driver model is enabled. + + +Enabling driver model for USB +- + +A new CONFIG_DM_USB option is provided to enable driver model for USB. This +causes the USB uclass to be included, and drops the equivalent code in +usb.c. In particular the usb_init() function is then implemented by the +uclass. + + +Support for ECHI and XCHI +- + +So far OHCI is not supported. Both EHCI and XHCI drivers should be declared +as drivers in the USB uclass. For example: + +static const struct udevice_id ehci_usb_ids[] = { + { .compatible = "nvidia,tegra20-ehci", .data = USB_CTLR_T20 }, + { .compatible = "nvidia,tegra30-ehci", .data = USB_CTLR_T30 }, + { .compatible = "nvidia,tegra114-ehci", .data = USB_CTLR_T114 }, + { } +}; + +U_BOOT_DRIVER(usb_ehci) = { + .name = "ehci_tegra", + .id = UCLASS_USB, + .of_match = ehci_usb_ids, + .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .probe = tegra_ehci_usb_probe, + .remove = tegra_ehci_usb_remove, + .ops= &ehci_usb_ops, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct fdt_usb), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; + +Here ehci_usb_ids is used to list the controllers that the driver supports. +Each has its own data value. Controllers must be in the UCLASS_USB uclass. + +The ofdata_to_platdata() method allows the controller driver to grab any +necessary settings from the device tree. + +The ops here are ehci_usb_ops. All EHCI drivers will use these same ops in +most cases, since they are all ECHI-compatible. For ECHI there are also some +special operations that can be overriden when calling ehci_register(). + +The driver can use priv_auto_alloc_size to set the size of its private data. +This can hold run-time information needed by the driver for operation. It +exists when the device is probed (not when it is bound) and is removed when +the driver is removed. + +Note that usb_platdata is currently only used to deal with setting up a bus +in USB device mode (OTG operation). It can be omitted if that is not +supported. + +The driver's probe() method should do the basic controller init and then +call ehci_register() to register itself as an EHCI device. It should call +ehci_deregister() in the remove() method. Registering a new EHCI device +does not by itself cause the bus to be scanned. + +The old ehci_hcd_init() function is no-longer used. Nor is it necessary to +set up the USB controllers from board init code. When 'usb start' is used, +each controller will be probed and its bus scanned. + +XHCI works in a similar way. + + +Data structures +--- + +The following primary data structures are in use: + +- struct usb_device + This holds information about a device on the bus. All devices have + this structure, even the root hub. The controller itself does not + have this structure. You can access it for a device 'dev' with + dev_get_parentdata(dev). It matches the old structure except that the + parent and child information is not present (since driver model + handles that). Once the device is set up, you can find the device + descriptor and current configuration descriptor in this structure. + +- struct usb_platdata + This holds platform data for a controller. So far this is only used + as a work-around for controllers which can act as USB devices in OTG + mode, since the gadget framework does not use driver model. + +- struct usb_dev_platdata + This holds platform data for a device. You can access it for a + device 'dev' with dev_get_parent_platdata(dev). It holds the device + address and speed - anything that can be determined before the device + driver is actually set up. When probing the bus this structure is + used to provide essential information to the device driver. + +- struct usb_bus_priv + This is private information for each controller, maintained by the + controller uclass. It is mostly used to keep tr
[U-Boot] [PATCH v2 55/80] dm: usb: Add support for USB ethernet devices with driver model
Add support for scanning USB etghernet devices with driver model. This mostly involves scanning all buses since device numbering is not unique across buses. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/eth/usb_ether.c | 52 ++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 7cb96e3..c72b7e4 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -5,7 +5,9 @@ */ #include +#include #include +#include #include "usb_ether.h" @@ -118,8 +120,6 @@ static void probe_valid_drivers(struct usb_device *dev) int usb_host_eth_scan(int mode) { int i, old_async; - struct usb_device *dev; - if (mode == 1) printf(" scanning usb for ethernet devices... "); @@ -138,23 +138,59 @@ int usb_host_eth_scan(int mode) } usb_max_eth_dev = 0; +#ifdef CONFIG_DM_USB + /* +* TODO: We should add USB_DEVICE() declarations to each USB ethernet +* driver and then most of this file can be removed. +*/ + struct udevice *bus; + struct uclass *uc; + int ret; + + ret = uclass_get(UCLASS_USB, &uc); + if (ret) + return ret; + uclass_foreach_dev(bus, uc) { + for (i = 0; i < USB_MAX_DEVICE; i++) { + struct usb_device *dev; + + dev = usb_get_dev_index(bus, i); /* get device */ + debug("i=%d, %s\n", i, dev ? dev->dev->name : "(done)"); + if (!dev) + break; /* no more devices available */ + + /* +* find valid usb_ether driver for this device, +* if any +*/ + probe_valid_drivers(dev); + + /* check limit */ + if (usb_max_eth_dev == USB_MAX_ETH_DEV) + break; + } /* for */ + } +#else for (i = 0; i < USB_MAX_DEVICE; i++) { + struct usb_device *dev; + dev = usb_get_dev_index(i); /* get device */ debug("i=%d\n", i); - if (dev == NULL) + if (!dev) break; /* no more devices available */ /* find valid usb_ether driver for this device, if any */ probe_valid_drivers(dev); /* check limit */ - if (usb_max_eth_dev == USB_MAX_ETH_DEV) { - printf("max USB Ethernet Device reached: %d stopping\n", - usb_max_eth_dev); + if (usb_max_eth_dev == USB_MAX_ETH_DEV) break; - } } /* for */ - +#endif + if (usb_max_eth_dev == USB_MAX_ETH_DEV) { + printf("max USB Ethernet Device reached: %d stopping\n", + usb_max_eth_dev); + } usb_disable_asynch(old_async); /* restore asynch value */ printf("%d Ethernet Device(s) found\n", usb_max_eth_dev); if (usb_max_eth_dev > 0) -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 49/80] dm: usb: sandbox: Add a uclass for USB device emulation
With sandbox we want to be able to emulate USB devices so that we can test the USB stack. Add a uclass to support this. It implements the same operations as a normal USB device driver, but in this case passes them on to an emulation driver. Signed-off-by: Simon Glass --- Changes in v2: None Makefile | 1 + drivers/usb/Kconfig| 2 + drivers/usb/emul/Kconfig | 8 ++ drivers/usb/emul/Makefile | 8 ++ drivers/usb/emul/usb-emul-uclass.c | 263 + include/dm/uclass-id.h | 1 + include/usb.h | 64 - 7 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/emul/Kconfig create mode 100644 drivers/usb/emul/Makefile create mode 100644 drivers/usb/emul/usb-emul-uclass.c diff --git a/Makefile b/Makefile index 1b3ebe7..c389869 100644 --- a/Makefile +++ b/Makefile @@ -637,6 +637,7 @@ libs-y += drivers/spi/ libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/ libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ libs-y += drivers/serial/ +libs-y += drivers/usb/emul/ libs-y += drivers/usb/eth/ libs-y += drivers/usb/gadget/ libs-y += drivers/usb/host/ diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index a4414ef..637ef3d 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -51,6 +51,8 @@ config DM_USB source "drivers/usb/host/Kconfig" +source "drivers/usb/emul/Kconfig" + config USB_STORAGE bool "USB Mass Storage support" ---help--- diff --git a/drivers/usb/emul/Kconfig b/drivers/usb/emul/Kconfig new file mode 100644 index 000..ae1ab23 --- /dev/null +++ b/drivers/usb/emul/Kconfig @@ -0,0 +1,8 @@ +config USB_EMUL + bool "Support for USB device emulation" + depends on DM_USB && SANDBOX + help + Since sandbox does not have access to a real USB bus, it is possible + to use device emulators instead. This allows testing of the USB + stack on sandbox without needing a real device, or any host machine + USB resources. diff --git a/drivers/usb/emul/Makefile b/drivers/usb/emul/Makefile new file mode 100644 index 000..f75bbd8 --- /dev/null +++ b/drivers/usb/emul/Makefile @@ -0,0 +1,8 @@ +# +# (C) Copyright 2015 Google, Inc +# Written by Simon Glass +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-$(CONFIG_USB_EMUL) += usb-emul-uclass.o diff --git a/drivers/usb/emul/usb-emul-uclass.c b/drivers/usb/emul/usb-emul-uclass.c new file mode 100644 index 000..205f2c5 --- /dev/null +++ b/drivers/usb/emul/usb-emul-uclass.c @@ -0,0 +1,263 @@ +/* + * (C) Copyright 2015 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static int copy_to_unicode(char *buff, int length, const char *str) +{ + int ptr; + int i; + + if (length < 2) + return 0; + buff[1] = USB_DT_STRING; + for (ptr = 2, i = 0; ptr + 1 < length && *str; i++, ptr += 2) { + buff[ptr] = str[i]; + buff[ptr + 1] = 0; + } + buff[0] = ptr; + + return ptr; +} + +static int usb_emul_get_string(struct usb_string *strings, int index, + char *buff, int length) +{ + if (index == 0) { + char *desc = buff; + + desc[0] = 4; + desc[1] = USB_DT_STRING; + desc[2] = 0x09; + desc[3] = 0x14; + return 4; + } else if (strings) { + struct usb_string *ptr; + + for (ptr = strings; ptr->s; ptr++) { + if (ptr->id == index) + return copy_to_unicode(buff, length, ptr->s); + } + } + + return -EINVAL; +} + +static struct usb_generic_descriptor **find_descriptor( + struct usb_generic_descriptor **ptr, int type, int index) +{ + debug("%s: type=%x, index=%d\n", __func__, type, index); + for (; *ptr; ptr++) { + if ((*ptr)->bDescriptorType != type) + continue; + switch (type) { + case USB_DT_CONFIG: { + struct usb_config_descriptor *cdesc; + + cdesc = (struct usb_config_descriptor *)*ptr; + if (cdesc && cdesc->bConfigurationValue == index) + return ptr; + break; + } + default: + return ptr; + } + } + debug("%s: config ptr=%p\n", __func__, *ptr); + + return ptr; +} + +static int usb_emul_get_descriptor(struct usb_dev_platdata *plat, int value, + void *buffer, int length) +{ + struct usb_generic_descriptor **ptr; + int type = value >> 8; + int index = value & 0xff; + int upt
[U-Boot] [PATCH v2 65/80] dm: usb: Support driver model in XHCI
Add driver model support in the XHCI support code so that it can be used by XHCI USB drivers. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/xhci-mem.c | 1 + drivers/usb/host/xhci.c | 179 ++-- drivers/usb/host/xhci.h | 24 ++ 3 files changed, 197 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 1b55534..79cb17e 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 4d94618..6d9d4a6 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -108,11 +109,24 @@ static struct descriptor { }, }; +#ifndef CONFIG_DM_USB static struct xhci_ctrl xhcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; +#endif struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev) { +#ifdef CONFIG_DM_USB + struct udevice *dev; + + /* Find the USB controller */ + for (dev = udev->dev; +device_get_uclass_id(dev) != UCLASS_USB; +dev = dev->parent) + ; + return dev_get_priv(dev); +#else return udev->controller; +#endif } /** @@ -467,7 +481,7 @@ static int xhci_address_device(struct usb_device *udev, int root_portnr) * @param udev pointer to the Device Data Structure * @return Returns 0 on succes else return error code on failure */ -int usb_alloc_device(struct usb_device *udev) +int _xhci_alloc_device(struct usb_device *udev) { struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); union xhci_trb *event; @@ -505,6 +519,13 @@ int usb_alloc_device(struct usb_device *udev) return 0; } +#ifndef CONFIG_DM_USB +int usb_alloc_device(struct usb_device *udev) +{ + return _xhci_alloc_device(udev); +} +#endif + /* * Full speed devices may have a max packet size greater than 8 bytes, but the * USB core doesn't know that until it reads the first 8 bytes of the @@ -864,9 +885,8 @@ unknown: * @param interval interval of the interrupt * @return 0 */ -int -submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, - int length, int interval) +static int _xhci_submit_int_msg(struct usb_device *udev, unsigned long pipe, + void *buffer, int length, int interval) { /* * TODO: Not addressing any interrupt type transfer requests @@ -884,9 +904,8 @@ submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, * @param length length of the buffer * @return returns 0 if successful else -1 on failure */ -int -submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, - int length) +static int _xhci_submit_bulk_msg(struct usb_device *udev, unsigned long pipe, +void *buffer, int length) { if (usb_pipetype(pipe) != PIPE_BULK) { printf("non-bulk pipe (type=%lu)", usb_pipetype(pipe)); @@ -1005,6 +1024,7 @@ static int xhci_lowlevel_stop(struct xhci_ctrl *ctrl) return 0; } +#ifndef CONFIG_DM_USB int submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) { @@ -1018,6 +1038,18 @@ int submit_control_msg(struct usb_device *udev, unsigned long pipe, hop->portnr); } +int submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, + int length) +{ + return _xhci_submit_bulk_msg(udev, pipe, buffer, length); +} + +int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, + int length, int interval) +{ + return _xhci_submit_int_msg(udev, pipe, buffer, length, interval); +} + /** * Intialises the XHCI host controller * and allocates the necessary data structures @@ -1067,3 +1099,136 @@ int usb_lowlevel_stop(int index) return 0; } +#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_parentdata(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, + struct devrequest *setup) +{ +
[U-Boot] [PATCH v2 48/80] dm: usb: Move struct usb_string to a common place
This is needed for sandbox USB device emulation, so move it to a place where it can be found by things other than gadgets. Signed-off-by: Simon Glass --- Changes in v2: None include/linux/usb/ch9.h| 13 + include/linux/usb/gadget.h | 13 - 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index bd48704..10675b4 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -1002,4 +1002,17 @@ struct usb_set_sel_req { */ #define USB_SELF_POWER_VBUS_MAX_DRAW 100 +/** + * struct usb_string - wraps a C string and its USB id + * @id:the (nonzero) ID for this string + * @s:the string, in UTF-8 encoding + * + * If you're using usb_gadget_get_string(), use this to wrap a string + * together with its ID. + */ +struct usb_string { + u8 id; + const char *s; +}; + #endif /* __LINUX_USB_CH9_H */ diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 9bccd45..bd409bc 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -806,19 +806,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver); /* utility to simplify dealing with string descriptors */ /** - * struct usb_string - wraps a C string and its USB id - * @id:the (nonzero) ID for this string - * @s:the string, in UTF-8 encoding - * - * If you're using usb_gadget_get_string(), use this to wrap a string - * together with its ID. - */ -struct usb_string { - u8 id; - const char *s; -}; - -/** * struct usb_gadget_strings - a set of USB strings in a given language * @language:identifies the strings' language (0x0409 for en-us) * @strings:array of strings with their ids -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 53/80] dm: usb: sandbox: Add a driver for sandbox
This driver supports using emulation devices to provide a USB bus within sandbox. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/Makefile | 1 + drivers/usb/host/usb-sandbox.c | 117 + 2 files changed, 118 insertions(+) create mode 100644 drivers/usb/host/usb-sandbox.c diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 9419295..7658f87 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -7,6 +7,7 @@ ifdef CONFIG_DM_USB obj-$(CONFIG_CMD_USB) += usb-uclass.o +obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif # ohci diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c new file mode 100644 index 000..c5f9822 --- /dev/null +++ b/drivers/usb/host/usb-sandbox.c @@ -0,0 +1,117 @@ +/* + * (C) Copyright 2015 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static void usbmon_trace(struct udevice *bus, ulong pipe, +struct devrequest *setup, struct udevice *emul) +{ + static const char types[] = "ZICB"; + int type; + + type = (pipe & USB_PIPE_TYPE_MASK) >> USB_PIPE_TYPE_SHIFT; + debug("0 0 S %c%c:%d:%03ld:%ld", types[type], + pipe & USB_DIR_IN ? 'i' : 'o', + bus->seq, + (pipe & USB_PIPE_DEV_MASK) >> USB_PIPE_DEV_SHIFT, + (pipe & USB_PIPE_EP_MASK) >> USB_PIPE_EP_SHIFT); + if (setup) { + debug(" s %02x %02x %04x %04x %04x", setup->requesttype, + setup->request, setup->value, setup->index, + setup->length); + } + debug(" %s", emul ? emul->name : "(no emul found)"); + + debug("\n"); +} + +static int sandbox_submit_control(struct udevice *bus, + struct usb_device *udev, + unsigned long pipe, + void *buffer, int length, + struct devrequest *setup) +{ + struct udevice *emul; + int ret; + + /* Just use child of dev as emulator? */ + debug("%s: bus=%s\n", __func__, bus->name); + ret = usb_emul_find(bus, pipe, &emul); + usbmon_trace(bus, pipe, setup, emul); + if (ret) + return ret; + ret = usb_emul_control(emul, udev, pipe, buffer, length, setup); + if (ret < 0) { + debug("ret=%d\n", ret); + udev->status = ret; + udev->act_len = 0; + } else { + udev->status = 0; + udev->act_len = ret; + } + + return ret; +} + +static int sandbox_submit_bulk(struct udevice *bus, struct usb_device *udev, + unsigned long pipe, void *buffer, int length) +{ + struct udevice *emul; + int ret; + + /* Just use child of dev as emulator? */ + debug("%s: bus=%s\n", __func__, bus->name); + ret = usb_emul_find(bus, pipe, &emul); + usbmon_trace(bus, pipe, NULL, emul); + if (ret) + return ret; + ret = usb_emul_bulk(emul, udev, pipe, buffer, length); + if (ret < 0) { + debug("ret=%d\n", ret); + udev->status = ret; + udev->act_len = 0; + } else { + udev->status = 0; + udev->act_len = ret; + } + + return ret; +} + +static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev) +{ + return 0; +} + +static int sandbox_usb_probe(struct udevice *dev) +{ + return 0; +} + +static const struct dm_usb_ops sandbox_usb_ops = { + .control= sandbox_submit_control, + .bulk = sandbox_submit_bulk, + .alloc_device = sandbox_alloc_device, +}; + +static const struct udevice_id sandbox_usb_ids[] = { + { .compatible = "sandbox,usb" }, + { } +}; + +U_BOOT_DRIVER(usb_sandbox) = { + .name = "usb_sandbox", + .id = UCLASS_USB, + .of_match = sandbox_usb_ids, + .probe = sandbox_usb_probe, + .ops= &sandbox_usb_ops, +}; -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 66/80] dm: usb: Rename the XHCI HCD to U-Boot
This should be "U-Boot", not "u-boot". Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6d9d4a6..7396c2d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -704,7 +704,7 @@ static int xhci_submit_root(struct usb_device *udev, unsigned long pipe, srclen = 4; break; case 1: /* Vendor String */ - srcptr = "\16\3u\0-\0b\0o\0o\0t\0"; + srcptr = "\16\3U\0-\0B\0o\0o\0t\0"; srclen = 14; break; case 2: /* Product Name */ -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 68/80] dm: usb: exynos: Use driver model for USB
Convert Exynos boards over to use driver model for USB. This does not remove any unnecessary code so far. Signed-off-by: Simon Glass --- Changes in v2: None arch/arm/cpu/armv7/exynos/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/cpu/armv7/exynos/Kconfig b/arch/arm/cpu/armv7/exynos/Kconfig index eb86a7f..b042fba 100644 --- a/arch/arm/cpu/armv7/exynos/Kconfig +++ b/arch/arm/cpu/armv7/exynos/Kconfig @@ -86,6 +86,9 @@ config SYS_MALLOC_F config SYS_MALLOC_F_LEN default 0x400 +config DM_USB + default y + source "board/samsung/smdkv310/Kconfig" source "board/samsung/trats/Kconfig" source "board/samsung/universal_c210/Kconfig" -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 28/80] dm: usb: Convert usb_storage to driver model
Add support for scanning USB storage devices with driver model. This mostly involves adding a USB device ID for storage devices. Signed-off-by: Simon Glass --- Changes in v2: None common/usb_storage.c | 51 +-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/common/usb_storage.c b/common/usb_storage.c index 67494b7..8b8962e 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -9,6 +9,8 @@ * * Adapted for U-Boot: * (C) Copyright 2001 Denis Peter, MPL AG Switzerland + * Driver model conversion: + * (C) Copyright 2015 Google, Inc * * For BBB support (C) Copyright 2003 * Gary Jennejohn, DENX Software Engineering @@ -33,11 +35,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include @@ -106,7 +110,6 @@ struct us_data { static struct us_data usb_stor[USB_MAX_STOR_DEV]; - #define USB_STOR_TRANSPORT_GOOD 0 #define USB_STOR_TRANSPORT_FAILED -1 #define USB_STOR_TRANSPORT_ERROR -2 @@ -119,7 +122,6 @@ unsigned long usb_stor_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer); unsigned long usb_stor_write(int device, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); -struct usb_device * usb_get_dev_index(int index); void uhci_show_temp_int_td(void); #ifdef CONFIG_PARTITIONS @@ -223,6 +225,7 @@ void usb_stor_reset(void) usb_max_devs = 0; } +#ifndef CONFIG_DM_USB /*** * scan the usb and reports device info * to the user if mode = 1 @@ -253,6 +256,7 @@ int usb_stor_scan(int mode) return 0; return -1; } +#endif static int usb_stor_irq(struct usb_device *dev) { @@ -1396,3 +1400,46 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, debug("partype: %d\n", dev_desc->part_type); return 1; } + +#ifdef CONFIG_DM_USB + +static int usb_mass_storage_probe(struct udevice *dev) +{ + struct usb_device *udev = dev_get_parentdata(dev); + int ret; + + usb_disable_asynch(1); /* asynch transfer not allowed */ + ret = usb_stor_probe_device(udev); + usb_disable_asynch(0); /* asynch transfer allowed */ + + return ret; +} + +static const struct udevice_id usb_mass_storage_ids[] = { + { .compatible = "usb-mass-storage" }, + { } +}; + +U_BOOT_DRIVER(usb_mass_storage) = { + .name = "usb_mass_storage", + .id = UCLASS_MASS_STORAGE, + .of_match = usb_mass_storage_ids, + .probe = usb_mass_storage_probe, +}; + +UCLASS_DRIVER(usb_mass_storage) = { + .id = UCLASS_MASS_STORAGE, + .name = "usb_mass_storage", +}; + +static const struct usb_device_id mass_storage_id_table[] = { + { + .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, + .bInterfaceClass = USB_CLASS_MASS_STORAGE + }, + { } /* Terminating entry */ +}; + +USB_DEVICE(usb_mass_storage, mass_storage_id_table); + +#endif -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 59/80] dm: usb: tegra: Move most of init/uninit into a function
We want to use mostly the same init and uninit code for driver model, so move the common part into two functions. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-tegra.c | 143 -- 1 file changed, 81 insertions(+), 62 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 04653e4..940a583 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -703,6 +703,82 @@ static int fdt_decode_usb(const void *blob, int node, struct fdt_usb *config) return 0; } +int usb_common_init(struct fdt_usb *config, enum usb_init_type init) +{ + int ret = 0; + + switch (init) { + case USB_INIT_HOST: + switch (config->dr_mode) { + case DR_MODE_HOST: + case DR_MODE_OTG: + break; + default: + printf("tegrausb: Invalid dr_mode %d for host mode\n", + config->dr_mode); + return -1; + } + break; + case USB_INIT_DEVICE: + if (config->periph_id != PERIPH_ID_USBD) { + printf("tegrausb: Device mode only supported on first USB controller\n"); + return -1; + } + if (!config->utmi) { + printf("tegrausb: Device mode only supported with UTMI PHY\n"); + return -1; + } + switch (config->dr_mode) { + case DR_MODE_DEVICE: + case DR_MODE_OTG: + break; + default: + printf("tegrausb: Invalid dr_mode %d for device mode\n", + config->dr_mode); + return -1; + } + break; + default: + printf("tegrausb: Unknown USB_INIT_* %d\n", init); + return -1; + } + +#ifndef CONFIG_DM_USB + /* skip init, if the port is already initialized */ + if (config->initialized && config->init_type == init) + return 0; +#endif + + debug("%d, %d\n", config->utmi, config->ulpi); + if (config->utmi) + ret = init_utmi_usb_controller(config, init); + else if (config->ulpi) + ret = init_ulpi_usb_controller(config, init); + if (ret) + return ret; + + set_up_vbus(config, init); + + config->init_type = init; + + return 0; +} + +void usb_common_uninit(struct fdt_usb *priv) +{ + struct usb_ctlr *usbctlr; + + usbctlr = priv->reg; + + /* Stop controller */ + writel(0, &usbctlr->usb_cmd); + udelay(1000); + + /* Initiate controller reset */ + writel(2, &usbctlr->usb_cmd); + udelay(1000); +} + static const struct ehci_ops tegra_ehci_ops = { .set_usb_mode = tegra_ehci_set_usbmode, .get_port_speed = tegra_ehci_get_port_speed, @@ -795,6 +871,7 @@ int ehci_hcd_init(int index, enum usb_init_type init, { struct fdt_usb *config; struct usb_ctlr *usbctlr; + int ret; if (index >= port_count) return -1; @@ -802,62 +879,14 @@ int ehci_hcd_init(int index, enum usb_init_type init, config = &port[index]; ehci_set_controller_priv(index, config, &tegra_ehci_ops); - switch (init) { - case USB_INIT_HOST: - switch (config->dr_mode) { - case DR_MODE_HOST: - case DR_MODE_OTG: - break; - default: - printf("tegrausb: Invalid dr_mode %d for host mode\n", - config->dr_mode); - return -1; - } - break; - case USB_INIT_DEVICE: - if (config->periph_id != PERIPH_ID_USBD) { - printf("tegrausb: Device mode only supported on first USB controller\n"); - return -1; - } - if (!config->utmi) { - printf("tegrausb: Device mode only supported with UTMI PHY\n"); - return -1; - } - switch (config->dr_mode) { - case DR_MODE_DEVICE: - case DR_MODE_OTG: - break; - default: - printf("tegrausb: Invalid dr_mode %d for device mode\n", - config->dr_mode); - return -1; - } - break; - default: - printf("tegrausb: Unknown USB_INIT_* %d\n", init); - return -1; - } - - /* skip init, if the port is already initialized */ - if (config->initialized && config->init_type == init) - goto success; - - if (config->utmi
[U-Boot] [PATCH v2 56/80] dm: usb: exynos: Add driver model support to exynos EHCI
Update this driver with driver model support for USB. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-exynos.c | 112 - 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index f3c077d..86cf631 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -24,19 +25,73 @@ /* Declare global data pointer */ DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_DM_USB +struct exynos_ehci_platdata { + struct usb_platdata usb_plat; + fdt_addr_t hcd_base; + fdt_addr_t phy_base; + struct gpio_desc vbus_gpio; +}; +#endif + /** * Contains pointers to register base addresses * for the usb controller. */ struct exynos_ehci { + struct ehci_ctrl ctrl; struct exynos_usb_phy *usb; struct ehci_hccr *hcd; +#ifndef CONFIG_DM_USB struct gpio_desc vbus_gpio; +#endif }; +#ifndef CONFIG_DM_USB static struct exynos_ehci exynos; +#endif -#ifdef CONFIG_OF_CONTROL +#ifdef CONFIG_DM_USB +static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +{ + struct exynos_ehci_platdata *plat = dev_get_platdata(dev); + const void *blob = gd->fdt_blob; + unsigned int node; + int depth; + + /* +* Get the base address for XHCI controller from the device node +*/ + plat->hcd_base = dev_get_addr(dev); + if (plat->hcd_base == FDT_ADDR_T_NONE) { + debug("Can't get the XHCI register base address\n"); + return -ENXIO; + } + + depth = 0; + node = fdtdec_next_compatible_subnode(blob, dev->of_offset, + COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth); + if (node <= 0) { + debug("XHCI: Can't get device node for usb3-phy controller\n"); + return -ENODEV; + } + + /* +* Get the base address for usbphy from the device node +*/ + plat->phy_base = fdtdec_get_addr(blob, node, "reg"); + if (plat->phy_base == FDT_ADDR_T_NONE) { + debug("Can't get the usbphy register address\n"); + return -ENXIO; + } + + /* Vbus gpio */ + gpio_request_by_name(dev, "samsung,vbus-gpio", 0, +&plat->vbus_gpio, GPIOD_IS_OUT); + + return 0; +} +#else static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos) { fdt_addr_t addr; @@ -215,6 +270,7 @@ static void reset_usb_phy(struct exynos_usb_phy *usb) set_usbhost_phy_ctrl(POWER_USB_HOST_PHY_CTRL_DISABLE); } +#ifndef CONFIG_DM_USB /* * EHCI-initialization * Create the appropriate control structures to manage @@ -268,3 +324,57 @@ int ehci_hcd_stop(int index) return 0; } +#endif + +#ifdef CONFIG_DM_USB +static int ehci_usb_probe(struct udevice *dev) +{ + struct exynos_ehci_platdata *plat = dev_get_platdata(dev); + struct exynos_ehci *ctx = dev_get_priv(dev); + struct ehci_hcor *hcor; + + ctx->hcd = (struct ehci_hccr *)plat->hcd_base; + ctx->usb = (struct exynos_usb_phy *)plat->phy_base; + hcor = (struct ehci_hcor *)((uint32_t)ctx->hcd + + HC_LENGTH(ehci_readl(&ctx->hcd->cr_capbase))); + + /* setup the Vbus gpio here */ + if (dm_gpio_is_valid(&plat->vbus_gpio)) + dm_gpio_set_value(&plat->vbus_gpio, 1); + + setup_usb_phy(ctx->usb); + + return ehci_register(dev, ctx->hcd, hcor, NULL, 0, USB_INIT_HOST); +} + +static int ehci_usb_remove(struct udevice *dev) +{ + struct exynos_ehci *ctx = dev_get_priv(dev); + int ret; + + ret = ehci_deregister(dev); + if (ret) + return ret; + reset_usb_phy(ctx->usb); + + return 0; +} + +static const struct udevice_id ehci_usb_ids[] = { + { .compatible = "samsung,exynos-ehci" }, + { } +}; + +U_BOOT_DRIVER(usb_ehci) = { + .name = "ehci_exynos", + .id = UCLASS_USB, + .of_match = ehci_usb_ids, + .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .probe = ehci_usb_probe, + .remove = ehci_usb_remove, + .ops= &ehci_usb_ops, + .priv_auto_alloc_size = sizeof(struct exynos_ehci), + .platdata_auto_alloc_size = sizeof(struct exynos_ehci_platdata), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; +#endif -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 36/80] dm: usb: Pass EHCI controller pointer to ehci_get_portsc_register()
Adjust this function so that it is passed an EHCI controller pointer so that implementations can look up their controller. This makes the weak functions use a consistent API. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-faraday.c | 4 ++-- drivers/usb/host/ehci-hcd.c | 6 +++--- drivers/usb/host/ehci.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/ehci-faraday.c b/drivers/usb/host/ehci-faraday.c index c64672b..b865fea 100644 --- a/drivers/usb/host/ehci-faraday.c +++ b/drivers/usb/host/ehci-faraday.c @@ -134,7 +134,7 @@ int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg) * This ehci_get_portsc_register() overrides the weak function * in "ehci-hcd.c". */ -uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port) +uint32_t *ehci_get_portsc_register(struct ehci_ctrl *ctrl, int port) { /* Faraday EHCI has one and only one portsc register */ if (port) { @@ -144,5 +144,5 @@ uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port) } /* Faraday EHCI PORTSC register offset is 0x20 from hcor */ - return (uint32_t *)((uint8_t *)hcor + 0x20); + return (uint32_t *)((uint8_t *)ctrl->hcor + 0x20); } diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 196e23a..4b0074e 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -144,7 +144,7 @@ __weak void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, mdelay(50); } -__weak uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port) +__weak uint32_t *ehci_get_portsc_register(struct ehci_ctrl *ctrl, int port) { if (port < 0 || port >= CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) { /* Printing the message would cause a scan failure! */ @@ -152,7 +152,7 @@ __weak uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port) return NULL; } - return (uint32_t *)&hcor->or_portsc[port]; + return (uint32_t *)&ctrl->hcor->or_portsc[port]; } static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec) @@ -687,7 +687,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer, case USB_REQ_GET_STATUS | ((USB_RT_PORT | USB_DIR_IN) << 8): case USB_REQ_SET_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8): case USB_REQ_CLEAR_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8): - status_reg = ehci_get_portsc_register(ctrl->hcor, port - 1); + status_reg = ehci_get_portsc_register(ctrl, port - 1); if (!status_reg) return -1; break; diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 164b3cb..0fd59bc 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -256,7 +256,7 @@ int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg); void ehci_set_usbmode(struct ehci_ctrl *ctrl); void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, uint32_t *reg); -uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port); +uint32_t *ehci_get_portsc_register(struct ehci_ctrl *ctrl, int port); /** * ehci_set_controller_priv() - Set up private data for the controller -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 62/80] dm: usb: xhci: Use explicit parameters for xhci_alloc_virt_device()
This function should not be delving into struct usb_device. Pass in the parameters it needs directly. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/xhci-mem.c | 4 +--- drivers/usb/host/xhci.c | 2 +- drivers/usb/host/xhci.h | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 89908e8..4644ffa 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -352,12 +352,10 @@ static struct xhci_container_ctx * @param udev pointer to USB deivce structure * @return 0 on success else -1 on failure */ -int xhci_alloc_virt_device(struct usb_device *udev) +int xhci_alloc_virt_device(struct xhci_ctrl *ctrl, unsigned int slot_id) { u64 byte_64 = 0; - unsigned int slot_id = udev->slot_id; struct xhci_virt_device *virt_dev; - struct xhci_ctrl *ctrl = udev->controller; /* Slot ID 0 is reserved */ if (ctrl->devs[slot_id]) { diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ab39878..de006f7 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -491,7 +491,7 @@ int usb_alloc_device(struct usb_device *udev) xhci_acknowledge_event(ctrl); - ret = xhci_alloc_virt_device(udev); + ret = xhci_alloc_virt_device(ctrl, udev->slot_id); if (ret < 0) { /* * TODO: Unsuccessful Address Device command shall leave diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6e76872..00faa81 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1246,7 +1246,7 @@ void xhci_flush_cache(uint32_t addr, u32 type_len); void xhci_inval_cache(uint32_t addr, u32 type_len); void xhci_cleanup(struct xhci_ctrl *ctrl); struct xhci_ring *xhci_ring_alloc(unsigned int num_segs, bool link_trbs); -int xhci_alloc_virt_device(struct usb_device *udev); +int xhci_alloc_virt_device(struct xhci_ctrl *ctrl, unsigned int slot_id); int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr, struct xhci_hcor *hcor); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 32/80] dm: usb: tegra: Store the controller type explicitly
At present the tegra driver uses a separate pointer to know which controller type is in use. This works because only one controller type is used at a time. With driver model we want to make the controller state hermetic in the sense that it is not necessary to look elsewhere to know the controller type. This will permit a controller to implement the EHCI weak functions without reference to global data structures. To achieve this, define an enum for the controller type and store it with the information on each EHCI controller. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-tegra.c | 30 -- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 0831fe9..9a73e60 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -61,6 +61,14 @@ enum dr_mode { DR_MODE_OTG,/* supports both */ }; +enum usb_ctlr_type { + USB_CTLR_T20, + USB_CTLR_T30, + USB_CTLR_T114, + + USB_CTRL_COUNT, +}; + /* Information about a USB port */ struct fdt_usb { struct usb_ctlr *reg; /* address of registers in physical memory */ @@ -69,6 +77,7 @@ struct fdt_usb { unsigned enabled:1; /* 1 to enable, 0 to disable */ unsigned has_legacy_mode:1; /* 1 if this port has legacy mode */ unsigned initialized:1; /* has this port already been initialized? */ + enum usb_ctlr_type type; enum usb_init_type init_type; enum dr_mode dr_mode; /* dual role mode */ enum periph_id periph_id;/* peripheral id */ @@ -162,7 +171,7 @@ struct fdt_usb_controller { const unsigned *pll_parameter; }; -static struct fdt_usb_controller fdt_usb_controllers[] = { +static struct fdt_usb_controller fdt_usb_controllers[USB_CTRL_COUNT] = { { .compat = COMPAT_NVIDIA_TEGRA20_USB, .has_hostpc = 0, @@ -284,7 +293,7 @@ void usbf_reset_controller(struct fdt_usb *config, struct usb_ctlr *usbctlr) setbits_le32(&usbctlr->susp_ctrl, UTMIP_PHY_ENB); } -static const unsigned *get_pll_timing(void) +static const unsigned *get_pll_timing(struct fdt_usb_controller *controller) { const unsigned *timing; @@ -331,6 +340,7 @@ static void init_phy_mux(struct fdt_usb *config, uint pts, static int init_utmi_usb_controller(struct fdt_usb *config, enum usb_init_type init) { + struct fdt_usb_controller *controller; u32 b_sess_valid_mask, val; int loop_count; const unsigned *timing; @@ -363,11 +373,14 @@ static int init_utmi_usb_controller(struct fdt_usb *config, VBUS_SENSE_CTL_MASK, VBUS_SENSE_CTL_A_SESS_VLD << VBUS_SENSE_CTL_SHIFT); + controller = &fdt_usb_controllers[config->type]; + debug("controller=%p, type=%d\n", controller, config->type); + /* * PLL Delay CONFIGURATION settings. The following parameters control * the bring up of the plls. */ - timing = get_pll_timing(); + timing = get_pll_timing(controller); if (!controller->has_hostpc) { val = readl(&usbctlr->utmip_misc_cfg1); @@ -702,10 +715,12 @@ static int fdt_decode_usb(const void *blob, int node, struct fdt_usb *config) * @blob: fdt blob * @node_list: list of nodes to process (any <=0 are ignored) * @count: number of nodes to process + * @id:controller type (enum usb_ctlr_type) * * Return: 0 - ok, -1 - error */ -static int process_usb_nodes(const void *blob, int node_list[], int count) +static int process_usb_nodes(const void *blob, int node_list[], int count, +enum usb_ctlr_type id) { struct fdt_usb config; int node, i; @@ -729,9 +744,11 @@ static int process_usb_nodes(const void *blob, int node_list[], int count) return -1; } if (!clk_done) { - config_clock(get_pll_timing()); + config_clock(get_pll_timing( + &fdt_usb_controllers[id])); clk_done = 1; } + config.type = id; config.initialized = 0; /* add new USB port to the list of available ports */ @@ -753,7 +770,7 @@ int usb_process_devicetree(const void *blob) count = fdtdec_find_aliases_for_id(blob, "usb", controller->compat, node_list, USB_PORTS_MAX); if (count) { - err = process_usb_nodes(blob, node_list, count); + err = process_usb_nodes(blob, node_list, count, i); if (err) printf("%s: Error processing USB node!\n", __fu
[U-Boot] [PATCH v2 61/80] dm: usb: xhci: Use a function to get xhci_ctrl
Rather than getting this directly from struct usb_device, call a function to obtain it. This will make it possible for driver model to provide it another way. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/xhci-ring.c | 8 drivers/usb/host/xhci.c | 19 --- drivers/usb/host/xhci.h | 2 ++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b5aade9..246b697 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -353,7 +353,7 @@ static void giveback_first_trb(struct usb_device *udev, int ep_index, int start_cycle, struct xhci_generic_trb *start_trb) { - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); /* * Pass all the TRBs to the hardware at once and make sure this write @@ -477,7 +477,7 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected) */ static void abort_td(struct usb_device *udev, int ep_index) { - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); struct xhci_ring *ring = ctrl->devs[udev->slot_id]->eps[ep_index].ring; union xhci_trb *event; u32 field; @@ -554,7 +554,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, int start_cycle; u32 field = 0; u32 length_field = 0; - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); int slot_id = udev->slot_id; int ep_index; struct xhci_virt_device *virt_dev; @@ -748,7 +748,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, u32 length_field; u64 buf_64 = 0; struct xhci_generic_trb *start_trb; - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); int slot_id = udev->slot_id; int ep_index; u32 trb_fields[4]; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 87f2972..ab39878 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -110,6 +110,11 @@ static struct descriptor { static struct xhci_ctrl xhcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; +struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev) +{ + return udev->controller; +} + /** * Waits for as per specified amount of time * for the "result" to match with "done" @@ -250,7 +255,7 @@ static int xhci_configure_endpoints(struct usb_device *udev, bool ctx_change) { struct xhci_container_ctx *in_ctx; struct xhci_virt_device *virt_dev; - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); union xhci_trb *event; virt_dev = ctrl->devs[udev->slot_id]; @@ -298,7 +303,7 @@ static int xhci_set_configuration(struct usb_device *udev) int ep_index; unsigned int dir; unsigned int ep_type; - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); int num_of_ep; int ep_flag = 0; u64 trb_64 = 0; @@ -382,7 +387,7 @@ static int xhci_set_configuration(struct usb_device *udev) static int xhci_address_device(struct usb_device *udev) { int ret = 0; - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); struct xhci_slot_ctx *slot_ctx; struct xhci_input_control_ctx *ctrl_ctx; struct xhci_virt_device *virt_dev; @@ -463,8 +468,8 @@ static int xhci_address_device(struct usb_device *udev) */ int usb_alloc_device(struct usb_device *udev) { + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); union xhci_trb *event; - struct xhci_ctrl *ctrl = udev->controller; int ret; /* @@ -510,7 +515,7 @@ int usb_alloc_device(struct usb_device *udev) */ int xhci_check_maxpacket(struct usb_device *udev) { - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); unsigned int slot_id = udev->slot_id; int ep_index = 0; /* control endpoint */ struct xhci_container_ctx *in_ctx; @@ -640,7 +645,7 @@ static int xhci_submit_root(struct usb_device *udev, unsigned long pipe, int len, srclen; uint32_t reg; volatile uint32_t *status_reg; - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); struct xhci_hcor *hcor = ctrl->hcor; if ((req->requesttype & USB_RT_PORT) && @@ -904,7 +909,7 @@ int submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) { - struct xhci_ctrl *ctrl = udev->controller; + struct xhci_ctr
[U-Boot] [PATCH v2 42/80] dm: usb: Allow USB drivers to be declared and auto-probed
USB devices in U-Boot are currently probed only after all devices have been enumerated. Each type of device is probed by custom code, e.g.: - USB storage - Keyboard - Ethernet With driver model this approach doesn't work very well. We could build a picture of the bus and then go back and add the devices later, but this means that the data structures are incomplete for quite a while. It also does not follow the model of being able to bind a device when we discover it. We would prefer to have devices automatically be bound as the device is enumerated. This allows us to attach drivers to particular USB classes or product/vendor IDs. This is the method used by Linux. Add the required #defines from Linux, a way of declaring a USB driver and the logic to locate the correct driver given the USB device's descriptors. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/usb-uclass.c | 206 +- include/usb.h | 107 ++ 2 files changed, 311 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 22dcd14..a86e905 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -2,6 +2,8 @@ * (C) Copyright 2015 Google, Inc * Written by Simon Glass * + * usb_match_device() modified from Linux kernel v4.0. + * * SPDX-License-Identifier:GPL-2.0+ */ @@ -247,6 +249,179 @@ int usb_legacy_port_reset(struct usb_device *parent, int portnr) return usb_port_reset(parent, portnr); } +/* returns 0 if no match, 1 if match */ +int usb_match_device(const struct usb_device_descriptor *desc, +const struct usb_device_id *id) +{ + if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && + id->idVendor != le16_to_cpu(desc->idVendor)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && + id->idProduct != le16_to_cpu(desc->idProduct)) + return 0; + + /* No need to test id->bcdDevice_lo != 0, since 0 is never + greater than any unsigned number. */ + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && + (id->bcdDevice_lo > le16_to_cpu(desc->bcdDevice))) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && + (id->bcdDevice_hi < le16_to_cpu(desc->bcdDevice))) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && + (id->bDeviceClass != desc->bDeviceClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && + (id->bDeviceSubClass != desc->bDeviceSubClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && + (id->bDeviceProtocol != desc->bDeviceProtocol)) + return 0; + + return 1; +} + +/* returns 0 if no match, 1 if match */ +int usb_match_one_id_intf(const struct usb_device_descriptor *desc, + const struct usb_interface_descriptor *int_desc, + const struct usb_device_id *id) +{ + /* The interface class, subclass, protocol and number should never be +* checked for a match if the device class is Vendor Specific, +* unless the match record specifies the Vendor ID. */ + if (desc->bDeviceClass == USB_CLASS_VENDOR_SPEC && + !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && + (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS | + USB_DEVICE_ID_MATCH_INT_SUBCLASS | + USB_DEVICE_ID_MATCH_INT_PROTOCOL | + USB_DEVICE_ID_MATCH_INT_NUMBER))) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && + (id->bInterfaceClass != int_desc->bInterfaceClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && + (id->bInterfaceSubClass != int_desc->bInterfaceSubClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && + (id->bInterfaceProtocol != int_desc->bInterfaceProtocol)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_NUMBER) && + (id->bInterfaceNumber != int_desc->bInterfaceNumber)) + return 0; + + return 1; +} + +/* returns 0 if no match, 1 if match */ +int usb_match_one_id(struct usb_device_descriptor *desc, +struct usb_interface_descriptor *int_desc, +const struct usb_device_id *id) +{ + if (!usb_match_device(desc, id)) + return 0; + + return usb_match_one_id_intf(desc, int_desc, id); +} + +/** + * usb_find_and_bind_driver() - Find and bind the right USB driver + * + * This only looks at certain fields in the descriptor. + */ +static int usb_find_an
[U-Boot] [PATCH v2 39/80] dm: usb: Drop the EHCI weak functions
These are a pain with driver model because we might have different EHCI drivers which want to implement them differently. Now that they use consistent function signatures, we can in good conscience move them to a struct. Signed-off-by: Simon Glass --- Changes in v2: None board/genesi/mx51_efikamx/efikamx-usb.c | 5 +- drivers/usb/host/ehci-faraday.c | 113 +++- drivers/usb/host/ehci-hcd.c | 49 +++--- drivers/usb/host/ehci-mx5.c | 12 drivers/usb/host/ehci-tegra.c | 26 drivers/usb/host/ehci.h | 27 +--- 6 files changed, 136 insertions(+), 96 deletions(-) diff --git a/board/genesi/mx51_efikamx/efikamx-usb.c b/board/genesi/mx51_efikamx/efikamx-usb.c index 0c0b8d3..9dfd249 100644 --- a/board/genesi/mx51_efikamx/efikamx-usb.c +++ b/board/genesi/mx51_efikamx/efikamx-usb.c @@ -173,8 +173,9 @@ int board_ehci_hcd_init(int port) return 0; } -void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, - uint32_t *reg) +/* This overrides a weak function */ +void mx5_ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, + uint32_t *reg) { uint32_t port = OTG_BASE_ADDR + (0x200 * CONFIG_MXC_USB_PORT); struct usb_ehci *ehci = (struct usb_ehci *)port; diff --git a/drivers/usb/host/ehci-faraday.c b/drivers/usb/host/ehci-faraday.c index b865fea..821222c 100644 --- a/drivers/usb/host/ehci-faraday.c +++ b/drivers/usb/host/ehci-faraday.c @@ -29,6 +29,59 @@ static inline int ehci_is_fotg2xx(union ehci_faraday_regs *regs) return !readl(®s->usb.easstr); } +void faraday_ehci_set_usbmode(struct ehci_ctrl *ctrl) +{ + /* nothing needs to be done */ +} + +int faraday_ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg) +{ + int spd, ret = PORTSC_PSPD_HS; + union ehci_faraday_regs *regs; + + ret = (void __iomem *)((ulong)ctrl->hcor - 0x10); + if (ehci_is_fotg2xx(regs)) + spd = OTGCSR_SPD(readl(®s->otg.otgcsr)); + else + spd = BMCSR_SPD(readl(®s->usb.bmcsr)); + + switch (spd) { + case 0:/* full speed */ + ret = PORTSC_PSPD_FS; + break; + case 1:/* low speed */ + ret = PORTSC_PSPD_LS; + break; + case 2:/* high speed */ + ret = PORTSC_PSPD_HS; + break; + default: + printf("ehci-faraday: invalid device speed\n"); + break; + } + + return ret; +} + +uint32_t *faraday_ehci_get_portsc_register(struct ehci_ctrl *ctrl, int port) +{ + /* Faraday EHCI has one and only one portsc register */ + if (port) { + /* Printing the message would cause a scan failure! */ + debug("The request port(%d) is not configured\n", port); + return NULL; + } + + /* Faraday EHCI PORTSC register offset is 0x20 from hcor */ + return (uint32_t *)((uint8_t *)ctrl->hcor + 0x20); +} + +static const struct ehci_ops faraday_ehci_ops = { + .set_usb_mode = faraday_ehci_set_usbmode, + .get_port_speed = faraday_ehci_get_port_speed, + .get_portsc_register= faraday_ehci_get_portsc_register, +}; + /* * Create the appropriate control structures to manage * a new EHCI host controller. @@ -43,6 +96,7 @@ int ehci_hcd_init(int index, enum usb_init_type init, if (index < 0 || index >= ARRAY_SIZE(base_list)) return -1; + ehci_set_controller_priv(index, NULL, &faraday_ehci_ops); regs = (void __iomem *)base_list[index]; hccr = (struct ehci_hccr *)®s->usb.hccr; hcor = (struct ehci_hcor *)®s->usb.hcor; @@ -87,62 +141,3 @@ int ehci_hcd_stop(int index) { return 0; } - -/* - * This ehci_set_usbmode() overrides the weak function - * in "ehci-hcd.c". - */ -void ehci_set_usbmode(struct ehci_ctrl *ctrl) -{ - /* nothing needs to be done */ -} - -/* - * This ehci_get_port_speed() overrides the weak function - * in "ehci-hcd.c". - */ -int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg) -{ - int spd, ret = PORTSC_PSPD_HS; - union ehci_faraday_regs *regs; - - ret = (void __iomem *)((ulong)ctrl->hcor - 0x10); - if (ehci_is_fotg2xx(regs)) - spd = OTGCSR_SPD(readl(®s->otg.otgcsr)); - else - spd = BMCSR_SPD(readl(®s->usb.bmcsr)); - - switch (spd) { - case 0:/* full speed */ - ret = PORTSC_PSPD_FS; - break; - case 1:/* low speed */ - ret = PORTSC_PSPD_LS; - break; - case 2:/* high speed */ - ret = PORTSC_PSPD_HS; - break; - default: - printf("ehci-faraday: invalid device speed\n"); - break; - } - - return ret; -} - -/* - * This ehci_g
[U-Boot] [PATCH v2 13/80] dm: usb: Adjust usb_alloc_new_device() to return an error
This function returns NULL on error at present. Adjust it so that we can return a real error, as is needed with driver model. Also improve the error handling in its caller, usb_hub_port_connect_change(), and adjust the code order to prepare for driver model. Signed-off-by: Simon Glass --- Changes in v2: None common/usb.c | 17 - common/usb_hub.c | 41 ++--- include/usb.h| 20 ++-- 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/common/usb.c b/common/usb.c index 32e15cd..f87c6a5 100644 --- a/common/usb.c +++ b/common/usb.c @@ -94,12 +94,12 @@ int usb_init(void) controllers_initialized++; start_index = dev_index; printf("scanning bus %d for devices... ", i); - dev = usb_alloc_new_device(ctrl); + ret = usb_alloc_new_device(ctrl, &dev); /* * device 0 is always present * (root hub, so let it analyze) */ - if (dev) + if (!ret) usb_new_device(dev); if (start_index == dev_index) @@ -827,16 +827,13 @@ struct usb_device *usb_get_dev_index(int index) return &usb_dev[index]; } -/* returns a pointer of a new device structure or NULL, if - * no device struct is available - */ -struct usb_device *usb_alloc_new_device(void *controller) +int usb_alloc_new_device(struct udevice *controller, struct usb_device **devp) { int i; debug("New Device %d\n", dev_index); if (dev_index == USB_MAX_DEVICE) { printf("ERROR, too many USB Devices, max=%d\n", USB_MAX_DEVICE); - return NULL; + return -ENOSPC; } /* default Address is 0, real addresses start with 1 */ usb_dev[dev_index].devnum = dev_index + 1; @@ -846,7 +843,9 @@ struct usb_device *usb_alloc_new_device(void *controller) usb_dev[dev_index].parent = NULL; usb_dev[dev_index].controller = controller; dev_index++; - return &usb_dev[dev_index - 1]; + *devp = &usb_dev[dev_index - 1]; + + return 0; } /* @@ -854,7 +853,7 @@ struct usb_device *usb_alloc_new_device(void *controller) * Called in error cases where configuring a newly attached * device fails for some reason. */ -void usb_free_device(void) +void usb_free_device(struct udevice *controller) { dev_index--; debug("Freeing device node: %d\n", dev_index); diff --git a/common/usb_hub.c b/common/usb_hub.c index 66b4a72..7199e25 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -206,16 +207,18 @@ int hub_port_reset(struct usb_device *dev, int port, } -void usb_hub_port_connect_change(struct usb_device *dev, int port) +int usb_hub_port_connect_change(struct usb_device *dev, int port) { struct usb_device *usb; ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); unsigned short portstatus; + int ret, speed; /* Check status */ - if (usb_get_port_status(dev, port + 1, portsts) < 0) { + ret = usb_get_port_status(dev, port + 1, portsts); + if (ret < 0) { debug("get_port_status failed\n"); - return; + return ret; } portstatus = le16_to_cpu(portsts->wPortStatus); @@ -233,47 +236,55 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port) debug("usb_disconnect(&hub->children[port]);\n"); /* Return now if nothing is connected */ if (!(portstatus & USB_PORT_STAT_CONNECTION)) - return; + return -ENOTCONN; } mdelay(200); /* Reset the port */ - if (hub_port_reset(dev, port, &portstatus) < 0) { + ret = hub_port_reset(dev, port, &portstatus); + if (ret < 0) { printf("cannot reset port %i!?\n", port + 1); - return; + return ret; } mdelay(200); - /* Allocate a new device struct for it */ - usb = usb_alloc_new_device(dev->controller); - switch (portstatus & USB_PORT_STAT_SPEED_MASK) { case USB_PORT_STAT_SUPER_SPEED: - usb->speed = USB_SPEED_SUPER; + speed = USB_SPEED_SUPER; break; case USB_PORT_STAT_HIGH_SPEED: - usb->speed = USB_SPEED_HIGH; + speed = USB_SPEED_HIGH; break; case USB_PORT_STAT_LOW_SPEED: - usb->speed = USB_SPEED_LOW; + speed = USB_SPEED_LOW; break; default: - usb->speed = USB_SPEED_FULL; + speed = USB_SPEED_FULL; break; } + ret = usb_alloc_new_device(dev->controller, &usb); + i
[U-Boot] [PATCH v2 30/80] dm: usb: Pass EHCI controller pointer to ehci_get_port_speed()
Adjust this function so that it is passed an EHCI controller pointer so that implementations can look up their controller. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/ehci-faraday.c | 5 +++-- drivers/usb/host/ehci-hcd.c | 4 ++-- drivers/usb/host/ehci-tegra.c | 5 +++-- drivers/usb/host/ehci.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/ehci-faraday.c b/drivers/usb/host/ehci-faraday.c index 3b761bc..e386813 100644 --- a/drivers/usb/host/ehci-faraday.c +++ b/drivers/usb/host/ehci-faraday.c @@ -101,11 +101,12 @@ void ehci_set_usbmode(int index) * This ehci_get_port_speed() overrides the weak function * in "ehci-hcd.c". */ -int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg) +int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg) { int spd, ret = PORTSC_PSPD_HS; - union ehci_faraday_regs *regs = (void __iomem *)((ulong)hcor - 0x10); + union ehci_faraday_regs *regs; + ret = (void __iomem *)((ulong)ctrl->hcor - 0x10); if (ehci_is_fotg2xx(regs)) spd = OTGCSR_SPD(readl(®s->otg.otgcsr)); else diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 10a0671..fed3942 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -119,7 +119,7 @@ static struct descriptor { #define ehci_is_TDI() (0) #endif -__weak int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg) +__weak int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg) { return PORTSC_PSPD(reg); } @@ -781,7 +781,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer, tmpbuf[1] |= USB_PORT_STAT_POWER >> 8; if (ehci_is_TDI()) { - switch (ehci_get_port_speed(ctrl->hcor, reg)) { + switch (ehci_get_port_speed(ctrl, reg)) { case PORTSC_PSPD_FS: break; case PORTSC_PSPD_LS: diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index b5ad1e3..0831fe9 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -225,13 +225,14 @@ void ehci_set_usbmode(int index) * This ehci_get_port_speed overrides the weak function ehci_get_port_speed * in "ehci-hcd.c". */ -int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg) +int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg) { uint32_t tmp; uint32_t *reg_ptr; if (controller->has_hostpc) { - reg_ptr = (uint32_t *)((u8 *)&hcor->or_usbcmd + HOSTPC1_DEVLC); + reg_ptr = (uint32_t *)((u8 *)&ctrl->hcor->or_usbcmd + + HOSTPC1_DEVLC); tmp = ehci_readl(reg_ptr); return HOSTPC1_PSPD(tmp); } else diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 3e5427a..ec4d6b0 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -251,7 +251,7 @@ struct ehci_ctrl { }; /* Weak functions that drivers can override */ -int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg); +int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg); void ehci_set_usbmode(int index); void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg); uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port); -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 03/80] dm: test: bus: Use a local variable to simplify code
Adjust this test to avoid repeating the same code too often. Signed-off-by: Simon Glass --- Changes in v2: None test/dm/bus.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/dm/bus.c b/test/dm/bus.c index faffe6a..116a52d 100644 --- a/test/dm/bus.c +++ b/test/dm/bus.c @@ -273,20 +273,22 @@ DM_TEST(dm_test_bus_parent_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* As above but the size is controlled by the uclass */ static int dm_test_bus_parent_data_uclass(struct dm_test_state *dms) { + struct driver *drv; struct udevice *bus; int size; int ret; /* Set the driver size to 0 so that the uclass size is used */ ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus)); - size = bus->driver->per_child_auto_alloc_size; + drv = (struct driver *)bus->driver; + size = drv->per_child_auto_alloc_size; bus->uclass->uc_drv->per_child_auto_alloc_size = size; - bus->driver->per_child_auto_alloc_size = 0; + drv->per_child_auto_alloc_size = 0; ret = test_bus_parent_data(dms); if (ret) return ret; bus->uclass->uc_drv->per_child_auto_alloc_size = 0; - bus->driver->per_child_auto_alloc_size = size; + drv->per_child_auto_alloc_size = size; return 0; } @@ -414,19 +416,21 @@ DM_TEST(dm_test_bus_parent_platdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); static int dm_test_bus_parent_platdata_uclass(struct dm_test_state *dms) { struct udevice *bus; + struct driver *drv; int size; int ret; /* Set the driver size to 0 so that the uclass size is used */ ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus)); - size = bus->driver->per_child_platdata_auto_alloc_size; + drv = (struct driver *)bus->driver; + size = drv->per_child_platdata_auto_alloc_size; bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size; - bus->driver->per_child_platdata_auto_alloc_size = 0; + drv->per_child_platdata_auto_alloc_size = 0; ret = test_bus_parent_platdata(dms); if (ret) return ret; bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = 0; - bus->driver->per_child_platdata_auto_alloc_size = size; + drv->per_child_platdata_auto_alloc_size = size; return 0; } -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 04/80] dm: exynos: snow: Move the keyboard to I2C
The snow keyboard on shipping devices is actually on I2C not SPI. Move the label to indicate this. Signed-off-by: Simon Glass --- Changes in v2: None arch/arm/dts/exynos5250-snow.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts index 7d8be69..d6777ee 100644 --- a/arch/arm/dts/exynos5250-snow.dts +++ b/arch/arm/dts/exynos5250-snow.dts @@ -40,7 +40,7 @@ }; i2c4: i2c@12ca { - cros-ec@1e { + cros_ec: cros-ec@1e { reg = <0x1e>; compatible = "google,cros-ec"; i2c-max-frequency = <10>; @@ -65,7 +65,7 @@ spi@131b { spi-max-frequency = <100>; spi-deactivate-delay = <100>; - cros_ec: cros-ec@0 { + cros-ec@0 { reg = <0>; compatible = "google,cros-ec"; spi-max-frequency = <500>; -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 43/80] dm: usb: Bind generic USB devices when there is no driver
At present USB devices with no driver model driver cannot be seen in the device list, and we fail to set them up correctly. This means they cannot be used. While having real drivers that support driver model for all USB devices is the eventual goal, we are not there yet. As a stop-gap, add a generic USB driver which is bound when we do not have a real driver. This allows the device to be set up and shown on the bus. It also allows ad-hoc code (such as usb_ether) to find these devices and set them up. Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/host/usb-uclass.c | 18 +- include/dm/uclass-id.h| 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index a86e905..fa5f14e 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -384,7 +384,13 @@ static int usb_find_and_bind_driver(struct udevice *parent, } } - ret = -ENOENT; + /* Bind a generic driver so that the device can be used */ + snprintf(name, sizeof(name), "generic_bus_%x_dev_%x", bus_seq, devnum); + str = strdup(name); + if (!str) + return -ENOMEM; + ret = device_bind_driver(parent, "usb_dev_generic_drv", str, devp); + error: debug("%s: No match found: %d\n", __func__, ret); return ret; @@ -592,3 +598,13 @@ UCLASS_DRIVER(usb) = { .child_pre_probe = usb_child_pre_probe, .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), }; + +UCLASS_DRIVER(usb_dev_generic) = { + .id = UCLASS_USB_DEV_GENERIC, + .name = "usb_dev_generic", +}; + +U_BOOT_DRIVER(usb_dev_generic_drv) = { + .id = UCLASS_USB_DEV_GENERIC, + .name = "usb_dev_generic_drv", +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index acec938..42a6f1f 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -41,6 +41,7 @@ enum uclass_id { UCLASS_ETH, /* Ethernet device */ UCLASS_USB, /* USB bus */ UCLASS_USB_HUB, /* USB hub */ + UCLASS_USB_DEV_GENERIC, /* USB generic device */ UCLASS_COUNT, UCLASS_INVALID = -1, -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 27/80] dm: usb: Move storage device scanning into its own function
The usb_stor_scan() function is quite long, so split out the code that scans each device into its own function. Also, rather than setting up the block device list once at the start, set it up as each device is scanned. This makes it possible to use this code from driver model. Signed-off-by: Simon Glass --- Changes in v2: None common/usb_storage.c | 97 1 file changed, 59 insertions(+), 38 deletions(-) diff --git a/common/usb_storage.c b/common/usb_storage.c index acea5ae..67494b7 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -168,6 +169,60 @@ static unsigned int usb_get_max_lun(struct us_data *us) return (len > 0) ? *result : 0; } +static int usb_stor_probe_device(struct usb_device *dev) +{ + if (dev == NULL) + return -ENOENT; /* no more devices available */ + + debug("\n\nProbing for storage\n"); + if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) { + /* OK, it's a storage device. Iterate over its LUNs + * and populate `usb_dev_desc'. + */ + int lun, max_lun, start = usb_max_devs; + + max_lun = usb_get_max_lun(&usb_stor[usb_max_devs]); + for (lun = 0; + lun <= max_lun && usb_max_devs < USB_MAX_STOR_DEV; + lun++) { + struct block_dev_desc *blkdev; + + blkdev = &usb_dev_desc[usb_max_devs]; + memset(blkdev, '\0', sizeof(block_dev_desc_t)); + blkdev->if_type = IF_TYPE_USB; + blkdev->dev = usb_max_devs; + blkdev->part_type = PART_TYPE_UNKNOWN; + blkdev->target = 0xff; + blkdev->type = DEV_TYPE_UNKNOWN; + blkdev->block_read = usb_stor_read; + blkdev->block_write = usb_stor_write; + blkdev->lun = lun; + blkdev->priv = dev; + + if (usb_stor_get_info(dev, &usb_stor[start], + &usb_dev_desc[usb_max_devs]) == + 1) { + usb_max_devs++; + debug("%s: Found device %p\n", __func__, dev); + } + } + } + + /* if storage device */ + if (usb_max_devs == USB_MAX_STOR_DEV) { + printf("max USB Storage Device reached: %d stopping\n", + usb_max_devs); + return -ENOSPC; + } + + return 0; +} + +void usb_stor_reset(void) +{ + usb_max_devs = 0; +} + /*** * scan the usb and reports device info * to the user if mode = 1 @@ -176,54 +231,20 @@ static unsigned int usb_get_max_lun(struct us_data *us) int usb_stor_scan(int mode) { unsigned char i; - struct usb_device *dev; if (mode == 1) printf(" scanning usb for storage devices... "); usb_disable_asynch(1); /* asynch transfer not allowed */ - for (i = 0; i < USB_MAX_STOR_DEV; i++) { - memset(&usb_dev_desc[i], 0, sizeof(block_dev_desc_t)); - usb_dev_desc[i].if_type = IF_TYPE_USB; - usb_dev_desc[i].dev = i; - usb_dev_desc[i].part_type = PART_TYPE_UNKNOWN; - usb_dev_desc[i].target = 0xff; - usb_dev_desc[i].type = DEV_TYPE_UNKNOWN; - usb_dev_desc[i].block_read = usb_stor_read; - usb_dev_desc[i].block_write = usb_stor_write; - } - - usb_max_devs = 0; + usb_stor_reset(); for (i = 0; i < USB_MAX_DEVICE; i++) { + struct usb_device *dev; + dev = usb_get_dev_index(i); /* get device */ debug("i=%d\n", i); - if (dev == NULL) - break; /* no more devices available */ - - if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) { - /* OK, it's a storage device. Iterate over its LUNs -* and populate `usb_dev_desc'. -*/ - int lun, max_lun, start = usb_max_devs; - - max_lun = usb_get_max_lun(&usb_stor[usb_max_devs]); - for (lun = 0; -lun <= max_lun && usb_max_devs < USB_MAX_STOR_DEV; -lun++) { - usb_dev_desc[usb_max_devs].lun = lun; - if (usb_stor_get_info(dev, &usb_stor[start], - &usb_dev_desc[usb_max_devs]) == 1) { - usb
[U-Boot] [PATCH v2 44/80] dm: usb: Allow setting up a USB controller as a device/gadget
Some controllers support OTG (on-the-go) where they can operate as either host or device. The gadget layer in U-Boot supports this. While this layer does not interact with driver model, we can provide a function which sets up the controller in the correct way. This way the code at least builds (although it likely will not work). Signed-off-by: Simon Glass --- Changes in v2: None drivers/usb/gadget/ci_udc.c | 4 drivers/usb/host/usb-uclass.c | 24 2 files changed, 28 insertions(+) diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index b0ef35e..0afc987 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -883,7 +883,11 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH) return -EINVAL; +#ifdef CONFIG_DM_USB + ret = usb_setup_ehci_gadget(&controller.ctrl); +#else ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl); +#endif if (ret) return ret; diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index fa5f14e..29ef5d9 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -249,6 +249,30 @@ int usb_legacy_port_reset(struct usb_device *parent, int portnr) return usb_port_reset(parent, portnr); } +int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) +{ + struct usb_platdata *plat; + struct udevice *dev; + int ret; + + /* Find the old device and remove it */ + ret = uclass_find_device_by_seq(UCLASS_USB, 0, true, &dev); + if (ret) + return ret; + ret = device_remove(dev); + if (ret) + return ret; + + plat = dev_get_platdata(dev); + plat->init_type = USB_INIT_DEVICE; + ret = device_probe(dev); + if (ret) + return ret; + *ctlrp = dev_get_priv(dev); + + return 0; +} + /* returns 0 if no match, 1 if match */ int usb_match_device(const struct usb_device_descriptor *desc, const struct usb_device_id *id) -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 33/80] dm: usb: Pass EHCI controller pointer to ehci_powerup_fixup()
Adjust this function so that it is passed an EHCI controller pointer so that implementations can look up their controller. Signed-off-by: Simon Glass --- Changes in v2: None board/genesi/mx51_efikamx/efikamx-usb.c | 3 ++- drivers/usb/host/ehci-hcd.c | 5 +++-- drivers/usb/host/ehci-tegra.c | 3 ++- drivers/usb/host/ehci.h | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/board/genesi/mx51_efikamx/efikamx-usb.c b/board/genesi/mx51_efikamx/efikamx-usb.c index 0b43101..0c0b8d3 100644 --- a/board/genesi/mx51_efikamx/efikamx-usb.c +++ b/board/genesi/mx51_efikamx/efikamx-usb.c @@ -173,7 +173,8 @@ int board_ehci_hcd_init(int port) return 0; } -void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg) +void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, + uint32_t *reg) { uint32_t port = OTG_BASE_ADDR + (0x200 * CONFIG_MXC_USB_PORT); struct usb_ehci *ehci = (struct usb_ehci *)port; diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d85308f..e9f58e3 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -138,7 +138,8 @@ __weak void ehci_set_usbmode(int index) ehci_writel(reg_ptr, tmp); } -__weak void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg) +__weak void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, + uint32_t *reg) { mdelay(50); } @@ -843,7 +844,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer, * usb 2.0 specification say 50 ms resets on * root */ - ehci_powerup_fixup(status_reg, ®); + ehci_powerup_fixup(ctrl, status_reg, ®); ehci_writel(status_reg, reg & ~EHCI_PS_PR); /* diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 9a73e60..5d746f2 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -198,7 +198,8 @@ static struct fdt_usb_controller *controller; * This ehci_powerup_fixup overrides the weak function ehci_powerup_fixup * in "ehci-hcd.c". */ -void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg) +void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, + uint32_t *reg) { mdelay(50); /* This is to avoid PORT_ENABLE bit to be cleared in "ehci-hcd.c". */ diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index d538bb6..a00c7e7 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -254,7 +254,8 @@ struct ehci_ctrl { /* Weak functions that drivers can override */ int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg); void ehci_set_usbmode(int index); -void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg); +void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, + uint32_t *reg); uint32_t *ehci_get_portsc_register(struct ehci_hcor *hcor, int port); /** -- 2.2.0.rc0.207.ga3a616c ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot