diff mbox

[U-Boot,v2,2/4] mx6cuboxi: Add USB host support

Message ID 1430357292-8062-2-git-send-email-festevam@gmail.com
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Commit Message

Fabio Estevam April 30, 2015, 1:28 a.m. UTC
From: Fabio Estevam <fabio.estevam@freescale.com>

Enable USB Host1 port.

Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Remove USB ether options as suggested by Tom

 board/solidrun/mx6cuboxi/mx6cuboxi.c | 26 ++++++++++++++++++++++++++
 include/configs/mx6cuboxi.h          | 10 ++++++++++
 2 files changed, 36 insertions(+)

Comments

Vagrant Cascadian April 30, 2015, 9:26 p.m. UTC | #1
On 2015-04-29, Fabio Estevam wrote:
> Enable USB Host1 port.
>
> Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Remove USB ether options as suggested by Tom

Removing those options broke network boot.  With this patch, u-boot
reports:

  Net:   Phy 0 not found

And the dhcp command fails to get an ip address.

With both CONFIG_USB_HOST_ETHER and CONFIG_USB_ETHER_ASIX defined in
mx6cuboxi.h, u-boot reports:

  Net:   FEC

And then the dhcp command works as expected...

Perhaps the CONFIG_USB*ETHER options conditionall enable some other
feature that FEC depends on?


live well,
  vagrant
Fabio Estevam April 30, 2015, 9:40 p.m. UTC | #2
On Thu, Apr 30, 2015 at 6:26 PM, Vagrant Cascadian <vagrant@aikidev.net> wrote:

> Removing those options broke network boot.  With this patch, u-boot
> reports:
>
>   Net:   Phy 0 not found
>
> And the dhcp command fails to get an ip address.
>
> With both CONFIG_USB_HOST_ETHER and CONFIG_USB_ETHER_ASIX defined in
> mx6cuboxi.h, u-boot reports:
>
>   Net:   FEC
>
> And then the dhcp command works as expected...
>
> Perhaps the CONFIG_USB*ETHER options conditionall enable some other
> feature that FEC depends on?

Could you try?

=> setenv ethaddr
=> save
=> reset

TFTP transfer is working fine here.

Regards,

Fabio Estevam
Vagrant Cascadian April 30, 2015, 10:20 p.m. UTC | #3
On 2015-04-30, Fabio Estevam wrote:
> On Thu, Apr 30, 2015 at 6:26 PM, Vagrant Cascadian <vagrant@aikidev.net> wrote:
>
>> Removing those options broke network boot.  With this patch, u-boot
>> reports:
>>
>>   Net:   Phy 0 not found
>>
>> And the dhcp command fails to get an ip address.
>>
>> With both CONFIG_USB_HOST_ETHER and CONFIG_USB_ETHER_ASIX defined in
>> mx6cuboxi.h, u-boot reports:
>>
>>   Net:   FEC
>>
>> And then the dhcp command works as expected...
>>
>> Perhaps the CONFIG_USB*ETHER options conditionall enable some other
>> feature that FEC depends on?

After trying this several times, that build of u-boot no longer works
either.


> Could you try?
>
> => setenv ethaddr
> => save
> => reset

No change.


> TFTP transfer is working fine here.

It was working here too, and now it doesn't. I clearly misdiagnosed the
cause...


live well,
  vagrant
Vagrant Cascadian April 30, 2015, 10:21 p.m. UTC | #4
On 2015-04-29, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Enable USB Host1 port.
>
> Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Remove USB ether options as suggested by Tom

USB keyboard, USB hub and two USB sticks all worked.

Tested-By: Vagrant Cascadian <vagrant@aikidev.net>

>  board/solidrun/mx6cuboxi/mx6cuboxi.c | 26 ++++++++++++++++++++++++++
>  include/configs/mx6cuboxi.h          | 10 ++++++++++
>  2 files changed, 36 insertions(+)
>
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index eab92f1..9aa0259 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -31,6 +31,8 @@
>  #include <asm/io.h>
>  #include <asm/arch/sys_proto.h>
>  #include <spl.h>
> +#include <usb.h>
> +#include <usb/ehci-fsl.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -52,6 +54,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
>  
>  #define ETH_PHY_RESET	IMX_GPIO_NR(4, 15)
> +#define USB_H1_VBUS	IMX_GPIO_NR(1, 0)
>  
>  int dram_init(void)
>  {
> @@ -79,6 +82,10 @@ static iomux_v3_cfg_t const hb_cbi_sense[] = {
>  	IOMUX_PADS(PAD_EIM_DA4__GPIO3_IO04   | MUX_PAD_CTRL(UART_PAD_CTRL)),
>  };
>  
> +static iomux_v3_cfg_t const usb_pads[] = {
> +	IOMUX_PADS(PAD_GPIO_0__GPIO1_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL)),
> +};
> +
>  static void setup_iomux_uart(void)
>  {
>  	SETUP_IOMUX_PADS(uart1_pads);
> @@ -253,6 +260,21 @@ static int setup_display(void)
>  }
>  #endif /* CONFIG_VIDEO_IPUV3 */
>  
> +#ifdef CONFIG_USB_EHCI_MX6
> +static void setup_usb(void)
> +{
> +	SETUP_IOMUX_PADS(usb_pads);
> +}
> +
> +int board_ehci_hcd_init(int port)
> +{
> +	if (port == 1)
> +		gpio_direction_output(USB_H1_VBUS, 1);
> +
> +	return 0;
> +}
> +#endif
> +
>  int board_early_init_f(void)
>  {
>  	int ret = 0;
> @@ -261,6 +283,10 @@ int board_early_init_f(void)
>  #ifdef CONFIG_VIDEO_IPUV3
>  	ret = setup_display();
>  #endif
> +
> +#ifdef CONFIG_USB_EHCI_MX6
> +	setup_usb();
> +#endif
>  	return ret;
>  }
>  
> diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
> index 207a2a6..34d24dc 100644
> --- a/include/configs/mx6cuboxi.h
> +++ b/include/configs/mx6cuboxi.h
> @@ -82,6 +82,16 @@
>  #define CONFIG_IMX_HDMI
>  #define CONFIG_IMX_VIDEO_SKIP
>  
> +/* USB */
> +#define CONFIG_CMD_USB
> +#define CONFIG_USB_EHCI
> +#define CONFIG_USB_EHCI_MX6
> +#define CONFIG_USB_STORAGE
> +#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
> +#define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
> +#define CONFIG_MXC_USB_FLAGS		0
> +#define CONFIG_USB_MAX_CONTROLLER_COUNT	2
> +
>  #define CONFIG_SYS_NO_FLASH
>  
>  /* Command definition */
> -- 
> 1.9.1
Vagrant Cascadian April 30, 2015, 11:50 p.m. UTC | #5
So network works fine on the hummingboard i1 and i2ex, but the cubox
i4pro is still inconsistant:

  Net:   Phy 0 not found
  PHY reset timed out
  FEC

It definitely worked at some point before. I used the same SD card on
all three boards.

live well,
  vagrant
Fabio Estevam May 1, 2015, 2:14 a.m. UTC | #6
Hi Vagrant,

On Thu, Apr 30, 2015 at 8:50 PM, Vagrant Cascadian <vagrant@aikidev.net> wrote:
> So network works fine on the hummingboard i1 and i2ex, but the cubox
> i4pro is still inconsistant:
>
>   Net:   Phy 0 not found
>   PHY reset timed out
>   FEC

When you see this error: does U-boot warn you about the MAC address
stored in the environment does not match the one read by the fuses?

I think if you use a clean environment (env default -f -a, or do the
setenv ethaddr; save) then the MAC address will be re-read from the
fuse and stored in the env. Then ethernet should work fine.

Regards,

Fabio Estevam
Vagrant Cascadian May 1, 2015, 5:50 a.m. UTC | #7
On 2015-04-30, Fabio Estevam wrote:
> On Thu, Apr 30, 2015 at 8:50 PM, Vagrant Cascadian <vagrant@aikidev.net> wrote:
>> So network works fine on the hummingboard i1 and i2ex, but the cubox
>> i4pro is still inconsistant:
>>
>>   Net:   Phy 0 not found
>>   PHY reset timed out
>>   FEC
>
> When you see this error: does U-boot warn you about the MAC address
> stored in the environment does not match the one read by the fuses?

No such warning. Rather than keep you guessing, here's the output on
boot:

U-Boot 2015.04+dfsg1-2~20150430~5 (Apr 30 2015 - 20:46:44)

CPU:   Freescale i.MX6Q rev1.2 at 792 MHz
CPU:   Temperature 17 C
Reset cause: POR
Board: MX6 Cubox-i
DRAM:  2 GiB
MMC:   FSL_SDHC: 0
*** Warning - bad CRC, using default environment

No panel detected: default to HDMI
Display: HDMI (1024x768)
In:    serial
Out:   vga
Err:   vga
Net:   Phy 0 not found
PHY reset timed out
FEC
starting USB...
USB0:   Port not available.
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
Hit any key to stop autoboot:  0


> I think if you use a clean environment (env default -f -a

Running "env default -f -a" resets the environment and clears out
ethaddr (as well as board_name and board_rev, which can be tricky for
findfdt), though I believe it is already using the default environment
because of the message:

  *** Warning - bad CRC, using default environment

But it doesn't really help with the ethernet changes.


> or do the setenv ethaddr; save) then the MAC address will be re-read
> from the fuse and stored in the env. Then ethernet should work fine.

I'm guessing you mean "saveenv" and not "save".

"setenv ethaddr; saveenv ; reset" still fails to work.


I generally try to avoid using saveenv as it makes it harder to test the
default environment when testing a new version of u-boot.


live well,
  vagrant
Stefano Babic May 1, 2015, 7:33 a.m. UTC | #8
Hi Vagrant,

On 01/05/2015 07:50, Vagrant Cascadian wrote:

> Net:   Phy 0 not found
> PHY reset timed out
> FEC

ok, the PHY is not found, but I cannot understand how Fabio's changes
dropping ASIX can be the cause. Have you reverted back U-Boot to V1 set
of patchset to check again if it works ? It looks a completely unrelated
cause.

Best regards,
Stefano Babic
Fabio Estevam May 1, 2015, 3:06 p.m. UTC | #9
On Fri, May 1, 2015 at 4:33 AM, Stefano Babic <sbabic@denx.de> wrote:
> Hi Vagrant,
>
> On 01/05/2015 07:50, Vagrant Cascadian wrote:
>
>> Net:   Phy 0 not found
>> PHY reset timed out
>> FEC
>
> ok, the PHY is not found, but I cannot understand how Fabio's changes
> dropping ASIX can be the cause. Have you reverted back U-Boot to V1 set
> of patchset to check again if it works ? It looks a completely unrelated
> cause.

Yes, this is something I did not understand as well.

Vagrant, could you confirm that v1 did not have this FEC issue?

Thanks
Vagrant Cascadian May 1, 2015, 4:20 p.m. UTC | #10
On 2015-05-01, Stefano Babic wrote:
> On 01/05/2015 07:50, Vagrant Cascadian wrote:
>
>> Net:   Phy 0 not found
>> PHY reset timed out
>> FEC
>
> ok, the PHY is not found, but I cannot understand how Fabio's changes
> dropping ASIX can be the cause. Have you reverted back U-Boot to V1 set
> of patchset to check again if it works ? It looks a completely unrelated
> cause.

I did revert back, and at first that seemed to fix it, but after more
testing, the issue appears to be intermittent, and unrelated to the USB
changes.

So my earlier Tested-By stands; I think it's worth applying.

live well,
  vagrant
Fabio Estevam May 1, 2015, 5:10 p.m. UTC | #11
On Fri, May 1, 2015 at 1:20 PM, Vagrant Cascadian <vagrant@aikidev.net> wrote:

> I did revert back, and at first that seemed to fix it, but after more
> testing, the issue appears to be intermittent, and unrelated to the USB
> changes.
>
> So my earlier Tested-By stands; I think it's worth applying.

Ok, thanks for the clarification.

I will try to reproduce/investigate this FEC/PHY issue next week.

Regards,

Fabio Estevam
Fabio Estevam May 1, 2015, 8:20 p.m. UTC | #12
On Fri, May 1, 2015 at 2:10 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Fri, May 1, 2015 at 1:20 PM, Vagrant Cascadian <vagrant@aikidev.net> wrote:
>
>> I did revert back, and at first that seemed to fix it, but after more
>> testing, the issue appears to be intermittent, and unrelated to the USB
>> changes.
>>
>> So my earlier Tested-By stands; I think it's worth applying.
>
> Ok, thanks for the clarification.
>
> I will try to reproduce/investigate this FEC/PHY issue next week.

Looking at Solid-run's tree they have the following commit that may be
related to this PHY issue:

commit efc4835294122212052a8b8b2a23d14fa2b72177
Author: Rabeeh Khoury <rabeeh@solid-run.com>
Date:   Sat Jan 25 17:57:51 2014 +0200

    fecmxc_initialize_multi change from phy id to phy mask

    The fecmxc_initialize_multi now accepts phy address mask instead of a
    single phy address.

    Modified otherboard that directly uses fecmxc_initialize_multi()

    Modified also i.MX6 RXD0/RXD1 pad to pull down (they are also directly
    connected to the Atheros 8035/8030 although they should be functional
    only in the RMII mode - 8030).

    Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
Stefano Babic May 2, 2015, 9:15 a.m. UTC | #13
On 30/04/2015 03:28, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Enable USB Host1 port.
> 
> Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index eab92f1..9aa0259 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -31,6 +31,8 @@ 
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
 #include <spl.h>
+#include <usb.h>
+#include <usb/ehci-fsl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -52,6 +54,7 @@  DECLARE_GLOBAL_DATA_PTR;
 	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
 
 #define ETH_PHY_RESET	IMX_GPIO_NR(4, 15)
+#define USB_H1_VBUS	IMX_GPIO_NR(1, 0)
 
 int dram_init(void)
 {
@@ -79,6 +82,10 @@  static iomux_v3_cfg_t const hb_cbi_sense[] = {
 	IOMUX_PADS(PAD_EIM_DA4__GPIO3_IO04   | MUX_PAD_CTRL(UART_PAD_CTRL)),
 };
 
+static iomux_v3_cfg_t const usb_pads[] = {
+	IOMUX_PADS(PAD_GPIO_0__GPIO1_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+};
+
 static void setup_iomux_uart(void)
 {
 	SETUP_IOMUX_PADS(uart1_pads);
@@ -253,6 +260,21 @@  static int setup_display(void)
 }
 #endif /* CONFIG_VIDEO_IPUV3 */
 
+#ifdef CONFIG_USB_EHCI_MX6
+static void setup_usb(void)
+{
+	SETUP_IOMUX_PADS(usb_pads);
+}
+
+int board_ehci_hcd_init(int port)
+{
+	if (port == 1)
+		gpio_direction_output(USB_H1_VBUS, 1);
+
+	return 0;
+}
+#endif
+
 int board_early_init_f(void)
 {
 	int ret = 0;
@@ -261,6 +283,10 @@  int board_early_init_f(void)
 #ifdef CONFIG_VIDEO_IPUV3
 	ret = setup_display();
 #endif
+
+#ifdef CONFIG_USB_EHCI_MX6
+	setup_usb();
+#endif
 	return ret;
 }
 
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 207a2a6..34d24dc 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -82,6 +82,16 @@ 
 #define CONFIG_IMX_HDMI
 #define CONFIG_IMX_VIDEO_SKIP
 
+/* USB */
+#define CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_MX6
+#define CONFIG_USB_STORAGE
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
+#define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS		0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT	2
+
 #define CONFIG_SYS_NO_FLASH
 
 /* Command definition */