Re: [U-Boot] [PATCH v2 80/80] dm: usb: Add a README for driver model

2015-04-06 Thread Jim Lin

There are some typos. Please correct them, thanks.

On 03/26/2015 02:23 AM, Simon Glass wrote:

Add some documentation describing how USB is implemented with USB. This
might make things easier for people to understand.

Signed-off-by: Simon Glass s...@chromium.org
---

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

EHCI
XHCI


+-
+
+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

EHCI-compatible
For EHCI

+special operations that can be overriden when calling ehci_register().

overridden


+This defines a single controller, containing a root hub (which is required).
+The hub is emulated by a hub emulator, and the emulated hub has a single
+flash stick to emulate on one of its ports.
+
+When 'usb start' is used, the following 'dm tree' output will be available:
+
+ usb [ + ]`-- usb@1
+ usb_hub [ + ]`-- hub
+ usb_emul[ + ]|-- hub-emul
+ usb_emul[ + ]|   `-- flash-stick
+ usb_mass_st [ + ]`-- usb_mass_storage
+
+
+This may look a confusing. Most of it mirrors the device tree, but the

may look confusing
--nvpublic
___
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

2015-03-26 Thread Jim Lin

Please ignore my question because it is answered by [PATCH v2 34/80].

On 03/26/2015 11:38 AM, Jim Lin wrote:

-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 s...@chromium.org
---

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 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

2015-03-25 Thread Jim Lin

 -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 s...@chromium.org
 ---
 
 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


Re: [U-Boot] [PATCH v5 0/3] ubs: tegra: two fixes and cleanup

2014-03-12 Thread Jim Lin
On Mon, 2014-03-03 at 02:46 +0800, Stefan Agner wrote:
 Only patch 1 is an actual issue while the second patch is
 something I stumbled upon, and the third is more about
 housekeeping.
 
 I descieded to ifdef the driver, I think that this is easier to
 read and does not mix register access style. The function
 ehci_get_port_speed however don't get a pointer to the usb_ctlr
 struct and thouse has to work around that. I don't changed the
 register access style there because of this reason.
 
 The third patch is optional and implements Stephen's suggestion
 to merge the USB headers. I'm not sure wheater Tegra124 would
 also profit from this merge, if yes, I think then its definitely
 worth doing it.
 
 ---
 Changes since v4:
 - Merged Tegra124 USB header file as well
 
 Changes since v3:
 - Minor cleanup in USB header file
 
 Changes since v2:
 - Split into multiple patches
 - Using ifdef to account for differences between Tegra20/Tegra30
 - Merging of the header files
 
 Changes since v1:
 - Take differences between USBD and other USB ports into account
   port_sc1
 
 ---
 Stefan Agner (3):
   usb: tegra: fix USB2 powerdown for Tegra30 and later
   usb: tegra: fix PHY configuration
   usb: tegra: combine header file
 
  arch/arm/include/asm/arch-tegra/usb.h| 223 -
  arch/arm/include/asm/arch-tegra114/usb.h | 156 --
  arch/arm/include/asm/arch-tegra124/usb.h | 268 
 ---
  arch/arm/include/asm/arch-tegra20/usb.h  | 155 --
  arch/arm/include/asm/arch-tegra30/usb.h  | 168 ---
  board/nvidia/common/board.c  |   1 -
  drivers/usb/host/ehci-tegra.c|  28 +++-
  7 files changed, 245 insertions(+), 754 deletions(-)
  delete mode 100644 arch/arm/include/asm/arch-tegra114/usb.h
  delete mode 100644 arch/arm/include/asm/arch-tegra124/usb.h
  delete mode 100644 arch/arm/include/asm/arch-tegra20/usb.h
  delete mode 100644 arch/arm/include/asm/arch-tegra30/usb.h
 
This series
Acked-by: Jim Lin ji...@nvidia.com

--nvpublic

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


Re: [U-Boot] [PATCH] usb: tegra: Fix PHY configuration for Tegra 3

2014-02-14 Thread Jim Lin
On Fri, 2014-02-14 at 03:21 +0800, Stefan Agner wrote:
 On Tegra 3, the PTS (parallel transceiver select) and STS (serial
 transceiver select) are part of the HOSTPC1_DEVLC_0 register rather
 than PORTSC1_0 register. Since the reset configuration usually
 matches the configured registers, this error did not show up on
 Tegra 3 devices.
 
 Also clear the forced powerdown bit in the UTMIP_PLL_CFG2_0 register
 which brings USB2 in UTMI mode to work. This was clearly missing
 since the forced powerdown bit is set in reset by default for all
 USB ports.
 
 Signed-off-by: Stefan Agner ste...@agner.ch
 ---
  drivers/usb/host/ehci-tegra.c | 22 ++
  1 file changed, 18 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 index 0b42aa5..fdd56c9 100644
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c
 @@ -461,6 +461,9 @@ static int init_utmi_usb_controller(struct fdt_usb 
 *config)
   if (config-periph_id == PERIPH_ID_USBD)
   clrbits_le32(clkrst-crc_utmip_pll_cfg2,
UTMIP_FORCE_PD_SAMP_A_POWERDOWN);
 + if (config-periph_id == PERIPH_ID_USB2)
 + clrbits_le32(clkrst-crc_utmip_pll_cfg2,
 +  UTMIP_FORCE_PD_SAMP_B_POWERDOWN);
   if (config-periph_id == PERIPH_ID_USB3)
   clrbits_le32(clkrst-crc_utmip_pll_cfg2,
UTMIP_FORCE_PD_SAMP_C_POWERDOWN);
 @@ -483,9 +486,15 @@ static int init_utmi_usb_controller(struct fdt_usb 
 *config)
   clrbits_le32(usbctlr-icusb_ctrl, IC_ENB1);
  
   /* Select UTMI parallel interface */
 - clrsetbits_le32(usbctlr-port_sc1, PTS_MASK,
 - PTS_UTMI  PTS_SHIFT);
 - clrbits_le32(usbctlr-port_sc1, STS);
 + if (!controller-has_hostpc) {
 + clrsetbits_le32(usbctlr-port_sc1, PTS_MASK,
 + PTS_UTMI  PTS_SHIFT);
 + clrbits_le32(usbctlr-port_sc1, STS);
 + } else {
 + clrsetbits_le32(usbctlr-hostpc1_devlc, PTS_MASK,
 + PTS_UTMI  PTS_SHIFT);
 + clrbits_le32(usbctlr-hostpc1_devlc, STS);
 + }

Could you help to change above code like this?
Thanks.

+   if (!controller-has_hostpc) {
+   if (config-periph_id == PERIPH_ID_USBD) {
+   clrsetbits_le32(usbctlr-port_sc1, PTS1_MASK,
+   PTS_UTMI  PTS1_SHIFT);
+   clrbits_le32(usbctlr-port_sc1, STS1);
+   } else {
+   clrsetbits_le32(usbctlr-port_sc1, PTS_MASK,
+   PTS_UTMI  PTS_SHIFT);
+   clrbits_le32(usbctlr-port_sc1, STS);
+   }
+   } else {
+   clrsetbits_le32(usbctlr-hostpc1_devlc, PTS_MASK,
+   PTS_UTMI  PTS_SHIFT);
+   clrbits_le32(usbctlr-hostpc1_devlc, STS);
+   }

Others look good.

--nvpublic

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


Re: [U-Boot] [PATCH v2] usb: tegra: Fix PHY configuration for Tegra 3

2014-02-14 Thread Jim Lin


寄件者: Stefan Agner [ste...@agner.ch]
寄件日期: 2014年2月15日 上午 06:52
收件者: u-boot@lists.denx.de; Jim Lin; Tom Warren; swar...@wwwdotorg.org; 
s...@chromium.org; d...@lynxeye.de
主旨: Re: [PATCH v2] usb: tegra: Fix PHY configuration for Tegra 3

Am 2014-02-14 23:45, schrieb Stefan Agner:
   /* Select ULPI parallel interface */
 - clrsetbits_le32(usbctlr-port_sc1, PTS_MASK, PTS_ULPI  PTS_SHIFT);
 + if (!controller-has_hostpc) {
 + clrsetbits_le32(usbctlr-port_sc1, PTS_MASK,
 + PTS_ULPI  PTS_SHIFT);
 + else
 + clrsetbits_le32(usbctlr-hostpc1_devlc, PTS_MASK,
 + PTS_ULPI  PTS_SHIFT);

   /* enable ULPI transceiver */
   setbits_le32(usbctlr-susp_ctrl, ULPI_PHY_ENB);

Ok, just noticed that we need to address the different USBD register
layout on Tegra 2 here too.

Furthermore, the code does not compile with Tegra 2 header file since
the hostpc1_devlc field is missing there. The function
ehci_get_port_speed uses a define and some calculation to work around
this issue. Another solution would be to create a dummy field in the
Tegra 2 USB register header file... Any thoughts on that?

[Jim} Try use
 usbctlr-usb_cmd + HOSTPC1_DEVLC 
instead of  usbctlr-hostpc1_devlc

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


Re: [U-Boot] [PATCH V2 13/13] ARM: tegra: fix bootp issue for Tegra124 too

2014-01-26 Thread Jim Lin
On Fri, 2014-01-24 at 08:43 +0800, Stephen Warren wrote:
 From: Jim Lin ji...@nvidia.com
 
 Fix the timeout issue after running bootp command in U-Boot console.
 
 TXFIFOTHRES bits of TXFILLTUNING register should be set to 0x10 after a
 controller reset and before RUN bit is se, (per technical reference
 manual.

Stephen,
Could you help to replace , with t and put right parenthesis?
Like

controller reset and before RUN bit is set (per technical reference
manual).

Thanks,

--nvpublic



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


[U-Boot] [PATCH 1/1] ARM: config: USB: Tegra30/114: Fix EHCI timeout issue on bootp

2013-11-05 Thread Jim Lin
Fix the timeout issue after running bootp command in u-boot
console. For example you see EHCI timed out on TD- token=0x
TXFIFOTHRES bits of TXFILLTUNING register should be set to 0x10
after a controller reset and before RUN bit is set
(per technical reference manual).

Signed-off-by: Jim Lin ji...@nvidia.com
---
 include/configs/tegra114-common.h |1 +
 include/configs/tegra30-common.h  |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/configs/tegra114-common.h 
b/include/configs/tegra114-common.h
index c3de9a9..a4e8a5f 100644
--- a/include/configs/tegra114-common.h
+++ b/include/configs/tegra114-common.h
@@ -82,5 +82,6 @@
 
 /* For USB EHCI controller */
 #define CONFIG_EHCI_IS_TDI
+#define CONFIG_USB_EHCI_TXFIFO_THRESH  0x10
 
 #endif /* _TEGRA114_COMMON_H_ */
diff --git a/include/configs/tegra30-common.h b/include/configs/tegra30-common.h
index 99acbfd..b5550d7 100644
--- a/include/configs/tegra30-common.h
+++ b/include/configs/tegra30-common.h
@@ -79,5 +79,6 @@
 
 /* For USB EHCI controller */
 #define CONFIG_EHCI_IS_TDI
+#define CONFIG_USB_EHCI_TXFIFO_THRESH  0x10
 
 #endif /* _TEGRA30_COMMON_H_ */
-- 
1.7.7

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


Re: [U-Boot] [PATCH v9 2/2] console: usb: kbd: To improve TFTP booting performance

2013-08-26 Thread Jim Lin
Marek,
In common/usb_kbd.c, you applied code to wrong place.
You should apply my change to function usb_kbd_testc(), instead of 
usb_kbd_getc().
Could you help to correct it?

Thanks,
Jim

-Original Message-
From: Marek Vasut [mailto:ma...@denx.de] 
Sent: Wednesday, August 21, 2013 12:27 PM
To: Jim Lin
Cc: joe.hershber...@gmail.com; u-boot@lists.denx.de; Tom Warren; 
swar...@wwwdotorg.org
Subject: Re: [PATCH v9 2/2] console: usb: kbd: To improve TFTP booting 
performance

Dear Jim Lin,

 TFTP booting is slow when a USB keyboard is installed and stdin has 
 usbkbd added.
 This fix is to change Ctrl-C polling for USB keyboard to every second 
 when NET transfer is running.
 
 Signed-off-by: Jim Lin ji...@nvidia.com
 ---
 Changes in v2:
  1. Change configuration name from CONFIG_CTRLC_POLL_MS to 
 CONFIG_CTRLC_POLL_S. 2. New code will be executed only when 
 CONFIG_CTRLC_POLL_S is defined in configuration header file.
  3. Add description in README.console.
 Changes in v3:
  1. Move changes to common/usb_kbd.c and doc/README.usb  2. Rename 
 config setting to CONFIG_USBKB_TESTC_PERIOD.
  3. Remove slow response on USB-keyboard input when TFTP boot is not 
 running. Changes in v4:
  1. Remove changes in doc/README.usb, common/usb_kbd.c and
 CONFIG_USBKB_TESTC_PERIOD
  2. Modify net/net.c
 Changes in v5:
  1. Change variable name to ctrlc_t_start.
  2. Use two calls of get_timer(0) to get time gap.
 Changes in v6:
  1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
 USB keyboard status.
  2. In include/usb.h, add external variable declaration net_busy_flag 
 Changes in v7:
  1. In common/usb_kbd.c and include/usb.h, add #ifdef CONFIG_CMD_NET.
  2. In common/usb_kbd.c, modify code to get correct time gap.
 Changes in v8:
  1. Add __maybe_unused for variable kbd_testc_tms.
 Changes in v9:
  1. Move external variable declaration from include/usb.h to 
 common/usb_kbd.c
 
  common/usb_kbd.c |   15 +++
  1 files changed, 15 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,
Marek Vasut

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


[U-Boot] [PATCH 1/1] console: usb: kbd: To fix slow TFTP booting

2013-08-26 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.
My previous patch is expected to be put into usb_kbd_testc(). But it went
into usb_kbd_getc() after applied.
This patch is to put change in correct place.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 common/usb_kbd.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 89e30e8..1ad67ca 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -354,6 +354,16 @@ static int usb_kbd_testc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
+#ifdef CONFIG_CMD_NET
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key-pressed every second (first check may be
+* less than 1 second) to improve TFTP booting performance.
+*/
+   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   kbd_testc_tms = get_timer(0);
+#endif
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
@@ -370,16 +380,6 @@ static int usb_kbd_getc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
-#ifdef CONFIG_CMD_NET
-   /*
-* If net_busy_flag is 1, NET transfer is running,
-* then we check key-pressed every second (first check may be
-* less than 1 second) to improve TFTP booting performance.
-*/
-   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
-   return 0;
-   kbd_testc_tms = get_timer(0);
-#endif
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
-- 
1.7.7

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


[U-Boot] [PATCH v9 1/2] NET: Add net_busy_flag if CONFIG_USB_KEYBOARD is defined

2013-08-13 Thread Jim Lin
This flag is to make console aware that NET transfer is running or not.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. Add CONFIG_USB_KEYBOARD
Changes in v8:
 1. net/net.c, add __maybe_unused for variable net_busy_flag.
Changes in v9:
 None
 net/net.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..65daaa0 100644
--- a/net/net.c
+++ b/net/net.c
@@ -207,6 +207,8 @@ static int net_check_prereq(enum proto_t protocol);
 
 static int NetTryCount;
 
+int __maybe_unused net_busy_flag;
+
 /**/
 
 static int on_bootfile(const char *name, const char *value, enum env_op op,
@@ -341,6 +343,9 @@ int NetLoop(enum proto_t protocol)
eth_init_state_only(bd);
 
 restart:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
net_set_state(NETLOOP_CONTINUE);
 
/*
@@ -453,6 +458,9 @@ restart:
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
 #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
 #endif /* CONFIG_MII, ... */
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 1;
+#endif
 
/*
 *  Main packet reception loop.  Loop receiving packets until
@@ -558,6 +566,9 @@ restart:
}
 
 done:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
 #ifdef CONFIG_CMD_TFTPPUT
/* Clear out the handlers */
net_set_udp_handler(NULL);
-- 
1.7.7

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


[U-Boot] [PATCH v9 2/2] console: usb: kbd: To improve TFTP booting performance

2013-08-13 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. In common/usb_kbd.c and include/usb.h, add #ifdef CONFIG_CMD_NET.
 2. In common/usb_kbd.c, modify code to get correct time gap.
Changes in v8:
 1. Add __maybe_unused for variable kbd_testc_tms.
Changes in v9:
 1. Move external variable declaration from include/usb.h to common/usb_kbd.c

 common/usb_kbd.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 3174b5e..46100e6 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -121,6 +121,11 @@ struct usb_kbd_pdata {
uint8_t flags;
 };
 
+extern int __maybe_unused net_busy_flag;
+
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long __maybe_unused kbd_testc_tms;
+
 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)
 {
@@ -366,6 +371,16 @@ static int usb_kbd_testc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
+#ifdef CONFIG_CMD_NET
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key-pressed every second (first check may be
+* less than 1 second) to improve TFTP booting performance.
+*/
+   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   kbd_testc_tms = get_timer(0);
+#endif
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
-- 
1.7.7

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


[U-Boot] [PATCH v8 RESEND 1/2] NET: Add net_busy_flag if CONFIG_USB_KEYBOARD is defined

2013-08-09 Thread Jim Lin
This flag is to make console aware that NET transfer is running or not.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. Add CONFIG_USB_KEYBOARD
Changes in v8:
 1. net/net.c, add __maybe_unused for variable net_busy_flag.

 net/net.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..65daaa0 100644
--- a/net/net.c
+++ b/net/net.c
@@ -207,6 +207,8 @@ static int net_check_prereq(enum proto_t protocol);
 
 static int NetTryCount;
 
+int __maybe_unused net_busy_flag;
+
 /**/
 
 static int on_bootfile(const char *name, const char *value, enum env_op op,
@@ -341,6 +343,9 @@ int NetLoop(enum proto_t protocol)
eth_init_state_only(bd);
 
 restart:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
net_set_state(NETLOOP_CONTINUE);
 
/*
@@ -453,6 +458,9 @@ restart:
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
 #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
 #endif /* CONFIG_MII, ... */
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 1;
+#endif
 
/*
 *  Main packet reception loop.  Loop receiving packets until
@@ -558,6 +566,9 @@ restart:
}
 
 done:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
 #ifdef CONFIG_CMD_TFTPPUT
/* Clear out the handlers */
net_set_udp_handler(NULL);
-- 
1.7.7

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


[U-Boot] [PATCH v8 RESEND 2/2] console: usb: kbd: To improve TFTP booting performance

2013-08-09 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. In common/usb_kbd.c and include/usb.h, add #ifdef CONFIG_CMD_NET.
 2. In common/usb_kbd.c, modify code to get correct time gap.
Changes in v8:
 1. Add __maybe_unused for variable kbd_testc_tms.

 common/usb_kbd.c |   13 +
 include/usb.h|2 +-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 3174b5e..4e7b304 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -121,6 +121,9 @@ struct usb_kbd_pdata {
uint8_t flags;
 };
 
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long __maybe_unused kbd_testc_tms;
+
 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)
 {
@@ -366,6 +369,16 @@ static int usb_kbd_testc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
+#ifdef CONFIG_CMD_NET
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key-pressed every second (first check may be
+* less than 1 second) to improve TFTP booting performance.
+*/
+   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   kbd_testc_tms = get_timer(0);
+#endif
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
diff --git a/include/usb.h b/include/usb.h
index d7b082d..5c95bf5 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -206,7 +206,7 @@ int usb_host_eth_scan(int mode);
 
 int drv_usb_kbd_init(void);
 int usb_kbd_deregister(void);
-
+extern int __maybe_unused net_busy_flag;
 #endif
 /* routines */
 int usb_init(void); /* initialize the USB Controller */
-- 
1.7.7

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


[U-Boot] [PATCH v8 2/2] console: usb: kbd: To improve TFTP booting performance

2013-08-02 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. In common/usb_kbd.c and include/usb.h, add #ifdef CONFIG_CMD_NET.
 2. In common/usb_kbd.c, modify code to get correct time gap.
Changes in v8:
 1. Add __maybe_unused for variable kbd_testc_tms.

 common/usb_kbd.c |   13 +
 include/usb.h|2 +-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 3174b5e..4e7b304 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -121,6 +121,9 @@ struct usb_kbd_pdata {
uint8_t flags;
 };
 
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long __maybe_unused kbd_testc_tms;
+
 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)
 {
@@ -366,6 +369,16 @@ static int usb_kbd_testc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
+#ifdef CONFIG_CMD_NET
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key-pressed every second (first check may be
+* less than 1 second) to improve TFTP booting performance.
+*/
+   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   kbd_testc_tms = get_timer(0);
+#endif
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
diff --git a/include/usb.h b/include/usb.h
index d7b082d..5c95bf5 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -206,7 +206,7 @@ int usb_host_eth_scan(int mode);
 
 int drv_usb_kbd_init(void);
 int usb_kbd_deregister(void);
-
+extern int __maybe_unused net_busy_flag;
 #endif
 /* routines */
 int usb_init(void); /* initialize the USB Controller */
-- 
1.7.7

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


[U-Boot] [PATCH v8 1/2] NET: Add net_busy_flag if CONFIG_USB_KEYBOARD is defined

2013-08-02 Thread Jim Lin
This flag is to make console aware that NET transfer is running or not.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. Add CONFIG_USB_KEYBOARD
Changes in v8:
 1. net/net.c, add __maybe_unused for variable net_busy_flag.

 net/net.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..65daaa0 100644
--- a/net/net.c
+++ b/net/net.c
@@ -207,6 +207,8 @@ static int net_check_prereq(enum proto_t protocol);
 
 static int NetTryCount;
 
+int __maybe_unused net_busy_flag;
+
 /**/
 
 static int on_bootfile(const char *name, const char *value, enum env_op op,
@@ -341,6 +343,9 @@ int NetLoop(enum proto_t protocol)
eth_init_state_only(bd);
 
 restart:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
net_set_state(NETLOOP_CONTINUE);
 
/*
@@ -453,6 +458,9 @@ restart:
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
 #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
 #endif /* CONFIG_MII, ... */
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 1;
+#endif
 
/*
 *  Main packet reception loop.  Loop receiving packets until
@@ -558,6 +566,9 @@ restart:
}
 
 done:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
 #ifdef CONFIG_CMD_TFTPPUT
/* Clear out the handlers */
net_set_udp_handler(NULL);
-- 
1.7.7

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


Re: [U-Boot] [PATCH v7 2/2] console: usb: kbd: To improve TFTP booting performance

2013-07-31 Thread Jim Lin
On Fri, 2013-07-19 at 19:17 +0800, Wolfgang Denk wrote:
 Dear Jim Lin,
 
 In message 1374226576-13401-2-git-send-email-ji...@nvidia.com you wrote:
  TFTP booting is slow when a USB keyboard is installed and
  stdin has usbkbd added.
  This fix is to change Ctrl-C polling for USB keyboard to every second
  when NET transfer is running.
 ...
  +#ifdef CONFIG_CMD_NET
  +/* The period of time between two calls of usb_kbd_testc(). */
  +static unsigned long kbd_testc_tms;
  +#endif
   
   /* Generic keyboard event polling. */
   void usb_kbd_generic_poll(void)
  @@ -366,6 +370,16 @@ static int usb_kbd_testc(void)
  struct usb_device *usb_kbd_dev;
  struct usb_kbd_pdata *data;
   
  +#ifdef CONFIG_CMD_NET
  +   /*
  +* If net_busy_flag is 1, NET transfer is running,
  +* then we check key pressed every second to improve
  +* TFTP booting performance.
  +*/
  +   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
  +   return 0;
  +   kbd_testc_tms = get_timer(0);
  +#endif
 
 You did not comment on my remark about  kbd_testc_tms  being used
 basically with a random start value for each invocation of a network
 command.  The every second above is wrong.  The actual interval may
 be much shorter (even nearly zero, at least once), or longer.
I will change the comment as the following.
/*
 * If net_busy_flag is 1, NET transfer is running,
 * then we check key pressed every second (first check
 * may be less than 1 second)
 * to improve TFTP booting performance.
 */

The behavior you mentioned is not that critical.

--nvpublic

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


Re: [U-Boot] [PATCH v7 2/2] console: usb: kbd: To improve TFTP booting performance

2013-07-31 Thread Jim Lin
On Fri, 2013-07-19 at 21:53 +0800, Marek Vasut wrote:
 Dear Jim Lin,
 
  On Fri, 2013-07-19 at 19:17 +0800, Wolfgang Denk wrote:
   Dear Jim Lin,
   
   In message 1374226576-13401-2-git-send-email-ji...@nvidia.com you wrote:
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.
   
   ...
   
+#ifdef CONFIG_CMD_NET
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long kbd_testc_tms;
+#endif

 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)

@@ -366,6 +370,16 @@ static int usb_kbd_testc(void)

struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;

+#ifdef CONFIG_CMD_NET
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key pressed every second to improve
+* TFTP booting performance.
+*/
+   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   kbd_testc_tms = get_timer(0);
+#endif
   
   You did not comment on my remark about  kbd_testc_tms  being used
   basically with a random start value for each invocation of a network
   command.  The every second above is wrong.  The actual interval may
   be much shorter (even nearly zero, at least once), or longer.
  
  Okay, I will check again.
  
 I'll wait for v3. In the meantime, I homestly dont like having such hacks on 
 both sides, but I dont think much can be done about it. Maybe use 
 __maybe_unused 
 for the net_busy_flag to drop the ifdef ?
I don't quite understand what you wanted me to do.
Could you give me an example? What to add and what to remove.
Thanks.

--nvpublic


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


Re: [U-Boot] [PATCH v7 2/2] console: usb: kbd: To improve TFTP booting performance

2013-07-31 Thread Jim Lin
On Fri, 2013-07-19 at 21:53 +0800, Marek Vasut wrote:
 Dear Jim Lin,
 
  On Fri, 2013-07-19 at 19:17 +0800, Wolfgang Denk wrote:
   Dear Jim Lin,
   
   In message 1374226576-13401-2-git-send-email-ji...@nvidia.com you wrote:
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.
   
   ...
   
+#ifdef CONFIG_CMD_NET
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long kbd_testc_tms;
+#endif

 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)

@@ -366,6 +370,16 @@ static int usb_kbd_testc(void)

struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;

+#ifdef CONFIG_CMD_NET
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key pressed every second to improve
+* TFTP booting performance.
+*/
+   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   kbd_testc_tms = get_timer(0);
+#endif
   
   You did not comment on my remark about  kbd_testc_tms  being used
   basically with a random start value for each invocation of a network
   command.  The every second above is wrong.  The actual interval may
   be much shorter (even nearly zero, at least once), or longer.
  
  Okay, I will check again.
  
 I'll wait for v3. In the meantime, I homestly dont like having such hacks on 
 both sides, but I dont think much can be done about it. Maybe use 
 __maybe_unused 
 for the net_busy_flag to drop the ifdef ?
I don't quite understand what you wanted me to do.
Could you give me an example? What to add and what to remove.
Thanks.

--nvpublic



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


[U-Boot] [PATCH v7 2/2] console: usb: kbd: To improve TFTP booting performance

2013-07-19 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. In common/usb_kbd.c and include/usb.h, add #ifdef CONFIG_CMD_NET.
 2. In common/usb_kbd.c, modify code to get correct time gap.

 common/usb_kbd.c |   14 ++
 include/usb.h|4 +++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 3174b5e..05e0c7e 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -120,6 +120,10 @@ struct usb_kbd_pdata {
 
uint8_t flags;
 };
+#ifdef CONFIG_CMD_NET
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long kbd_testc_tms;
+#endif
 
 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)
@@ -366,6 +370,16 @@ static int usb_kbd_testc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
+#ifdef CONFIG_CMD_NET
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key pressed every second to improve
+* TFTP booting performance.
+*/
+   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   kbd_testc_tms = get_timer(0);
+#endif
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
diff --git a/include/usb.h b/include/usb.h
index d7b082d..e1901d1 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -206,7 +206,9 @@ int usb_host_eth_scan(int mode);
 
 int drv_usb_kbd_init(void);
 int usb_kbd_deregister(void);
-
+#ifdef CONFIG_CMD_NET
+extern int net_busy_flag;
+#endif
 #endif
 /* routines */
 int usb_init(void); /* initialize the USB Controller */
-- 
1.7.7

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


[U-Boot] [PATCH v7 1/2] NET: Add net_busy_flag if CONFIG_USB_KEYBOARD is defined

2013-07-19 Thread Jim Lin
This flag is to have console aware that NET transfer is running or not.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag
Changes in v7:
 1. Add CONFIG_USB_KEYBOARD

 net/net.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..38f7bf7 100644
--- a/net/net.c
+++ b/net/net.c
@@ -206,6 +206,9 @@ uchar *NetTxPacket;
 static int net_check_prereq(enum proto_t protocol);
 
 static int NetTryCount;
+#ifdef CONFIG_USB_KEYBOARD
+int net_busy_flag;
+#endif
 
 /**/
 
@@ -341,6 +344,9 @@ int NetLoop(enum proto_t protocol)
eth_init_state_only(bd);
 
 restart:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
net_set_state(NETLOOP_CONTINUE);
 
/*
@@ -453,6 +459,9 @@ restart:
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
 #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
 #endif /* CONFIG_MII, ... */
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 1;
+#endif
 
/*
 *  Main packet reception loop.  Loop receiving packets until
@@ -558,6 +567,9 @@ restart:
}
 
 done:
+#ifdef CONFIG_USB_KEYBOARD
+   net_busy_flag = 0;
+#endif
 #ifdef CONFIG_CMD_TFTPPUT
/* Clear out the handlers */
net_set_udp_handler(NULL);
-- 
1.7.7

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


Re: [U-Boot] [PATCH v7 2/2] console: usb: kbd: To improve TFTP booting performance

2013-07-19 Thread Jim Lin
On Fri, 2013-07-19 at 19:17 +0800, Wolfgang Denk wrote:
 Dear Jim Lin,
 
 In message 1374226576-13401-2-git-send-email-ji...@nvidia.com you wrote:
  TFTP booting is slow when a USB keyboard is installed and
  stdin has usbkbd added.
  This fix is to change Ctrl-C polling for USB keyboard to every second
  when NET transfer is running.
 ...
  +#ifdef CONFIG_CMD_NET
  +/* The period of time between two calls of usb_kbd_testc(). */
  +static unsigned long kbd_testc_tms;
  +#endif
   
   /* Generic keyboard event polling. */
   void usb_kbd_generic_poll(void)
  @@ -366,6 +370,16 @@ static int usb_kbd_testc(void)
  struct usb_device *usb_kbd_dev;
  struct usb_kbd_pdata *data;
   
  +#ifdef CONFIG_CMD_NET
  +   /*
  +* If net_busy_flag is 1, NET transfer is running,
  +* then we check key pressed every second to improve
  +* TFTP booting performance.
  +*/
  +   if (net_busy_flag  (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
  +   return 0;
  +   kbd_testc_tms = get_timer(0);
  +#endif
 
 You did not comment on my remark about  kbd_testc_tms  being used
 basically with a random start value for each invocation of a network
 command.  The every second above is wrong.  The actual interval may
 be much shorter (even nearly zero, at least once), or longer.
Okay, I will check again.




---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v6 2/2] NET: Add net_busy_flag

2013-07-18 Thread Jim Lin
This flag is to have console aware that NET transfer is running or not.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. Add net_busy_flag to make console aware NET transfer is running or not.

 net/net.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..76d8ea9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -207,6 +207,8 @@ static int net_check_prereq(enum proto_t protocol);
 
 static int NetTryCount;
 
+int net_busy_flag;
+
 /**/
 
 static int on_bootfile(const char *name, const char *value, enum env_op op,
@@ -341,6 +343,7 @@ int NetLoop(enum proto_t protocol)
eth_init_state_only(bd);
 
 restart:
+   net_busy_flag = 0;
net_set_state(NETLOOP_CONTINUE);
 
/*
@@ -454,6 +457,8 @@ restart:
 #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
 #endif /* CONFIG_MII, ... */
 
+   net_busy_flag = 1;
+
/*
 *  Main packet reception loop.  Loop receiving packets until
 *  someone sets `net_state' to a state that terminates.
@@ -558,6 +563,7 @@ restart:
}
 
 done:
+   net_busy_flag = 0;
 #ifdef CONFIG_CMD_TFTPPUT
/* Clear out the handlers */
net_set_udp_handler(NULL);
-- 
1.7.7

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


[U-Boot] [PATCH v6 1/2] console: usb: kbd: To improve TFTP booting performance

2013-07-18 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
stdin has usbkbd added.
This fix is to change Ctrl-C polling for USB keyboard to every second
when NET transfer is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.
Changes in v6:
 1. In common/usb_kbd.c, check net_busy_flag to determine whether we poll
USB keyboard status.
 2. In include/usb.h, add external variable declaration net_busy_flag


 common/usb_kbd.c |   15 +++
 include/usb.h|2 +-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 3174b5e..3288c69 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -121,6 +121,9 @@ struct usb_kbd_pdata {
uint8_t flags;
 };
 
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long kbd_testc_tms;
+
 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)
 {
@@ -366,6 +369,18 @@ static int usb_kbd_testc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
+   /*
+* If net_busy_flag is 1, NET transfer is running,
+* then we check key pressed every second to improve
+* TFTP booting performance.
+*/
+   if (net_busy_flag) {
+   if (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ)
+   return 0;
+   else
+   kbd_testc_tms = get_timer(0);
+   }
+
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
diff --git a/include/usb.h b/include/usb.h
index d7b082d..824b394 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -206,7 +206,7 @@ int usb_host_eth_scan(int mode);
 
 int drv_usb_kbd_init(void);
 int usb_kbd_deregister(void);
-
+extern int net_busy_flag;
 #endif
 /* routines */
 int usb_init(void); /* initialize the USB Controller */
-- 
1.7.7

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


Re: [U-Boot] [PATCH v5 1/1] NET: Improve TFTP booting performance when CONFIG_USB_KEYBOARD

2013-07-09 Thread Jim Lin
On Tue, 2013-07-09 at 06:17 +0800, Joe Hershberger wrote:
 Hi Jim and Stephen,
 
 On Wed, Jul 3, 2013 at 11:01 PM, Jim Lin ji...@nvidia.com wrote:
  TFTP booting is slow when a USB keyboard is installed and
  CONFIG_USB_KEYBOARD is defined.
  This fix is to change Ctrl-C polling to every second when NET transfer
  is running.
 
  Signed-off-by: Jim Lin ji...@nvidia.com
  ---
  Changes in v2:
   1. Change configuration name from CONFIG_CTRLC_POLL_MS to 
  CONFIG_CTRLC_POLL_S.
   2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
  configuration header file.
   3. Add description in README.console.
  Changes in v3:
   1. Move changes to common/usb_kbd.c and doc/README.usb
   2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
   3. Remove slow response on USB-keyboard input when TFTP boot is not 
  running.
  Changes in v4:
   1. Remove changes in doc/README.usb, common/usb_kbd.c and
  CONFIG_USBKB_TESTC_PERIOD
   2. Modify net/net.c
  Changes in v5:
   1. Change variable name to ctrlc_t_start.
   2. Use two calls of get_timer(0) to get time gap.
 
   net/net.c |   22 ++
   1 files changed, 22 insertions(+), 0 deletions(-)
 
  diff --git a/net/net.c b/net/net.c
  index df94789..ec88b02 100644
  --- a/net/net.c
  +++ b/net/net.c
  @@ -322,6 +322,11 @@ int NetLoop(enum proto_t protocol)
   {
  bd_t *bd = gd-bd;
  int ret = -1;
  +#ifdef CONFIG_USB_KEYBOARD
  +   unsigned long ctrlc_t_start;
  +   unsigned long ctrlc_t;
  +   int ctrlc_result;
  +#endif
 
  NetRestarted = 0;
  NetDevExists = 0;
  @@ -472,7 +477,24 @@ restart:
  /*
   *  Abort if ctrl-c was pressed.
   */
  +#ifdef CONFIG_USB_KEYBOARD
 
 It seems this is the result of the USB Keyboard behavior.  Why is it a
 good idea to litter the TFTP code with this unrelated code?  It seems

So far this is the best place to resolve this issue.

 the very same check could be down inside of ctrlc() somewhere that is
 at least console I/O related.  Besides, having it in a common place
 will allow any operation that accesses the keyboard to benefit from
 not hanging up on slow USB stuff.
 
 It also seems that it should depend on what the actual source of the
 stdin is, not just if you compiled in CONFIG_USB_KEYBOARD support.

This issue only goes with USB keyboard installed and CONFIG_USB_KEYBOARD
defined. Therefore compiled in CONFIG_USB_KEYBOARD support.
Non-usb-keyboard doesn't have such issue.

 Again, something that belongs in the console source.
 
  +   /*
  +* Reduce ctrl-c checking to 1 second once
  +* to improve TFTP boot performance.
  +*/
  +   if (ctrlc_t_start  get_timer(0))
  +   ctrlc_t_start = get_timer(0);
  +   ctrlc_t = get_timer(0) - ctrlc_t_start;
 
 Why is it preferable to do the subtraction yourself instead of letting
 get_timer() do it?  I.e. what compelled did you change this from v4?

As Wolfgang Denk said in another mail, 
An exception is arch/arm/cpu/sa1100/timer.c which does not respect
the base argument at all, i. e. which is broken.
.

So this v5 patch uses get_timer(0), like other code did in this file.

 
  +   if (ctrlc_t  CONFIG_SYS_HZ) {
 
 Why is hard-coding it to 1 second a good idea?
  Is that really how unresponsive it has to be to not
  significantly impact TFTP boot time?

Do you want me to add a CONFIG setting to have this time adjustable?
I was thinking 1 second checking on Ctrl-C should be fine while TFT
boot is running.

--
nvpublic

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


[U-Boot] [PATCH v4 1/1] NET: Improve TFTP booting performance when CONFIG_USB_KEYBOARD

2013-07-03 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
CONFIG_USB_KEYBOARD is defined.
The fix is to change Ctrl-C polling to every second when NET transfer
is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c

 net/net.c |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..06b41e0 100644
--- a/net/net.c
+++ b/net/net.c
@@ -322,6 +322,11 @@ int NetLoop(enum proto_t protocol)
 {
bd_t *bd = gd-bd;
int ret = -1;
+#ifdef CONFIG_USB_KEYBOARD
+   unsigned long kbd_ctrlc_tms = 0;
+   unsigned long ctrlc_t;
+   int ctrlc_result;
+#endif
 
NetRestarted = 0;
NetDevExists = 0;
@@ -472,7 +477,22 @@ restart:
/*
 *  Abort if ctrl-c was pressed.
 */
+#ifdef CONFIG_USB_KEYBOARD
+   /*
+* Reduce ctrl-c checking to 1 second once
+* to improve TFTP boot performance.
+*/
+   ctrlc_t = get_timer(kbd_ctrlc_tms);
+   if (ctrlc_t  CONFIG_SYS_HZ) {
+   ctrlc_result = ctrlc();
+   kbd_ctrlc_tms = get_timer(0);
+   } else {
+   ctrlc_result = 0;
+   }
+   if (ctrlc_result) {
+#else
if (ctrlc()) {
+#endif
/* cancel any ARP that may not have completed */
NetArpWaitPacketIP = 0;
 
-- 
1.7.7

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


[U-Boot] [PATCH v5 1/1] NET: Improve TFTP booting performance when CONFIG_USB_KEYBOARD

2013-07-03 Thread Jim Lin
TFTP booting is slow when a USB keyboard is installed and
CONFIG_USB_KEYBOARD is defined.
This fix is to change Ctrl-C polling to every second when NET transfer
is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.
Changes in v4:
 1. Remove changes in doc/README.usb, common/usb_kbd.c and
CONFIG_USBKB_TESTC_PERIOD 
 2. Modify net/net.c
Changes in v5:
 1. Change variable name to ctrlc_t_start.
 2. Use two calls of get_timer(0) to get time gap.

 net/net.c |   22 ++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..ec88b02 100644
--- a/net/net.c
+++ b/net/net.c
@@ -322,6 +322,11 @@ int NetLoop(enum proto_t protocol)
 {
bd_t *bd = gd-bd;
int ret = -1;
+#ifdef CONFIG_USB_KEYBOARD
+   unsigned long ctrlc_t_start;
+   unsigned long ctrlc_t;
+   int ctrlc_result;
+#endif
 
NetRestarted = 0;
NetDevExists = 0;
@@ -472,7 +477,24 @@ restart:
/*
 *  Abort if ctrl-c was pressed.
 */
+#ifdef CONFIG_USB_KEYBOARD
+   /*
+* Reduce ctrl-c checking to 1 second once
+* to improve TFTP boot performance.
+*/
+   if (ctrlc_t_start  get_timer(0))
+   ctrlc_t_start = get_timer(0);
+   ctrlc_t = get_timer(0) - ctrlc_t_start;
+   if (ctrlc_t  CONFIG_SYS_HZ) {
+   ctrlc_result = ctrlc();
+   ctrlc_t_start = get_timer(0);
+   } else {
+   ctrlc_result = 0;
+   }
+   if (ctrlc_result) {
+#else
if (ctrlc()) {
+#endif
/* cancel any ARP that may not have completed */
NetArpWaitPacketIP = 0;
 
-- 
1.7.7

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


Re: [U-Boot] [PATCH v3 1/2] console: usbkbd: Improve TFTP booting performance

2013-06-28 Thread Jim Lin
On Fri, 2013-06-28 at 13:09 +0800, Stephen Warren wrote:
 On 06/27/2013 09:59 PM, Jim Lin wrote:
  On Fri, 2013-06-28 at 02:20 +0800, Stephen Warren wrote:
  On 06/27/2013 03:45 AM, Jim Lin wrote:
  TFTP booting is observed a little bit slow, especially when a USB
  keyboard is installed.
  The fix is to move polling to every second if we sense that other task
  like TFTP boot is running.
 
 
  diff --git a/common/usb_kbd.c b/common/usb_kbd.c
 
  +#ifdef CONFIG_USBKB_TESTC_PERIOD
  + /*
  +  * T is the time between two calls of usb_kbd_testc().
  +  * If CONFIG_USBKB_TESTC_PERIOD ms  T  1000 ms,
  +  * it implies other task like TFTP boot is running,
  +  * then we reduce polling to every second
  +  * to improve TFTP booting performance.
  +  */
  + if ((get_timer(kbd_testc_tms) =
  + (CONFIG_USBKB_TESTC_PERIOD * CONFIG_SYS_HZ / 1000)) 
  + (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
  + return 0;
  + else
  + kbd_testc_tms = get_timer(0);
  +#endif
 
  I have a hard time understanding why the fact that some other task is
  running implies anything at all re: how often usb_kbd_testc() would be
  called.
  In my case it takes about 95 ms on Tegra20 and Tegra114 for
  usb_kbd_testc() to be called periodically.
  So I set CONFIG_USBKB_TESTC_PERIOD to 100.
  Like I said, if CONFIG_USBKB_TESTC_PERIOD ms  T  1000 ms
  we reduce polling (send command to USB keyboard to check is there
  any key pressed) to every second.
 
 OK, so I think how this works is: If nothing is happening, then
 usb_kbd_testc() is repeatedly called back-to-back with no delay between.
 So, if the time between two calls to usb_kbd_testc() is much longer than
 the time it takes to execute it once, then something else is going on,
 and hence the code should skip some calls to usb_kbd_testc().
 
 If that's how this works, then why require CONFIG_USBKBD_TESTC_PERIOD to
 be set? Why not simply measure the time between when usb_kbd_testc()
 returns, and when it is re-entered? If it's very short, nothing else is
 happening. If it's very long, something else is happening. That is a far
 more direct measurement, and is immune to e.g. CPU frequency differences
Good idea and will be introduced in next revision.

 in a way that a static value for CONFIG_USBKBD_TESTC_PERIOD is not.
 
 Also, any kind of time measurement doesn't solve the issue I mentioned
 re: how granular the other task is.
 
 Finally, if you're sitting at the command-prompt, is usb_kbd_testc()
 used at all? How does regular typing using a USB keyboard interact with
 this code; will typing react fast, but CTRL-C react slowly?
They should react at same rate.

--
nvpublic


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


[U-Boot] [PATCH v3 2/2] config: Tegra: Improve TFTP booting performance

2013-06-27 Thread Jim Lin
Add CONFIG_USBKB_TESTC_PERIOD configuration if CONFIG_USB_KEYBOARD
is defined in platform configuration file.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 - None
Changes in v3:
 - Add CONFIG_USBKB_TESTC_PERIOD in include/configs/tegra-common-post.h

 include/configs/tegra-common-post.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/configs/tegra-common-post.h 
b/include/configs/tegra-common-post.h
index 6ed2fde..ee341ef 100644
--- a/include/configs/tegra-common-post.h
+++ b/include/configs/tegra-common-post.h
@@ -128,6 +128,7 @@
 #ifdef CONFIG_USB_KEYBOARD
 #define STDIN_KBD_USB ,usbkbd
 #define CONFIG_SYS_USB_EVENT_POLL
+#define CONFIG_USBKB_TESTC_PERIOD 100
 #define CONFIG_PREBOOT usb start
 #else
 #define STDIN_KBD_USB 
-- 
1.7.7

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


[U-Boot] [PATCH v3 1/2] console: usbkbd: Improve TFTP booting performance

2013-06-27 Thread Jim Lin
TFTP booting is observed a little bit slow, especially when a USB
keyboard is installed.
The fix is to move polling to every second if we sense that other task
like TFTP boot is running.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
configuration header file.
 3. Add description in README.console.
Changes in v3:
 1. Move changes to common/usb_kbd.c and doc/README.usb
 2. Rename config setting to CONFIG_USBKB_TESTC_PERIOD.
 3. Remove slow response on USB-keyboard input when TFTP boot is not running.

 common/usb_kbd.c |   20 
 doc/README.usb   |   15 ++-
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 3174b5e..25bf677 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -121,6 +121,11 @@ struct usb_kbd_pdata {
uint8_t flags;
 };
 
+#ifdef CONFIG_USBKB_TESTC_PERIOD
+/* The period of time between two calls of usb_kbd_testc(). */
+static unsigned long kbd_testc_tms;
+#endif
+
 /* Generic keyboard event polling. */
 void usb_kbd_generic_poll(void)
 {
@@ -366,6 +371,21 @@ static int usb_kbd_testc(void)
struct usb_device *usb_kbd_dev;
struct usb_kbd_pdata *data;
 
+#ifdef CONFIG_USBKB_TESTC_PERIOD
+   /*
+* T is the time between two calls of usb_kbd_testc().
+* If CONFIG_USBKB_TESTC_PERIOD ms  T  1000 ms,
+* it implies other task like TFTP boot is running,
+* then we reduce polling to every second
+* to improve TFTP booting performance.
+*/
+   if ((get_timer(kbd_testc_tms) =
+   (CONFIG_USBKB_TESTC_PERIOD * CONFIG_SYS_HZ / 1000)) 
+   (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
+   return 0;
+   else
+   kbd_testc_tms = get_timer(0);
+#endif
dev = stdio_get_by_name(DEVNAME);
usb_kbd_dev = (struct usb_device *)dev-priv;
data = usb_kbd_dev-privptr;
diff --git a/doc/README.usb b/doc/README.usb
index b4c3ef5..ff4ee6f 100644
--- a/doc/README.usb
+++ b/doc/README.usb
@@ -80,7 +80,20 @@ CONFIG_USB_UHCI  defines the lowlevel part.A 
lowlevel part must be defined
 CONFIG_USB_KEYBOARD enables the USB Keyboard
 CONFIG_USB_STORAGE  enables the USB storage devices
 CONFIG_USB_HOST_ETHER  enables USB ethernet adapter support
-
+CONFIG_USBKB_TESTC_PERIOD defines the average time (in ms) between two calls
+   of usb_kbd_testc() when TFTP boot is not running
+   In u-boot console, usb_kbd_testc() will be called
+   periodically.
+   When this configuration is defined and other task like
+   TFTP boot is running, USB keyboard will be polled less
+   frequently and will be polled every second.
+   This is to improve TFTP booting performance when USB
+   keyboard is installed.
+   In u-boot console, no impact on keyboard input if TFTP
+   boot is not running.
+   Example:
+   Define the following in configuration header file
+   #define CONFIG_USBKB_TESTC_PERIOD 100
 
 USB Host Networking
 ===
-- 
1.7.7

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


Re: [U-Boot] [PATCH v3 1/2] console: usbkbd: Improve TFTP booting performance

2013-06-27 Thread Jim Lin
On Fri, 2013-06-28 at 02:20 +0800, Stephen Warren wrote:
 On 06/27/2013 03:45 AM, Jim Lin wrote:
  TFTP booting is observed a little bit slow, especially when a USB
  keyboard is installed.
  The fix is to move polling to every second if we sense that other task
  like TFTP boot is running.
  
 
  diff --git a/common/usb_kbd.c b/common/usb_kbd.c
 
  +#ifdef CONFIG_USBKB_TESTC_PERIOD
  +   /*
  +* T is the time between two calls of usb_kbd_testc().
  +* If CONFIG_USBKB_TESTC_PERIOD ms  T  1000 ms,
  +* it implies other task like TFTP boot is running,
  +* then we reduce polling to every second
  +* to improve TFTP booting performance.
  +*/
  +   if ((get_timer(kbd_testc_tms) =
  +   (CONFIG_USBKB_TESTC_PERIOD * CONFIG_SYS_HZ / 1000)) 
  +   (get_timer(kbd_testc_tms)  CONFIG_SYS_HZ))
  +   return 0;
  +   else
  +   kbd_testc_tms = get_timer(0);
  +#endif
 
 I have a hard time understanding why the fact that some other task is
 running implies anything at all re: how often usb_kbd_testc() would be
 called.
In my case it takes about 95 ms on Tegra20 and Tegra114 for
usb_kbd_testc() to be called periodically.
So I set CONFIG_USBKB_TESTC_PERIOD to 100.
Like I said, if CONFIG_USBKB_TESTC_PERIOD ms  T  1000 ms
we reduce polling (send command to USB keyboard to check is there
any key pressed) to every second.

 
 It's quite possible that some other task is extremely fine-grained,
 and calls usb_kbd_testc() every 0.1ms, and would be severely negatively
 affected by usb_kbd_testc() taking a long time to execute.
 
 Conversly, it's quite possible that some other task is quite granular,
 and calls usb_kbd_testc() a wide intervals, say every 200ms.
 
 So, I think this change keys of entirely the wrong thing.
 
 Shouldn't the TFTP process (or use of USB networking?) or other
 long-running tasks that do check for keyboard IO simply set some flag to
 indicate to usb_kbd_testc() that it should run at a reduced rate, or
 even just have those long-running processses call usb_kbd_testc() at a
 reduced rate themselves?
To fix in usb_kbd_testc() is easier because this issue happens only when
USB keyboard is installed and CONFIG_USB_KEYBOARD is defined.

--
nvpublic

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


[U-Boot] [PATCH v5 3/3] Tegra: Config: Enable Tegra30/Tegra114 USB function

2013-06-21 Thread Jim Lin
Add USB EHCI, storage and network support.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
  - Add support for Beaver board.
Changes in v3:
  - None
Changes in v4:
  - None
Changes in v5:
  - 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(-)

diff --git a/include/configs/beaver.h b/include/configs/beaver.h
index 058da4f..165de13 100644
--- a/include/configs/beaver.h
+++ b/include/configs/beaver.h
@@ -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 */
diff --git a/include/configs/cardhu.h b/include/configs/cardhu.h
index 6a99175..fd46083 100644
--- a/include/configs/cardhu.h
+++ b/include/configs/cardhu.h
@@ -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 */
diff --git a/include/configs/dalmore.h b/include/configs/dalmore.h
index 7b68f7c..2723843 100644
--- a/include/configs/dalmore.h
+++ b/include/configs/dalmore.h
@@ -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 */
diff --git a/include/configs/tegra114-common.h 
b/include/configs/tegra114-common.h
index 721b29c..44e98e5 100644
--- a/include/configs/tegra114-common.h
+++ b/include/configs/tegra114-common.h
@@ -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_ */
diff --git a/include/configs/tegra30-common.h b/include/configs/tegra30-common.h
index ed36e11..7ea36be 100644
--- a/include/configs/tegra30-common.h
+++ b/include/configs/tegra30-common.h
@@ -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_ */
-- 
1.7.7

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


[U-Boot] [PATCH v5 1/3] ARM: Tegra: FDT: Add USB EHCI function for T30/T114

2013-06-21 Thread Jim Lin
Add DT node for USB EHCI function.
Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 - Remove PLL parameters from dt file
Changes in v3:
 - Change VBus GPIO from H.05 to DD.04 for Beaver board.
Changes in v4:
 - Change Beaver VBus GPIO to H.05 and value to 0 for polarity to be High.
   I don't have Beaver board. So this needs somebody to help test.
   Thanks.
 - Change Cardhu VBus GPIO value from 3 to 1 because only bit 0 is meaningful.
Changes in v5:
 - Move changes on fdtdec.h and fdtdec.c to patch 2/3
 - Modify PHY type to hsic for USB2 port

 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 ++
 5 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index f86d18d..626cc3c 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disable;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = hsic;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/arch/arm/dts/tegra30.dtsi b/arch/arm/dts/tegra30.dtsi
index ccf154f..fee1c36 100644
--- a/arch/arm/dts/tegra30.dtsi
+++ b/arch/arm/dts/tegra30.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disabled;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = hsic;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/board/nvidia/dts/tegra114-dalmore.dts 
b/board/nvidia/dts/tegra114-dalmore.dts
index 86e9459..435c01e 100644
--- a/board/nvidia/dts/tegra114-dalmore.dts
+++ b/board/nvidia/dts/tegra114-dalmore.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@78000400;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -61,4 +62,10 @@
bus-width = 8;
status = okay;
};
+
+   usb@7d008000 {
+   /* SPDIF_IN: USB_VBUS_EN1 */
+   nvidia,vbus-gpio = gpio 86 0;
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-beaver.dts 
b/board/nvidia/dts/tegra30-beaver.dts
index 836169f..a7cc93e 100644
--- a/board/nvidia/dts/tegra30-beaver.dts
+++ b/board/nvidia/dts/tegra30-beaver.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -68,4 +69,9 @@
status = okay;
bus-width = 8;
};
+
+   usb@7d008000 {
+   nvidia,vbus-gpio = gpio 236 0; /* PDD4 */
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-cardhu.dts 
b/board/nvidia/dts/tegra30-cardhu.dts
index 4d22b48..ea2cf76 100644
--- a/board/nvidia/dts/tegra30-cardhu.dts
+++ b/board/nvidia/dts/tegra30-cardhu.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000

[U-Boot] [PATCH v5 2/3] ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114

2013-06-21 Thread Jim Lin
Tegra30 and Tegra114 are compatible except PLL parameters.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
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
Changes in v4:
 - In board.c, add inclusion of asm/arch-tegra/usb.h for build warning.
 - In ehci-tegra.c, modify board_usb_init to find usb nodes with compatible ID
   in table fdt_usb_controllers and use matched feature flags later.
 - In ehci-tegra.c, removing is_T30_compatible and is_T114_compatible variables
   due to above change.
 - In ehci-tegra.c, change variable port_clear_csc to port_addr_clear_csc.
 - In pinmux-config-cardhu.h, chnage GMI_AD13 pinmux state to be OUTPUT
   in order to be driven HIGH for Beaver board.
Changes in v5:
 - Modify fdtdec.h and fdtdec.c.
 - In ehci-tegra.c, use u32 has_hostpc:1; for alignment concern.
 - Remove previous change of pinmux-config-cardhu.h.

 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   |1 +
 drivers/usb/host/ehci-tegra.c |  300 +
 include/fdtdec.h  |2 +
 lib/fdtdec.c  |2 +
 9 files changed, 803 insertions(+), 173 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

diff --git a/arch/arm/include/asm/arch-tegra/clk_rst.h 
b/arch/arm/include/asm/arch-tegra/clk_rst.h
index c754ec7..9b8de9c 100644
--- a/arch/arm/include/asm/arch-tegra/clk_rst.h
+++ b/arch/arm/include/asm/arch-tegra/clk_rst.h
@@ -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)
diff --git a/arch/arm/include/asm/arch-tegra/usb.h 
b/arch/arm/include/asm/arch-tegra/usb.h
index ef6c089..cefe0d2 100644
--- a/arch/arm/include/asm/arch-tegra/usb.h
+++ b/arch/arm/include/asm/arch-tegra/usb.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
+ * Copyright (c) 2013 NVIDIA Corporation
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -22,120 +23,6 @@
 #ifndef _TEGRA_USB_H_
 #define _TEGRA_USB_H_
 
-
-/* USB Controller (USBx_CONTROLLER_) regs */
-struct usb_ctlr {
-   /* 0x000 */
-   uint id;
-   uint reserved0;
-   uint host;
-   uint device;
-
-   /* 0x010 */
-   uint txbuf;
-   uint rxbuf;
-   uint reserved1[2];
-
-   /* 0x020 */
-   uint reserved2[56];
-
-   /* 0x100 */
-   u16 cap_length;
-   u16 hci_version;
-   uint hcs_params;
-   uint hcc_params;
-   uint reserved3[5];
-
-   /* 0x120 */
-   uint dci_version;
-   uint dcc_params;
-   uint reserved4[6];
-
-   /* 0x140 */
-   uint usb_cmd;
-   uint usb_sts;
-   uint usb_intr;
-   uint frindex;
-
-   /* 0x150 */
-   uint reserved5;
-   uint periodic_list_base;
-   uint async_list_addr;
-   uint async_tt_sts;
-
-   /* 0x160 */
-   uint burst_size;
-   uint tx_fill_tuning;
-   uint reserved6;   /* is this port_sc1 on some controllers? */
-   uint icusb_ctrl;
-
-   /* 0x170 */
-   uint ulpi_viewport;
-   uint reserved7;
-   uint endpt_nak;
-   uint endpt_nak_enable;
-
-   /* 0x180 */
-   uint reserved;
-   uint port_sc1;
-   uint reserved8[6];
-
-   /* 0x1a0 */
-   uint reserved9;
-   uint otgsc;
-   uint usb_mode;
-   uint

[U-Boot] [PATCH v4 3/3] Tegra: Config: Enable Tegra30/Tegra114 USB function

2013-06-20 Thread Jim Lin
Add USB EHCI, storage and network support.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
  - Add support for Beaver board.
Changes in v3:
  - None
Changes in v4:
  - 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(-)

diff --git a/include/configs/beaver.h b/include/configs/beaver.h
index 058da4f..165de13 100644
--- a/include/configs/beaver.h
+++ b/include/configs/beaver.h
@@ -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 */
diff --git a/include/configs/cardhu.h b/include/configs/cardhu.h
index 6a99175..fd46083 100644
--- a/include/configs/cardhu.h
+++ b/include/configs/cardhu.h
@@ -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 */
diff --git a/include/configs/dalmore.h b/include/configs/dalmore.h
index 7b68f7c..2723843 100644
--- a/include/configs/dalmore.h
+++ b/include/configs/dalmore.h
@@ -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 */
diff --git a/include/configs/tegra114-common.h 
b/include/configs/tegra114-common.h
index 721b29c..44e98e5 100644
--- a/include/configs/tegra114-common.h
+++ b/include/configs/tegra114-common.h
@@ -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_ */
diff --git a/include/configs/tegra30-common.h b/include/configs/tegra30-common.h
index ed36e11..7ea36be 100644
--- a/include/configs/tegra30-common.h
+++ b/include/configs/tegra30-common.h
@@ -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_ */
-- 
1.7.7

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


[U-Boot] [PATCH v4 2/3] ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114

2013-06-20 Thread Jim Lin
Tegra30 and Tegra114 are compatible except PLL parameters.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
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
Changes in v4:
 - In board.c, add inclusion of asm/arch-tegra/usb.h for build warning.
 - In ehci-tegra.c, modify board_usb_init to find usb nodes with compatible ID
   in table fdt_usb_controllers and use matched feature flags later.
 - In ehci-tegra.c, removing is_T30_compatible and is_T114_compatible variables
   due to above change.
 - In ehci-tegra.c, change variable port_clear_csc to port_addr_clear_csc.
 - In pinmux-config-cardhu.h, chnage GMI_AD13 pinmux state to be OUTPUT
   in order to be driven HIGH for Beaver board.

 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/cardhu/pinmux-config-cardhu.h |4 +-
 board/nvidia/common/board.c|1 +
 drivers/usb/host/ehci-tegra.c  |  300 ---
 8 files changed, 802 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

diff --git a/arch/arm/include/asm/arch-tegra/clk_rst.h 
b/arch/arm/include/asm/arch-tegra/clk_rst.h
index c754ec7..9b8de9c 100644
--- a/arch/arm/include/asm/arch-tegra/clk_rst.h
+++ b/arch/arm/include/asm/arch-tegra/clk_rst.h
@@ -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)
diff --git a/arch/arm/include/asm/arch-tegra/usb.h 
b/arch/arm/include/asm/arch-tegra/usb.h
index ef6c089..cefe0d2 100644
--- a/arch/arm/include/asm/arch-tegra/usb.h
+++ b/arch/arm/include/asm/arch-tegra/usb.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
+ * Copyright (c) 2013 NVIDIA Corporation
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -22,120 +23,6 @@
 #ifndef _TEGRA_USB_H_
 #define _TEGRA_USB_H_
 
-
-/* USB Controller (USBx_CONTROLLER_) regs */
-struct usb_ctlr {
-   /* 0x000 */
-   uint id;
-   uint reserved0;
-   uint host;
-   uint device;
-
-   /* 0x010 */
-   uint txbuf;
-   uint rxbuf;
-   uint reserved1[2];
-
-   /* 0x020 */
-   uint reserved2[56];
-
-   /* 0x100 */
-   u16 cap_length;
-   u16 hci_version;
-   uint hcs_params;
-   uint hcc_params;
-   uint reserved3[5];
-
-   /* 0x120 */
-   uint dci_version;
-   uint dcc_params;
-   uint reserved4[6];
-
-   /* 0x140 */
-   uint usb_cmd;
-   uint usb_sts;
-   uint usb_intr;
-   uint frindex;
-
-   /* 0x150 */
-   uint reserved5;
-   uint periodic_list_base;
-   uint async_list_addr;
-   uint async_tt_sts;
-
-   /* 0x160 */
-   uint burst_size;
-   uint tx_fill_tuning;
-   uint reserved6;   /* is this port_sc1 on some controllers? */
-   uint icusb_ctrl;
-
-   /* 0x170 */
-   uint ulpi_viewport;
-   uint reserved7;
-   uint endpt_nak;
-   uint endpt_nak_enable;
-
-   /* 0x180 */
-   uint reserved;
-   uint port_sc1;
-   uint reserved8[6];
-
-   /* 0x1a0 */
-   uint reserved9;
-   uint otgsc;
-   uint usb_mode;
-   uint endpt_setup_stat;
-
-   /* 0x1b0 */
-   uint reserved10[20];
-
-   /* 0x200 */
-   uint reserved11[0x80];
-
-   /* 0x400 */
-   uint susp_ctrl;
-   uint phy_vbus_sensors;
-   uint

[U-Boot] [PATCH v4 1/3] ARM: Tegra: FDT: Add USB EHCI function for T30/T114

2013-06-20 Thread Jim Lin
Add DT node for USB EHCI function.
Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
 - Remove PLL parameters from dt file
Changes in v3:
 - Change VBus GPIO from H.05 to DD.04 for Beaver board.
Changes in v4:
 - Change Beaver VBus GPIO to H.05 and value to 0 for polarity to be High.
   I don't have Beaver board. So this needs somebody to help test.
   Thanks.
 - Change Cardhu VBus GPIO value from 3 to 1 because only bit 0 is meaningful.

 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(-)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index f86d18d..f87d05a 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disable;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = utmi;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/arch/arm/dts/tegra30.dtsi b/arch/arm/dts/tegra30.dtsi
index ccf154f..e5275c2 100644
--- a/arch/arm/dts/tegra30.dtsi
+++ b/arch/arm/dts/tegra30.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disabled;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = utmi;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/board/nvidia/dts/tegra114-dalmore.dts 
b/board/nvidia/dts/tegra114-dalmore.dts
index 86e9459..435c01e 100644
--- a/board/nvidia/dts/tegra114-dalmore.dts
+++ b/board/nvidia/dts/tegra114-dalmore.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@78000400;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -61,4 +62,10 @@
bus-width = 8;
status = okay;
};
+
+   usb@7d008000 {
+   /* SPDIF_IN: USB_VBUS_EN1 */
+   nvidia,vbus-gpio = gpio 86 0;
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-beaver.dts 
b/board/nvidia/dts/tegra30-beaver.dts
index 836169f..fa147ef 100644
--- a/board/nvidia/dts/tegra30-beaver.dts
+++ b/board/nvidia/dts/tegra30-beaver.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -68,4 +69,9 @@
status = okay;
bus-width = 8;
};
+
+   usb@7d008000 {
+   nvidia,vbus-gpio = gpio 61 0; /* PH5 */
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-cardhu.dts 
b/board/nvidia/dts/tegra30-cardhu.dts
index 4d22b48..2c97812 100644
--- a/board/nvidia/dts/tegra30-cardhu.dts
+++ b/board/nvidia/dts/tegra30-cardhu.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000;
};
 
memory

Re: [U-Boot] [PATCH v4 2/3] ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114

2013-06-20 Thread Jim Lin

On 06/20/2013 02:13 AM, Jim Lin wrote:
 Tegra30 and Tegra114 are compatible except PLL parameters.

 Tested on Tegra30 Cardhu, and Tegra114 Dalmore
 platforms. All works well.
 Changes in v4:

  - In pinmux-config-cardhu.h, chnage GMI_AD13 pinmux state to be OUTPUT
in order to be driven HIGH for Beaver board.

That should be reverted. As I mentioned in my previous response,
GMI_AD13 is the wrong pin.
Please help me, test this v4 patch set on Beaver board, and
tell me result.
Thanks.

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


[U-Boot] [PATCH v3 1/3] ARM: Tegra: FDT: Add USB EHCI function for T30/T114

2013-06-17 Thread Jim Lin
Add DT node for USB EHCI function.
Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.

Signed-off-by: Jim Lin ji...@nvidia.com
---
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(-)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index f86d18d..f87d05a 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disable;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = utmi;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/arch/arm/dts/tegra30.dtsi b/arch/arm/dts/tegra30.dtsi
index ccf154f..e5275c2 100644
--- a/arch/arm/dts/tegra30.dtsi
+++ b/arch/arm/dts/tegra30.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disabled;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = utmi;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/board/nvidia/dts/tegra114-dalmore.dts 
b/board/nvidia/dts/tegra114-dalmore.dts
index 86e9459..435c01e 100644
--- a/board/nvidia/dts/tegra114-dalmore.dts
+++ b/board/nvidia/dts/tegra114-dalmore.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@78000400;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -61,4 +62,10 @@
bus-width = 8;
status = okay;
};
+
+   usb@7d008000 {
+   /* SPDIF_IN: USB_VBUS_EN1 */
+   nvidia,vbus-gpio = gpio 86 0;
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-beaver.dts 
b/board/nvidia/dts/tegra30-beaver.dts
index 836169f..a7cc93e 100644
--- a/board/nvidia/dts/tegra30-beaver.dts
+++ b/board/nvidia/dts/tegra30-beaver.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -68,4 +69,9 @@
status = okay;
bus-width = 8;
};
+
+   usb@7d008000 {
+   nvidia,vbus-gpio = gpio 236 0; /* PDD4 */
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-cardhu.dts 
b/board/nvidia/dts/tegra30-cardhu.dts
index 4d22b48..071a464 100644
--- a/board/nvidia/dts/tegra30-cardhu.dts
+++ b/board/nvidia/dts/tegra30-cardhu.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -63,4 +64,9 @@
status = okay;
bus-width = 8;
};
+
+   usb@7d008000 {
+   nvidia,vbus-gpio = gpio 233 3

[U-Boot] [PATCH v3 2/3] ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114

2013-06-17 Thread Jim Lin
Tegra30 and Tegra114 are compatible except PLL parameters.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
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

diff --git a/arch/arm/include/asm/arch-tegra/clk_rst.h 
b/arch/arm/include/asm/arch-tegra/clk_rst.h
index c754ec7..9b8de9c 100644
--- a/arch/arm/include/asm/arch-tegra/clk_rst.h
+++ b/arch/arm/include/asm/arch-tegra/clk_rst.h
@@ -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)
diff --git a/arch/arm/include/asm/arch-tegra/usb.h 
b/arch/arm/include/asm/arch-tegra/usb.h
index ef6c089..cefe0d2 100644
--- a/arch/arm/include/asm/arch-tegra/usb.h
+++ b/arch/arm/include/asm/arch-tegra/usb.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
+ * Copyright (c) 2013 NVIDIA Corporation
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -22,120 +23,6 @@
 #ifndef _TEGRA_USB_H_
 #define _TEGRA_USB_H_
 
-
-/* USB Controller (USBx_CONTROLLER_) regs */
-struct usb_ctlr {
-   /* 0x000 */
-   uint id;
-   uint reserved0;
-   uint host;
-   uint device;
-
-   /* 0x010 */
-   uint txbuf;
-   uint rxbuf;
-   uint reserved1[2];
-
-   /* 0x020 */
-   uint reserved2[56];
-
-   /* 0x100 */
-   u16 cap_length;
-   u16 hci_version;
-   uint hcs_params;
-   uint hcc_params;
-   uint reserved3[5];
-
-   /* 0x120 */
-   uint dci_version;
-   uint dcc_params;
-   uint reserved4[6];
-
-   /* 0x140 */
-   uint usb_cmd;
-   uint usb_sts;
-   uint usb_intr;
-   uint frindex;
-
-   /* 0x150 */
-   uint reserved5;
-   uint periodic_list_base;
-   uint async_list_addr;
-   uint async_tt_sts;
-
-   /* 0x160 */
-   uint burst_size;
-   uint tx_fill_tuning;
-   uint reserved6;   /* is this port_sc1 on some controllers? */
-   uint icusb_ctrl;
-
-   /* 0x170 */
-   uint ulpi_viewport;
-   uint reserved7;
-   uint endpt_nak;
-   uint endpt_nak_enable;
-
-   /* 0x180 */
-   uint reserved;
-   uint port_sc1;
-   uint reserved8[6];
-
-   /* 0x1a0 */
-   uint reserved9;
-   uint otgsc;
-   uint usb_mode;
-   uint endpt_setup_stat;
-
-   /* 0x1b0 */
-   uint reserved10[20];
-
-   /* 0x200 */
-   uint reserved11[0x80];
-
-   /* 0x400 */
-   uint susp_ctrl;
-   uint phy_vbus_sensors;
-   uint phy_vbus_wakeup_id;
-   uint phy_alt_vbus_sys;
-
-   /* 0x410 */
-   uint usb1_legacy_ctrl;
-   uint reserved12[4];
-
-   /* 0x424 */
-   uint ulpi_timing_ctrl_0;
-   uint ulpi_timing_ctrl_1;
-   uint reserved13[53];
-
-   /* 0x500 */
-   uint reserved14[64 * 3];
-
-   /* 0x800 */
-   uint utmip_pll_cfg0;
-   uint utmip_pll_cfg1;
-   uint utmip_xcvr_cfg0;
-   uint utmip_bias_cfg0;
-
-   /* 0x810 */
-   uint utmip_hsrx_cfg0;
-   uint utmip_hsrx_cfg1;
-   uint utmip_fslsrx_cfg0;
-   uint utmip_fslsrx_cfg1

[U-Boot] [PATCH v3 3/3] Tegra: Config: Enable Tegra30/Tegra114 USB function

2013-06-17 Thread Jim Lin
Add USB EHCI, storage and network support.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
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(-)

diff --git a/include/configs/beaver.h b/include/configs/beaver.h
index 058da4f..165de13 100644
--- a/include/configs/beaver.h
+++ b/include/configs/beaver.h
@@ -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 */
diff --git a/include/configs/cardhu.h b/include/configs/cardhu.h
index 6a99175..fd46083 100644
--- a/include/configs/cardhu.h
+++ b/include/configs/cardhu.h
@@ -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 */
diff --git a/include/configs/dalmore.h b/include/configs/dalmore.h
index 7b68f7c..2723843 100644
--- a/include/configs/dalmore.h
+++ b/include/configs/dalmore.h
@@ -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 */
diff --git a/include/configs/tegra114-common.h 
b/include/configs/tegra114-common.h
index 721b29c..44e98e5 100644
--- a/include/configs/tegra114-common.h
+++ b/include/configs/tegra114-common.h
@@ -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_ */
diff --git a/include/configs/tegra30-common.h b/include/configs/tegra30-common.h
index ed36e11..7ea36be 100644
--- a/include/configs/tegra30-common.h
+++ b/include/configs/tegra30-common.h
@@ -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_ */
-- 
1.7.7

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


Re: [U-Boot] [PATCH v2 1/3] ARM: Tegra: FDT: Add USB EHCI function for T30/T114

2013-06-16 Thread Jim Lin
On Sun, 2013-06-16 at 03:46 +0800, Marek Vasut wrote:
 Dear Jim Lin,
 
  Add DT node for USB EHCI function.
  Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.
 
 I'd like to get ACK from someone with the actual hardware.
 
 btw. How usable is the cardhu with current U-Boot ? That's the ASUS TF700, 
 right? How can I install U-Boot on it, is there any howto?
I know nothing about ASUS TF700.
The T30-Cardhu board I have is a demo board.




---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/3] Tegra: Config: Enable Tegra30/Tegra114 USB function

2013-06-14 Thread Jim Lin
Add USB EHCI, storage and network support.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 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(-)

diff --git a/include/configs/beaver.h b/include/configs/beaver.h
index 058da4f..165de13 100644
--- a/include/configs/beaver.h
+++ b/include/configs/beaver.h
@@ -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 */
diff --git a/include/configs/cardhu.h b/include/configs/cardhu.h
index 6a99175..fd46083 100644
--- a/include/configs/cardhu.h
+++ b/include/configs/cardhu.h
@@ -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 */
diff --git a/include/configs/dalmore.h b/include/configs/dalmore.h
index 7b68f7c..2723843 100644
--- a/include/configs/dalmore.h
+++ b/include/configs/dalmore.h
@@ -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 */
diff --git a/include/configs/tegra114-common.h 
b/include/configs/tegra114-common.h
index 721b29c..44e98e5 100644
--- a/include/configs/tegra114-common.h
+++ b/include/configs/tegra114-common.h
@@ -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_ */
diff --git a/include/configs/tegra30-common.h b/include/configs/tegra30-common.h
index ed36e11..7ea36be 100644
--- a/include/configs/tegra30-common.h
+++ b/include/configs/tegra30-common.h
@@ -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_ */
-- 
1.7.7

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


[U-Boot] [PATCH v2 1/3] ARM: Tegra: FDT: Add USB EHCI function for T30/T114

2013-06-14 Thread Jim Lin
Add DT node for USB EHCI function.
Add support for T30-Cardhu, T30-Beaver, T114-Dalmore boards.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 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(-)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index f86d18d..f87d05a 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disable;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = utmi;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra114-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/arch/arm/dts/tegra30.dtsi b/arch/arm/dts/tegra30.dtsi
index ccf154f..e5275c2 100644
--- a/arch/arm/dts/tegra30.dtsi
+++ b/arch/arm/dts/tegra30.dtsi
@@ -216,4 +216,31 @@
clocks = tegra_car 15;
status = disabled;
};
+
+   usb@7d00 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts = 52;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts = 53;
+   phy_type = utmi;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra30-ehci;
+   reg = 0x7d008000 0x4000;
+   interrupts = 129;
+   phy_type = utmi;
+   clocks = tegra_car 59;   /* PERIPH_ID_USB3 */
+   status = disabled;
+   };
 };
diff --git a/board/nvidia/dts/tegra114-dalmore.dts 
b/board/nvidia/dts/tegra114-dalmore.dts
index 86e9459..435c01e 100644
--- a/board/nvidia/dts/tegra114-dalmore.dts
+++ b/board/nvidia/dts/tegra114-dalmore.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@78000400;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -61,4 +62,10 @@
bus-width = 8;
status = okay;
};
+
+   usb@7d008000 {
+   /* SPDIF_IN: USB_VBUS_EN1 */
+   nvidia,vbus-gpio = gpio 86 0;
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-beaver.dts 
b/board/nvidia/dts/tegra30-beaver.dts
index 836169f..b003ae1 100644
--- a/board/nvidia/dts/tegra30-beaver.dts
+++ b/board/nvidia/dts/tegra30-beaver.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -68,4 +69,9 @@
status = okay;
bus-width = 8;
};
+
+   usb@7d008000 {
+   nvidia,vbus-gpio = gpio 61 3; /* PH5, USB13_VBUS_PULLUP */
+   status = okay;
+   };
 };
diff --git a/board/nvidia/dts/tegra30-cardhu.dts 
b/board/nvidia/dts/tegra30-cardhu.dts
index 4d22b48..071a464 100644
--- a/board/nvidia/dts/tegra30-cardhu.dts
+++ b/board/nvidia/dts/tegra30-cardhu.dts
@@ -14,6 +14,7 @@
i2c4 = /i2c@7000c700;
sdhci0 = /sdhci@78000600;
sdhci1 = /sdhci@7800;
+   usb0 = /usb@7d008000;
};
 
memory {
@@ -63,4 +64,9 @@
status = okay;
bus-width = 8;
};
+
+   usb@7d008000 {
+   nvidia,vbus-gpio = gpio 233 3;   /* PDD1, EN_3V3_PU */
+   status = okay;
+   };
 };
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 4e8032b..d19b9f3 100644
--- a/include/fdtdec.h
+++ b/include

[U-Boot] [PATCH v2 2/3] ARM: Tegra: USB: EHCI: Add support for Tegra30/Tegra114

2013-06-14 Thread Jim Lin
Tegra30 and Tegra114 are compatible except PLL parameters.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 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

diff --git a/arch/arm/include/asm/arch-tegra/clk_rst.h 
b/arch/arm/include/asm/arch-tegra/clk_rst.h
index c754ec7..9b8de9c 100644
--- a/arch/arm/include/asm/arch-tegra/clk_rst.h
+++ b/arch/arm/include/asm/arch-tegra/clk_rst.h
@@ -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)
diff --git a/arch/arm/include/asm/arch-tegra/usb.h 
b/arch/arm/include/asm/arch-tegra/usb.h
index ef6c089..cefe0d2 100644
--- a/arch/arm/include/asm/arch-tegra/usb.h
+++ b/arch/arm/include/asm/arch-tegra/usb.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
+ * Copyright (c) 2013 NVIDIA Corporation
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -22,120 +23,6 @@
 #ifndef _TEGRA_USB_H_
 #define _TEGRA_USB_H_
 
-
-/* USB Controller (USBx_CONTROLLER_) regs */
-struct usb_ctlr {
-   /* 0x000 */
-   uint id;
-   uint reserved0;
-   uint host;
-   uint device;
-
-   /* 0x010 */
-   uint txbuf;
-   uint rxbuf;
-   uint reserved1[2];
-
-   /* 0x020 */
-   uint reserved2[56];
-
-   /* 0x100 */
-   u16 cap_length;
-   u16 hci_version;
-   uint hcs_params;
-   uint hcc_params;
-   uint reserved3[5];
-
-   /* 0x120 */
-   uint dci_version;
-   uint dcc_params;
-   uint reserved4[6];
-
-   /* 0x140 */
-   uint usb_cmd;
-   uint usb_sts;
-   uint usb_intr;
-   uint frindex;
-
-   /* 0x150 */
-   uint reserved5;
-   uint periodic_list_base;
-   uint async_list_addr;
-   uint async_tt_sts;
-
-   /* 0x160 */
-   uint burst_size;
-   uint tx_fill_tuning;
-   uint reserved6;   /* is this port_sc1 on some controllers? */
-   uint icusb_ctrl;
-
-   /* 0x170 */
-   uint ulpi_viewport;
-   uint reserved7;
-   uint endpt_nak;
-   uint endpt_nak_enable;
-
-   /* 0x180 */
-   uint reserved;
-   uint port_sc1;
-   uint reserved8[6];
-
-   /* 0x1a0 */
-   uint reserved9;
-   uint otgsc;
-   uint usb_mode;
-   uint endpt_setup_stat;
-
-   /* 0x1b0 */
-   uint reserved10[20];
-
-   /* 0x200 */
-   uint reserved11[0x80];
-
-   /* 0x400 */
-   uint susp_ctrl;
-   uint phy_vbus_sensors;
-   uint phy_vbus_wakeup_id;
-   uint phy_alt_vbus_sys;
-
-   /* 0x410 */
-   uint usb1_legacy_ctrl;
-   uint reserved12[4];
-
-   /* 0x424 */
-   uint ulpi_timing_ctrl_0;
-   uint ulpi_timing_ctrl_1;
-   uint reserved13[53];
-
-   /* 0x500 */
-   uint reserved14[64 * 3];
-
-   /* 0x800 */
-   uint utmip_pll_cfg0;
-   uint utmip_pll_cfg1;
-   uint utmip_xcvr_cfg0;
-   uint utmip_bias_cfg0;
-
-   /* 0x810 */
-   uint utmip_hsrx_cfg0;
-   uint utmip_hsrx_cfg1;
-   uint utmip_fslsrx_cfg0;
-   uint utmip_fslsrx_cfg1;
-
-   /* 0x820 */
-   uint utmip_tx_cfg0;
-   uint utmip_misc_cfg0;
-   uint utmip_misc_cfg1;
-   uint utmip_debounce_cfg0;
-
-   /* 0x830 */
-   uint utmip_bat_chrg_cfg0;
-   uint utmip_spare_cfg0;
-   uint utmip_xcvr_cfg1;
-   uint utmip_bias_cfg1;
-};
-
-
 /* USB1_LEGACY_CTRL */
 #define USB1_NO_LEGACY_MODE1
 
@@ -146,25 +33,18 @@ struct usb_ctlr {
 #define VBUS_SENSE_CTL_AB_SESS_VLD 2
 #define VBUS_SENSE_CTL_A_SESS_VLD  3
 
-/* USB2_IF_ULPI_TIMING_CTRL_0 */
-#define ULPI_OUTPUT_PINMUX_BYP (1  10)
-#define ULPI_CLKOUT_PINMUX_BYP (1  11)
-
-/* USB2_IF_ULPI_TIMING_CTRL_1 */
-#define ULPI_DATA_TRIMMER_LOAD (1

[U-Boot] [PATCH 1/1 RESEND] NET: Fix system hanging if NET device is not installed

2013-06-05 Thread Jim Lin
If we try to boot from NET device, NetInitLoop in net.c will be invoked.
If NET device is not installed, eth_get_dev() function will return
eth_current value, which is NULL.
When NetInitLoop is called, eth_get_dev-enetaddr will access
restricted memory area and therefore cause hanging.
This issue is found on Tegra30 Cardhu platform after adding
CONFIG_CMD_NET and CONFIG_CMD_DHCP in config header file.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 net/net.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..7663b9c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -271,7 +271,8 @@ static void NetInitLoop(void)
 #endif
env_changed_id = env_id;
}
-   memcpy(NetOurEther, eth_get_dev()-enetaddr, 6);
+   if (eth_get_dev())
+   memcpy(NetOurEther, eth_get_dev()-enetaddr, 6);
 
return;
 }
-- 
1.7.7

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


[U-Boot] [PATCH 1/1] NET: Fix system hanging if NET device is not installed

2013-05-17 Thread Jim Lin
If we try to boot from NET device, NetInitLoop in net.c will be invoked.
If NET device is not installed, eth_get_dev() function will return
eth_current value, which is NULL.
When NetInitLoop is called, eth_get_dev-enetaddr will access
restricted memory area and therefore cause hanging.
This issue is found on Tegra30 Cardhu platform after adding
CONFIG_CMD_NET and CONFIG_CMD_DHCP in config header file.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 net/net.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/net.c b/net/net.c
index df94789..7663b9c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -271,7 +271,8 @@ static void NetInitLoop(void)
 #endif
env_changed_id = env_id;
}
-   memcpy(NetOurEther, eth_get_dev()-enetaddr, 6);
+   if (eth_get_dev())
+   memcpy(NetOurEther, eth_get_dev()-enetaddr, 6);
 
return;
 }
-- 
1.7.7

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


Re: [U-Boot] [PATCH 2/3] ARM: Tegra: USB: Add driver support for Tegra30/Tegra114

2013-05-03 Thread Jim Lin
On Fri, 2013-05-03 at 03:29 +0800, Stephen Warren wrote:
 On 04/29/2013 03:21 AM, Jim Lin wrote:
  Tegra30 and Tegra114 are compatible except
  1. T30 takes 55 ms to finish Port Reset. T114 takes
 50 ms.
 
 Is that 55-vs-50 some aspect of the HW specification itself, or the
 overall result of multiple separate delays? I ask because the statement
 that one piece of HW differs from another only in a delay, especially
 where that delay is enormous in HW terms, seem very unusual.

50 ms comes from USB 2.0 specification for root port.
55 ms comes from T30 Technical Reference Manual.
Overall result of multiple separate delays.

--
nvpublic

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


Re: [U-Boot] [PATCH 1/3] ARM: Tegra: FDT: Add USB support for T20/T30/T114

2013-05-03 Thread Jim Lin
On Fri, 2013-05-03 at 03:10 +0800, Stephen Warren wrote:
 On 04/29/2013 03:21 AM, Jim Lin wrote:
  Add DT node for USB function.
 
  diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
 
  +/* This table has USB timing parameters for each Oscillator frequency we
  + * support. There are four sets of values:
  + *
  + * 1. PLLU configuration information (reference clock is osc/clk_m and
  + * PLLU-FOs are fixed at 12MHz/60MHz/480MHz).
  + * Reference frequency MHZ 12.0  13.0 19.2  26.0
  + * 
  + *  DIVN  960   960200   960
  + *  DIVM   1213  426
  + *  CPCON  1212  312
  + *  LFCON   2 2  2 2
  + *
  + * 2. PLL CONFIGURATION  PARAMETERS for different clock generators:
  + * Reference frequency MHZ 12.0  13.0  19.2  26.0
  + * 
  + * PLLU_ENABLE_DLY_COUNT   02 2 3 4
  + * PLLU_STABLE_COUNT   475175   102
  + * PLL_ACTIVE_DLY_COUNT08 912 9
  + * XTAL_FREQ_COUNT118   127   188   254
  + *
  + * 3. Debounce values IdDig, Avalid, Bvalid, VbusValid, VbusWakeUp, and
  + * SessEnd. Each of these signals have their own debouncer and for each of
  + * those one out of two debouncing times can be chosen (BIAS_DEBOUNCE_A or
  + * BIAS_DEBOUNCE_B).
  + *
  + * The values of DEBOUNCE_A and DEBOUNCE_B are calculated as follows:
  + *0x - No debouncing at all
  + *n ms = n * 1000 / (1/19.2MHz) / 4
  + *
  + * So to program a 10 ms debounce for BIAS_DEBOUNCE_A, we have:
  + * BIAS_DEBOUNCE_A[15:0] = 10 * 1000 * 19.2 / 4  = 48000 = 0xBB80
  + *
  + * We need to use only DebounceA for BOOTROM. We don't need the DebounceB
  + * values, so we can keep those to default.
  + *
  + * 4. The 20 microsecond delay after bias cell operation.
  + *UTMIP_BIAS_PAD_TRK_COUNT
  + *
  + * enum {
  + * PARAM_DIVN, // PLL FEEDBACK DIVIDER
  + * PARAM_DIVM, // PLL INPUT DIVIDER
  + * PARAM_DIVP, // POST DIVIDER (2^N)
  + * PARAM_CPCON,// BASE PLLC CHARGE Pump setup ctrl
  + * PARAM_LFCON,// BASE PLLC LOOP FILter setup ctrl
  + * PARAM_ENABLE_DELAY_COUNT,   // PLL-U Enable Delay Count
  + * PARAM_STABLE_COUNT, // PLL-U STABLE count
  + * PARAM_ACTIVE_DELAY_COUNT,   // PLL-U Active delay count
  + * PARAM_XTAL_FREQ_COUNT,  // PLL-U XTAL frequency count
  + * PARAM_DEBOUNCE_A_TIME,  // 10MS DELAY for BIAS_DEBOUNCE_A
  + * PARAM_BIAS_TIME,// 20US DELAY AFter bias cell op
  + * // UTMIP_BIAS_PAD_TRK_COUNT
  + *};
  + */
  +   usbparams@0 {
  +   compatible = nvidia,usbparams;
  +   osc-frequency = 1300;
  +   /* DivN, DivM, DivP, CPCON, LFCON, Delays  Debounce, Bias */
  +   params = 0x3c0 0x0d 0x00 0xc 2  0x02 0x33 0x09 0x7f  0x7ef4 6;
  +   };
  +
  +   usbparams@1 {
  +   compatible = nvidia,usbparams;
  +   osc-frequency = 1920;
  +   params = 0x0c8 0x04 0x00 0x3 2  0x03 0x4b 0x0c 0xbc  0xbb80 8;
  +   };
  +
  +   usbparams@2 {
  +   compatible = nvidia,usbparams;
  +   osc-frequency = 1200;
  +   params = 0x3c0 0x0c 0x00 0xc 2  0x02 0x2f 0x08 0x76  0x7530 5;
  +   };
  +
  +   usbparams@3 {
  +   compatible = nvidia,usbparams;
  +   osc-frequency = 2600;
  +   params = 0x3c0 0x1a 0x00 0xc 2  0x04 0x66 0x09 0xfe  0xfde8 
  0xb;
  +   };
 
 None of the above should be present; this is SoC-specific information
 and should be part of the USB driver itself. There's no benefit to
 putting the information into DT just to parse it back out into the same
 tables that the driver could have contained in the first place.
Parameters are not completely same for T20, T30, and T114.
Putting over dt file is for expanding on future chips.

 
 The same comment applies to all 3 tegra*.dtsi files. For the Tegra20
 case, please make sure that what you add here is identical to what has
 been proposed for the final kernel USB bindings. Ask Venu (now CC'd) for
 a pointer to that.
 
  +   usb@7d00 {
  +   compatible = nvidia,tegra30-ehci, nvidia,tegra114-ehci;
  +   reg = 0x7d00 0x4000;
  +   interrupts =  52 ;
 
 There shouldn't be spaces after  or before .
 
 The bindings here don't match the kernel. Please make sure they do.
 This patch only touches 2 board files: Cardhu and Dalmore. Will USB
 support on other boards continue to work without any DT changes?
 Existing functionality can't be broken. I'd expect to see a bunch more
 DT files edited here.
For T20, I only have Seaboard and Harmony platforms.
For other T20 platforms, I may blindly add USB support as you suggested,
is that okay?


--
nvpublic

Re: [U-Boot] [PATCH 2/3] ARM: Tegra: USB: Add driver support for Tegra30/Tegra114

2013-05-02 Thread Jim Lin
On Thu, 2013-05-02 at 03:33 +0800, Marek Vasut wrote:
 Dear Tom Rini,
 
  On Wed, May 01, 2013 at 09:16:45AM -0700, Tom Warren wrote:
   Tom,
   
   On Tue, Apr 30, 2013 at 10:20 AM, Tom Rini tr...@ti.com wrote:
On Tue, Apr 30, 2013 at 09:21:18AM -0700, Tom Warren wrote:
 Marek,
 
  -Original Message-
  From: Marek Vasut [mailto:ma...@denx.de]
  Sent: Monday, April 29, 2013 4:47 PM
  To: Jim Lin
  Cc: u-boot@lists.denx.de; Tom Warren; Stephen Warren
  Subject: Re: [PATCH 2/3] ARM: Tegra: USB: Add driver support for
  Tegra30/Tegra114
  
  Dear Jim Lin,
  
   Tegra30 and Tegra114 are compatible except 1. T30 takes 55 ms to
   finish Port Reset. T114 takes
   
  50 ms.
   
   2. PLL parameters
   
   Tested on Tegra20 Harmony/Seaboard, Tegra30 Cardhu, and Tegra114
   Dalmore platforms. All works well.
   
   Signed-off-by: Jim Lin ji...@nvidia.com
   ---
   
arch/arm/include/asm/arch-tegra/clk_rst.h  |   10 +
arch/arm/include/asm/arch-tegra/usb.h  |  249
-- arch/arm/include/asm/arch-tegra114/tegra.h |
   1 +
arch/arm/include/asm/arch-tegra114/usb.h   |  287
  
  +
  
arch/arm/include/asm/arch-tegra20/usb.h|  279
  
  +
  
arch/arm/include/asm/arch-tegra30/usb.h|  294
  
  ++
  
  Do we now have three copies of the same stuff ?
 
 When only T20 was supported (for USB), there was a common
 (arch-tegra/usb.h) header. That's been moved to arch-tegra20/usb.h,
 and (unfortunately) there are 2 new usb.h files due to the HW
 differences in the registers between T20 and T30/T114.  I don't see
 any easy way to have a common usb.h file for Tegra w/o adding ugly
 #ifdefs to the USB register space struct(s).

Just how different are they?  Are all of the related defines and masks
different too?  Do we have conflicts? Moved registers?  Just
conflicting values?  A quick peek shows '30' and '114' are pretty
similar, except for masks.  Maybe splitting the struct up so you can
discard some of the reserved gaps, run-time checking to see if we can
or cannot use a particular part of the struct?
   
   This is really Jim's patchset (and his specialty), but here's what I know
   about Tegra USB regs:
   
   T20 had a gap in the registers @ offset 0x130. T30 (and T114) moved the
   offset of the command/status/interrupt regs down to fill in this gap,
   which dragged all the subsequent registers back 16 bytes. The two SoCs
   'families' sync up again at offset 0x400 and are pretty much equal from
   there on out to 0x840.
   
   The defines are probably 90% the same, with some weirdness for the first
   USB controller (USB1) and its PTS/STS bits that differs in offset from
   the other 2 controllers (again, no clue why the HW guys would do this).
   
   So we could have the 3 different USB headers in the arch-tegraXX area
   contain the register structs, and have a common arch-tegra/usb.h that has
   the #defines that are the same, and is included in the arch-tegraxx/usb.h
   files. That would reduce this down somewhat, without the ugliness of
   #ifdefs in the structs.
   
   What do you think?
  
  Sounds like the best we can do then.  It's probable that trying to
  define USB_REGMAP_GAPSIZE1/2 or whatever to do it on the fly would just
  be uglier still.  Thanks!
 
 This is a problem with the struct-based access indeed. I agree with Tom it'd 
 be 
 worth to at least try distilling the common part into header shared between 
 those three CPUs.
OK. I will add this into next version of patch.

 
 btw you're also adding some kernel-doc-alike annotations to functions, why 
 don't 
 you follow kerneldoc style altogether?
I don't understand what you meant here.
Could you give me an example? Like what I did is wrong or not good. And
what is correct or better one.
Thanks.

--
nvpublic

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


[U-Boot] [PATCH 0/3] Tegra: USB: EHCI: add Tegra30 compatible support

2013-04-29 Thread Jim Lin
Tegra114 USB EHCI is compatible with Tegra30 USB EHCI
except:
1. Port Reset - Tegra30 takes 55ms, Tegra114 takes 50 ms to finish.
2. PLL parameters.

Jim Lin (3):
  ARM: Tegra: FDT: Add USB support for T20/T30/T114
  ARM: Tegra: USB: Add driver support for Tegra30/Tegra114
  Tegra: Config: Enable Tegra30/Tegra114 USB function

 arch/arm/dts/tegra114.dtsi |  105 
 arch/arm/dts/tegra20.dtsi  |   81 ++
 arch/arm/dts/tegra30.dtsi  |  108 
 arch/arm/include/asm/arch-tegra/clk_rst.h  |   10 +
 arch/arm/include/asm/arch-tegra/usb.h  |  249 --
 arch/arm/include/asm/arch-tegra114/tegra.h |1 +
 arch/arm/include/asm/arch-tegra114/usb.h   |  287 +
 arch/arm/include/asm/arch-tegra20/usb.h|  279 +
 arch/arm/include/asm/arch-tegra30/usb.h|  294 ++
 board/nvidia/common/board.c|2 +-
 board/nvidia/dts/tegra114-dalmore.dts  |7 +
 board/nvidia/dts/tegra30-cardhu.dts|6 +
 drivers/usb/host/ehci-hcd.c|   40 ++-
 drivers/usb/host/ehci-tegra.c  |  376 ---
 include/configs/cardhu.h   |   14 +
 include/configs/dalmore.h  |   14 +
 include/configs/tegra114-common.h  |3 +
 include/configs/tegra30-common.h   |3 +
 include/fdtdec.h   |2 +
 lib/fdtdec.c   |2 +
 20 files changed, 1523 insertions(+), 360 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-tegra/usb.h
 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

-- 
1.7.7

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


[U-Boot] [PATCH 1/3] ARM: Tegra: FDT: Add USB support for T20/T30/T114

2013-04-29 Thread Jim Lin
Add DT node for USB function.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 arch/arm/dts/tegra114.dtsi|  105 
 arch/arm/dts/tegra20.dtsi |   81 
 arch/arm/dts/tegra30.dtsi |  108 +
 board/nvidia/dts/tegra114-dalmore.dts |7 ++
 board/nvidia/dts/tegra30-cardhu.dts   |6 ++
 include/fdtdec.h  |2 +
 lib/fdtdec.c  |2 +
 7 files changed, 311 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index f86d18d..0f8387b 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -216,4 +216,109 @@
clocks = tegra_car 15;
status = disable;
};
+
+/* This table has USB timing parameters for each Oscillator frequency we
+ * support. There are four sets of values:
+ *
+ * 1. PLLU configuration information (reference clock is osc/clk_m and
+ * PLLU-FOs are fixed at 12MHz/60MHz/480MHz).
+ * Reference frequency MHZ 12.0  13.0 19.2  26.0
+ * 
+ *  DIVN  960   960200   960
+ *  DIVM   1213  426
+ *  CPCON  1212  312
+ *  LFCON   2 2  2 2
+ *
+ * 2. PLL CONFIGURATION  PARAMETERS for different clock generators:
+ * Reference frequency MHZ 12.0  13.0  19.2  26.0
+ * 
+ * PLLU_ENABLE_DLY_COUNT   02 2 3 4
+ * PLLU_STABLE_COUNT   475175   102
+ * PLL_ACTIVE_DLY_COUNT08 912 9
+ * XTAL_FREQ_COUNT118   127   188   254
+ *
+ * 3. Debounce values IdDig, Avalid, Bvalid, VbusValid, VbusWakeUp, and
+ * SessEnd. Each of these signals have their own debouncer and for each of
+ * those one out of two debouncing times can be chosen (BIAS_DEBOUNCE_A or
+ * BIAS_DEBOUNCE_B).
+ *
+ * The values of DEBOUNCE_A and DEBOUNCE_B are calculated as follows:
+ *0x - No debouncing at all
+ *n ms = n * 1000 / (1/19.2MHz) / 4
+ *
+ * So to program a 10 ms debounce for BIAS_DEBOUNCE_A, we have:
+ * BIAS_DEBOUNCE_A[15:0] = 10 * 1000 * 19.2 / 4  = 48000 = 0xBB80
+ *
+ * We need to use only DebounceA for BOOTROM. We don't need the DebounceB
+ * values, so we can keep those to default.
+ *
+ * 4. The 20 microsecond delay after bias cell operation.
+ *UTMIP_BIAS_PAD_TRK_COUNT
+ *
+ * enum {
+ * PARAM_DIVN, // PLL FEEDBACK DIVIDER
+ * PARAM_DIVM, // PLL INPUT DIVIDER
+ * PARAM_DIVP, // POST DIVIDER (2^N)
+ * PARAM_CPCON,// BASE PLLC CHARGE Pump setup ctrl
+ * PARAM_LFCON,// BASE PLLC LOOP FILter setup ctrl
+ * PARAM_ENABLE_DELAY_COUNT,   // PLL-U Enable Delay Count
+ * PARAM_STABLE_COUNT, // PLL-U STABLE count
+ * PARAM_ACTIVE_DELAY_COUNT,   // PLL-U Active delay count
+ * PARAM_XTAL_FREQ_COUNT,  // PLL-U XTAL frequency count
+ * PARAM_DEBOUNCE_A_TIME,  // 10MS DELAY for BIAS_DEBOUNCE_A
+ * PARAM_BIAS_TIME,// 20US DELAY AFter bias cell op
+ * // UTMIP_BIAS_PAD_TRK_COUNT
+ *};
+ */
+   usbparams@0 {
+   compatible = nvidia,usbparams;
+   osc-frequency = 1300;
+   /* DivN, DivM, DivP, CPCON, LFCON, Delays  Debounce, Bias */
+   params = 0x3c0 0x0d 0x00 0xc 2  0x02 0x33 0x09 0x7f  0x7ef4 6;
+   };
+
+   usbparams@1 {
+   compatible = nvidia,usbparams;
+   osc-frequency = 1920;
+   params = 0x0c8 0x04 0x00 0x3 2  0x03 0x4b 0x0c 0xbc  0xbb80 8;
+   };
+
+   usbparams@2 {
+   compatible = nvidia,usbparams;
+   osc-frequency = 1200;
+   params = 0x3c0 0x0c 0x00 0xc 2  0x02 0x2f 0x08 0x76  0x7530 5;
+   };
+
+   usbparams@3 {
+   compatible = nvidia,usbparams;
+   osc-frequency = 2600;
+   params = 0x3c0 0x1a 0x00 0xc 2  0x04 0x66 0x09 0xfe  0xfde8 
0xb;
+   };
+
+   usb@7d00 {
+   compatible = nvidia,tegra30-ehci, nvidia,tegra114-ehci;
+   reg = 0x7d00 0x4000;
+   interrupts =  52 ;
+   phy_type = utmi;
+   clocks = tegra_car 22;   /* PERIPH_ID_USBD */
+   status = disabled;
+   };
+
+   usb@7d004000 {
+   compatible = nvidia,tegra30-ehci, nvidia,tegra114-ehci;
+   reg = 0x7d004000 0x4000;
+   interrupts =  53 ;
+   phy_type = utmi;
+   clocks = tegra_car 58;   /* PERIPH_ID_USB2 */
+   status = disabled;
+   };
+
+   usb@7d008000 {
+   compatible = nvidia,tegra30-ehci, nvidia,tegra114-ehci

[U-Boot] [PATCH 3/3] Tegra: Config: Enable Tegra30/Tegra114 USB function

2013-04-29 Thread Jim Lin
Add USB EHCI, storage and network support.

Tested on Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 include/configs/cardhu.h  |   14 ++
 include/configs/dalmore.h |   14 ++
 include/configs/tegra114-common.h |3 +++
 include/configs/tegra30-common.h  |3 +++
 4 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/include/configs/cardhu.h b/include/configs/cardhu.h
index 6a99175..fd46083 100644
--- a/include/configs/cardhu.h
+++ b/include/configs/cardhu.h
@@ -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 */
diff --git a/include/configs/dalmore.h b/include/configs/dalmore.h
index 7b68f7c..2723843 100644
--- a/include/configs/dalmore.h
+++ b/include/configs/dalmore.h
@@ -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 */
diff --git a/include/configs/tegra114-common.h 
b/include/configs/tegra114-common.h
index 721b29c..44e98e5 100644
--- a/include/configs/tegra114-common.h
+++ b/include/configs/tegra114-common.h
@@ -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_ */
diff --git a/include/configs/tegra30-common.h b/include/configs/tegra30-common.h
index ed36e11..7ea36be 100644
--- a/include/configs/tegra30-common.h
+++ b/include/configs/tegra30-common.h
@@ -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_ */
-- 
1.7.7

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


[U-Boot] [PATCH 2/3] ARM: Tegra: USB: Add driver support for Tegra30/Tegra114

2013-04-29 Thread Jim Lin
Tegra30 and Tegra114 are compatible except
1. T30 takes 55 ms to finish Port Reset. T114 takes
   50 ms.
2. PLL parameters

Tested on Tegra20 Harmony/Seaboard, Tegra30 Cardhu, and Tegra114 Dalmore
platforms. All works well.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 arch/arm/include/asm/arch-tegra/clk_rst.h  |   10 +
 arch/arm/include/asm/arch-tegra/usb.h  |  249 --
 arch/arm/include/asm/arch-tegra114/tegra.h |1 +
 arch/arm/include/asm/arch-tegra114/usb.h   |  287 +
 arch/arm/include/asm/arch-tegra20/usb.h|  279 +
 arch/arm/include/asm/arch-tegra30/usb.h|  294 ++
 board/nvidia/common/board.c|2 +-
 drivers/usb/host/ehci-hcd.c|   40 ++-
 drivers/usb/host/ehci-tegra.c  |  376 ---
 9 files changed, 1178 insertions(+), 360 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-tegra/usb.h
 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

diff --git a/arch/arm/include/asm/arch-tegra/clk_rst.h 
b/arch/arm/include/asm/arch-tegra/clk_rst.h
index c754ec7..9b8de9c 100644
--- a/arch/arm/include/asm/arch-tegra/clk_rst.h
+++ b/arch/arm/include/asm/arch-tegra/clk_rst.h
@@ -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)
diff --git a/arch/arm/include/asm/arch-tegra/usb.h 
b/arch/arm/include/asm/arch-tegra/usb.h
deleted file mode 100644
index ef6c089..000
--- a/arch/arm/include/asm/arch-tegra/usb.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 2011 The Chromium OS Authors.
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef _TEGRA_USB_H_
-#define _TEGRA_USB_H_
-
-
-/* USB Controller (USBx_CONTROLLER_) regs */
-struct usb_ctlr {
-   /* 0x000 */
-   uint id;
-   uint reserved0;
-   uint host;
-   uint device;
-
-   /* 0x010 */
-   uint txbuf;
-   uint rxbuf;
-   uint reserved1[2];
-
-   /* 0x020 */
-   uint reserved2[56];
-
-   /* 0x100 */
-   u16 cap_length;
-   u16 hci_version;
-   uint hcs_params;
-   uint hcc_params;
-   uint reserved3[5];
-
-   /* 0x120 */
-   uint dci_version;
-   uint dcc_params;
-   uint reserved4[6];
-
-   /* 0x140 */
-   uint usb_cmd;
-   uint usb_sts;
-   uint usb_intr;
-   uint frindex;
-
-   /* 0x150 */
-   uint reserved5;
-   uint periodic_list_base;
-   uint async_list_addr;
-   uint async_tt_sts;
-
-   /* 0x160 */
-   uint burst_size;
-   uint tx_fill_tuning;
-   uint reserved6;   /* is this port_sc1 on some controllers? */
-   uint icusb_ctrl;
-
-   /* 0x170 */
-   uint ulpi_viewport;
-   uint reserved7;
-   uint endpt_nak;
-   uint endpt_nak_enable;
-
-   /* 0x180 */
-   uint reserved;
-   uint port_sc1;
-   uint reserved8[6];
-
-   /* 0x1a0 */
-   uint reserved9;
-   uint otgsc;
-   uint usb_mode;
-   uint endpt_setup_stat;
-
-   /* 0x1b0 */
-   uint reserved10[20];
-
-   /* 0x200 */
-   uint reserved11[0x80];
-
-   /* 0x400 */
-   uint susp_ctrl;
-   uint phy_vbus_sensors;
-   uint phy_vbus_wakeup_id;
-   uint phy_alt_vbus_sys;
-
-   /* 0x410 */
-   uint usb1_legacy_ctrl;
-   uint reserved12[4];
-
-   /* 0x424 */
-   uint ulpi_timing_ctrl_0;
-   uint ulpi_timing_ctrl_1;
-   uint reserved13[53];
-
-   /* 0x500 */
-   uint reserved14[64 * 3];
-
-   /* 0x800 */
-   uint utmip_pll_cfg0;
-   uint utmip_pll_cfg1

[U-Boot] [PATCH 1/1] USB: EHCI: Add weak functions to support new chip

2013-03-27 Thread Jim Lin
Add ehci_get_port_speed() and ehci_set_usbmode() weak functions
for platform driver to support new chip.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 drivers/usb/host/ehci-hcd.c |   40 
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c816878..6a55cd2 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -122,6 +122,31 @@ static struct descriptor {
 #define ehci_is_TDI()  (0)
 #endif
 
+int __ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg)
+{
+   return PORTSC_PSPD(reg);
+}
+
+int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg)
+   __attribute__((weak, alias(__ehci_get_port_speed)));
+
+void __ehci_set_usbmode(int index)
+{
+   uint32_t tmp;
+   uint32_t *reg_ptr;
+
+   reg_ptr = (uint32_t *)((u8 *)ehcic[index].hcor-or_usbcmd + USBMODE);
+   tmp = ehci_readl(reg_ptr);
+   tmp |= USBMODE_CM_HC;
+#if defined(CONFIG_EHCI_MMIO_BIG_ENDIAN)
+   tmp |= USBMODE_BE;
+#endif
+   ehci_writel(reg_ptr, tmp);
+}
+
+void ehci_set_usbmode(int index)
+   __attribute__((weak, alias(__ehci_set_usbmode)));
+
 void __ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
 {
mdelay(50);
@@ -149,8 +174,6 @@ static int handshake(uint32_t *ptr, uint32_t mask, uint32_t 
done, int usec)
 static int ehci_reset(int index)
 {
uint32_t cmd;
-   uint32_t tmp;
-   uint32_t *reg_ptr;
int ret = 0;
 
cmd = ehci_readl(ehcic[index].hcor-or_usbcmd);
@@ -163,15 +186,8 @@ static int ehci_reset(int index)
goto out;
}
 
-   if (ehci_is_TDI()) {
-   reg_ptr = (uint32_t *)((u8 *)ehcic[index].hcor + USBMODE);
-   tmp = ehci_readl(reg_ptr);
-   tmp |= USBMODE_CM_HC;
-#if defined(CONFIG_EHCI_MMIO_BIG_ENDIAN)
-   tmp |= USBMODE_BE;
-#endif
-   ehci_writel(reg_ptr, tmp);
-   }
+   if (ehci_is_TDI())
+   ehci_set_usbmode(index);
 
 #ifdef CONFIG_USB_EHCI_TXFIFO_THRESH
cmd = ehci_readl(ehcic[index].hcor-or_txfilltuning);
@@ -711,7 +727,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 (PORTSC_PSPD(reg)) {
+   switch (ehci_get_port_speed(ctrl-hcor, reg)) {
case PORTSC_PSPD_FS:
break;
case PORTSC_PSPD_LS:
-- 
1.7.7

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


Re: [U-Boot] [PATCH 1/1 v3] console: USB: KBD: Fix incorrect autoboot timeout

2013-03-21 Thread Jim Lin
Thanks for pointing out the potential issue.

-Original Message-
From: Jon Hunter [mailto:jon-hun...@ti.com] 
Sent: Thursday, March 21, 2013 7:57 AM
To: Jim Lin
Cc: u-boot@lists.denx.de; ma...@denx.de; w...@denx.de; tr...@ti.com; Tom Warren
Subject: Re: [U-Boot] [PATCH 1/1 v3] console: USB: KBD: Fix incorrect autoboot 
timeout


On 01/24/2013 05:05 AM, Jim Lin wrote:
 Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if 
 CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in 
 configuration file and when tstc() function for checking key pressed 
 takes longer time than 10 ms (e.g., 50 ms) to finish.
 
 Signed-off-by: Jim Lin ji...@nvidia.com
 ---
 Changes in v2:
- use do-while and get_timer to count timeout.
 Changes in v3:
- revert original udelay(1); for safety.
 
  common/main.c |   10 +-
  1 files changed, 5 insertions(+), 5 deletions(-)
 
 diff --git a/common/main.c b/common/main.c index b145f85..dcd2a42 
 100644
 --- a/common/main.c
 +++ b/common/main.c
 @@ -225,6 +225,7 @@ static inline
  int abortboot(int bootdelay)
  {
   int abort = 0;
 + unsigned long ts;
  
  #ifdef CONFIG_MENUPROMPT
   printf(CONFIG_MENUPROMPT);
 @@ -248,11 +249,10 @@ int abortboot(int bootdelay)  #endif
  
   while ((bootdelay  0)  (!abort)) {
 - int i;
 -
   --bootdelay;
 - /* delay 100 * 10ms */
 - for (i=0; !abort  i100; ++i) {
 + /* delay 1000 ms */
 + ts = get_timer(0);
 + do {
   if (tstc()) {   /* we got a key press   */
   abort  = 1; /* don't auto boot  */
   bootdelay = 0;  /* no more delay*/
 @@ -264,7 +264,7 @@ int abortboot(int bootdelay)
   break;
   }
   udelay(1);
 - }
 + } while (!abort  get_timer(ts)  1000);
  
   printf(\b\b\b%2d , bootdelay);
   }

This change is causing problems with auto-delay on one of my boards by making 
it inaccurate :-(

The question is what should get_timer() be returning? If it is meant to be 
milliseconds then I guess I need to fix get_timer() for my board.
However, if it is just meant to be timer ticks at the SYS_HZ rate then I don't 
see how the above change guarantees the do-while loop waits 1000 ms per 
iteration without normalising to SYS_HZ.

For my board I made the following change to make it work ...

diff --git a/common/main.c b/common/main.c index a15f020..32c4f8a 100644
--- a/common/main.c
+++ b/common/main.c
@@ -264,7 +264,7 @@ int abortboot(int bootdelay)
break;
}
udelay(1);
-   } while (!abort  get_timer(ts)  1000);
+   } while (!abort  !(get_timer(ts) / CONFIG_SYS_HZ));

printf(\b\b\b%2d , bootdelay);

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


Re: [U-Boot] [PATCH 1/1] console: Improve TFTP booting performance

2013-01-28 Thread Jim Lin
On Fri, 2013-01-25 at 17:20 +0800, Wolfgang Denk wrote:
 Dear Jim Lin,
 
 In message 1359097425-20517-1-git-send-email-ji...@nvidia.com you wrote:
  TFTP booting is observed a little bit slow, especially when a USB
  keyboard is installed.
  The fix is to check whether Ctrl-C key is pressed every
  CONFIG_CTRLC_POLL_MS ms.
  If CONFIG_CTRLC_POLL_MS is not defined in configuration file, we
  define it as 1000.
 
 ...also:
 
  +#ifndef CONFIG_CTRLC_POLL_MS
  +/*
  + * Process Ctrl-C every 1000 ms by default to improve performance
  + * (like TFTP boot) when interlaced with other tasks.
  + */
  +#define CONFIG_CTRLC_POLL_MS 1000
  +#endif
  +static unsigned long ctrlc_ts = CONFIG_CTRLC_POLL_MS;
 
 Don't set such a default.  If this is good for you, OK.  But for all
 others, the behaviour should not change at all.
 
 
 Also, are you positively sure that your callto get_timer() does not
 mess up with other timers in the network subsystem?
 
OK. I will rewrite and check again.
Thanks.

--nvpublic


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


Re: [U-Boot] [PATCH 1/1 v2] console: USB: KBD: Fix incorrect autoboot timeout

2013-01-24 Thread Jim Lin
On Thu, 2013-01-24 at 03:33 +0800, Wolfgang Denk wrote:
 Dear Jim Lin,
 
 In message 1358937511-32664-1-git-send-email-ji...@nvidia.com you wrote:
  Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if
  CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in
  configuration file and when tstc() function for checking key pressed
  takes longer time than 10 ms (e.g., 50 ms) to finish.
 
 Thanks.  One minor nitpick...
 
  +   /* delay 1000 ms */
  +   ts = get_timer(0);
  +   do {
  if (tstc()) {   /* we got a key press   */
  abort  = 1; /* don't auto boot  */
  bootdelay = 0;  /* no more delay*/
  @@ -263,8 +263,7 @@ int abortboot(int bootdelay)
   # endif
  break;
  }
  -   udelay(1);
  -   }
  +   } while (!abort  get_timer(ts)  1000);
 
 I recommend to keep a short udelay() [say, an udelay(1000)] in the
 loop, as this will make sure that watchdog still gets triggered on
 systems that need this.
 
I will keep
   udelay(1);
for safety in next patch.

Thanks.

-- nvpublic

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


[U-Boot] [PATCH 1/1 v3] console: USB: KBD: Fix incorrect autoboot timeout

2013-01-24 Thread Jim Lin
Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if
CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in
configuration file and when tstc() function for checking key pressed
takes longer time than 10 ms (e.g., 50 ms) to finish.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
   - use do-while and get_timer to count timeout.
Changes in v3:
   - revert original udelay(1); for safety.

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

diff --git a/common/main.c b/common/main.c
index b145f85..dcd2a42 100644
--- a/common/main.c
+++ b/common/main.c
@@ -225,6 +225,7 @@ static inline
 int abortboot(int bootdelay)
 {
int abort = 0;
+   unsigned long ts;
 
 #ifdef CONFIG_MENUPROMPT
printf(CONFIG_MENUPROMPT);
@@ -248,11 +249,10 @@ int abortboot(int bootdelay)
 #endif
 
while ((bootdelay  0)  (!abort)) {
-   int i;
-
--bootdelay;
-   /* delay 100 * 10ms */
-   for (i=0; !abort  i100; ++i) {
+   /* delay 1000 ms */
+   ts = get_timer(0);
+   do {
if (tstc()) {   /* we got a key press   */
abort  = 1; /* don't auto boot  */
bootdelay = 0;  /* no more delay*/
@@ -264,7 +264,7 @@ int abortboot(int bootdelay)
break;
}
udelay(1);
-   }
+   } while (!abort  get_timer(ts)  1000);
 
printf(\b\b\b%2d , bootdelay);
}
-- 
1.7.3


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/1] console: Improve TFTP booting performance

2013-01-24 Thread Jim Lin
TFTP booting is observed a little bit slow, especially when a USB
keyboard is installed.
The fix is to check whether Ctrl-C key is pressed every
CONFIG_CTRLC_POLL_MS ms.
If CONFIG_CTRLC_POLL_MS is not defined in configuration file, we
define it as 1000.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 common/console.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/common/console.c b/common/console.c
index bf73178..3339a93 100644
--- a/common/console.c
+++ b/common/console.c
@@ -524,9 +524,21 @@ int vprintf(const char *fmt, va_list args)
 /* test if ctrl-c was pressed */
 static int ctrlc_disabled = 0; /* see disable_ctrl() */
 static int ctrlc_was_pressed = 0;
+#ifndef CONFIG_CTRLC_POLL_MS
+/*
+ * Process Ctrl-C every 1000 ms by default to improve performance
+ * (like TFTP boot) when interlaced with other tasks.
+ */
+#define CONFIG_CTRLC_POLL_MS 1000
+#endif
+static unsigned long ctrlc_ts = CONFIG_CTRLC_POLL_MS;
 int ctrlc(void)
 {
if (!ctrlc_disabled  gd-have_console) {
+   if (get_timer(ctrlc_ts)  CONFIG_CTRLC_POLL_MS)
+   return 0;
+   else
+   ctrlc_ts = get_timer(0);
if (tstc()) {
switch (getc()) {
case 0x03:  /* ^C - Control C */
-- 
1.7.3


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] console: USB: KBD: Fix incorrect autoboot timeout

2013-01-23 Thread Jim Lin
On Wed, 2013-01-23 at 16:38 +0800, Wolfgang Denk wrote:
 Dear Jim Lin,
 
 In message 1358923034-2727-1-git-send-email-ji...@nvidia.com you wrote:
  Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if
  CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in
  configuration file and when tstc() function for checking key pressed takes
  longer time than 10 ms (e.g., 50 ms) to finish.
 ...
 
  /* delay 100 * 10ms */
  -   for (i=0; !abort  i100; ++i) {
  +   j = 100;
  +   for (i = 0; !abort  i  j; ++i) {
  +   ts = get_timer(0);
  if (tstc()) {   /* we got a key press   */
  abort  = 1; /* don't auto boot  */
  bootdelay = 0;  /* no more delay*/
  @@ -263,7 +266,11 @@ int abortboot(int bootdelay)
   # endif
  break;
  }
  -   udelay(1);
  +   ts = get_timer(ts);
  +   if (ts  10)
  +   mdelay(10 - ts);
  +   else
  +   j = 1000 / (int) ts;
  }
 
 This is a pretty awkward implementation.  If you feel the current
 plain delay loop based approach is not exact enough, then please
 implement a real timeout - you are calling the timer anyway, so just
 use the timer values instead of a loop count.
 
Thanks for pointing this out. I will improve it and resend.



---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/1 v2] console: USB: KBD: Fix incorrect autoboot timeout

2013-01-23 Thread Jim Lin
Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if
CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in
configuration file and when tstc() function for checking key pressed
takes longer time than 10 ms (e.g., 50 ms) to finish.

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
   - use do-while and get_timer to count timeout

 common/main.c |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/common/main.c b/common/main.c
index b145f85..4dac01d 100644
--- a/common/main.c
+++ b/common/main.c
@@ -225,6 +225,7 @@ static inline
 int abortboot(int bootdelay)
 {
int abort = 0;
+   unsigned long ts;
 
 #ifdef CONFIG_MENUPROMPT
printf(CONFIG_MENUPROMPT);
@@ -248,11 +249,10 @@ int abortboot(int bootdelay)
 #endif
 
while ((bootdelay  0)  (!abort)) {
-   int i;
-
--bootdelay;
-   /* delay 100 * 10ms */
-   for (i=0; !abort  i100; ++i) {
+   /* delay 1000 ms */
+   ts = get_timer(0);
+   do {
if (tstc()) {   /* we got a key press   */
abort  = 1; /* don't auto boot  */
bootdelay = 0;  /* no more delay*/
@@ -263,8 +263,7 @@ int abortboot(int bootdelay)
 # endif
break;
}
-   udelay(1);
-   }
+   } while (!abort  get_timer(ts)  1000);
 
printf(\b\b\b%2d , bootdelay);
}
-- 
1.7.3


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/1] console: USB: KBD: Fix incorrect autoboot timeout

2013-01-22 Thread Jim Lin
Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if
CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in
configuration file and when tstc() function for checking key pressed takes
longer time than 10 ms (e.g., 50 ms) to finish.

Signed-off-by: Jim Lin ji...@nvidia.com
---
 common/main.c |   13 ++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/common/main.c b/common/main.c
index b145f85..8cdfb8b 100644
--- a/common/main.c
+++ b/common/main.c
@@ -225,6 +225,7 @@ static inline
 int abortboot(int bootdelay)
 {
int abort = 0;
+   unsigned long ts;
 
 #ifdef CONFIG_MENUPROMPT
printf(CONFIG_MENUPROMPT);
@@ -248,11 +249,13 @@ int abortboot(int bootdelay)
 #endif
 
while ((bootdelay  0)  (!abort)) {
-   int i;
+   int i, j;
 
--bootdelay;
/* delay 100 * 10ms */
-   for (i=0; !abort  i100; ++i) {
+   j = 100;
+   for (i = 0; !abort  i  j; ++i) {
+   ts = get_timer(0);
if (tstc()) {   /* we got a key press   */
abort  = 1; /* don't auto boot  */
bootdelay = 0;  /* no more delay*/
@@ -263,7 +266,11 @@ int abortboot(int bootdelay)
 # endif
break;
}
-   udelay(1);
+   ts = get_timer(ts);
+   if (ts  10)
+   mdelay(10 - ts);
+   else
+   j = 1000 / (int) ts;
}
 
printf(\b\b\b%2d , bootdelay);
-- 
1.7.3


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Slow tftp boot with Ubuntu 12.04 tftp server

2013-01-17 Thread Jim Lin
Could you remove CONFIG_USB_KEYBOARD setting from your configuration
file (.h under include/configs) and recompile to see whether problem
disappears?

If yes, this is the problem I'm working on.
Otherwise it's another issue.

On Thu, 2013-01-17 at 23:29 +0800, David Aldrich wrote:
 I would like to give some more information about my problem.  u-boot's tftp 
 transfers do eventually complete and the evm boots.  I can then execute tftp 
 get commands from Linux on the evm and these execute quickly. So the problem 
 definitely has to do with the way u-boot uses tftp.
 
 BR
 
 David
 
  -Original Message-
  From: u-boot-boun...@lists.denx.de [mailto:u-boot-
  boun...@lists.denx.de] On Behalf Of David Aldrich
  Sent: 17 January 2013 11:19
  To: u-boot@lists.denx.de
  Subject: [U-Boot] Slow tftp boot with Ubuntu 12.04 tftp server
  
  Hi
  
  I am using an Advantech TMX320TCI6614 EVM to develop code for an ARM
  core on a TI C66x device.  The ARM core runs:
  
  U-Boot 2011.06-2-gc4611c1-dirty (May 30 2012 - 15:38:01)
  
  I have booted this target card for several months from a tftp server running
  under Ubuntu 10.04, with no problems.  But, this week, I have tried to move
  to a tftp server that runs on a different machine running Ubuntu 12.04 LTS.
  
  Since moving to Ubuntu 12.04 the tftp download is very slow, although it
  does succeed eventually.  I have tried getting the boot files using a tftp 
  client
  running on another Ubuntu host and the download is fast.
  
  Please can anyone suggest a reason for the slow download when using the
  EVM with the 12.04 server?
  
  Best regards
  
  David
  
  
  
   Click
  https://www.mailcontrol.com/sr/gy6n!KN6KZHGX2PQPOmvUi5k6UwC82173
  j1nKEDGDxQEKt0qtqc7COBYlPdIuP1TMPbtT3ZYZ55kxH4nYzTQYQ==  to
  report this email as spam.
 ___
 U-Boot mailing list
 U-Boot@lists.denx.de
 http://lists.denx.de/mailman/listinfo/u-boot
--nvpublic

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


Re: [U-Boot] [PATCH v2 3/7] usb: ehci: Support interrupt transfers via periodic list

2012-12-18 Thread Jim Lin
There is a potential bug. See below.

 +struct int_queue {
 +   struct QH *first;
 +   struct QH *current;
 +   struct QH *last;
 +   struct qTD *tds;
 +};
 +
 +#define NEXT_QH(qh) (struct QH *)((qh)-qh_link  ~0x1f)
 +
 +static int
 +enable_periodic(struct ehci_ctrl *ctrl)
 +{
 +   uint32_t cmd;
 +   struct ehci_hcor *hcor = ctrl-hcor;
 +   int ret;
 +
 +   cmd = ehci_readl(hcor-or_usbcmd);
 +   cmd |= CMD_PSE;
 +   ehci_writel(hcor-or_usbcmd, cmd);
 +
 +   ret = handshake((uint32_t *)hcor-or_usbsts,
 +   STD_PSS, STD_PSS, 100 * 1000);
Using STS_PSS may be better. STS means status, for USBSTS register.

 +   if (ret  0) {
 +   printf(EHCI failed: timeout when enabling periodic list\n);
 +   return -ETIMEDOUT;
 +   }
 +   udelay(1000);
 +   return 0;
 +}
 +
 +static int
 +disable_periodic(struct ehci_ctrl *ctrl)
 +{
 +   uint32_t cmd;
 +   struct ehci_hcor *hcor = ctrl-hcor;
 +   int ret;
 +
 +   cmd = ehci_readl(hcor-or_usbcmd);
 +   cmd = ~CMD_PSE;
 +   ehci_writel(hcor-or_usbcmd, cmd);
 +
 +   ret = handshake((uint32_t *)hcor-or_usbsts,
 +   STD_PSS, 0, 100 * 1000);
Using STS_PSS may be better. STS means status, for USBSTS register.

 +   if (ret  0) {
 +   printf(EHCI failed: timeout when enabling periodic list\n);
 +   return -ETIMEDOUT;
 +   }
 +   return 0;
 +}
 +
 +static int periodic_schedules;
 +
 +struct int_queue *
 +create_int_queue(struct usb_device *dev, unsigned long pipe, int queuesize,
 +int elementsize, void *buffer)
 +{
 +   struct ehci_ctrl *ctrl = dev-controller;
 +   struct int_queue *result = NULL;
 +   int i;
 +
 +   debug(Enter create_int_queue\n);
 +   if (usb_pipetype(pipe) != PIPE_INTERRUPT) {
 +   debug(non-interrupt pipe (type=%lu), usb_pipetype(pipe));
 +   return NULL;
 +   }
 +
 +   /* limit to 4 full pages worth of data -
 +* we can safely fit them in a single TD,
 +* no matter the alignment
 +*/
 +   if (elementsize = 16384) {
 +   debug(too large elements for interrupt transfers\n);
 +   return NULL;
 +   }
 +
 +   result = malloc(sizeof(*result));
 +   if (!result) {
 +   debug(ehci intr queue: out of memory\n);
 +   goto fail1;
 +   }
 +   result-first = memalign(32, sizeof(struct QH) * queuesize);
 +   if (!result-first) {
 +   debug(ehci intr queue: out of memory\n);
 +   goto fail2;
 +   }
 +   result-current = result-first;
 +   result-last = result-first + elementsize - 1;
If input queuesize is 1 and elementsize is 8 (for a low-speed keyboard),
result-first points to one allocated QH.
result-last points to 8th QH (starting from result-first).
But we only allocate one QH space for result-first.
The location pointed by result-last is beyond the space we allocate.
It seems not right.

 +   result-tds = memalign(32, sizeof(struct qTD) * queuesize);
 +   if (!result-tds) {
 +   debug(ehci intr queue: out of memory\n);
 +   goto fail3;
 +   }
 +   memset(result-first, 0, sizeof(struct QH) * queuesize);
 +   memset(result-tds, 0, sizeof(struct qTD) * queuesize);
 +
 +   for (i = 0; i  queuesize; i++) {
 +   struct QH *qh = result-first + i;
 +   struct qTD *td = result-tds + i;
 +   void **buf = qh-buffer;
 +
 +   qh-qh_link = (uint32_t)(qh+1) | QH_LINK_TYPE_QH;
 +   if (i == queuesize - 1)
 +   qh-qh_link = QH_LINK_TERMINATE;
 +
 +   qh-qh_overlay.qt_next = (uint32_t)td;
 +   qh-qh_endpt1 = (0  28) | /* No NAK reload (ehci 4.9) */
 +   (usb_maxpacket(dev, pipe)  16) | /* MPS */
 +   (1  14) |
 +   QH_ENDPT1_EPS(ehci_encode_speed(dev-speed)) |
 +   (usb_pipeendpoint(pipe)  8) | /* Endpoint Number */
 +   (usb_pipedevice(pipe)  0);
 +   qh-qh_endpt2 = (1  30); /* 1 Tx per mframe */
 +   if (dev-speed == USB_SPEED_LOW ||
 +   dev-speed == USB_SPEED_FULL) {
 +   debug(TT: port: %d, hub address: %d\n,
 +   dev-portnr, dev-parent-devnum);
 +   qh-qh_endpt2 |= (dev-portnr  23) |
 +   (dev-parent-devnum  16) |
 +   (0x1c  8) | /* C-mask: microframes 2-4 */
 +   (1  0); /* S-mask: microframe 0 */
 +   }
 +
 +   td-qt_next = QT_NEXT_TERMINATE;
 +   td-qt_altnext = QT_NEXT_TERMINATE;
 +   debug(communication direction is '%s'\n,
 + usb_pipein(pipe) ? in : out);
 +   

Re: [U-Boot] [PATCH v2 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-08-13 Thread Jim Lin
-Original Message-
From: Marek Vasut [mailto:ma...@denx.de] 
Sent: Sunday, August 12, 2012 7:47 AM
To: Jim Lin
Cc: u-boot@lists.denx.de; Wolfgang Denk; Tom Warren
Subject: Re: [U-Boot] [PATCH v2 1/1] USB: EHCI: Initialize multiple USB 
controllers at once

 diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 
 a8e3ae5..8d3093b 100644
 --- a/common/cmd_usb.c
 +++ b/common/cmd_usb.c
 @@ -554,7 +554,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, 
 char
 * const argv[]) }
 if (strncmp(argv[1], tree, 4) == 0) {
 printf(\nDevice Tree:\n);
 +#ifdef CONFIG_USB_MULTI

How's this supposed to work? Shouldn't this call usb_show_tree on roots of all 
the trees?

You see the following  if dev-parent is NULL that means it's the only root hub 
under a controller
, then we show devices under this root hub of the controller by usb_show_tree.
Root hub under different controller is listed as separate device.

 +   for (i = 0; i  USB_MAX_DEVICE; i++) {
 +   dev = usb_get_dev_index(i);
 +   if (dev == NULL)
 +   break;
 +   if (dev-parent == NULL)
 +   usb_show_tree(dev);
 +   }
 +#else
 usb_show_tree(usb_get_dev_index(0));
 +#endif
 return 0;
 }
 if (strncmp(argv[1], inf, 3) == 0) { diff --git 
 a/common/usb.c b/common/usb.c index 1b40228..065c70c 100644
 --- a/common/usb.c
 +++ b/common/usb.c

 +#endif
 +   USB_PRINTF(scan end\n);
 +   usb_started = 1;
 +   return 0;
 +   } else {
 +   printf(Error, couldn't init Lowlevel part\n);
 +   usb_started = 0;
 +   return -1;
 +   }
 +}
 +
 +/
 +*
 * + * Stop USB this stops the LowLevel Part and deregisters USB 
 devices. + */
 +int usb_stop(void)
 +{
 +   int i;
 +
 +   if (usb_started) {
 +   asynch_allowed = 1;
 +   usb_started = 0;
 +   usb_hub_reset();
 +   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++)
 +   usb_lowlevel_stop(i);
 +   }
 +   return 0;
 +}
 +#else
  /**
   * some forward declerations...
   */
 @@ -127,6 +210,7 @@ int usb_stop(void)
 }
 return res;
  }
 +#endif
 
  /*
   * disables the asynch behaviour of the control message. This is used 
 for data @@ -750,11 +834,18 @@ struct usb_device 
 *usb_get_dev_index(int index) return usb_dev[index];  }
 
 -
 +#ifdef CONFIG_USB_MULTI

I still believe it's possible to get rid of this MULTI crap, simply set the 
multiness to 1 for non-multi setups. How big overhead will that generate?
I assume you want me to use code in ifdef CONFIG_USB_MULTI block,
remove CONFIG_USB_MULTI and if  CONFIG_USB_MAX_CONTROLLER_COUNT is 1
, then do non-multi setups.

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


Re: [U-Boot] [PATCH v2 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-08-13 Thread Jim Lin
-Original Message-
From: Marek Vasut [mailto:ma...@denx.de] 
Sent: Sunday, August 12, 2012 7:47 AM
To: Jim Lin
Cc: u-boot@lists.denx.de; Wolfgang Denk; Tom Warren
Subject: Re: [U-Boot] [PATCH v2 1/1] USB: EHCI: Initialize multiple USB 
controllers at once

Dear Jim Lin,

 Add support for command line usb reset or usb start to initialize 
 , usb stop to stop multiple USB controllers at once.
 Other command like usb tree also supports multiple controllers.
 
 New added definitions in header file are:
 CONFIG_USB_MULTI
 CONFIG_USB_MAX_CONTROLLER_COUNT
 
 Signed-off-by: Jim Lin ji...@nvidia.com
 ---
 Changes in v2:
 - Renaming from CONFIG_USB_INIT_MULTI to CONFIG_USB_MULTI
 - Define CONFIG_USB_MAX_CONTROLLER_COUNT as 1 if not defined
 - Remove volatile from structure ehci_ctrl of ehci-hcd.c for a 
 checkpatch.pl warning
 
  common/cmd_usb.c|   10 +++
  common/usb.c|   98 +-
  common/usb_hub.c|4 +
  drivers/usb/host/ehci-hcd.c |  167
 +++--- drivers/usb/host/ehci.h |  
  5 ++
  include/usb.h   |   12 +++
  6 files changed, 251 insertions(+), 45 deletions(-)
 
 diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 
 a8e3ae5..8d3093b 100644
 --- a/common/cmd_usb.c
 +++ b/common/cmd_usb.c
 @@ -554,7 +554,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, 
 char
 * const argv[]) }
 if (strncmp(argv[1], tree, 4) == 0) {
 printf(\nDevice Tree:\n);
 +#ifdef CONFIG_USB_MULTI

How's this supposed to work? Shouldn't this call usb_show_tree on roots of all 
the trees?
See the following code, if dev-parent is NULL, then current device is  root 
hub, we show devices below it

 +   for (i = 0; i  USB_MAX_DEVICE; i++) {
 +   dev = usb_get_dev_index(i);
 +   if (dev == NULL)
 +   break;
 +   if (dev-parent == NULL)
 +   usb_show_tree(dev);
 +   }
 +#else
 usb_show_tree(usb_get_dev_index(0));
 +#endif
 return 0;
 }
 if (strncmp(argv[1], inf, 3) == 0) { diff --git 
 a/common/usb.c b/common/usb.c index 1b40228..065c70c 100644
 --- a/common/usb.c
 +++ b/common/usb.c
 @@ -77,6 +77,89 @@ static int asynch_allowed;
 
  char usb_started; /* flag for the started/stopped USB status */
 
 +#ifdef CONFIG_USB_MULTI
 +/
 +*
 ** + * Init USB Device
 + */
 +#ifndef CONFIG_USB_MAX_CONTROLLER_COUNT #define 
 +CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif
 +
 +int usb_init(void)
 +{
 +   void *ctrl;
 +   int i;
 +   struct usb_device *dev;
 +
 +   running = 0;
 +   dev_index = 0;
 +   asynch_allowed = 1;
 +   usb_hub_reset();
 +
 +   /* first make all devices unknown */
 +   for (i = 0; i  USB_MAX_DEVICE; i++) {
 +   memset(usb_dev[i], 0, sizeof(struct usb_device));
 +   usb_dev[i].devnum = -1;
 +   }
 +
 +   /* init low_level USB */
 +   printf(USB:   );
 +   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
 +   /* init low_level USB */
 +   ctrl = usb_lowlevel_init(i);
 +   /*
 +* if lowlevel init is OK, scan the bus for devices
 +* i.e. search HUBs and configure them
 +*/
 +   if (ctrl) {
 +   running = 1;
 +
 +   printf(scanning bus for devices... );
 +   dev = usb_alloc_new_device(ctrl);
 +   /*
 +* device 0 is always present
 +* (root hub, so let it analyze)
 +*/
 +   if (dev)
 +   usb_new_device(dev);
 +   }
 +   }
 +
 +   if (running) {
 +   if (!dev_index)
 +   printf(No USB Device found\n);
 +   else
 +   printf(%d USB Device(s) found\n, dev_index); 
 +#ifdef CONFIG_USB_KEYBOARD
 +   drv_usb_kbd_init();

Will the keyboard driver survive this?
Yes I have tried it after doing the following.
1. Define CONFIG_USB_KEYBOARD, CONFIG_SYS_USB_EVENT_POLL, CONFIG_USB_MULTI, and 
CONFIG_USB_MAX_CONTROLLER_COUNT 3
 in config header file like seaboard.h to compile
2. Install USB keyboard
3. Run usb reset in u-boot serial console
4. Run coninfo to see usbkbd appeared
5. Run setenv stdin usbkbd
6. Typing u-boot console command on USB keyboard

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


[U-Boot] [PATCH v2 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-08-10 Thread Jim Lin
Add support for command line usb reset or usb start to initialize
, usb stop to stop multiple USB controllers at once.
Other command like usb tree also supports multiple controllers.

New added definitions in header file are:
CONFIG_USB_MULTI
CONFIG_USB_MAX_CONTROLLER_COUNT

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
- Renaming from CONFIG_USB_INIT_MULTI to CONFIG_USB_MULTI
- Define CONFIG_USB_MAX_CONTROLLER_COUNT as 1 if not defined
- Remove volatile from structure ehci_ctrl of ehci-hcd.c for a checkpatch.pl 
warning

 common/cmd_usb.c|   10 +++
 common/usb.c|   98 +-
 common/usb_hub.c|4 +
 drivers/usb/host/ehci-hcd.c |  167 +++---
 drivers/usb/host/ehci.h |5 ++
 include/usb.h   |   12 +++
 6 files changed, 251 insertions(+), 45 deletions(-)

diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index a8e3ae5..8d3093b 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -554,7 +554,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
}
if (strncmp(argv[1], tree, 4) == 0) {
printf(\nDevice Tree:\n);
+#ifdef CONFIG_USB_MULTI
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   dev = usb_get_dev_index(i);
+   if (dev == NULL)
+   break;
+   if (dev-parent == NULL)
+   usb_show_tree(dev);
+   }
+#else
usb_show_tree(usb_get_dev_index(0));
+#endif
return 0;
}
if (strncmp(argv[1], inf, 3) == 0) {
diff --git a/common/usb.c b/common/usb.c
index 1b40228..065c70c 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -77,6 +77,89 @@ static int asynch_allowed;
 
 char usb_started; /* flag for the started/stopped USB status */
 
+#ifdef CONFIG_USB_MULTI
+/***
+ * Init USB Device
+ */
+#ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
+#endif
+
+int usb_init(void)
+{
+   void *ctrl;
+   int i;
+   struct usb_device *dev;
+
+   running = 0;
+   dev_index = 0;
+   asynch_allowed = 1;
+   usb_hub_reset();
+
+   /* first make all devices unknown */
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   memset(usb_dev[i], 0, sizeof(struct usb_device));
+   usb_dev[i].devnum = -1;
+   }
+
+   /* init low_level USB */
+   printf(USB:   );
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
+   /* init low_level USB */
+   ctrl = usb_lowlevel_init(i);
+   /*
+* if lowlevel init is OK, scan the bus for devices
+* i.e. search HUBs and configure them
+*/
+   if (ctrl) {
+   running = 1;
+
+   printf(scanning bus for devices... );
+   dev = usb_alloc_new_device(ctrl);
+   /*
+* device 0 is always present
+* (root hub, so let it analyze)
+*/
+   if (dev)
+   usb_new_device(dev);
+   }
+   }
+
+   if (running) {
+   if (!dev_index)
+   printf(No USB Device found\n);
+   else
+   printf(%d USB Device(s) found\n, dev_index);
+#ifdef CONFIG_USB_KEYBOARD
+   drv_usb_kbd_init();
+#endif
+   USB_PRINTF(scan end\n);
+   usb_started = 1;
+   return 0;
+   } else {
+   printf(Error, couldn't init Lowlevel part\n);
+   usb_started = 0;
+   return -1;
+   }
+}
+
+/**
+ * Stop USB this stops the LowLevel Part and deregisters USB devices.
+ */
+int usb_stop(void)
+{
+   int i;
+
+   if (usb_started) {
+   asynch_allowed = 1;
+   usb_started = 0;
+   usb_hub_reset();
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++)
+   usb_lowlevel_stop(i);
+   }
+   return 0;
+}
+#else
 /**
  * some forward declerations...
  */
@@ -127,6 +210,7 @@ int usb_stop(void)
}
return res;
 }
+#endif
 
 /*
  * disables the asynch behaviour of the control message. This is used for data
@@ -750,11 +834,18 @@ struct usb_device *usb_get_dev_index(int index)
return usb_dev[index];
 }
 
-
+#ifdef CONFIG_USB_MULTI
+/* Save input pointer 'controller' into device structure.
+ * 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

[U-Boot] [PATCH 1/1] tegra20: Initialize multiple USB controllers at once

2012-08-10 Thread Jim Lin
Add support for command line usb reset or usb start to initialize
, usb stop to stop multiple USB controllers at once.
Other commands like usb tree also support multiple controllers.

Example to add definitions in header file like include/configs/seaboard.h are:
define CONFIG_USB_MULTI
define CONFIG_USB_MAX_CONTROLLER_COUNT 3

Signed-off-by: Jim Lin ji...@nvidia.com
---
 arch/arm/cpu/armv7/tegra20/usb.c|   15 +++
 arch/arm/include/asm/arch-tegra20/usb.h |4 
 drivers/usb/host/ehci-tegra.c   |   15 +++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/arch/arm/cpu/armv7/tegra20/usb.c
index 178bb13..141d608 100644
--- a/arch/arm/cpu/armv7/tegra20/usb.c
+++ b/arch/arm/cpu/armv7/tegra20/usb.c
@@ -352,7 +352,11 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor)
 
if (portnum = port_count)
return -1;
+#ifdef CONFIG_USB_MULTI
+   tegrausb_stop_port(portnum);
+#else
tegrausb_stop_port();
+#endif
set_host_mode(port[portnum]);
 
usbctlr = port[portnum].reg;
@@ -362,6 +366,16 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor)
return 0;
 }
 
+#ifdef CONFIG_USB_MULTI
+int tegrausb_stop_port(unsigned portnum)
+{
+   struct usb_ctlr *usbctlr;
+
+   if (portnum = port_count)
+   return -1;
+
+   usbctlr = port[portnum].reg;
+#else
 int tegrausb_stop_port(void)
 {
struct usb_ctlr *usbctlr;
@@ -370,6 +384,7 @@ int tegrausb_stop_port(void)
return -1;
 
usbctlr = port[port_current].reg;
+#endif
 
/* Stop controller */
writel(0, usbctlr-usb_cmd);
diff --git a/arch/arm/include/asm/arch-tegra20/usb.h 
b/arch/arm/include/asm/arch-tegra20/usb.h
index 638033b..e7bc167 100644
--- a/arch/arm/include/asm/arch-tegra20/usb.h
+++ b/arch/arm/include/asm/arch-tegra20/usb.h
@@ -247,6 +247,10 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor);
  *
  * @return 0 if ok, -1 if no port was active
  */
+#ifdef CONFIG_USB_MULTI
+int tegrausb_stop_port(unsigned portnum);
+#else
 int tegrausb_stop_port(void);
+#endif
 
 #endif /* _TEGRA_USB_H_ */
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 4646b29..fa2e1b1 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -50,6 +50,12 @@ void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
  */
+#ifdef CONFIG_USB_MULTI
+int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+{
+   return tegrausb_start_port(index, hccr, hcor);
+}
+#else
 int ehci_hcd_init(void)
 {
u32 our_hccr, our_hcor;
@@ -66,13 +72,22 @@ int ehci_hcd_init(void)
 
return 0;
 }
+#endif
 
 /*
  * Destroy the appropriate control structures corresponding
  * the the EHCI host controller.
  */
+#ifdef CONFIG_USB_MULTI
+int ehci_hcd_stop(int index)
+{
+   tegrausb_stop_port(index);
+   return 0;
+}
+#else
 int ehci_hcd_stop(void)
 {
tegrausb_stop_port();
return 0;
 }
+#endif
-- 
1.7.3


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-08-08 Thread Jim Lin
Add support for command line usb reset or usb start to initialize
, usb stop to stop multiple USB controllers at once.
Other command like usb tree also supports multiple controllers.

New added definitions in header file are:
CONFIG_USB_MULTI
CONFIG_USB_MAX_CONTROLLER_COUNT

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
- Renaming from CONFIG_USB_INIT_MULTI to CONFIG_USB_MULTI
- Define CONFIG_USB_MAX_CONTROLLER_COUNT as 1 if not defined
- Remove volatile from structure ehci_ctrl of ehci-hcd.c for a checkpatch.pl 
warning

 common/cmd_usb.c|   10 +++
 common/usb.c|   98 +-
 common/usb_hub.c|4 +
 drivers/usb/host/ehci-hcd.c |  167 +++---
 drivers/usb/host/ehci.h |5 ++
 include/usb.h   |   12 +++
 6 files changed, 251 insertions(+), 45 deletions(-)

diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index a8e3ae5..8d3093b 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -554,7 +554,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
}
if (strncmp(argv[1], tree, 4) == 0) {
printf(\nDevice Tree:\n);
+#ifdef CONFIG_USB_MULTI
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   dev = usb_get_dev_index(i);
+   if (dev == NULL)
+   break;
+   if (dev-parent == NULL)
+   usb_show_tree(dev);
+   }
+#else
usb_show_tree(usb_get_dev_index(0));
+#endif
return 0;
}
if (strncmp(argv[1], inf, 3) == 0) {
diff --git a/common/usb.c b/common/usb.c
index 1b40228..065c70c 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -77,6 +77,89 @@ static int asynch_allowed;

 char usb_started; /* flag for the started/stopped USB status */

+#ifdef CONFIG_USB_MULTI
+/***
+ * Init USB Device
+ */
+#ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
+#endif
+
+int usb_init(void)
+{
+   void *ctrl;
+   int i;
+   struct usb_device *dev;
+
+   running = 0;
+   dev_index = 0;
+   asynch_allowed = 1;
+   usb_hub_reset();
+
+   /* first make all devices unknown */
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   memset(usb_dev[i], 0, sizeof(struct usb_device));
+   usb_dev[i].devnum = -1;
+   }
+
+   /* init low_level USB */
+   printf(USB:   );
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
+   /* init low_level USB */
+   ctrl = usb_lowlevel_init(i);
+   /*
+* if lowlevel init is OK, scan the bus for devices
+* i.e. search HUBs and configure them
+*/
+   if (ctrl) {
+   running = 1;
+
+   printf(scanning bus for devices... );
+   dev = usb_alloc_new_device(ctrl);
+   /*
+* device 0 is always present
+* (root hub, so let it analyze)
+*/
+   if (dev)
+   usb_new_device(dev);
+   }
+   }
+
+   if (running) {
+   if (!dev_index)
+   printf(No USB Device found\n);
+   else
+   printf(%d USB Device(s) found\n, dev_index);
+#ifdef CONFIG_USB_KEYBOARD
+   drv_usb_kbd_init();
+#endif
+   USB_PRINTF(scan end\n);
+   usb_started = 1;
+   return 0;
+   } else {
+   printf(Error, couldn't init Lowlevel part\n);
+   usb_started = 0;
+   return -1;
+   }
+}
+
+/**
+ * Stop USB this stops the LowLevel Part and deregisters USB devices.
+ */
+int usb_stop(void)
+{
+   int i;
+
+   if (usb_started) {
+   asynch_allowed = 1;
+   usb_started = 0;
+   usb_hub_reset();
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++)
+   usb_lowlevel_stop(i);
+   }
+   return 0;
+}
+#else
 /**
  * some forward declerations...
  */
@@ -127,6 +210,7 @@ int usb_stop(void)
}
return res;
 }
+#endif

 /*
  * disables the asynch behaviour of the control message. This is used for data
@@ -750,11 +834,18 @@ struct usb_device *usb_get_dev_index(int index)
return usb_dev[index];
 }

-
+#ifdef CONFIG_USB_MULTI
+/* Save input pointer 'controller' into device structure.
+ * 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)
+#else

[U-Boot] [PATCH 2/2] tegra20: Initialize multiple USB controllers at once

2012-08-08 Thread Jim Lin
Add support for command line usb reset or usb start to initialize
, usb stop to stop multiple USB controllers at once.
Other commands like usb tree also support multiple controllers.

Example to add definitions in header file like include/configs/seaboard.h are:
define CONFIG_USB_MULTI
define CONFIG_USB_MAX_CONTROLLER_COUNT 3

Signed-off-by: Jim Lin ji...@nvidia.com
---
 arch/arm/cpu/armv7/tegra20/usb.c|   15 +++
 arch/arm/include/asm/arch-tegra20/usb.h |4 
 drivers/usb/host/ehci-tegra.c   |   15 +++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/arch/arm/cpu/armv7/tegra20/usb.c
index 178bb13..141d608 100644
--- a/arch/arm/cpu/armv7/tegra20/usb.c
+++ b/arch/arm/cpu/armv7/tegra20/usb.c
@@ -352,7 +352,11 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor)
 
if (portnum = port_count)
return -1;
+#ifdef CONFIG_USB_MULTI
+   tegrausb_stop_port(portnum);
+#else
tegrausb_stop_port();
+#endif
set_host_mode(port[portnum]);
 
usbctlr = port[portnum].reg;
@@ -362,6 +366,16 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor)
return 0;
 }
 
+#ifdef CONFIG_USB_MULTI
+int tegrausb_stop_port(unsigned portnum)
+{
+   struct usb_ctlr *usbctlr;
+
+   if (portnum = port_count)
+   return -1;
+
+   usbctlr = port[portnum].reg;
+#else
 int tegrausb_stop_port(void)
 {
struct usb_ctlr *usbctlr;
@@ -370,6 +384,7 @@ int tegrausb_stop_port(void)
return -1;
 
usbctlr = port[port_current].reg;
+#endif
 
/* Stop controller */
writel(0, usbctlr-usb_cmd);
diff --git a/arch/arm/include/asm/arch-tegra20/usb.h 
b/arch/arm/include/asm/arch-tegra20/usb.h
index 638033b..e7bc167 100644
--- a/arch/arm/include/asm/arch-tegra20/usb.h
+++ b/arch/arm/include/asm/arch-tegra20/usb.h
@@ -247,6 +247,10 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor);
  *
  * @return 0 if ok, -1 if no port was active
  */
