blob: e030a0ab1478c8f57a4595d740dd0d02ecdf28ec [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 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Stelian Popd1aea1c2008-01-30 21:15:54 +00006 */
7
8#include <common.h>
9
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020010#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
Stelian Popd1aea1c2008-01-30 21:15:54 +000011
Jean-Christophe PLAGNIOL-VILLARD23164f12009-04-16 21:30:44 +020012#include <asm/arch/clk.h>
Stelian Popd1aea1c2008-01-30 21:15:54 +000013
14int usb_cpu_init(void)
15{
Bo Shen4a985df2013-10-21 16:14:00 +080016#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
Wenyou Yangcb88cd82016-02-03 10:20:44 +080017 if (at91_pllb_clk_enable(get_pllb_init()))
18 return -1;
19
Bo Shen8ed87832013-10-21 16:13:59 +080020#ifdef CONFIG_AT91SAM9N12
Wenyou Yang2f7be642016-02-02 11:11:53 +080021 at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
Bo Shen8ed87832013-10-21 16:13:59 +080022#endif
Bo Shen4a985df2013-10-21 16:14:00 +080023#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
Wenyou Yang2f7be642016-02-02 11:11:53 +080024 if (at91_upll_clk_enable())
25 return -1;
Sergey Matyukevichd25010d2010-06-09 23:09:06 +040026
Wenyou Yang2f7be642016-02-02 11:11:53 +080027 at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
Stelian Pope9fe2cf2008-11-09 00:14:46 +010028#endif
29
Bo Shencf905632014-08-06 17:24:56 +080030 at91_periph_clk_enable(ATMEL_ID_UHP);
Bo Shen72979a32013-05-12 22:40:53 +000031
Wenyou Yangfbd4ac12016-02-03 10:16:51 +080032 at91_system_clk_enable(ATMEL_PMC_UHP);
Bo Shenbed082f2013-04-17 00:09:51 +000033#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
Wenyou Yangfbd4ac12016-02-03 10:16:51 +080034 at91_system_clk_enable(AT91_PMC_HCK0);
Stelian Pop61e69d72008-05-08 20:52:22 +020035#endif
Stelian Popd1aea1c2008-01-30 21:15:54 +000036
37 return 0;
38}
39
40int usb_cpu_stop(void)
41{
Bo Shencf905632014-08-06 17:24:56 +080042 at91_periph_clk_disable(ATMEL_ID_UHP);
Bo Shen72979a32013-05-12 22:40:53 +000043
Wenyou Yangfbd4ac12016-02-03 10:16:51 +080044 at91_system_clk_disable(ATMEL_PMC_UHP);
Bo Shenbed082f2013-04-17 00:09:51 +000045#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
Wenyou Yangfbd4ac12016-02-03 10:16:51 +080046 at91_system_clk_disable(AT91_PMC_HCK0);
Stelian Pop61e69d72008-05-08 20:52:22 +020047#endif
Stelian Pope9fe2cf2008-11-09 00:14:46 +010048
Bo Shen4a985df2013-10-21 16:14:00 +080049#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
Bo Shen8ed87832013-10-21 16:13:59 +080050#ifdef CONFIG_AT91SAM9N12
Wenyou Yang2f7be642016-02-02 11:11:53 +080051 at91_usb_clk_init(0);
Bo Shen8ed87832013-10-21 16:13:59 +080052#endif
Wenyou Yangcb88cd82016-02-03 10:20:44 +080053
54 if (at91_pllb_clk_disable())
55 return -1;
56
Bo Shen4a985df2013-10-21 16:14:00 +080057#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
Wenyou Yang2f7be642016-02-02 11:11:53 +080058 if (at91_upll_clk_disable())
59 return -1;
Stelian Pope9fe2cf2008-11-09 00:14:46 +010060#endif
61
Stelian Popd1aea1c2008-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-VILLARD03836942008-10-16 15:01:15 +020070#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */