[U-Boot] [PATCH V2 15/18] arm: mx6: cm_fx6: add usb support

Igor Grinberg grinberg at compulab.co.il
Wed Aug 13 16:04:48 CEST 2014


On 08/10/14 20:12, Nikita Kiryanov wrote:
> Add USB and USB OTG host support for Compulab CM-FX6 CoM.
> 
> Cc: Igor Grinberg <grinberg at compulab.co.il>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Tom Rini <trini at ti.com>
> Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
> ---
> Changes in V2:
> 	- No changes
> 
>  board/compulab/cm_fx6/cm_fx6.c | 75 ++++++++++++++++++++++++++++++++++++++++++
>  board/compulab/cm_fx6/common.h |  3 ++
>  include/configs/cm_fx6.h       | 10 ++++++
>  3 files changed, 88 insertions(+)
> 
> diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
> index e993de2..28c54b4 100644
> --- a/board/compulab/cm_fx6/cm_fx6.c
> +++ b/board/compulab/cm_fx6/cm_fx6.c

[...]

> +static int cm_fx6_usb_hub_reset(void)
> +{
> +	int err;
> +
> +	err = gpio_request(CM_FX6_USB_HUB_RST, "usb hub rst");
> +	if (err) {
> +		printf("USB hub rst gpio request failed: %d\n", err);
> +		return -1;
> +	}
> +
> +	SETUP_IOMUX_PAD(PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL));
> +	gpio_direction_output(CM_FX6_USB_HUB_RST, 0);
> +	udelay(10);
> +	gpio_direction_output(CM_FX6_USB_HUB_RST, 1);
> +	mdelay(1);
> +
> +	return 0;
> +}
> +
> +static void cm_fx6_init_usb_otg(void)

Can this function also return int as the one above?

> +{
> +	int ret;
> +	struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
> +
> +	ret = gpio_request(SB_FX6_USB_OTG_PWR, "usb-pwr");
> +	if (ret)
> +		printf("USB OTG pwr gpio request failed: %d\n", ret);
> +
> +	SETUP_IOMUX_PAD(PAD_EIM_D22__GPIO3_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL));
> +	SETUP_IOMUX_PAD(PAD_ENET_RX_ER__USB_OTG_ID |
> +						MUX_PAD_CTRL(WEAK_PULLDOWN));
> +	clrbits_le32(&iomux->gpr[1], IOMUXC_GPR1_OTG_ID_MASK);
> +	/* disable ext. charger detect, or it'll affect signal quality at dp. */
> +	gpio_direction_output(SB_FX6_USB_OTG_PWR, 0);
> +}
> +
> +#define MX6_USBNC_BASEADDR	0x2184800
> +#define USBNC_USB_H1_PWR_POL	(1 << 9)
> +int board_ehci_hcd_init(int port)
> +{
> +	u32 *usbnc_usb_uh1_ctrl = (u32 *)(MX6_USBNC_BASEADDR + 4);
> +	u32 val;
> +
> +	switch (port) {
> +	case 0:
> +		cm_fx6_init_usb_otg();
> +		break;
> +	case 1:
> +		SETUP_IOMUX_PAD(PAD_GPIO_0__USB_H1_PWR |
> +						MUX_PAD_CTRL(NO_PAD_CTRL));
> +
> +		/* Set PWR polarity to match power switch's enable polarity */
> +		val = __raw_readl(usbnc_usb_uh1_ctrl);
> +		val |= USBNC_USB_H1_PWR_POL;
> +		__raw_writel(val, usbnc_usb_uh1_ctrl);

Can we have setbits_le32() here?

> +		return cm_fx6_usb_hub_reset();
> +	default:
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
> +int board_ehci_power(int port, int on)
> +{
> +	return port ? 0 : gpio_direction_output(SB_FX6_USB_OTG_PWR, on);

Here port is a port number, not some bool conditional.
Please be explicit about it and don't use the construct above for such cases.

[...]

-- 
Regards,
Igor.


More information about the U-Boot mailing list