arm: vf610: fix double iomux configuration for vf610twr board
[u-boot/qq2440-u-boot.git] / drivers / usb / host / utmi-armada100.c
blob1e878280f2036bde1f99263ff142563c22557822
1 /*
2 * (C) Copyright 2012
3 * eInfochips Ltd. <www.einfochips.com>
4 * Written-by: Ajay Bhargav <ajay.bhargav@einfochips.com>
6 * (C) Copyright 2009
7 * Marvell Semiconductor <www.marvell.com>
9 * SPDX-License-Identifier: GPL-2.0+
12 #include <common.h>
13 #include <asm/io.h>
14 #include <usb.h>
15 #include <asm/arch/cpu.h>
16 #include <asm/arch/armada100.h>
17 #include <asm/arch/utmi-armada100.h>
19 static int utmi_phy_init(void)
21 struct armd1usb_phy_reg *phy_regs =
22 (struct armd1usb_phy_reg *)UTMI_PHY_BASE;
23 int timeout;
25 setbits_le32(&phy_regs->utmi_ctrl, INPKT_DELAY_SOF | PLL_PWR_UP);
26 udelay(1000);
27 setbits_le32(&phy_regs->utmi_ctrl, PHY_PWR_UP);
29 clrbits_le32(&phy_regs->utmi_pll, PLL_FBDIV_MASK | PLL_REFDIV_MASK);
30 setbits_le32(&phy_regs->utmi_pll, N_DIVIDER << PLL_FBDIV | M_DIVIDER);
32 setbits_le32(&phy_regs->utmi_tx, PHSEL_VAL << CK60_PHSEL);
34 /* Calibrate pll */
35 timeout = 10000;
36 while (--timeout && ((readl(&phy_regs->utmi_pll) & PLL_READY) == 0))
38 if (!timeout)
39 return -1;
41 udelay(200);
42 setbits_le32(&phy_regs->utmi_pll, VCOCAL_START);
43 udelay(400);
44 clrbits_le32(&phy_regs->utmi_pll, VCOCAL_START);
46 udelay(200);
47 setbits_le32(&phy_regs->utmi_tx, RCAL_START);
48 udelay(400);
49 clrbits_le32(&phy_regs->utmi_tx, RCAL_START);
51 timeout = 10000;
52 while (--timeout && ((readl(&phy_regs->utmi_pll) & PLL_READY) == 0))
54 if (!timeout)
55 return -1;
57 return 0;
61 * Initialize USB host controller's UTMI Physical interface
63 int utmi_init(void)
65 struct armd1mpmu_registers *mpmu_regs =
66 (struct armd1mpmu_registers *)ARMD1_MPMU_BASE;
68 struct armd1apmu_registers *apmu_regs =
69 (struct armd1apmu_registers *)ARMD1_APMU_BASE;
71 /* Turn on 26Mhz ref clock for UTMI PLL */
72 setbits_le32(&mpmu_regs->acgr, APB2_26M_EN | AP_26M);
74 /* USB Clock reset */
75 writel(USB_SPH_AXICLK_EN, &apmu_regs->usbcrc);
76 writel(USB_SPH_AXICLK_EN | USB_SPH_AXI_RST, &apmu_regs->usbcrc);
78 /* Initialize UTMI transceiver */
79 return utmi_phy_init();