+#ifdef CONFIG_USB_MULTI
+int tegrausb_stop_port(unsigned portnum);
+#else
 int tegrausb_stop_port(void);
+#endif
 
 #endif /* _TEGRA_USB_H_ */
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 4646b29..fa2e1b1 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -50,6 +50,12 @@ void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
  * Create the appropriate control structures to manage
  * a new EHCI host controller.
  */
+#ifdef CONFIG_USB_MULTI
+int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+{
+   return tegrausb_start_port(index, hccr, hcor);
+}
+#else
 int ehci_hcd_init(void)
 {
u32 our_hccr, our_hcor;
@@ -66,13 +72,22 @@ int ehci_hcd_init(void)
 
return 0;
 }
+#endif
 
 /*
  * Destroy the appropriate control structures corresponding
  * the the EHCI host controller.
  */
+#ifdef CONFIG_USB_MULTI
+int ehci_hcd_stop(int index)
+{
+   tegrausb_stop_port(index);
+   return 0;
+}
+#else
 int ehci_hcd_stop(void)
 {
tegrausb_stop_port();
return 0;
 }
+#endif
-- 
1.7.3

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


[U-Boot] [PATCH v2 1/2] USB: EHCI: Initialize multiple USB controllers at once

2012-08-08 Thread Jim Lin
Add support for command line usb reset or usb start to initialize , usb 
stop to stop multiple USB controllers at once.
Other command like usb tree also supports multiple controllers.

