ARM: Tegra: FDT: Add USB EHCI function for T30/T114
Subsystems (5)
PATCH v3 1/3 ARM: Tegra: FDT: Add USB EHCI function for T30/T114
Add DT node for USB EHCI function.
Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.
---
Changes in v2:
- Remove PLL parameters from dt file
Changes in v3:
- Change VBus GPIO from H.05 to DD.04 for Beaver board. I don't have Beaver board. So this needs somebody to help test. Thanks.
arch/arm/dts/tegra114.dtsi | 27 +++++++++++++++++++++++++++ arch/arm/dts/tegra30.dtsi | 27 +++++++++++++++++++++++++++ board/nvidia/dts/tegra114-dalmore.dts | 7 +++++++ board/nvidia/dts/tegra30-beaver.dts | 6 ++++++ board/nvidia/dts/tegra30-cardhu.dts | 6 ++++++ include/fdtdec.h | 2 ++ lib/fdtdec.c | 2 ++ 7 files changed, 77 insertions(+), 0 deletions(-)
arch/arm/dts/tegra114.dtsi +27 -0
@@ -216,4 +216,31 @@ clocks = <&tegra_car 15>; status = "disable"; }; + + usb at 7d000000 { + compatible = "nvidia,tegra114-ehci"; + reg = <0x7d000000 0x4000>; + interrupts = <52>; + phy_type = "utmi"; + clocks = <&tegra_car 22>; /* PERIPH_ID_USBD */ + status = "disabled"; + }; + + usb at 7d004000 { + compatible = "nvidia,tegra114-ehci"; + reg = <0x7d004000 0x4000>; + interrupts = <53>; + phy_type = "utmi"; + clocks = <&tegra_car 58>; /* PERIPH_ID_USB2 */ + status = "disabled"; + }; + + usb at 7d008000 { + compatible = "nvidia,tegra114-ehci"; + reg = <0x7d008000 0x4000>; + interrupts = <129>; + phy_type = "utmi"; + clocks = <&tegra_car 59>; /* PERIPH_ID_USB3 */ + status = "disabled"; + }; };
arch/arm/dts/tegra30.dtsi +27 -0
@@ -216,4 +216,31 @@ clocks = <&tegra_car 15>; status = "disabled"; }; + + usb at 7d000000 { + compatible = "nvidia,tegra30-ehci"; + reg = <0x7d000000 0x4000>; + interrupts = <52>; + phy_type = "utmi"; + clocks = <&tegra_car 22>; /* PERIPH_ID_USBD */ + status = "disabled"; + }; + + usb at 7d004000 { + compatible = "nvidia,tegra30-ehci"; + reg = <0x7d004000 0x4000>; + interrupts = <53>; + phy_type = "utmi"; + clocks = <&tegra_car 58>; /* PERIPH_ID_USB2 */ + status = "disabled"; + }; + + usb at 7d008000 { + compatible = "nvidia,tegra30-ehci"; + reg = <0x7d008000 0x4000>; + interrupts = <129>; + phy_type = "utmi"; + clocks = <&tegra_car 59>; /* PERIPH_ID_USB3 */ + status = "disabled"; + }; };
board/nvidia/dts/tegra114-dalmore.dts +7 -0
@@ -14,6 +14,7 @@ i2c4 = "/i2c at 7000c700"; sdhci0 = "/sdhci at 78000600"; sdhci1 = "/sdhci at 78000400"; + usb0 = "/usb at 7d008000"; }; memory {
@@ -61,4 +62,10 @@ bus-width = <8>; status = "okay"; }; + + usb at 7d008000 { + /* SPDIF_IN: USB_VBUS_EN1 */ + nvidia,vbus-gpio = <&gpio 86 0>; + status = "okay"; + }; };
board/nvidia/dts/tegra30-beaver.dts +6 -0
@@ -14,6 +14,7 @@ i2c4 = "/i2c at 7000c700"; sdhci0 = "/sdhci at 78000600"; sdhci1 = "/sdhci at 78000000"; + usb0 = "/usb at 7d008000"; }; memory {
@@ -68,4 +69,9 @@ status = "okay"; bus-width = <8>; }; + + usb at 7d008000 { + nvidia,vbus-gpio = <&gpio 236 0>; /* PDD4 */ + status = "okay"; + }; };
board/nvidia/dts/tegra30-cardhu.dts +6 -0
@@ -14,6 +14,7 @@ i2c4 = "/i2c at 7000c700"; sdhci0 = "/sdhci at 78000600"; sdhci1 = "/sdhci at 78000000"; + usb0 = "/usb at 7d008000"; }; memory {
@@ -63,4 +64,9 @@ status = "okay"; bus-width = <8>; }; + + usb at 7d008000 { + nvidia,vbus-gpio = <&gpio 233 3>; /* PDD1, EN_3V3_PU */ + status = "okay"; + }; };
include/fdtdec.h +2 -0
@@ -64,6 +64,8 @@ struct fdt_memory {enum fdt_compat_id {COMPAT_UNKNOWN ,COMPAT_NVIDIA_TEGRA20_USB ,/* Tegra20 USB port */ +COMPAT_NVIDIA_TEGRA30_USB ,/* Tegra30 USB port */ +COMPAT_NVIDIA_TEGRA114_USB ,/* Tegra114 USB port */ COMPAT_NVIDIA_TEGRA114_I2C ,/* Tegra114 I2C w/single clock source */ COMPAT_NVIDIA_TEGRA20_I2C ,/* Tegra20 i2c */ COMPAT_NVIDIA_TEGRA20_DVC ,/* Tegra20 dvc (really just i2c) */
lib/fdtdec.c +2 -0
@@ -37,6 +37,8 @@ DECLARE_GLOBAL_DATA_PTR;static const char *const compat_names[COMPAT_COUNT ] = {COMPAT (UNKNOWN ,"<none>" ),COMPAT (NVIDIA_TEGRA20_USB ,"nvidia,tegra20-ehci" ), +COMPAT (NVIDIA_TEGRA30_USB ,"nvidia,tegra30-ehci" ), +COMPAT (NVIDIA_TEGRA114_USB ,"nvidia,tegra114-ehci" ),COMPAT (NVIDIA_TEGRA114_I2C ,"nvidia,tegra114-i2c" ),COMPAT (NVIDIA_TEGRA20_I2C ,"nvidia,tegra20-i2c" ),COMPAT (NVIDIA_TEGRA20_DVC ,"nvidia,tegra20-i2c-dvc" ),
Signature · 1 line
1.7.7
PATCH v3 2/3 ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114
Tegra30 and Tegra114 are compatible except PLL parameters.
Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.
---
Changes in v2:
- Move common definitions into arch-tegra/usb.h and
chip specific definitions into arch-tegraXX(X)/usb.h
- In ehci-tegra.c, add PLL parameters for Tegra30 and Tegra114.
- In ehci-tegra.c, use the port pointed by "nvidia,has-legacy-mode" to know whether we do special handling on Port Reset.
- Remove some irrelevant whitespace changes.
- Use if-else, instead of goto in ehci-tegra.c init_utmi_usb_controller().
- Use original coding for PTS_MASK in ehci-tegra.c init_utmi_usb_controller().
Reason is that these bits are read-only on Tegra20. Don't need special handling between USB1 and USB3 ports.
- Use if-else, instead of goto in ehci-tegra.c board_usb_init().
Changes in v3:
None
arch/arm/include/asm/arch-tegra/clk_rst.h | 10 + arch/arm/include/asm/arch-tegra/usb.h | 182 ++++-------------- arch/arm/include/asm/arch-tegra114/usb.h | 156 +++++++++++++++ arch/arm/include/asm/arch-tegra20/usb.h | 155 +++++++++++++++ arch/arm/include/asm/arch-tegra30/usb.h | 168 ++++++++++++++++ board/nvidia/common/board.c | 2 +- drivers/usb/host/ehci-tegra.c | 297 +++++++++++++++++++++++++---- 7 files changed, 796 insertions(+), 174 deletions(-) create mode 100644 arch/arm/include/asm/arch-tegra114/usb.h create mode 100644 arch/arm/include/asm/arch-tegra20/usb.h create mode 100644 arch/arm/include/asm/arch-tegra30/usb.h
arch/arm/include/asm/arch-tegra/clk_rst.h +10 -0
@@ -225,6 +225,16 @@ enum { IN_408_OUT_9_6_DIVISOR = 83, }; +/* CLK_RST_CONTROLLER_UTMIP_PLL_CFG1_0 */ +#define PLLU_POWERDOWN (1 << 16) +#define PLL_ENABLE_POWERDOWN (1 << 14) +#define PLL_ACTIVE_POWERDOWN (1 << 12) + +/* CLK_RST_CONTROLLER_UTMIP_PLL_CFG2_0 */ +#define UTMIP_FORCE_PD_SAMP_C_POWERDOWN (1 << 4) +#define UTMIP_FORCE_PD_SAMP_B_POWERDOWN (1 << 2) +#define UTMIP_FORCE_PD_SAMP_A_POWERDOWN (1 << 0) +/* CLK_RST_CONTROLLER_OSC_CTRL_0 */ #define OSC_XOBP_SHIFT 1#define OSC_XOBP_MASK (1U << OSC_XOBP_SHIFT)
arch/arm/include/asm/arch-tegra/usb.h +43 -139
248 lines not on this page · raw message
arch/arm/include/asm/arch-tegra114/usb.h new file +156 -0
156 lines not on this page · raw message
arch/arm/include/asm/arch-tegra20/usb.h new file +155 -0
155 lines not on this page · raw message
arch/arm/include/asm/arch-tegra30/usb.h new file +168 -0
168 lines not on this page · raw message
board/nvidia/common/board.c +1 -1
@@ -46,7 +46,7 @@#include <asm/arch/emc.h> #endif #ifdef CONFIG_USB_EHCI_TEGRA -#include <asm/arch-tegra/usb.h> +#include <asm/arch/usb.h> #endif #ifdef CONFIG_TEGRA_MMC #include <asm/arch-tegra/tegra_mmc.h>
drivers/usb/host/ehci-tegra.c +263 -34
423 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v3 2/3 ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114
On Mon, Jun 17, 2013 at 05:09:56PM +0800, Jim Lin wrote:
[...]
board/nvidia/common/board.c line 52
Quoted 13 lines
board/nvidia/common/board.c +1
-1@@ -46,7 +46,7 @@#include <asm/arch/emc.h> #endif #ifdef CONFIG_USB_EHCI_TEGRA -#include <asm/arch-tegra/usb.h> +#include <asm/arch/usb.h> #endif #ifdef CONFIG_TEGRA_MMC #include <asm/arch-tegra/tegra_mmc.h>
With this hunk applied I get the following new build warning:
../../nvidia/common/board.c: In function 'board_init': ../../nvidia/common/board.c:171:2: warning: implicit declaration of function 'board_usb_init' [-Wimplicit-function-declaration] board_usb_init(gd->fdt_blob); ^
Reverting that one hunk makes the warning go away again and everything still builds fine, so I think it can just be removed from the patch.
Besides the one issue I'm still seeing with the very old flash drive, which might turn out not to be specific to Tegra, this series:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130617/83ed2a1d/attachment.pgp>
PATCH v3 2/3 ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114
In reply to Jim Lindrivers/usb/host/ehci-tegra.c struct fdt_usb { · line 97
Quoted 8 lines · Jim Lin
Tegra30 and Tegra114 are compatible except PLL parameters.
Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.drivers/usb/host/ehci-tegra.c +1
-0+static u32 port_clear_csc;/* Port that needs to clear CSC after Port Reset */
What "units" is that variable in? The variable name should be more like "status_reg_addr_needing_clear_csc".
drivers/usb/host/ehci-tegra.c struct fdt_usb { · line 99
Quoted 2 lines
drivers/usb/host/ehci-tegra.c +2
-0+static unsigned is_T30_compatible; +static unsigned is_T114_compatible;
Given that there is code in this patch that does:
+ if (is_T30_compatible) {
+ if (is_T114_compatible)
I think those should be is_T30_or_later and is_T114_or_later.
But, testing against SoC version is the wrong way to go. Instead, the code should set a bunch of feature flags based on the SoC it's running on during initialization, and then test those feature flags throughout the code. That way, if Tegra30 and (hypothetical future chips) Tegra200 and Tegra300 need a fix, but Tegra114 doesn't, you don't have to write tortuous if statements throughout the code, but simply have a lookup table that maps from SoC ID to the set of feature/fix flags that it needs.
See for example Linux kernel driver drivers/gpio/gpio-tegra.c's tegra20_gpio_config, tegra30_gpio_config, and tegra_gpio_of_match[], or drivers/dma/tegra20-apb-dma.c's tegra_dma_of_match[].
Quoted 5 lines
drivers/usb/host/ehci-tegra.c +5
-0+static const unsigned *get_pll_timing (void ) +{ +const unsigned *timing; + +if (is_T30_compatible) {
drivers/usb/host/ehci-tegra.c void usbf_reset_controller(struct fdt_usb *config, struct usb_ctlr *usbctlr) · line 291
Quoted 10 lines
drivers/usb/host/ehci-tegra.c +10
-0+if (is_T114_compatible) + timing = T114_usb_pll[clock_get_osc_freq ()]; +else + timing = T30_usb_pll[clock_get_osc_freq ()]; + }else { + timing = T20_usb_pll[clock_get_osc_freq ()]; + } + +return timing; +}
Following on from the feature flag discussion above, it'd be better to simply include a pointer in the per-SoC configuration table that pointed at the PLL table. That way, this function could be removed, and replaced with a simple read through a pointer.
Quoted 26 lines
drivers/usb/host/ehci-tegra.c +26
-0+int board_usb_init (const void *blob) +{ +int node_list[USB_PORTS_MAX ]; +int count, err =0 ; + + is_T30_compatible =0 ; + is_T114_compatible =0 ; + +/* count may return <0 on error */ + count =fdtdec_find_aliases_for_id (blob,"usb" , +COMPAT_NVIDIA_TEGRA20_USB , node_list,USB_PORTS_MAX ); +if (count) { + err =process_usb_nodes (blob, node_list, count); +if (err) +printf ("%s: Error processing T20 USB node!\n" , + __func__); +return err; + } + count =fdtdec_find_aliases_for_id (blob,"usb" , +COMPAT_NVIDIA_TEGRA114_USB , node_list,USB_PORTS_MAX ); +if (count) + is_T114_compatible =1 ; +else + count =fdtdec_find_aliases_for_id (blob,"usb" , +COMPAT_NVIDIA_TEGRA30_USB , node_list,USB_PORTS_MAX ); +if (count) {
drivers/usb/host/ehci-tegra.c int board_usb_init(const void *blob) · line 733
Quoted 10 lines
drivers/usb/host/ehci-tegra.c +10
-0+/* T114 is also mostly compatible to T30 */ + is_T30_compatible =1 ; + err =process_usb_nodes (blob, node_list, count); +if (err) { +if (is_T114_compatible) +printf ("%s: Error processing T114 USB node!\n" , + __func__); +else +printf ("%s: Error processing T30 USB node!\n" , + __func__);
(Following on from the comment below: Why not just say "USB node" rather than "T30 USB node" or "T114 USB node" here. That way, you completely avoid having to write an if statement.
drivers/usb/host/ehci-tegra.c int board_usb_init(const void *blob) · line 738
Quoted 5 lines
drivers/usb/host/ehci-tegra.c +5
-0+ } + } + +return err; +}
This function is pretty convoluted. It'd be far better to enhance fdtdec_find_aliases_for_id() to accept a list of compatible values, and simply return all matching instances in one go. fdtdec_find_aliases_for_id() should also return the "type" of each match, so you know if each one is a Tegra20/30/114 port.
PATCH v3 3/3 Tegra: Config: Enable Tegra30/Tegra114 USB function
In reply to Jim LinAdd USB EHCI, storage and network support.
Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.
---
Changes in v2:
- Add support for Beaver board.
Changes in v3:
- None
include/configs/beaver.h | 14 ++++++++++++++ include/configs/cardhu.h | 14 ++++++++++++++ include/configs/dalmore.h | 14 ++++++++++++++ include/configs/tegra114-common.h | 3 +++ include/configs/tegra30-common.h | 3 +++ 5 files changed, 48 insertions(+), 0 deletions(-)
include/configs/beaver.h +14 -0
@@ -71,6 +71,20 @@#define CONFIG_CMD_SF #define CONFIG_SPI_FLASH_SIZE (4 << 20) +/* USB Host support */ +#define CONFIG_USB_EHCI +#define CONFIG_USB_EHCI_TEGRA +#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 +#include "tegra-common-post.h" #endif /* __CONFIG_H */
include/configs/cardhu.h +14 -0
@@ -70,6 +70,20 @@#define CONFIG_CMD_SF #define CONFIG_SPI_FLASH_SIZE (4 << 20) +/* USB Host support */ +#define CONFIG_USB_EHCI +#define CONFIG_USB_EHCI_TEGRA +#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 +#include "tegra-common-post.h" #endif /* __CONFIG_H */
include/configs/dalmore.h +14 -0
@@ -75,6 +75,20 @@#define CONFIG_CMD_SF #define CONFIG_SPI_FLASH_SIZE (4 << 20) +/* USB Host support */ +#define CONFIG_USB_EHCI +#define CONFIG_USB_EHCI_TEGRA +#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 +#include "tegra-common-post.h" #endif /* __CONFIG_H */
include/configs/tegra114-common.h +3 -0
@@ -77,4 +77,7 @@/* Total I2C ports on Tegra114 */ #define TEGRA_I2C_NUM_CONTROLLERS 5 +/* For USB EHCI controller */ +#define CONFIG_EHCI_IS_TDI +#endif /* _TEGRA114_COMMON_H_ */
include/configs/tegra30-common.h +3 -0
@@ -90,4 +90,7 @@/* Total I2C ports on Tegra30 */ #define TEGRA_I2C_NUM_CONTROLLERS 5 +/* For USB EHCI controller */ +#define CONFIG_EHCI_IS_TDI +#endif /* _TEGRA30_COMMON_H_ */
Signature · 1 line
1.7.7
PATCH v3 3/3 Tegra: Config: Enable Tegra30/Tegra114 USB function
include/configs/beaver.h
Quoted 8 lines · Jim Lin
Add USB EHCI, storage and network support.
Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.include/configs/beaver.h +1
-0+/* USB Host support */
I notice that some Tegra20 boards include the following line here:
#define CONFIG_USB_MAX_CONTROLLER_COUNT 3
Is this necessary here too?
If it doesn't serve any purpose, can you send an extra patch to remove this from seaboard.h, harmony.h, trimslice.h, and colibtri_t20_iris.h. Thanks.
Quoted 4 lines
include/configs/beaver.h +4
-0+#define CONFIG_USB_EHCI +#define CONFIG_USB_EHCI_TEGRA +#define CONFIG_USB_STORAGE +#define CONFIG_CMD_USB
PATCH v3 3/3 Tegra: Config: Enable Tegra30/Tegra114 USB function
Dear Stephen Warren,
Quoted 12 lines · Jim Lin
include/configs/beaver.h
Quoted 8 lines
Add USB EHCI, storage and network support.
Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.include/configs/beaver.h +1
-0+/* USB Host support */ I notice that some Tegra20 boards include the following line here:
Quoted 7 lines
#define
CONFIG_USB_MAX_CONTROLLER_COUNT3Is this necessary here too?
If it doesn't serve any purpose, can you send an extra patch to remove this from
seaboard.h,harmony.h,trimslice.h, andcolibtri_t20_iris.h. Thanks.
The default value is 1, if you have multiple EHCI controllers on the board/chip, you want to configure this accordingly.
Best regards,
Marek Vasut
PATCH v3 1/3 ARM: Tegra: FDT: Add USB EHCI function for T30/T114
In reply to Jim LinQuoted 2 lines · Jim Lin
Add DT node for USB EHCI function.
Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.
This patch shouldn't touch both DT files and code at the same time. The code changes should be part of the patch to the USB driver.
board/nvidia/dts/tegra30-cardhu.dts line 71
Quoted 6 lines
board/nvidia/dts/tegra30-cardhu.dts +4
-0+ usb at 7d008000 { + nvidia,vbus-gpio = <&gpio 233 3>; /* PDD1, EN_3V3_PU */ + status = "okay"; + };
PDD1 is the wrong signal. That enables a 100L pullup to a bunch of different signals, including the VBUS GPIO. Instead, I think you should be using PEX_L1_PRSNT / EN_USB3_VBUS_OC / PDD4, which co-incidentally matches the value in the Beaver .dts file in this patch, most likely because Beaver is closely based on Cardhu.
PATCH v3 1/3 ARM: Tegra: FDT: Add USB EHCI function for T30/T114
Dear Stephen Warren,
Quoted 10 lines · Jim Lin
Quoted 2 lines
Add DT node for USB EHCI function.
Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.This patch shouldn't touch both DT files and code at the same time. The code changes should be part of the patch to the USB driver.
Quoted 3 lines
board/nvidia/dts/tegra30-cardhu.dts +0
-0
Quoted 10 lines
board/nvidia/dts/tegra30-cardhu.dts line 71
Quoted 4 lines
board/nvidia/dts/tegra30-cardhu.dts +4
-0+ usb at 7d008000 { + nvidia,vbus-gpio = <&gpio 233 3>; /* PDD1, EN_3V3_PU */ + status = "okay"; + };PDD1 is the wrong signal. That enables a 100L pullup to a bunch of different signals, including the VBUS GPIO. Instead, I think you should be using
PEX_L1_PRSNT/EN_USB3_VBUS_OC/ PDD4, which co-incidentally matches the value in the Beaver .dts file in this patch, most likely because Beaver is closely based on Cardhu.
Thanks for reviewing those, will wait for V4.
Best regards,
Marek Vasut