[U-Boot] [PATCH v5 4/4] Add USB support for Efika
Marek Vasut
marek.vasut at gmail.com
Tue Sep 27 13:50:53 CEST 2011
On Tuesday, September 27, 2011 01:01:36 PM Jana Rapava wrote:
> This commit adds USB support for EfikaMX and EfikaSB.
>
> Signed-off-by: Jana Rapava <fermata7 at gmail.com>
> Signed-off-by: Marek Vasut <marek.vasut at gmail.com>
> Cc: Remy Bohmer <linux at bohmer.net>
> Cc: Stefano Babic <sbabic at denx.de>
> ---
[...]
> +
> +#ifdef CONFIG_MACH_EFIKASB
Please update to mainline, use if (machine_is_efikasb()) { ... } .
> + /*
> + * Configure USBH2 pads (used on EfikaSB)
> + */
[...]
> +/*
> + * solve the VBUS reset problem on Efika
> + * by setting the CHRG_VBUS bit in the reset
> + */
> +void ehci_fixup(uint32_t *status_reg, uint32_t *reg_ref)
> +{
> + struct usb_ehci *ehci = (struct usb_ehci *)(OTG_BASE_ADDR +
> + (MX51_REGISTER_LAYOUT_LENGTH));
Too many parenthesis.
> + struct mxc_ulpi_regs *ulpi = (struct mxc_ulpi_regs *)0;
> +
> + u32 tmp = ulpi_read(ehci, (u32)&ulpi->otg_ctrl_write);
> + tmp |= ULPI_OTG_CHRG_VBUS;
> + ulpi_write(ehci, (u32)&ulpi->otg_ctrl_write, tmp);
> +
> + /* usb 2.0 specification say 50 ms resets on root */
> + wait_ms(50);
> +
> + /* terminate the reset */
Write a whole sentence, which begins with a capital letter and ends with dot ...
fix globally.
> + *reg_ref = ehci_readl(status_reg);
> + *reg_ref |= EHCI_PS_PE;
> +}
> +
> +void ehci0_init(struct usb_ehci *ehci)
> +{
> + writel(MX51_16BIT_UTMI, &ehci->portsc);
> +}
> +
> +void ehci1_init(struct usb_ehci *ehci, struct mxc_ulpi_regs *ulpi)
> +{
> + mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT2);
> + mxc_iomux_set_pad(MX51_PIN_USBH1_STP, PAD_CTL_DRV_HIGH |
> + PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST);
> + gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_USBH1_STP), 0);
> + udelay(1000);
> + gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_USBH1_STP), 1);
> + udelay(1000);
> +
> + mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0);
> + mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USB_PAD_CONFIG);
> + udelay(10000);
> +
> + clrbits_le32(&ehci->usbcmd, MX51_ITC_IMMEDIATE_MASK);
> + udelay(10000);
> +
> + writel(MX51_ULPI_MODE_MASK, &ehci->portsc);
> + udelay(10000);
> +
> + ulpi_init(ehci, ulpi);
> +}
> +
> +
> +void ehci2_init(struct usb_ehci *ehci, struct mxc_ulpi_regs *ulpi)
> +{
> + mxc_request_iomux(MX51_PIN_EIM_A26, IOMUX_CONFIG_ALT1);
> + mxc_iomux_set_pad(MX51_PIN_EIM_A26, PAD_CTL_DRV_HIGH |
> + PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST);
> + gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_EIM_A26), 0);
> + udelay(1000);
> + gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_EIM_A26), 1);
> + udelay(1000);
> +
> + mxc_request_iomux(MX51_PIN_EIM_A26, IOMUX_CONFIG_ALT2);
> + mxc_iomux_set_pad(MX51_PIN_EIM_A26, USB_PAD_CONFIG);
> +
> + writel(MX51_ULPI_MODE_MASK, &ehci->portsc);
> + udelay(10000);
> +
> + ulpi_init(ehci, ulpi);
> +}
> +
> +int ehci_hcd_init(void)
> +{
> + struct usb_ehci *ehci;
> + struct mx5_usb_control_regs *mx5_usb_control_regs;
> + struct mxc_ulpi_regs *ulpi;
> +
> + /* Init iMX51 EHCI */
> + efika_usb_phy_reset();
> + efika_usb_hub_reset();
> + efika_usb_enable_devices();
> +
> + mx5_usb_control_regs = (struct mx5_usb_control_regs *)(OTG_BASE_ADDR +
> + MX5_CTRL_REGS_OFFSET);
> + control_regs_setup(mx5_usb_control_regs);
> + ulpi = (struct mxc_ulpi_regs *)0;
Move this assignment at the begining.
> +
> + /* Init EHCI core */
> + ehci = (struct usb_ehci *)(OTG_BASE_ADDR +
> + (MX51_REGISTER_LAYOUT_LENGTH * CONFIG_MXC_USB_PORT));
> + hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength);
> + hcor = (struct ehci_hcor *)((uint32_t) hccr +
> + HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
DTTO
> + setbits_le32(&ehci->usbmode, CM_HOST);
> + setbits_le32(&ehci->control, USB_EN);
> +
> + switch (CONFIG_MXC_USB_PORT) {
> + case 0:
> + ehci0_init(ehci);
> + break;
> + case 1:
> + ehci1_init(ehci, ulpi);
> + break;
> +#ifdef MACH_EFIKASB
> + case 2:
> + ehci2_init(ehci, ulpi);
> + break;
> +#endif
> + };
> +
> + /* EfikaMX USB has issues ... */
> + udelay(10000);
> +
> + return 0;
> +}
> +
> +int ehci_hcd_stop(void)
> +{
> + return 0;
> +}
> diff --git a/board/efikamx/efikamx.c b/board/efikamx/efikamx.c
> index 5be1f6c..51c1854 100644
> --- a/board/efikamx/efikamx.c
> +++ b/board/efikamx/efikamx.c
> @@ -489,6 +489,15 @@ static inline void setup_iomux_ata(void) { }
> #endif
>
> /*
> + * EHCI USB
> + */
> +#ifdef CONFIG_CMD_USB
> +void setup_iomux_usb(void);
> +#else
> +static inline void setup_iomux_usb(void) { }
> +#endif
> +
Can you introduce efika.h header and move this to the header please.
> +/*
> * LED configuration
> */
> void setup_iomux_led(void)
> @@ -621,6 +630,7 @@ int board_late_init(void)
>
> setup_iomux_led();
> setup_iomux_ata();
> + setup_iomux_usb();
>
> efikamx_toggle_led(EFIKAMX_LED_BLUE);
>
> diff --git a/include/configs/efikamx.h b/include/configs/efikamx.h
> index fdd0a14..9632b5d 100644
> --- a/include/configs/efikamx.h
> +++ b/include/configs/efikamx.h
> @@ -40,6 +40,10 @@
>
> #define CONFIG_SYS_TEXT_BASE 0x97800000
>
> +#define CONFIG_L2_OFF
> +#define CONFIG_SYS_ICACHE_OFF
> +#define CONFIG_SYS_DCACHE_OFF
> +
> /*
> * Bootloader Components Configuration
> */
> @@ -168,6 +172,18 @@
> #endif
>
> /*
> + * USB
> + */
> +#define CONFIG_CMD_USB
> +#ifdef CONFIG_CMD_USB
> +#define CONFIG_USB_EHCI /* Enable EHCI USB support */
> +#define CONFIG_MXC_USB_PORT 1
> +#define CONFIG_EHCI_IS_TDI
> +#define CONFIG_USB_STORAGE
> +#define CONFIG_USB_KEYBOARD
The indent looks wrong, please fix.
> +#endif /* CONFIG_CMD_USB */
> +
> +/*
> * Filesystems
> */
> #ifdef CONFIG_CMD_FAT
Cheers
More information about the U-Boot
mailing list