blob: 29f3ba186adc5449420c86e860235c9a880f3a82 [file] [log] [blame]
Stelian Popd1aea1c2008-01-30 21:15:54 +00001/*
2 * (C) Copyright 2006
Stelian Popf9e848b2008-05-08 22:52:09 +02003 * DENX Software Engineering <mk@denx.de>
Stelian Popd1aea1c2008-01-30 21:15:54 +00004 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020026#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
Stelian Popd1aea1c2008-01-30 21:15:54 +000027
Jens Scharsiga4db1ca2010-02-03 22:46:58 +010028#ifndef CONFIG_AT91_LEGACY
29#define CONFIG_AT91_LEGACY
30#warning Please update to use C structur SoC access !
31#endif
32
Stelian Popd1aea1c2008-01-30 21:15:54 +000033#include <asm/arch/hardware.h>
Stelian Popd4bfbc52008-03-26 20:52:32 +010034#include <asm/arch/io.h>
35#include <asm/arch/at91_pmc.h>
Jean-Christophe PLAGNIOL-VILLARD23164f12009-04-16 21:30:44 +020036#include <asm/arch/clk.h>
Stelian Popd1aea1c2008-01-30 21:15:54 +000037
38int usb_cpu_init(void)
39{
Stelian Pope9fe2cf2008-11-09 00:14:46 +010040
41#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
RONETIX - Ilko Iliev500cda82009-06-05 16:54:31 +020042 defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
43 defined(CONFIG_AT91SAM9261)
Stelian Pope9fe2cf2008-11-09 00:14:46 +010044 /* Enable PLLB */
Jean-Christophe PLAGNIOL-VILLARD23164f12009-04-16 21:30:44 +020045 at91_sys_write(AT91_CKGR_PLLBR, get_pllb_init());
Stelian Pope9fe2cf2008-11-09 00:14:46 +010046 while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
47 ;
48#endif
49
Stelian Popd1aea1c2008-01-30 21:15:54 +000050 /* Enable USB host clock. */
Stelian Popd4bfbc52008-03-26 20:52:32 +010051 at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_UHP);
Stelian Pop61e69d72008-05-08 20:52:22 +020052#ifdef CONFIG_AT91SAM9261
53 at91_sys_write(AT91_PMC_SCER, AT91_PMC_UHP | AT91_PMC_HCK0);
54#else
Stelian Popd4bfbc52008-03-26 20:52:32 +010055 at91_sys_write(AT91_PMC_SCER, AT91_PMC_UHP);
Stelian Pop61e69d72008-05-08 20:52:22 +020056#endif
Stelian Popd1aea1c2008-01-30 21:15:54 +000057
58 return 0;
59}
60
61int usb_cpu_stop(void)
62{
63 /* Disable USB host clock. */
Stelian Popd4bfbc52008-03-26 20:52:32 +010064 at91_sys_write(AT91_PMC_PCDR, 1 << AT91_ID_UHP);
Stelian Pop61e69d72008-05-08 20:52:22 +020065#ifdef CONFIG_AT91SAM9261
66 at91_sys_write(AT91_PMC_SCDR, AT91_PMC_UHP | AT91_PMC_HCK0);
67#else
Stelian Popd4bfbc52008-03-26 20:52:32 +010068 at91_sys_write(AT91_PMC_SCDR, AT91_PMC_UHP);
Stelian Pop61e69d72008-05-08 20:52:22 +020069#endif
Stelian Pope9fe2cf2008-11-09 00:14:46 +010070
71#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
Nicolas Ferre4ef545e2009-03-22 14:48:16 +010072 defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20)
Stelian Pope9fe2cf2008-11-09 00:14:46 +010073 /* Disable PLLB */
74 at91_sys_write(AT91_CKGR_PLLBR, 0);
75 while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != 0)
76 ;
77#endif
78
Stelian Popd1aea1c2008-01-30 21:15:54 +000079 return 0;
80}
81
82int usb_cpu_init_fail(void)
83{
84 return usb_cpu_stop();
85}
86
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020087#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */