blob: 1d7d28048bc1914217cb3e2e7e0709aeccace015 [file] [log] [blame]
Bo Shenc0eede02012-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 Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Bo Shenc0eede02012-06-27 21:58:20 +00007 */
8
9#include <common.h>
Bo Shenc0eede02012-06-27 21:58:20 +000010#include <usb.h>
11#include <asm/io.h>
Bo Shenc0eede02012-06-27 21:58:20 +000012#include <asm/arch/clk.h>
13
14#include "ehci.h"
Bo Shenc0eede02012-06-27 21:58:20 +000015
Troy Kisky7d6bbb92013-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 Shenc0eede02012-06-27 21:58:20 +000018{
Bo Shenc0eede02012-06-27 21:58:20 +000019 /* Enable UTMI PLL */
Wenyou Yang2f7be642016-02-02 11:11:53 +080020 if (at91_upll_clk_enable())
21 return -1;
Bo Shenc0eede02012-06-27 21:58:20 +000022
23 /* Enable USB Host clock */
Bo Shena2a637d2014-08-06 17:24:57 +080024 at91_periph_clk_enable(ATMEL_ID_UHPHS);
Bo Shenc0eede02012-06-27 21:58:20 +000025
Lucas Stach3494a4c2012-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 Shenc0eede02012-06-27 21:58:20 +000029
30 return 0;
31}
32
Lucas Stach3494a4c2012-09-26 00:14:35 +020033int ehci_hcd_stop(int index)
Bo Shenc0eede02012-06-27 21:58:20 +000034{
Bo Shenc0eede02012-06-27 21:58:20 +000035 /* Disable USB Host Clock */
Bo Shena2a637d2014-08-06 17:24:57 +080036 at91_periph_clk_disable(ATMEL_ID_UHPHS);
Bo Shenc0eede02012-06-27 21:58:20 +000037
Bo Shenc0eede02012-06-27 21:58:20 +000038 /* Disable UTMI PLL */
Wenyou Yang2f7be642016-02-02 11:11:53 +080039 if (at91_upll_clk_disable())
40 return -1;
Bo Shenc0eede02012-06-27 21:58:20 +000041
42 return 0;
43}