2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-01-30 21:15:54 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2006
|
2008-05-08 20:52:09 +00:00
|
|
|
* DENX Software Engineering <mk@denx.de>
|
2008-01-30 21:15:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2009-04-16 19:30:44 +00:00
|
|
|
#include <asm/arch/clk.h>
|
2008-01-30 21:15:54 +00:00
|
|
|
|
|
|
|
int usb_cpu_init(void)
|
|
|
|
{
|
2013-10-21 08:14:00 +00:00
|
|
|
#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
|
2016-02-03 02:20:44 +00:00
|
|
|
if (at91_pllb_clk_enable(get_pllb_init()))
|
|
|
|
return -1;
|
|
|
|
|
2013-10-21 08:13:59 +00:00
|
|
|
#ifdef CONFIG_AT91SAM9N12
|
2016-02-02 03:11:53 +00:00
|
|
|
at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
|
2013-10-21 08:13:59 +00:00
|
|
|
#endif
|
2013-10-21 08:14:00 +00:00
|
|
|
#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
|
2016-02-02 03:11:53 +00:00
|
|
|
if (at91_upll_clk_enable())
|
|
|
|
return -1;
|
2010-06-09 19:09:06 +00:00
|
|
|
|
2016-02-02 03:11:53 +00:00
|
|
|
at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
|
2008-11-08 23:14:46 +00:00
|
|
|
#endif
|
|
|
|
|
2014-08-06 09:24:56 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_UHP);
|
2013-05-12 22:40:53 +00:00
|
|
|
|
2016-02-03 02:16:51 +00:00
|
|
|
at91_system_clk_enable(ATMEL_PMC_UHP);
|
2013-04-17 00:09:51 +00:00
|
|
|
#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
|
2016-02-03 02:16:51 +00:00
|
|
|
at91_system_clk_enable(AT91_PMC_HCK0);
|
2008-05-08 18:52:22 +00:00
|
|
|
#endif
|
2008-01-30 21:15:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usb_cpu_stop(void)
|
|
|
|
{
|
2014-08-06 09:24:56 +00:00
|
|
|
at91_periph_clk_disable(ATMEL_ID_UHP);
|
2013-05-12 22:40:53 +00:00
|
|
|
|
2016-02-03 02:16:51 +00:00
|
|
|
at91_system_clk_disable(ATMEL_PMC_UHP);
|
2013-04-17 00:09:51 +00:00
|
|
|
#if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
|
2016-02-03 02:16:51 +00:00
|
|
|
at91_system_clk_disable(AT91_PMC_HCK0);
|
2008-05-08 18:52:22 +00:00
|
|
|
#endif
|
2008-11-08 23:14:46 +00:00
|
|
|
|
2013-10-21 08:14:00 +00:00
|
|
|
#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
|
2013-10-21 08:13:59 +00:00
|
|
|
#ifdef CONFIG_AT91SAM9N12
|
2016-02-02 03:11:53 +00:00
|
|
|
at91_usb_clk_init(0);
|
2013-10-21 08:13:59 +00:00
|
|
|
#endif
|
2016-02-03 02:20:44 +00:00
|
|
|
|
|
|
|
if (at91_pllb_clk_disable())
|
|
|
|
return -1;
|
|
|
|
|
2013-10-21 08:14:00 +00:00
|
|
|
#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
|
2016-02-02 03:11:53 +00:00
|
|
|
if (at91_upll_clk_disable())
|
|
|
|
return -1;
|
2008-11-08 23:14:46 +00:00
|
|
|
#endif
|
|
|
|
|
2008-01-30 21:15:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usb_cpu_init_fail(void)
|
|
|
|
{
|
|
|
|
return usb_cpu_stop();
|
|
|
|
}
|