xref: /openbmc/u-boot/drivers/usb/host/ehci-atmel.c (revision 215099a5)
1 /*
2  * (C) Copyright 2012
3  * Atmel Semiconductor <www.atmel.com>
4  * Written-by: Bo Shen <voice.shen@atmel.com>
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #include <common.h>
10 #include <usb.h>
11 #include <asm/io.h>
12 #include <asm/arch/clk.h>
13 
14 #include "ehci.h"
15 
16 int ehci_hcd_init(int index, enum usb_init_type init,
17 		struct ehci_hccr **hccr, struct ehci_hcor **hcor)
18 {
19 	/* Enable UTMI PLL */
20 	if (at91_upll_clk_enable())
21 		return -1;
22 
23 	/* Enable USB Host clock */
24 	at91_periph_clk_enable(ATMEL_ID_UHPHS);
25 
26 	*hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI;
27 	*hcor = (struct ehci_hcor *)((uint32_t)*hccr +
28 			HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
29 
30 	return 0;
31 }
32 
33 int ehci_hcd_stop(int index)
34 {
35 	/* Disable USB Host Clock */
36 	at91_periph_clk_disable(ATMEL_ID_UHPHS);
37 
38 	/* Disable UTMI PLL */
39 	if (at91_upll_clk_disable())
40 		return -1;
41 
42 	return 0;
43 }
44