New added definitions in header file are:
CONFIG_USB_MULTI
CONFIG_USB_MAX_CONTROLLER_COUNT

Signed-off-by: Jim Lin ji...@nvidia.com
---
Changes in v2:
- Renaming from CONFIG_USB_INIT_MULTI to CONFIG_USB_MULTI
- Define CONFIG_USB_MAX_CONTROLLER_COUNT as 1 if not defined
- Remove volatile from structure ehci_ctrl of ehci-hcd.c for a checkpatch.pl 
warning
- Modify include/usb.h

 common/cmd_usb.c|   10 +++
 common/usb.c|   98 +-
 common/usb_hub.c|4 +
 drivers/usb/host/ehci-hcd.c |  167 +++---
 drivers/usb/host/ehci.h |5 ++
 include/usb.h   |   12 +++
 6 files changed, 251 insertions(+), 45 deletions(-)

diff --git a/common/cmd_usb.c b/common/cmd_usb.c index a8e3ae5..8d3093b 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -554,7 +554,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
}
if (strncmp(argv[1], tree, 4) == 0) {
printf(\nDevice Tree:\n);
+#ifdef CONFIG_USB_MULTI
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   dev = usb_get_dev_index(i);
+   if (dev == NULL)
+   break;
+   if (dev-parent == NULL)
+   usb_show_tree(dev);
+   }
+#else
usb_show_tree(usb_get_dev_index(0));
+#endif
return 0;
}
if (strncmp(argv[1], inf, 3) == 0) { diff --git a/common/usb.c 
b/common/usb.c index 1b40228..065c70c 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -77,6 +77,89 @@ static int asynch_allowed;

 char usb_started; /* flag for the started/stopped USB status */

+#ifdef CONFIG_USB_MULTI
+/**
+*
+ * Init USB Device
+ */
+#ifndef CONFIG_USB_MAX_CONTROLLER_COUNT #define
+CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif
+
+int usb_init(void)
+{
+   void *ctrl;
+   int i;
+   struct usb_device *dev;
+
+   running = 0;
+   dev_index = 0;
+   asynch_allowed = 1;
+   usb_hub_reset();
+
+   /* first make all devices unknown */
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   memset(usb_dev[i], 0, sizeof(struct usb_device));
+   usb_dev[i].devnum = -1;
+   }
+
+   /* init low_level USB */
+   printf(USB:   );
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
+   /* init low_level USB */
+   ctrl = usb_lowlevel_init(i);
+   /*
+* if lowlevel init is OK, scan the bus for devices
+* i.e. search HUBs and configure them
+*/
+   if (ctrl) {
+   running = 1;
+
+   printf(scanning bus for devices... );
+   dev = usb_alloc_new_device(ctrl);
+   /*
+* device 0 is always present
+* (root hub, so let it analyze)
+*/
+   if (dev)
+   usb_new_device(dev);
+   }
+   }
+
+   if (running) {
+   if (!dev_index)
+   printf(No USB Device found\n);
+   else
+   printf(%d USB Device(s) found\n, dev_index);
+#ifdef CONFIG_USB_KEYBOARD
+   drv_usb_kbd_init();
+#endif
+   USB_PRINTF(scan end\n);
+   usb_started = 1;
+   return 0;
+   } else {
+   printf(Error, couldn't init Lowlevel part\n);
+   usb_started = 0;
+   return -1;
+   }
+}
+
+/**
+
+ * Stop USB this stops the LowLevel Part and deregisters USB devices.
+ */
+int usb_stop(void)
+{
+   int i;
+
+   if (usb_started) {
+   asynch_allowed = 1;
+   usb_started = 0;
+   usb_hub_reset();
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++)
+   usb_lowlevel_stop(i);
+   }
+   return 0;
+}
+#else
 /**
  * some forward declerations...
  */
@@ -127,6 +210,7 @@ int usb_stop(void)
}
return res;
 }
+#endif

 /*
  * disables the asynch behaviour of the control message. This is used for data 
@@ -750,11 +834,18 @@ struct usb_device *usb_get_dev_index(int index)
return usb_dev[index];
 }

-
+#ifdef CONFIG_USB_MULTI
+/* Save input pointer 'controller' into device structure.
+ * returns a pointer of a new device structure or NULL, if
+ * no device struct is available
+ */
+struct usb_device

Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-07-30 Thread Jim Lin
-Original Message-
From: Marek Vasut [mailto:marek.va...@gmail.com] 
Sent: Friday, July 27, 2012 5:26 PM
To: u-boot@lists.denx.de
Cc: Jim Lin; Wolfgang Denk; Tom Warren
Subject: Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB 
controllers at once

 Wolfgang,
 Is there any chance to get this feature in after Stephen explained to you?
 
I'll poke into it. Can we not get rid of the added ifdef, eg. by setting up 
the 
controller number to 1 for those that don't define CONFIG_USB_MULTI now 
(everyone)
I assume you want me to add these in next patch.
1 . Use CONFIG_USB_MULTI, instead of CONFIG_USB_INIT_MULTI
 (current patch),
2. If CONFIG_USB_MULTI is not defined, then define 
CONFIG_USB_MAX_CONTROLLER_COUNT
 as 1.

 and adding some wrapping goo?

Don't understand what you meant.
Could you provide an example?
Thanks.

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


Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-07-30 Thread Jim Lin
-Original Message-
From: Marek Vasut [mailto:marek.va...@gmail.com] 
Sent: Monday, July 30, 2012 8:02 PM
To: Jim Lin
Cc: Wolfgang Denk; Tom Warren; u-boot@lists.denx.de
Subject: Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB 
controllers at once

Dear Jim Lin,

 -Original Message-
 From: Marek Vasut [mailto:marek.va...@gmail.com]
 Sent: Friday, July 27, 2012 5:26 PM
 To: u-boot@lists.denx.de
 Cc: Jim Lin; Wolfgang Denk; Tom Warren
 Subject: Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB
 controllers at once
 
  Wolfgang,
  Is there any chance to get this feature in after Stephen explained to
  you?
 
 I'll poke into it. Can we not get rid of the added ifdef, eg. by setting
 up the controller number to 1 for those that don't define
 CONFIG_USB_MULTI now (everyone)
 
 I assume you want me to add these in next patch.
 1 . Use CONFIG_USB_MULTI, instead of CONFIG_USB_INIT_MULTI
  (current patch),
 2. If CONFIG_USB_MULTI is not defined, then define
 CONFIG_USB_MAX_CONTROLLER_COUNT as 1.

