blob: 8ceabaf45c1b98501789b1039d03e8a937072b89 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stelian Popfefb6c12008-01-30 21:15:54 +00002/*
3 * (C) Copyright 2006
Stelian Pop567fb852008-05-08 22:52:09 +02004 * DENX Software Engineering <mk@denx.de>
Stelian Popfefb6c12008-01-30 21:15:54 +00005 */
6
7#include <common.h>
8
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +02009#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
Stelian Popfefb6c12008-01-30 21:15:54 +000010
Jean-Christophe PLAGNIOL-VILLARDdc39ae92009-04-16 21:30:44 +020011#include <asm/arch/clk.h>
Stelian Popfefb6c12008-01-30 21:15:54 +000012
13int usb_cpu_init(void)
14{
Bo Shendcd2f1a2013-10-21 16:14:00 +080015#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
Wenyou Yang9cf73852016-02-03 10:20:44 +080016 if (at91_pllb_clk_enable(get_pllb_init()))
17 return -1;
18
Bo Shend9bef0a2013-10-21 16:13:59 +080019#ifdef CONFIG_AT91SAM9N12
Wenyou Yangb55b5962016-02-02 11:11:53 +080020 at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
Bo Shend9bef0a2013-10-21 16:13:59 +080021#endif
Bo Shendcd2f1a2013-10-21 16:14:00 +080022#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
Wenyou Yangb55b5962016-02-02 11:11:53 +080023 if (at91_upll_clk_enable())
24 return -1;
Sergey Matyukevich64203c72010-06-09 23:09:06 +040025
Wenyou Yangb55b5962016-02-02 11:11:53 +080026 at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
Stelian Pop3e0cda02008-11-09 00:14:46 +010027#endif
28
Bo Shen01c8bf52014-08-06 17:24:56 +080029 at91_periph_clk_enable(ATMEL_ID_UHP);
Bo Shene5e8bb02013-05-12 22:40:53 +000030
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080031 at91_system_clk_enable(ATMEL_PMC_UHP);
Bo Shen158947d2013-04-17 00:09:51 +000032#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080033 at91_system_clk_enable(AT91_PMC_HCK0);
Stelian Popd99a8ff2008-05-08 20:52:22 +020034#endif
Stelian Popfefb6c12008-01-30 21:15:54 +000035
36 return 0;
37}
38
39int usb_cpu_stop(void)
40{
Bo Shen01c8bf52014-08-06 17:24:56 +080041 at91_periph_clk_disable(ATMEL_ID_UHP);
Bo Shene5e8bb02013-05-12 22:40:53 +000042
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080043 at91_system_clk_disable(ATMEL_PMC_UHP);
Bo Shen158947d2013-04-17 00:09:51 +000044#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
Wenyou Yangcd4de1d2016-02-03 10:16:51 +080045 at91_system_clk_disable(AT91_PMC_HCK0);
Stelian Popd99a8ff2008-05-08 20:52:22 +020046#endif
Stelian Pop3e0cda02008-11-09 00:14:46 +010047
Bo Shendcd2f1a2013-10-21 16:14:00 +080048#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
Bo Shend9bef0a2013-10-21 16:13:59 +080049#ifdef CONFIG_AT91SAM9N12
Wenyou Yangb55b5962016-02-02 11:11:53 +080050 at91_usb_clk_init(0);
Bo Shend9bef0a2013-10-21 16:13:59 +080051#endif
Wenyou Yang9cf73852016-02-03 10:20:44 +080052
53 if (at91_pllb_clk_disable())
54 return -1;
55
Bo Shendcd2f1a2013-10-21 16:14:00 +080056#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
Wenyou Yangb55b5962016-02-02 11:11:53 +080057 if (at91_upll_clk_disable())
58 return -1;
Stelian Pop3e0cda02008-11-09 00:14:46 +010059#endif
60
Stelian Popfefb6c12008-01-30 21:15:54 +000061 return 0;
62}
63
64int usb_cpu_init_fail(void)
65{
66 return usb_cpu_stop();
67}
68
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020069#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */