2 * (C) Copyright 2008, Excito Elektronik i Sk=E5ne AB
4 * Author: Tor Krill tor@excito.com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/bitops.h>
30 #include "usb_ehci_fsl.h"
31 #include "usb_ehci_core.h"
34 * Create the appropriate control structures to manage
35 * a new EHCI host controller.
37 * Excerpts from linux ehci fsl driver.
39 int ehci_hcd_init(void)
41 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
44 addr = (uint32_t)&(im->usb[0]);
45 hccr = (struct ehci_hccr *)(addr + FSL_SKIP_PCI);
46 hcor = (struct ehci_hcor *)((uint32_t) hccr +
47 HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
50 clrsetbits_be32(&(im->clk.sccr), MPC83XX_SCCR_USB_MASK,
51 MPC83XX_SCCR_USB_DRCM_11);
53 /* Confgure interface. */
54 temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
55 out_be32((void *)(addr + FSL_SOC_USB_CTRL), temp
56 | REFSEL_16MHZ | UTMI_PHY_EN);
58 /* Wait for clock to stabilize */
60 temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
62 } while (!(temp & PHY_CLK_VALID));
64 /* Set to Host mode */
65 temp = in_le32((void *)(addr + FSL_SOC_USB_USBMODE));
66 out_le32((void *)(addr + FSL_SOC_USB_USBMODE), temp | CM_HOST);
68 out_be32((void *)(addr + FSL_SOC_USB_SNOOP1), SNOOP_SIZE_2GB);
69 out_be32((void *)(addr + FSL_SOC_USB_SNOOP2),
70 0x80000000 | SNOOP_SIZE_2GB);
73 /* TODO: handle different phys? */
74 out_le32(&(hcor->or_portsc[0]), PORT_PTS_UTMI);
76 /* Enable interface. */
77 temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
78 out_be32((void *)(addr + FSL_SOC_USB_CTRL), temp | USB_EN);
80 out_be32((void *)(addr + FSL_SOC_USB_PRICTRL), 0x0000000c);
81 out_be32((void *)(addr + FSL_SOC_USB_AGECNTTHRSH), 0x00000040);
82 out_be32((void *)(addr + FSL_SOC_USB_SICTRL), 0x00000001);
84 /* Enable interface. */
85 temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
86 out_be32((void *)(addr + FSL_SOC_USB_CTRL), temp | USB_EN);
88 temp = in_le32((void *)(addr + FSL_SOC_USB_USBMODE));
94 * Destroy the appropriate control structures corresponding
95 * the the EHCI host controller.
97 int ehci_hcd_stop(void)