[U-Boot] [PATCH v4 4/4] Add USB support for Efika

Marek Vasut marek.vasut at gmail.com
Sun Sep 25 19:34:00 CEST 2011


On Sunday, September 25, 2011 07:25:10 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>
> ---
> Changes for v2:
>       - changed to proper patch
> Changes for v3:
>       - merged other USB patches from u-boot-pxa/efikasb
>       - offset-based access changed to struct-based access
>       - use {clrset,clr,set}bits_le32() calls
>       - CodingStyle and naming cleanup
> Changes for v4:
>        - split into patchset
>        - CodingStyle and naming cleanup
>        - remove endless loops
>        - silence compiler warnings
> 

Dear Jana Rapava,

[...]
> +
> +u32 ulpi_wait(u32 ulpi_bit, const char *operation, struct usb_ehci *ehci)

Put struct usb_ehci * at the first place.

> +{
> +	int timeout = ULPI_TIMEOUT;
> +	u32 tmp;

Better separation of chunks of code with newlines will help readability. Please 
fix globally.

> +	while (--timeout) {
> +		tmp = readl(&ehci->ulpi_viewpoint);
> +		if (!(tmp & ulpi_bit))
> +			break;
> +		WATCHDOG_RESET();
> +	}
> +	if (!timeout) {
> +		printf("ULPI %s timed out\n", operation);
> +		return 0;
> +	}
> +	return tmp;
> +}
> +
> +void ulpi_write(u8 *reg, u32 value, struct usb_ehci *ehci)

ulpi_write(ehci, reg, value), please fix globally and in similar functions.

Also, change u8 *reg to u8 reg, why are you passing a pointer?

[...]

> +
> +int ehci_hcd_init(void)
> +{
> +	struct usb_ehci *ehci;
> +	struct usb_control_regs *mx5_usb_control_regs;
> +	struct ulpi_regs *ulpi;
> +
> +	/* Init iMX51 EHCI */
> +	efika_usb_phy_reset();
> +	efika_usb_hub_reset();
> +	efika_usb_enable_devices();
> +
> +	mx5_usb_control_regs = (struct usb_control_regs *)(OTG_BASE_ADDR +
> +		 MX51_CTRL_REGS);

rename to MX5_CTRL_REGS_OFFSET.

> +	control_regs_setup(mx5_usb_control_regs);
> +
> +	ulpi = (struct ulpi_regs *)0;
> +	/* 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)));
> +	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);
> +
> +

One newline is enough.

> +	return 0;
> +}
> +

Cheers


More information about the U-Boot mailing list