]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - drivers/usb/host/ehci-atmel.c
1 // SPDX-License-Identifier: GPL-2.0+
4 * Atmel Semiconductor <www.atmel.com>
5 * Written-by: Bo Shen <voice.shen@atmel.com>
13 #include <asm/arch/clk.h>
17 #if !CONFIG_IS_ENABLED(DM_USB)
19 int ehci_hcd_init(int index
, enum usb_init_type init
,
20 struct ehci_hccr
**hccr
, struct ehci_hcor
**hcor
)
23 if (at91_upll_clk_enable())
26 /* Enable USB Host clock */
27 at91_periph_clk_enable(ATMEL_ID_UHPHS
);
29 *hccr
= (struct ehci_hccr
*)ATMEL_BASE_EHCI
;
30 *hcor
= (struct ehci_hcor
*)((uint32_t)*hccr
+
31 HC_LENGTH(ehci_readl(&(*hccr
)->cr_capbase
)));
36 int ehci_hcd_stop(int index
)
38 /* Disable USB Host Clock */
39 at91_periph_clk_disable(ATMEL_ID_UHPHS
);
41 /* Disable UTMI PLL */
42 if (at91_upll_clk_disable())
50 struct ehci_atmel_priv
{
51 struct ehci_ctrl ehci
;
54 static int ehci_atmel_enable_clk(struct udevice
*dev
)
59 ret
= clk_get_by_index(dev
, 0, &clk
);
63 ret
= clk_enable(&clk
);
67 ret
= clk_get_by_index(dev
, 1, &clk
);
71 ret
= clk_enable(&clk
);
80 static int ehci_atmel_probe(struct udevice
*dev
)
82 struct ehci_hccr
*hccr
;
83 struct ehci_hcor
*hcor
;
87 ret
= ehci_atmel_enable_clk(dev
);
89 debug("Failed to enable USB Host clock\n");
94 * Get the base address for EHCI controller from the device node
96 hcd_base
= devfdt_get_addr(dev
);
97 if (hcd_base
== FDT_ADDR_T_NONE
) {
98 debug("Can't get the EHCI register base address\n");
102 hccr
= (struct ehci_hccr
*)hcd_base
;
103 hcor
= (struct ehci_hcor
*)
104 ((u32
)hccr
+ HC_LENGTH(ehci_readl(&hccr
->cr_capbase
)));
106 debug("echi-atmel: init hccr %x and hcor %x hc_length %d\n",
107 (u32
)hccr
, (u32
)hcor
,
108 (u32
)HC_LENGTH(ehci_readl(&hccr
->cr_capbase
)));
110 return ehci_register(dev
, hccr
, hcor
, NULL
, 0, USB_INIT_HOST
);
113 static const struct udevice_id ehci_usb_ids
[] = {
114 { .compatible
= "atmel,at91sam9g45-ehci", },
118 U_BOOT_DRIVER(ehci_atmel
) = {
119 .name
= "ehci_atmel",
121 .of_match
= ehci_usb_ids
,
122 .probe
= ehci_atmel_probe
,
123 .remove
= ehci_deregister
,
124 .ops
= &ehci_usb_ops
,
125 .platdata_auto_alloc_size
= sizeof(struct usb_platdata
),
126 .priv_auto_alloc_size
= sizeof(struct ehci_atmel_priv
),
127 .flags
= DM_FLAG_ALLOC_PRIV_DMA
,