blob: e030a0ab1478c8f57a4595d740dd0d02ecdf28ec [file] [log] [blame]
Stelian Popfefb6c12008-01-30 21:15:54 +00001/*
2 * (C) Copyright 2006
Stelian Pop567fb852008-05-08 22:52:09 +02003 * DENX Software Engineering <mk@denx.de>
Stelian Popfefb6c12008-01-30 21:15:54 +00004 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Stelian Popfefb6c12008-01-30 21:15:54 +00006 */
7
8#include <common.h>
9
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020010#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
Stelian Popfefb6c12008-01-30 21:15:54 +000011
Jean-Christophe PLAGNIOL-VILLARDdc39ae92009-04-16 21:30:44 +020012#include <asm/arch/clk.h>
Stelian Popfefb6c12008-01-30 21:15:54 +000013
14int usb_cpu_init(void)
15{
Bo Shendcd2f1a2013-10-21 16:14:00 +080016#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
Wenyou Yang9cf73852016-02-03 10:20:44 +080017 if (at91_pllb_clk_enable(get_pllb_init()))
18 return -1;
19
Bo Shend9bef0a2013-10-21 16:13:59 +080020#ifdef CONFIG_AT91SAM9N12
Wenyou Yangb55b5962016-02-02 11:11:53 +080021 at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
Bo Shend9bef0a2013-10-21 16:13:59 +080022#endif
Bo Shendcd2f1a2013-10-21 16:14:00 +080023#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
Wenyou Yangb55b5962016-02-02 11:11:53 +080024 if (at91_upll_clk_enable())
25 return -1;
Sergey Matyukevich64203c72010-06-09 23:09:06 +040026
Wenyou Yangb55b5962016-02-02 11:11:53 +080027 at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
Stelian Pop3e0cda02008-11-09 00:14:46 +010028#endif
29
Bo Shen01c8bf52014-08-06 17:24:56 +080030 at91_periph_clk_enable(ATMEL_ID_UHP);
Bo Shene5e8bb02013-05-12 22:40:53 +000031
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080032 at91_system_clk_enable(ATMEL_PMC_UHP);
Bo Shen158947d2013-04-17 00:09:51 +000033#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080034 at91_system_clk_enable(AT91_PMC_HCK0);
Stelian Popd99a8ff2008-05-08 20:52:22 +020035#endif
Stelian Popfefb6c12008-01-30 21:15:54 +000036
37 return 0;
38}
39
40int usb_cpu_stop(void)
41{
Bo Shen01c8bf52014-08-06 17:24:56 +080042 at91_periph_clk_disable(ATMEL_ID_UHP);
Bo Shene5e8bb02013-05-12 22:40:53 +000043
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080044 at91_system_clk_disable(ATMEL_PMC_UHP);
Bo Shen158947d2013-04-17 00:09:51 +000045#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080046 at91_system_clk_disable(AT91_PMC_HCK0);
Stelian Popd99a8ff2008-05-08 20:52:22 +020047#endif
Stelian Pop3e0cda02008-11-09 00:14:46 +010048
Bo Shendcd2f1a2013-10-21 16:14:00 +080049#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
Bo Shend9bef0a2013-10-21 16:13:59 +080050#ifdef CONFIG_AT91SAM9N12
Wenyou Yangb55b5962016-02-02 11:11:53 +080051 at91_usb_clk_init(0);
Bo Shend9bef0a2013-10-21 16:13:59 +080052#endif
Wenyou Yang9cf73852016-02-03 10:20:44 +080053
54 if (at91_pllb_clk_disable())
55 return -1;
56
Bo Shendcd2f1a2013-10-21 16:14:00 +080057#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
Wenyou Yangb55b5962016-02-02 11:11:53 +080058 if (at91_upll_clk_disable())
59 return -1;
Stelian Pop3e0cda02008-11-09 00:14:46 +010060#endif
61
Stelian Popfefb6c12008-01-30 21:15:54 +000062 return 0;
63}
64
65int usb_cpu_init_fail(void)
66{
67 return usb_cpu_stop();
68}
69
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020070#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */