blob: 1d7d28048bc1914217cb3e2e7e0709aeccace015 [file] [log] [blame]
Bo Shencc30b782012-06-27 21:58:20 +00001/*
2 * (C) Copyright 2012
3 * Atmel Semiconductor <www.atmel.com>
4 * Written-by: Bo Shen <voice.shen@atmel.com>
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Bo Shencc30b782012-06-27 21:58:20 +00007 */
8
9#include <common.h>
Bo Shencc30b782012-06-27 21:58:20 +000010#include <usb.h>
11#include <asm/io.h>
Bo Shencc30b782012-06-27 21:58:20 +000012#include <asm/arch/clk.h>
13
14#include "ehci.h"
Bo Shencc30b782012-06-27 21:58:20 +000015
Troy Kisky127efc42013-10-10 15:27:57 -070016int ehci_hcd_init(int index, enum usb_init_type init,
17 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Bo Shencc30b782012-06-27 21:58:20 +000018{
Bo Shencc30b782012-06-27 21:58:20 +000019 /* Enable UTMI PLL */
Wenyou Yangb55b5962016-02-02 11:11:53 +080020 if (at91_upll_clk_enable())
21 return -1;
Bo Shencc30b782012-06-27 21:58:20 +000022
23 /* Enable USB Host clock */
Bo Shen97b20432014-08-06 17:24:57 +080024 at91_periph_clk_enable(ATMEL_ID_UHPHS);
Bo Shencc30b782012-06-27 21:58:20 +000025
Lucas Stach676ae062012-09-26 00:14:35 +020026 *hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI;
27 *hcor = (struct ehci_hcor *)((uint32_t)*hccr +
28 HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
Bo Shencc30b782012-06-27 21:58:20 +000029
30 return 0;
31}
32
Lucas Stach676ae062012-09-26 00:14:35 +020033int ehci_hcd_stop(int index)
Bo Shencc30b782012-06-27 21:58:20 +000034{
Bo Shencc30b782012-06-27 21:58:20 +000035 /* Disable USB Host Clock */
Bo Shen97b20432014-08-06 17:24:57 +080036 at91_periph_clk_disable(ATMEL_ID_UHPHS);
Bo Shencc30b782012-06-27 21:58:20 +000037
Bo Shencc30b782012-06-27 21:58:20 +000038 /* Disable UTMI PLL */
Wenyou Yangb55b5962016-02-02 11:11:53 +080039 if (at91_upll_clk_disable())
40 return -1;
Bo Shencc30b782012-06-27 21:58:20 +000041
42 return 0;
43}