Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 1 | /* |
2 | * (C) Copyright 2012 | ||||
3 | * Atmel Semiconductor <www.atmel.com> | ||||
4 | * Written-by: Bo Shen <voice.shen@atmel.com> | ||||
5 | * | ||||
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 7 | */ |
8 | |||||
9 | #include <common.h> | ||||
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 10 | #include <usb.h> |
11 | #include <asm/io.h> | ||||
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 12 | #include <asm/arch/clk.h> |
13 | |||||
14 | #include "ehci.h" | ||||
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 15 | |
Troy Kisky | 127efc4 | 2013-10-10 15:27:57 -0700 | [diff] [blame] | 16 | int ehci_hcd_init(int index, enum usb_init_type init, |
17 | struct ehci_hccr **hccr, struct ehci_hcor **hcor) | ||||
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 18 | { |
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 19 | /* Enable UTMI PLL */ |
Wenyou Yang | b55b596 | 2016-02-02 11:11:53 +0800 | [diff] [blame] | 20 | if (at91_upll_clk_enable()) |
21 | return -1; | ||||
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 22 | |
23 | /* Enable USB Host clock */ | ||||
Bo Shen | 97b2043 | 2014-08-06 17:24:57 +0800 | [diff] [blame] | 24 | at91_periph_clk_enable(ATMEL_ID_UHPHS); |
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 25 | |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 26 | *hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI; |
27 | *hcor = (struct ehci_hcor *)((uint32_t)*hccr + | ||||
28 | HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); | ||||
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 29 | |
30 | return 0; | ||||
31 | } | ||||
32 | |||||
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 33 | int ehci_hcd_stop(int index) |
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 34 | { |
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 35 | /* Disable USB Host Clock */ |
Bo Shen | 97b2043 | 2014-08-06 17:24:57 +0800 | [diff] [blame] | 36 | at91_periph_clk_disable(ATMEL_ID_UHPHS); |
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 37 | |
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 38 | /* Disable UTMI PLL */ |
Wenyou Yang | b55b596 | 2016-02-02 11:11:53 +0800 | [diff] [blame] | 39 | if (at91_upll_clk_disable()) |
40 | return -1; | ||||
Bo Shen | cc30b78 | 2012-06-27 21:58:20 +0000 | [diff] [blame] | 41 | |
42 | return 0; | ||||
43 | } |