Yes, is that a problem? Aka. have this always enabled and don't treat not 
having 
multiple controllers as a special case.

Item 2 is not necessary.
Because CONFIG_USB_MAX_CONTROLLER_COUNT will not be used if
CONFIG_USB_MULTI is not defined.

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


Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-07-26 Thread Jim Lin
Wolfgang,
Is there any chance to get this feature in after Stephen explained to you?

Thanks.

-Original Message-
From: Stephen Warren [mailto:swar...@wwwdotorg.org] 
Sent: Thursday, June 28, 2012 12:58 AM
To: Wolfgang Denk
Cc: Jim Lin; 'U-Boot@lists.denx.de'; Tom Warren
Subject: Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB 
controllers at once

On 06/27/2012 12:55 AM, Wolfgang Denk wrote:
 Dear Jim Lin,
 
 sending the very same message eight (8!) times doesnot make it a bit
 more convincing - on contrary.
 
 In message 4b9c9637d5087840a465bdcb251780e9e2d6eda...@hkmail02.nvidia.com 
 you wrote:

 U-Boot is not multi-tasking, so you can always access only a single
 USB device at a time ayway.  And it is a decoumented design principle
 that U-Boot must not initialize any devices it does not use itself.

 So why?
 Because of this complaint and request for devices under different 
 controllers
 to be working at same time.
 
 You make another claim here, but don't explain how this is supposed to
 work or whay the exact use case would be where this was needed.
 U-Boot will not be able to access multiple devices at the same time,
 so why would it be necessary to enable these?  It should be sufficient
 to enable the controller that is responsible for the single device
 that is currently being used.
 
 One particularly annoying consequence of this is when you use the Seaboard
 configuration on Springbank.
 Seaboard selects Tegra's USB3 as usb 0 device, which is the one you can 
 use,
 in order not to conflict with the flashing USB port USB1.
 However, Springbank only exposes USB1 since USB3 is used internally for the
 USB keyboard/mouse. As such, you cannot use the USB port on Springbank under
 U-Boot at the moment.
 
 
 I have to admit that I cannot make any sense from this statement.  The
 only thing I understand is that you are trying to use a configuration
 for one hardware (Seaboard) on another, incompatible hardware
 (Springbank).
 
 The simple answer to this problem is: don't do that, then.

Seaboard and Springbank are essentially the same board, and hence are
almost 100% SW compatible, so there's no problem running a Seaboard
build of U-Boot/kernel/... on Springbank.

The primary issue here is that many boards have multiple USB ports.
Users could plug e.g. a USB-Ethernet device into any of the ports.
Requiring the user to know which port is which ID so they can issue the
correct usb start n command is painful; no other SW stack limits
itself to a single port and so most people don't have a clue which ports
are numbered what; they just want USB to work.

The specific issue on Springbank is that there are multiple USB ports
that are useful at the essentially the same time. One of the USB ports
hosts a built-in USB keyboard (inside a sealed clamshell/netbook case),
which we would like to use for the U-boot console. Another USB port is
external, and people will plug in a USB-Ethernet dongle or USB storage
device there. so, if I need to usb start 0 to get the keyboard, and
usb start 1 to get USB Ethernet, then as soon as I usb start 1 to
get the Ethernet, I've just lost the console, and am unable to interact
with U-Boot any more...

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


Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-07-02 Thread Jim Lin
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org] 
 Sent: Thursday, June 28, 2012 12:58 AM
 To: Wolfgang Denk 
 Cc: Jim Lin; 'U-Boot@lists.denx.de'; Tom Warren
 Subject: Re: [U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB 
 controllers at once

  On 06/27/2012 12:55 AM, Wolfgang Denk wrote:
  Dear Jim Lin,
  
  sending the very same message eight (8!) times doesnot make it a bit
  more convincing - on contrary.
  
  In message 4b9c9637d5087840a465bdcb251780e9e2d6eda...@hkmail02.nvidia.com 
  you wrote:
 
  U-Boot is not multi-tasking, so you can always access only a single
  USB device at a time ayway.  And it is a decoumented design principle
  that U-Boot must not initialize any devices it does not use itself. 
 
  So why?
  Because of this complaint and request for devices under different 
  controllers
  to be working at same time.
  
  You make another claim here, but don't explain how this is supposed to
  work or whay the exact use case would be where this was needed.
  U-Boot will not be able to access multiple devices at the same time,
  so why would it be necessary to enable these?  It should be sufficient
  to enable the controller that is responsible for the single device
  that is currently being used.
  
  One particularly annoying consequence of this is when you use the Seaboard
  configuration on Springbank.
  Seaboard selects Tegra's USB3 as usb 0 device, which is the one you can 
  use,
  in order not to conflict with the flashing USB port USB1.
  However, Springbank only exposes USB1 since USB3 is used internally for the
  USB keyboard/mouse. As such, you cannot use the USB port on Springbank 
  under
  U-Boot at the moment.
  
  
  I have to admit that I cannot make any sense from this statement.  The
  only thing I understand is that you are trying to use a configuration
  for one hardware (Seaboard) on another, incompatible hardware
  (Springbank).
  
  The simple answer to this problem is: don't do that, then.

 Seaboard and Springbank are essentially the same board, and hence are
 almost 100% SW compatible, so there's no problem running a Seaboard
 build of U-Boot/kernel/... on Springbank.

 The primary issue here is that many boards have multiple USB ports.
 Users could plug e.g. a USB-Ethernet device into any of the ports.
 Requiring the user to know which port is which ID so they can issue the
 correct usb start n command is painful; no other SW stack limits
 itself to a single port and so most people don't have a clue which ports
 are numbered what; they just want USB to work.

 The specific issue on Springbank is that there are multiple USB ports
 that are useful at the essentially the same time. One of the USB ports
 hosts a built-in USB keyboard (inside a sealed clamshell/netbook case),
 which we would like to use for the U-boot console. Another USB port is
 external, and people will plug in a USB-Ethernet dongle or USB storage
 device there. so, if I need to usb start 0 to get the keyboard, and
 usb start 1 to get USB Ethernet, then as soon as I usb start 1 to
 get the Ethernet, I've just lost the console, and am unable to interact
 with U-Boot any more..

Wolfgang,
Any further thought about Stephen's request?
Thanks.

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


[U-Boot] [PATCH 1/1] USB: EHCI: Initialize multiple USB controllers at once

2012-06-26 Thread Jim Lin
Add support for command line usb reset or usb start to initialize
, usb stop to stop multiple USB controllers at once.
Other commands like usb tree also support multiple controllers.

New added definitions to be defined in header file are:
CONFIG_USB_INIT_MULTI
CONFIG_USB_MAX_CONTROLLER_COUNT

Signed-off-by: Jim Lin ji...@nvidia.com
---
 common/cmd_usb.c  |   10 +++
 common/usb.c  |  100 +++-
 common/usb_hub.c  |4 +
 drivers/usb/host/ehci-hcd.c   |  150 +---
 drivers/usb/host/ehci-tegra.c |2 +-
 drivers/usb/host/ehci.h   |5 ++
 include/usb.h |   10 +++
 7 files changed, 237 insertions(+), 44 deletions(-)

diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 9eba271..4c01a78 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -553,7 +553,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
}
if (strncmp(argv[1], tree, 4) == 0) {
printf(\nDevice Tree:\n);
+#ifdef CONFIG_USB_INIT_MULTI
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   dev = usb_get_dev_index(i);
+   if (dev == NULL)
+   break;
+   if (dev-parent == NULL)
+   usb_show_tree(dev);
+   }
+#else
usb_show_tree(usb_get_dev_index(0));
+#endif
return 0;
}
if (strncmp(argv[1], inf, 3) == 0) {
diff --git a/common/usb.c b/common/usb.c
index 1ec30bc..9fb0407 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -64,6 +64,10 @@
 #define USB_HUB_DEBUG  0
 #endif

+#ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
+#endif
+
 #define USB_PRINTF(fmt, args...)   debug_cond(USB_DEBUG, fmt, ##args)
 #define USB_HUB_PRINTF(fmt, args...)   debug_cond(USB_HUB_DEBUG, fmt, ##args)

@@ -81,6 +85,86 @@ char usb_started; /* flag for the started/stopped USB status 
*/
  */
 static void usb_scan_devices(void);

+#ifdef CONFIG_USB_INIT_MULTI
+/***
+ * Init USB Device
+ */
+
+int usb_init(void)
+{
+   void *ctrl;
+   int i;
+   struct usb_device *dev;
+
+   running = 0;
+   dev_index = 0;
+   asynch_allowed = 1;
+   usb_hub_reset();
+
+   /* first make all devices unknown */
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   memset(usb_dev[i], 0, sizeof(struct usb_device));
+   usb_dev[i].devnum = -1;
+   }
+
+   /* init low_level USB */
+   printf(USB:   );
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
+   /* init low_level USB */
+   ctrl = usb_lowlevel_init(i);
+   /*
+* if lowlevel init is OK, scan the bus for devices
+* i.e. search HUBs and configure them
+*/
+   if (ctrl) {
+   running = 1;
+
+   printf(scanning bus for devices... );
+   dev = usb_alloc_new_device(ctrl);
+   /*
+* device 0 is always present
+* (root hub, so let it analyze)
+*/
+   if (dev)
+   usb_new_device(dev);
+   }
+   }
+
+   if (running) {
+   if (!dev_index)
+   printf(No USB Device found\n);
+   else
+   printf(%d USB Device(s) found\n, dev_index);
+#ifdef CONFIG_USB_KEYBOARD
+   drv_usb_kbd_init();
+#endif
+   USB_PRINTF(scan end\n);
+   usb_started = 1;
+   return 0;
+   } else {
+   printf(Error, couldn't init Lowlevel part\n);
+   usb_started = 0;
+   return -1;
+   }
+}
+
+/**
+ * Stop USB this stops the LowLevel Part and deregisters USB devices.
+ */
+int usb_stop(void)
+{
+   int i;
+
+   if (usb_started) {
+   asynch_allowed = 1;
+   usb_started = 0;
+   usb_hub_reset();
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++)
+   usb_lowlevel_stop(i);
+   }
+   return 0;
+}
+#else
 /***
  * Init USB Device
  */
@@ -126,6 +210,7 @@ int usb_stop(void)
}
return res;
 }
+#endif

 /*
  * disables the asynch behaviour of the control message. This is used for data
@@ -747,11 +832,18 @@ struct usb_device *usb_get_dev_index(int index)
return usb_dev[index];
 }

-
+#ifdef CONFIG_USB_INIT_MULTI
+/* Save input pointer 'controller' into device structure.
+ * returns a pointer of a new device structure or NULL, if
+ * no device struct

[U-Boot] [PATCH v5 1/1] tegra: usb: Fix device enumeration problem of USB1

2012-06-25 Thread Jim Lin
A known hardware issue of USB1 port where bit 1 (connect status
change) of PORTSC register will be set after issuing Port Reset
(like usb reset in u-boot command line).
This will be treated as an error and stops later device enumeration.

Therefore we clear that bit after Port Reset in order to proceed
later device enumeration.

Signed-off-by: Jim Lin ji...@nvidia.com
---
To reproduce this issue, you can modify board .dts file to set
as the following to build u-boot binary.

 usb0 = /usb@c500;
 usb1 = /usb@c5008000;

Install device on USB1 port (address at 0xc500).
And run usb reset in u-boot console to enumerate device.

Before adding this patch, we could see problem every time.
After adding, tried 10 times of usb reset, usb tree, usb stop
, without seeing issue.

Changes in v5:
- Define USB address mask value in header file

Changes in v4:
- Add comment to describe replacing weak function ehci_powerup_fixup of 
ehci-hcd.c
- Remove using variable my_reg

Changes in v3:
- Move patch for USB1 controller into ehci_powerup_fixup of ehci-tegra.c
- Update copyright year to 2012

Changes in v2:
- Change config name
- Add a callback function at the end of ehci_submit_root() function

 arch/arm/include/asm/arch-tegra2/tegra2.h |1 +
 drivers/usb/host/ehci-tegra.c |   18 +-
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra2/tegra2.h 
b/arch/arm/include/asm/arch-tegra2/tegra2.h
index d4ada10..710334b 100644
--- a/arch/arm/include/asm/arch-tegra2/tegra2.h
+++ b/arch/arm/include/asm/arch-tegra2/tegra2.h
@@ -45,6 +45,7 @@
 #define NV_PA_CSITE_BASE   0x7004
 #define TEGRA_USB1_BASE0xC500
 #define TEGRA_USB3_BASE0xC5008000
+#define TEGRA_USB_ADDR_MASK0xC000
 
 #define TEGRA2_SDRC_CS0NV_PA_SDRAM_BASE
 #define LOW_LEVEL_SRAM_STACK   0x4000FFFC
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index a7e105b..4646b29 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 NVIDIA Corporation
+ * Copyright (c) 2009-2012 NVIDIA Corporation
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -29,6 +29,22 @@
 #include asm/errno.h
 #include asm/arch/usb.h
 
+/*
+ * A known hardware issue where Connect Status Change bit of PORTSC register
+ * of USB1 controller will be set after Port Reset.
+ * We have to clear it in order for later device enumeration to proceed.
+ * 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)
+{
+   mdelay(50);
+   if (((u32) status_reg  TEGRA_USB_ADDR_MASK) != TEGRA_USB1_BASE)
+   return;
+   /* For EHCI_PS_CSC to be cleared in ehci_hcd.c */
+   if (ehci_readl(status_reg)  EHCI_PS_CSC)
+   *reg |= EHCI_PS_CSC;
+}
 
 /*
  * Create the appropriate control structures to manage
-- 
1.7.3

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


Re: [U-Boot] [PATCH v4 1/1] tegra: usb: Fix device enumeration problem of USB1

2012-06-21 Thread Jim Lin
From: Marek Vasut [mailto:marek.va...@gmail.com] 
Sent: Thursday, June 21, 2012 6:16 PM
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c
 @@ -1,5 +1,5 @@
  /*
 - * Copyright (c) 2009 NVIDIA Corporation
 + * Copyright (c) 2009-2012 NVIDIA Corporation
   *
   * See file CREDITS for list of people who contributed to this
   * project.
 @@ -29,6 +29,22 @@
  #include asm/errno.h
  #include asm/arch/usb.h
 
 +/*
 + * A known hardware issue where Connect Status Change bit of PORTSC
 register + * of USB1 controller will be set after Port Reset.
 + * We have to clear it in order for later device enumeration to proceed.
 + * 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)

So it was even enough to use the already preinstalled callback? :-)

Yes.

 +{
 +mdelay(50);
 +if (((u32) status_reg  0xC000) != TEGRA_USB1_BASE)

What's this magic number here?

Address Mask value, any suggestion?

 +return;
 + /* For EHCI_PS_CSC to be cleared in ehci_hcd.c */
 +if (ehci_readl(status_reg)  EHCI_PS_CSC)
 +*reg |= EHCI_PS_CSC;

writel()

The real IO write (ehci_writel) is done in ehci-hcd.c after calling of 
ehci_powerup_fixup.
Any suggestion?
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/1] tegra: usb: Fix device enumeration problem of USB1

2012-06-20 Thread Jim Lin
A known hardware issue of USB1 port where bit 1 (connect status
change) of PORTSC register will be set after issuing Port Reset
(like usb reset in u-boot command line).
This will be treated as an error and stops later device enumeration.

Therefore we clear that bit after Port Reset in order to proceed
later device enumeration.

Signed-off-by: Jim Lin ji...@nvidia.com
---
To reproduce this issue, you can modify board .dts file to set
as the following to build u-boot binary.

 usb0 = /usb@c500;
 usb1 = /usb@c5008000;

Install device on USB1 port (address at 0xc500).
And run usb reset in u-boot console to enumerate device.

Before adding this patch, we could see problem every time.
After adding, tried 10 times of usb reset, usb tree, usb stop
, without seeing issue.

Changes in v4:
- Add comment to describe replacing weak function ehci_powerup_fixup of 
ehci-hcd.c
- Remove using variable my_reg

Changes in v3:
- Move patch for USB1 controller into ehci_powerup_fixup of ehci-tegra.c
- Update copyright year to 2012

Changes in v2:
- Change config name
- Add a callback function at the end of ehci_submit_root() function

 drivers/usb/host/ehci-tegra.c |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index a7e105b..6646d3a 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 NVIDIA Corporation
+ * Copyright (c) 2009-2012 NVIDIA Corporation
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -29,6 +29,22 @@
 #include asm/errno.h
 #include asm/arch/usb.h
 
+/*
+ * A known hardware issue where Connect Status Change bit of PORTSC register
+ * of USB1 controller will be set after Port Reset.
+ * We have to clear it in order for later device enumeration to proceed.
+ * 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)
+{
+   mdelay(50);
+   if (((u32) status_reg  0xC000) != TEGRA_USB1_BASE)
+   return;
+   /* For EHCI_PS_CSC to be cleared in ehci_hcd.c */
+   if (ehci_readl(status_reg)  EHCI_PS_CSC)
+   *reg |= EHCI_PS_CSC;
+}
 
 /*
  * Create the appropriate control structures to manage
-- 
1.7.3

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


[U-Boot] [PATCH v3 1/1] tegra: usb: Fix device enumeration problem of USB1

2012-06-20 Thread Jim Lin
A known hardware issue of USB1 port where bit 1 (connect status
change) of PORTSC register will be set after issuing Port Reset
(like usb reset in u-boot command line).
This will be treated as an error and stops later device enumeration.

Therefore we clear that bit after Port Reset in order to proceed
later device enumeration.

Signed-off-by: Jim Lin ji...@nvidia.com
---
To reproduce this issue, you can modify board .dts file to set
as the following to build u-boot binary.

 usb0 = /usb@c500;
 usb1 = /usb@c5008000;

Install device on USB1 port (address at 0xc500).
And run usb reset in u-boot console to enumerate device.

Before adding this patch, we could see problem every time.
After adding, tried 10 times of usb reset, usb tree, usb stop
, without seeing issue.

Changes in v3:
- Move patch for USB1 controller into ehci_powerup_fixup of ehci-tegra.c
- Update copyright year to 2012

Changes in v2:
- Change config name
- Add a callback function at the end of ehci_submit_root() function

 drivers/usb/host/ehci-tegra.c |   19 ++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index a7e105b..8e516e5 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 NVIDIA Corporation
+ * Copyright (c) 2009-2012 NVIDIA Corporation
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -29,6 +29,23 @@
 #include asm/errno.h
 #include asm/arch/usb.h
 
+/*
+ * A known hardware issue where Connect Status Change bit of PORTSC register
+ * of USB1 controller will be set after Port Reset.
+ * We have to clear it in order for later device enumeration to proceed.
+ */
+void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
+{
+   uint32_t my_reg;
+
+   mdelay(50);
+   if (((u32) status_reg  0xC000) != TEGRA_USB1_BASE)
+   return;
+   my_reg = ehci_readl(status_reg);
+   /* For EHCI_PS_CSC to be cleared in ehci_hcd.c */
+   if (my_reg  EHCI_PS_CSC)
+   *reg |= EHCI_PS_CSC;
+}
 
 /*
  * Create the appropriate control structures to manage
-- 
1.7.3

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


[U-Boot] [PATCH v2 1/1] tegra: usb: Fix device enumeration problem of USB1

2012-06-19 Thread Jim Lin
A known hardware issue of USB1 port where bit 1 (connect status
change) of PORTSC register will be set after issuing Port Reset
(like usb reset in u-boot command line).
This will be treated as an error and stops later device enumeration.

Therefore we add a definition in header file and a callback function
to clear that bit after Port Reset in order to proceed later device
enumeration.

CONFIG_USB_EHCI_SUBMIT_ROOT_POST_CALLBACK

Signed-off-by: Jim Lin ji...@nvidia.com
---
To reproduce this issue, you can modify board .dts file to set
as the following to build u-boot binary.

 usb0 = /usb@c500;
 usb1 = /usb@c5008000;

Install device on USB1 port (address at 0xc500).
And run usb reset in u-boot console to enumerate device.

Changes in v2:
- Change config name
- Add a callback function at the end of ehci_submit_root() function

 drivers/usb/host/ehci-hcd.c |4 
 drivers/usb/host/ehci-tegra.c   |   34 ++
 drivers/usb/host/ehci.h |4 
 include/configs/tegra2-common.h |8 
 4 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 38d6ae0..0b6b656 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -792,7 +792,11 @@ ehci_submit_root(struct usb_device *dev, unsigned long 
pipe, void *buffer,
 
dev-act_len = len;
dev-status = 0;
+#ifdef CONFIG_USB_EHCI_SUBMIT_ROOT_POST_CALLBACK
+   return ehci_submit_root_post_callback(dev, pipe, buffer, length, req);
+#else
return 0;
+#endif
 
 unknown:
debug(requesttype=%x, request=%x, value=%x, index=%x, length=%x\n,
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index a7e105b..3dd18d3 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -29,6 +29,40 @@
 #include asm/errno.h
 #include asm/arch/usb.h
 
+#ifdef CONFIG_USB_EHCI_SUBMIT_ROOT_POST_CALLBACK
+int
+ehci_submit_root_post_callback(struct usb_device *dev, unsigned long pipe,
+   void *buffer, int length, struct devrequest *req)
+{
+   u16 typeReq;
+   uint32_t reg;
+   uint32_t *status_reg;
+
+   status_reg = (uint32_t *)hcor-or_portsc[
+   le16_to_cpu(req-index) - 1];
+   if (((u32) status_reg  0xC000) != TEGRA_USB1_BASE)
+   return 0;
+   typeReq = req-request | req-requesttype  8;
+   switch (typeReq) {
+   case USB_REQ_SET_FEATURE | ((USB_DIR_OUT | USB_RT_PORT)  8):
+   switch (le16_to_cpu(req-value)) {
+   /*
+* A known HW issue on USB1 port where bit 1 (Connect Status
+* Change) of PORTSC register will be set after issuing Port
+* Reset. Clear that bit for later device enumeration.
+*/
+   case USB_PORT_FEAT_RESET:
+   reg = ehci_readl(status_reg);
+   reg = ~EHCI_PS_CLEAR;
+   reg |= EHCI_PS_CSC;
+   ehci_writel(status_reg, reg);
+   break;
+   }
+   break;
+   }
+   return 0;
+}
+#endif
 
 /*
  * Create the appropriate control structures to manage
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index cc00ce4..6c5d8f3 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -204,4 +204,8 @@ struct QH {
 int ehci_hcd_init(void);
 int ehci_hcd_stop(void);
 
+#ifdef CONFIG_USB_EHCI_SUBMIT_ROOT_POST_CALLBACK
+int ehci_submit_root_post_callback(struct usb_device *dev, unsigned long pipe,
+   void *buffer, int length, struct devrequest *req);
+#endif
 #endif /* USB_EHCI_H */
diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h
index 1931179..b4822d4 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -111,6 +111,14 @@
 #define CONFIG_EHCI_IS_TDI
 #define CONFIG_EHCI_DCACHE
 
+/*
+ * A known HW issue on USB1 port where bit 1 (Connect Status Change) of PORTSC
+ * register will be set after issuing Port Reset.
+ * This setting is to add a callback function to clear that bit for later
+ * device enumeration.
+ */
+#define CONFIG_USB_EHCI_SUBMIT_ROOT_POST_CALLBACK
+
 /* Total I2C ports on Tegra2 */
 #define TEGRA_I2C_NUM_CONTROLLERS  4
 
-- 
1.7.3

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


Re: [U-Boot] [PATCH 1/1] tegra: usb: Fix device enumeration problem of USB1

2012-06-15 Thread Jim Lin
On 06/14/2012 04:40 AM, Jim Lin wrote:
 For some reason, bit 1 (connect status change) of PORTSC will be set
 after issuing Port Reset (like usb reset in u-boot command line).
 This will be treated as an error and stops later device enumeration.
 
 Therefore we add a definition in header file to ignore checking of that bit
 after Port Reset.
 CONFIG_USB_RESET_IGNORE_CONNECT_CHANGE

(Again, I'm CC'ing the USB maintainer here)

Looking at the Linux kernel's Tegra EHCI driver:
a) This WAR is only needed on the first USB port, not all of them.

  [Jim] No penalty for USB2 and USB3 ports. Because u-boot hub_port_reset
  has at most 5 times of retry for a port.
  USB2 and USB3 ports will reset once in retry loop
  ('port connect change' bit will not set after reset).
  USB1 will have at most 2 times of reset in the retry loop after adding
  this patch.

b) This WAR is not complete; there's a loop in the kernel that resets
the port twice in order to guarantee that the port will become enabled.

  [Jim] Disagree. Because u-boot hub_port_reset has at most 5 times of retry
  for a port. U-boot and kernel code are not entirely same.

c) The kernel driver actively clears this CSC bit rather than leaving it
set and ignoring it. Is there any implication to this difference?

  [Jim] I can make next change to be consistent with kernel driver to clear
  CSC bit after Port Reset.

So, rather than just ifdef'ing this fix into the driver, wouldn't it be
better to add a callback from the USB core into the USB driver, so that
the Tegra EHCI driver could choose to only implement this WAR for port
1, and also do the multiple-reset-loop thing.

  [Jim] No callback for me to cut in. Also no penalty for other ports.

Finally, in the change description, the text for some reason is quite
unclear; it sounds like you have absolutely no idea why this happens. Is
this a known and root-caused HW bug for which this fix has been fully
validated? Or, is this patch just some random hack that seems to work
for you?

  [Jim] This is a known and root-caused HW bug.
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/1] tegra: usb: Fix device enumeration problem of USB1

2012-06-14 Thread Jim Lin
For some reason, bit 1 (connect status change) of PORTSC will be set
after issuing Port Reset (like usb reset in u-boot command line).
This will be treated as an error and stops later device enumeration.

Therefore we add a definition in header file to ignore checking of that bit
after Port Reset.
CONFIG_USB_RESET_IGNORE_CONNECT_CHANGE

Signed-off-by: Jim Lin ji...@nvidia.com
---
To reproduce this issue, you can modify board .dts file to set
as the following to build u-boot binary.

 usb0 = /usb@c500;
 usb1 = /usb@c5008000;

Install device on USB1 port (address at 0xc500).
And run usb reset in u-boot console to enumerate device.

 common/usb_hub.c|4 
 include/configs/tegra2-common.h |7 +++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index e0edaad..8e6bdd8 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -180,8 +180,12 @@ int hub_port_reset(struct usb_device *dev, int port,
(portstatus  USB_PORT_STAT_CONNECTION) ? 1 : 0,
(portstatus  USB_PORT_STAT_ENABLE) ? 1 : 0);
 
+#ifdef CONFIG_USB_RESET_IGNORE_CONNECT_CHANGE
+   if (!(portstatus  USB_PORT_STAT_CONNECTION))
+#else
if ((portchange  USB_PORT_STAT_C_CONNECTION) ||
!(portstatus  USB_PORT_STAT_CONNECTION))
+#endif
return -1;
 
if (portstatus  USB_PORT_STAT_ENABLE)
diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h
index 1931179..904c17e 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -111,6 +111,13 @@
 #define CONFIG_EHCI_IS_TDI
 #define CONFIG_EHCI_DCACHE
 
+/*
+ * For some reason, bit 1 (Connect Status Change) of PORTSC register will be
+ * set after issuing Port Reset. This setting is to ignore checking of that
+ * bit after reset.
+ */
+#define CONFIG_USB_RESET_IGNORE_CONNECT_CHANGE
+
 /* Total I2C ports on Tegra2 */
 #define TEGRA_I2C_NUM_CONTROLLERS  4
 
-- 
1.7.3

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


[U-Boot] [PATCH 1/1] tegra: seaboard: Initialize multiple USB controllers at once

2012-06-13 Thread Jim Lin
From: Jim Lin ji...@nvidia.com

Add support for command line usb reset or usb start to initialize
, usb stop to stop multiple USB controllers at once.
Other commands like usb tree also support multiple controllers.

New added definitions in header file are:
CONFIG_USB_INIT_MULTI
CONFIG_USB_MAX_CONTROLLER_COUNT

Signed-off-by: Jim Lin ji...@nvidia.com
---
 arch/arm/cpu/armv7/tegra2/usb.c|   15 +++
 arch/arm/include/asm/arch-tegra2/usb.h |4 +
 common/cmd_usb.c   |   10 ++
 common/usb.c   |  108 ++
 common/usb_hub.c   |4 +
 drivers/usb/host/ehci-hcd.c|  192 
 drivers/usb/host/ehci-tegra.c  |   17 +++-
 drivers/usb/host/ehci.h|5 +
 include/configs/seaboard.h |2 +
 include/usb.h  |   12 ++
 10 files changed, 368 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra2/usb.c b/arch/arm/cpu/armv7/tegra2/usb.c
index c80de7f..3d2cfb9 100644
--- a/arch/arm/cpu/armv7/tegra2/usb.c
+++ b/arch/arm/cpu/armv7/tegra2/usb.c
@@ -352,7 +352,11 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor)

if (portnum = port_count)
return -1;
+#ifdef CONFIG_USB_INIT_MULTI
+   tegrausb_stop_port(portnum);
+#else
tegrausb_stop_port();
+#endif
set_host_mode(port[portnum]);

usbctlr = port[portnum].reg;
@@ -362,6 +366,16 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor)
return 0;
 }

+#ifdef CONFIG_USB_INIT_MULTI
+int tegrausb_stop_port(unsigned portnum)
+{
+   struct usb_ctlr *usbctlr;
+
+   if (portnum = port_count)
+   return -1;
+
+   usbctlr = port[portnum].reg;
+#else
 int tegrausb_stop_port(void)
 {
struct usb_ctlr *usbctlr;
@@ -370,6 +384,7 @@ int tegrausb_stop_port(void)
return -1;

usbctlr = port[port_current].reg;
+#endif

/* Stop controller */
writel(0, usbctlr-usb_cmd);
diff --git a/arch/arm/include/asm/arch-tegra2/usb.h 
b/arch/arm/include/asm/arch-tegra2/usb.h
index 638033b..119d7b4 100644
--- a/arch/arm/include/asm/arch-tegra2/usb.h
+++ b/arch/arm/include/asm/arch-tegra2/usb.h
@@ -247,6 +247,10 @@ int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 
*hcor);
  *
  * @return 0 if ok, -1 if no port was active
  */
+#ifdef CONFIG_USB_INIT_MULTI
+int tegrausb_stop_port(unsigned portnum);
+#else
 int tegrausb_stop_port(void);
+#endif

 #endif /* _TEGRA_USB_H_ */
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 9eba271..4c01a78 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -553,7 +553,17 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
}
if (strncmp(argv[1], tree, 4) == 0) {
printf(\nDevice Tree:\n);
+#ifdef CONFIG_USB_INIT_MULTI
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   dev = usb_get_dev_index(i);
+   if (dev == NULL)
+   break;
+   if (dev-parent == NULL)
+   usb_show_tree(dev);
+   }
+#else
usb_show_tree(usb_get_dev_index(0));
+#endif
return 0;
}
if (strncmp(argv[1], inf, 3) == 0) {
diff --git a/common/usb.c b/common/usb.c
index 1ec30bc..b4275c5 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -81,6 +81,86 @@ char usb_started; /* flag for the started/stopped USB status 
*/
  */
 static void usb_scan_devices(void);

+#ifdef CONFIG_USB_INIT_MULTI
+/***
+ * Init USB Device
+ */
+
+int usb_init(void)
+{
+   void *ctrl;
+   int i;
+   struct usb_device *dev;
+
+   running = 0;
+   dev_index = 0;
+   asynch_allowed = 1;
+   usb_hub_reset();
+
+   /* first make all devices unknown */
+   for (i = 0; i  USB_MAX_DEVICE; i++) {
+   memset(usb_dev[i], 0, sizeof(struct usb_device));
+   usb_dev[i].devnum = -1;
+   }
+
+   /* init low_level USB */
+   printf(USB:   );
+   for (i = 0; i  CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
+   /* init low_level USB */
+   ctrl = usb_lowlevel_init(i);
+   /*
+* if lowlevel init is OK, scan the bus for devices
+* i.e. search HUBs and configure them
+*/
+   if (ctrl) {
+   running = 1;
+
+   printf(scanning bus for devices... );
+   dev = usb_alloc_new_device(ctrl);
+   /*
+* device 0 is always present
+* (root hub, so let it analyze)
+*/
+   if (dev)
+   usb_new_device(dev);
+   }
+   }
+
+   if (running

Re: [U-Boot] [PATCH 5/6] tegra: nand: Add Tegra NAND driver

2012-01-15 Thread Jim Lin
Simon,
Could you also add

  Signed-off-by: Jim Lin ji...@nvidia.com

for me?

Thanks,
Jim


-Original Message-
From: Mike Frysinger [mailto:vap...@gentoo.org] 
Sent: Sunday, January 15, 2012 12:12 PM
To: Simon Glass
Cc: u-boot@lists.denx.de; Jim Lin; Tom Warren; Scott Wood
Subject: Re: [U-Boot] [PATCH 5/6] tegra: nand: Add Tegra NAND driver

* PGP Signed by an unknown key

On Saturday 14 January 2012 23:08:45 Simon Glass wrote:
 On Sat, Jan 14, 2012 at 8:03 PM, Mike Frysinger wrote:
  On Friday 13 January 2012 18:10:55 Simon Glass wrote:
  From: Jim Lin ji...@nvidia.com
  
  A device tree is used to configure the NAND, including memory
  timings and block/pages sizes.
  
  If this node is not present or is disabled, then NAND will not
  be initialized.
  
  Signed-off-by: Simon Glass s...@chromium.org
  
  the Author needs to sign off too ...
 
 I have a lot like that. It doesn't feel right for me to just add their
 sign-off after all my changes. I was hoping that they would reply to
 the list with it. Does that work? The original commit does not have a
 sign-off.

sure, if the author replies with their s-o-b, or says they're OK with you 
adding it, that's fine.  but you're right that you can't just add it yourself 
without them saying so first ...
-mike

* Unknown Key
* 0xE837F581
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot