[U-Boot] [PATCH v4 5/5] usb: lpc32xx: add host USB driver
Marek Vasut
marex at denx.de
Tue Aug 4 23:33:39 CEST 2015
On Tuesday, August 04, 2015 at 11:04:42 PM, slemieux.tyco at gmail.com wrote:
> From: Sylvain Lemieux <slemieux at tycoint.com>
>
> Incorporate USB driver from legacy LPCLinux NXP BSP.
> The files taken from the legacy patch are:
> - lpc32xx USB driver
> - lpc3250 header file USB registers definition.
>
> The legacy driver was updated and clean-up as part
> of the integration with the latest u-boot.
>
> Signed-off-by: Sylvain Lemieux <slemieux at tycoint.com>
> ---
Hi!
> +static int wait_for_bit(void *reg, const uint32_t mask, bool set)
> +{
> + unsigned int timeout = 1000000;
> + uint32_t val;
> +
> + while (--timeout) {
Where did the get_timer() stuff disappear ? :'-(
> + val = readl(reg);
> + if (!set)
> + val = ~val;
> +
> + if ((val & mask) == mask)
> + return 0;
> +
> + udelay(1);
> + }
> +
> + debug("%s: Timeout (reg=%p mask=%08x wait_set=%i)\n",
> + __func__, reg, mask, set);
> +
> + return -ETIMEDOUT;
> +}
[...]
> +static int usbpll_setup(void)
> +{
> + uint32_t ret;
u32, please fix all around.
> + /* make sure clocks are disabled */
> + clrbits_le32(&clk_pwr->usb_ctrl,
> + CLK_USBCTRL_CLK_EN1 | CLK_USBCTRL_CLK_EN2);
> +
> + /* start PLL clock input */
> + setbits_le32(&clk_pwr->usb_ctrl, CLK_USBCTRL_CLK_EN1);
> +
> + /* Setup PLL. */
> + setbits_le32(&clk_pwr->usb_ctrl,
> + CLK_USBCTRL_FDBK_PLUS1(192 - 1));
> + setbits_le32(&clk_pwr->usb_ctrl, CLK_USBCTRL_POSTDIV_2POW(0x01));
> + setbits_le32(&clk_pwr->usb_ctrl, CLK_USBCTRL_PLL_PWRUP);
> +
> + ret = wait_for_bit(&clk_pwr->usb_ctrl, CLK_USBCTRL_PLL_STS, 1);
> + if (ret)
> + return -1;
> +
> + /* enable PLL output */
> + setbits_le32(&clk_pwr->usb_ctrl, CLK_USBCTRL_CLK_EN2);
> +
> + return 0;
> +}
[...]
> + ret = wait_for_bit(&otg->otg_clk_sts, mask, 1);
> + if (ret)
> + return -1;
return ret; should be just find in these cases.
> + setbits_le32(&otg->otg_sts_ctrl, OTG_HOST_EN);
> + isp1301_set_value(ISP1301_I2C_OTG_CONTROL_1_SET, OTG1_VBUS_DRV);
> +
> + return 0;
> +}
> +
> +int usb_cpu_stop(void)
> +{
> + /* vbus off */
> + isp1301_set_value(ISP1301_I2C_OTG_CONTROL_1_SET, OTG1_VBUS_DRV);
> +
> + clrbits_le32(&otg->otg_sts_ctrl, OTG_HOST_EN);
> +
> + clrbits_le32(&clk_pwr->usb_ctrl, CLK_USBCTRL_HCLK_EN);
> +
> + return 0;
> +}
> +
> +int usb_cpu_init_fail(void)
> +{
> + return usb_cpu_stop();
> +}
More information about the U-Boot
mailing list