* [U-Boot] [PATCH v2 0/4] ARM: at91: add UTMI PLL handle functions
@ 2015-12-09 7:57 Wenyou Yang
2015-12-09 7:57 ` [U-Boot] [PATCH v2 1/4] ARM: at91: clock: add UTMI PLL enable/disable function Wenyou Yang
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Wenyou Yang @ 2015-12-09 7:57 UTC (permalink / raw)
To: u-boot
To reduce the duplicated code, add UTMI PLL enable/disable functions,
replace the UTMI PLL handle code with these functions.
It is based on the following patch set.
[PATCH v2 0/5] ARM: at91: improve peripheral and system clock handle functions
Changes in v2:
- remain asm/io.h include.
Wenyou Yang (4):
ARM: at91: clock: add UTMI PLL enable/disable function
ARM: at91: armv7: clean up UTMI PLL handle code
drivers: usb: atmel: clean up the UTMI PLL code
board: atmel: siemens: clean up UTMI PLL code
arch/arm/mach-at91/armv7/sama5d2_devices.c | 5 +--
arch/arm/mach-at91/armv7/sama5d3_devices.c | 5 +--
arch/arm/mach-at91/armv7/sama5d4_devices.c | 5 +--
arch/arm/mach-at91/clock.c | 48 ++++++++++++++++++++++++++++
arch/arm/mach-at91/include/mach/clk.h | 3 ++
board/siemens/corvus/board.c | 4 +--
drivers/usb/host/ehci-atmel.c | 38 +++-------------------
drivers/usb/host/ohci-at91.c | 20 ++++--------
8 files changed, 66 insertions(+), 62 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 1/4] ARM: at91: clock: add UTMI PLL enable/disable function
2015-12-09 7:57 [U-Boot] [PATCH v2 0/4] ARM: at91: add UTMI PLL handle functions Wenyou Yang
@ 2015-12-09 7:57 ` Wenyou Yang
2015-12-10 9:36 ` Heiko Schocher
2015-12-09 7:57 ` [U-Boot] [PATCH v2 2/4] ARM: at91: armv7: clean up UTMI PLL handle code Wenyou Yang
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2015-12-09 7:57 UTC (permalink / raw)
To: u-boot
To avoid the duplicated code, add the UTMI PLL handle functions,
and add PMC_USB init function too.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---
Changes in v2: None
arch/arm/mach-at91/clock.c | 48 +++++++++++++++++++++++++++++++++
arch/arm/mach-at91/include/mach/clk.h | 3 +++
2 files changed, 51 insertions(+)
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 823d218..b8f8d48 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -10,6 +10,8 @@
#include <asm/arch/hardware.h>
#include <asm/arch/at91_pmc.h>
+#define EN_UPLL_TIMEOUT 500
+
void at91_periph_clk_enable(int id)
{
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
@@ -70,3 +72,49 @@ void at91_system_clk_disable(int sys_clk)
writel(sys_clk, &pmc->scdr);
}
+
+int at91_upll_clk_enable(void)
+{
+ struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+ ulong start_time, tmp_time;
+
+ if ((readl(&pmc->uckr) & AT91_PMC_UPLLEN) == AT91_PMC_UPLLEN)
+ return 0;
+
+ start_time = get_timer(0);
+ writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+ while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU) {
+ tmp_time = get_timer(0);
+ if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
+ printf("ERROR: failed to enable UPLL\n");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+int at91_upll_clk_disable(void)
+{
+ struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+ ulong start_time, tmp_time;
+
+ start_time = get_timer(0);
+ writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
+ while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU) {
+ tmp_time = get_timer(0);
+ if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
+ printf("ERROR: failed to stop UPLL\n");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+void at91_usb_clk_init(u32 value)
+{
+ struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+ writel(value, &pmc->usb);
+}
diff --git a/arch/arm/mach-at91/include/mach/clk.h b/arch/arm/mach-at91/include/mach/clk.h
index bef4e1c..b2604ef 100644
--- a/arch/arm/mach-at91/include/mach/clk.h
+++ b/arch/arm/mach-at91/include/mach/clk.h
@@ -130,5 +130,8 @@ int at91_enable_periph_generated_clk(u32 id, u32 clk_source, u32 div);
u32 at91_get_periph_generated_clk(u32 id);
void at91_system_clk_enable(int sys_clk);
void at91_system_clk_disable(int sys_clk);
+int at91_upll_clk_enable(void);
+int at91_upll_clk_disable(void);
+void at91_usb_clk_init(u32 value);
#endif /* __ASM_ARM_ARCH_CLK_H__ */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 2/4] ARM: at91: armv7: clean up UTMI PLL handle code
2015-12-09 7:57 [U-Boot] [PATCH v2 0/4] ARM: at91: add UTMI PLL handle functions Wenyou Yang
2015-12-09 7:57 ` [U-Boot] [PATCH v2 1/4] ARM: at91: clock: add UTMI PLL enable/disable function Wenyou Yang
@ 2015-12-09 7:57 ` Wenyou Yang
2015-12-10 9:36 ` Heiko Schocher
2015-12-09 7:57 ` [U-Boot] [PATCH v2 3/4] drivers: usb: atmel: clean up the UTMI PLL code Wenyou Yang
2015-12-09 7:57 ` [U-Boot] [PATCH v2 4/4] board: atmel: siemens: clean up " Wenyou Yang
3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2015-12-09 7:57 UTC (permalink / raw)
To: u-boot
Due to introducing the UTMI PLL enable function, use this function
to reduce the duplicated code.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---
Changes in v2: None
arch/arm/mach-at91/armv7/sama5d2_devices.c | 5 +----
arch/arm/mach-at91/armv7/sama5d3_devices.c | 5 +----
arch/arm/mach-at91/armv7/sama5d4_devices.c | 5 +----
3 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-at91/armv7/sama5d2_devices.c b/arch/arm/mach-at91/armv7/sama5d2_devices.c
index 88f8f2c..978eac2 100644
--- a/arch/arm/mach-at91/armv7/sama5d2_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d2_devices.c
@@ -7,7 +7,6 @@
#include <common.h>
#include <asm/io.h>
-#include <asm/arch/at91_pmc.h>
#include <asm/arch/clk.h>
#include <asm/arch/sama5d2.h>
@@ -48,9 +47,7 @@ char *get_cpu_name()
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
void at91_udp_hw_init(void)
{
- struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
- writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+ at91_upll_clk_enable();
at91_periph_clk_enable(ATMEL_ID_UDPHS);
}
diff --git a/arch/arm/mach-at91/armv7/sama5d3_devices.c b/arch/arm/mach-at91/armv7/sama5d3_devices.c
index 78ecfc8..64ac262 100644
--- a/arch/arm/mach-at91/armv7/sama5d3_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d3_devices.c
@@ -8,7 +8,6 @@
#include <common.h>
#include <asm/arch/sama5d3.h>
#include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
#include <asm/arch/clk.h>
#include <asm/arch/gpio.h>
#include <asm/io.h>
@@ -208,10 +207,8 @@ void at91_lcd_hw_init(void)
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
void at91_udp_hw_init(void)
{
- struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
/* Enable UPLL clock */
- writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+ at91_upll_clk_enable();
/* Enable UDPHS clock */
at91_periph_clk_enable(ATMEL_ID_UDPHS);
}
diff --git a/arch/arm/mach-at91/armv7/sama5d4_devices.c b/arch/arm/mach-at91/armv7/sama5d4_devices.c
index ce33cd4..ebb779e 100644
--- a/arch/arm/mach-at91/armv7/sama5d4_devices.c
+++ b/arch/arm/mach-at91/armv7/sama5d4_devices.c
@@ -8,7 +8,6 @@
#include <common.h>
#include <asm/io.h>
#include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
#include <asm/arch/clk.h>
#include <asm/arch/sama5_sfr.h>
#include <asm/arch/sama5d4.h>
@@ -37,10 +36,8 @@ char *get_cpu_name()
#ifdef CONFIG_USB_GADGET_ATMEL_USBA
void at91_udp_hw_init(void)
{
- struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
/* Enable UPLL clock */
- writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+ at91_upll_clk_enable();
/* Enable UDPHS clock */
at91_periph_clk_enable(ATMEL_ID_UDPHS);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 3/4] drivers: usb: atmel: clean up the UTMI PLL code
2015-12-09 7:57 [U-Boot] [PATCH v2 0/4] ARM: at91: add UTMI PLL handle functions Wenyou Yang
2015-12-09 7:57 ` [U-Boot] [PATCH v2 1/4] ARM: at91: clock: add UTMI PLL enable/disable function Wenyou Yang
2015-12-09 7:57 ` [U-Boot] [PATCH v2 2/4] ARM: at91: armv7: clean up UTMI PLL handle code Wenyou Yang
@ 2015-12-09 7:57 ` Wenyou Yang
2015-12-10 9:37 ` Heiko Schocher
2015-12-09 7:57 ` [U-Boot] [PATCH v2 4/4] board: atmel: siemens: clean up " Wenyou Yang
3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2015-12-09 7:57 UTC (permalink / raw)
To: u-boot
Due to introducing the new UTMI PLL clock handle functions,
use these function to reduce the duplicated code.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---
Changes in v2:
- remain asm/io.h include.
drivers/usb/host/ehci-atmel.c | 38 ++++----------------------------------
drivers/usb/host/ohci-at91.c | 20 +++++++-------------
2 files changed, 11 insertions(+), 47 deletions(-)
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index a33fb49..1d7d280 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -7,37 +7,18 @@
*/
#include <common.h>
-#include <watchdog.h>
#include <usb.h>
#include <asm/io.h>
-#include <asm/arch/hardware.h>
-#include <asm/arch/at91_pmc.h>
#include <asm/arch/clk.h>
#include "ehci.h"
-/* Enable UTMI PLL time out 500us
- * 10 times as datasheet specified
- */
-#define EN_UPLL_TIMEOUT 500UL
-
int ehci_hcd_init(int index, enum usb_init_type init,
struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{
- at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
- ulong start_time, tmp_time;
-
- start_time = get_timer(0);
/* Enable UTMI PLL */
- writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
- while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU) {
- WATCHDOG_RESET();
- tmp_time = get_timer(0);
- if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
- printf("ERROR: failed to enable UPLL\n");
- return -1;
- }
- }
+ if (at91_upll_clk_enable())
+ return -1;
/* Enable USB Host clock */
at91_periph_clk_enable(ATMEL_ID_UHPHS);
@@ -51,23 +32,12 @@ int ehci_hcd_init(int index, enum usb_init_type init,
int ehci_hcd_stop(int index)
{
- at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
- ulong start_time, tmp_time;
-
/* Disable USB Host Clock */
at91_periph_clk_disable(ATMEL_ID_UHPHS);
- start_time = get_timer(0);
/* Disable UTMI PLL */
- writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
- while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU) {
- WATCHDOG_RESET();
- tmp_time = get_timer(0);
- if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
- printf("ERROR: failed to stop UPLL\n");
- return -1;
- }
- }
+ if (at91_upll_clk_disable())
+ return -1;
return 0;
}
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index da85111..6ae6959 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -24,17 +24,13 @@ int usb_cpu_init(void)
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
;
#ifdef CONFIG_AT91SAM9N12
- writel(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2, &pmc->usb);
+ at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
#endif
#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
- /* Enable UPLL */
- writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
- &pmc->uckr);
- while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU)
- ;
+ if (at91_upll_clk_enable())
+ return -1;
- /* Select PLLA as input clock of OHCI */
- writel(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10, &pmc->usb);
+ at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
#endif
at91_periph_clk_enable(ATMEL_ID_UHP);
@@ -60,17 +56,15 @@ int usb_cpu_stop(void)
#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
#ifdef CONFIG_AT91SAM9N12
- writel(0, &pmc->usb);
+ at91_usb_clk_init(0);
#endif
/* Disable PLLB */
writel(0, &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
;
#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
- /* Disable UPLL */
- writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
- while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)
- ;
+ if (at91_upll_clk_disable())
+ return -1;
#endif
return 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 4/4] board: atmel: siemens: clean up UTMI PLL code
2015-12-09 7:57 [U-Boot] [PATCH v2 0/4] ARM: at91: add UTMI PLL handle functions Wenyou Yang
` (2 preceding siblings ...)
2015-12-09 7:57 ` [U-Boot] [PATCH v2 3/4] drivers: usb: atmel: clean up the UTMI PLL code Wenyou Yang
@ 2015-12-09 7:57 ` Wenyou Yang
2015-12-10 9:37 ` Heiko Schocher
3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2015-12-09 7:57 UTC (permalink / raw)
To: u-boot
Due to introducing the new UTMI PLL clock handle functions,
use the functions to reduce the duplicated code.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---
Changes in v2: None
board/siemens/corvus/board.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/board/siemens/corvus/board.c b/board/siemens/corvus/board.c
index 8729fe9..658e029 100644
--- a/board/siemens/corvus/board.c
+++ b/board/siemens/corvus/board.c
@@ -207,10 +207,8 @@ int board_early_init_f(void)
/* from ./arch/arm/mach-at91/armv7/sama5d3_devices.c */
void at91_udp_hw_init(void)
{
- struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
/* Enable UPLL clock */
- writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+ at91_upll_clk_enable();
/* Enable UDPHS clock */
at91_periph_clk_enable(ATMEL_ID_UDPHS);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 1/4] ARM: at91: clock: add UTMI PLL enable/disable function
2015-12-09 7:57 ` [U-Boot] [PATCH v2 1/4] ARM: at91: clock: add UTMI PLL enable/disable function Wenyou Yang
@ 2015-12-10 9:36 ` Heiko Schocher
0 siblings, 0 replies; 9+ messages in thread
From: Heiko Schocher @ 2015-12-10 9:36 UTC (permalink / raw)
To: u-boot
Hello Wenyou,
Am 09.12.2015 um 08:57 schrieb Wenyou Yang:
> To avoid the duplicated code, add the UTMI PLL handle functions,
> and add PMC_USB init function too.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> ---
>
> Changes in v2: None
>
> arch/arm/mach-at91/clock.c | 48 +++++++++++++++++++++++++++++++++
> arch/arm/mach-at91/include/mach/clk.h | 3 +++
> 2 files changed, 51 insertions(+)
Tested on the smartweb board, see log:
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/29/steps/shell/logs/tbotlog
Tested-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
> index 823d218..b8f8d48 100644
> --- a/arch/arm/mach-at91/clock.c
> +++ b/arch/arm/mach-at91/clock.c
> @@ -10,6 +10,8 @@
> #include <asm/arch/hardware.h>
> #include <asm/arch/at91_pmc.h>
>
> +#define EN_UPLL_TIMEOUT 500
> +
> void at91_periph_clk_enable(int id)
> {
> struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> @@ -70,3 +72,49 @@ void at91_system_clk_disable(int sys_clk)
>
> writel(sys_clk, &pmc->scdr);
> }
> +
> +int at91_upll_clk_enable(void)
> +{
> + struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> + ulong start_time, tmp_time;
> +
> + if ((readl(&pmc->uckr) & AT91_PMC_UPLLEN) == AT91_PMC_UPLLEN)
> + return 0;
> +
> + start_time = get_timer(0);
> + writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
> + while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU) {
> + tmp_time = get_timer(0);
> + if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
> + printf("ERROR: failed to enable UPLL\n");
> + return -1;
> + }
> + }
> +
> + return 0;
> +}
> +
> +int at91_upll_clk_disable(void)
> +{
> + struct at91_pmc *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> + ulong start_time, tmp_time;
> +
> + start_time = get_timer(0);
> + writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
> + while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU) {
> + tmp_time = get_timer(0);
> + if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
> + printf("ERROR: failed to stop UPLL\n");
> + return -1;
> + }
> + }
> +
> + return 0;
> +}
> +
> +void at91_usb_clk_init(u32 value)
> +{
> + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> +
> + writel(value, &pmc->usb);
> +}
> diff --git a/arch/arm/mach-at91/include/mach/clk.h b/arch/arm/mach-at91/include/mach/clk.h
> index bef4e1c..b2604ef 100644
> --- a/arch/arm/mach-at91/include/mach/clk.h
> +++ b/arch/arm/mach-at91/include/mach/clk.h
> @@ -130,5 +130,8 @@ int at91_enable_periph_generated_clk(u32 id, u32 clk_source, u32 div);
> u32 at91_get_periph_generated_clk(u32 id);
> void at91_system_clk_enable(int sys_clk);
> void at91_system_clk_disable(int sys_clk);
> +int at91_upll_clk_enable(void);
> +int at91_upll_clk_disable(void);
> +void at91_usb_clk_init(u32 value);
>
> #endif /* __ASM_ARM_ARCH_CLK_H__ */
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 2/4] ARM: at91: armv7: clean up UTMI PLL handle code
2015-12-09 7:57 ` [U-Boot] [PATCH v2 2/4] ARM: at91: armv7: clean up UTMI PLL handle code Wenyou Yang
@ 2015-12-10 9:36 ` Heiko Schocher
0 siblings, 0 replies; 9+ messages in thread
From: Heiko Schocher @ 2015-12-10 9:36 UTC (permalink / raw)
To: u-boot
Hello Wenyou,
Am 09.12.2015 um 08:57 schrieb Wenyou Yang:
> Due to introducing the UTMI PLL enable function, use this function
> to reduce the duplicated code.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> ---
>
> Changes in v2: None
>
> arch/arm/mach-at91/armv7/sama5d2_devices.c | 5 +----
> arch/arm/mach-at91/armv7/sama5d3_devices.c | 5 +----
> arch/arm/mach-at91/armv7/sama5d4_devices.c | 5 +----
> 3 files changed, 3 insertions(+), 12 deletions(-)
Tested on the smartweb board, see log:
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/29/steps/shell/logs/tbotlog
Tested-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/arch/arm/mach-at91/armv7/sama5d2_devices.c b/arch/arm/mach-at91/armv7/sama5d2_devices.c
> index 88f8f2c..978eac2 100644
> --- a/arch/arm/mach-at91/armv7/sama5d2_devices.c
> +++ b/arch/arm/mach-at91/armv7/sama5d2_devices.c
> @@ -7,7 +7,6 @@
>
> #include <common.h>
> #include <asm/io.h>
> -#include <asm/arch/at91_pmc.h>
> #include <asm/arch/clk.h>
> #include <asm/arch/sama5d2.h>
>
> @@ -48,9 +47,7 @@ char *get_cpu_name()
> #ifdef CONFIG_USB_GADGET_ATMEL_USBA
> void at91_udp_hw_init(void)
> {
> - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> -
> - writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
> + at91_upll_clk_enable();
>
> at91_periph_clk_enable(ATMEL_ID_UDPHS);
> }
> diff --git a/arch/arm/mach-at91/armv7/sama5d3_devices.c b/arch/arm/mach-at91/armv7/sama5d3_devices.c
> index 78ecfc8..64ac262 100644
> --- a/arch/arm/mach-at91/armv7/sama5d3_devices.c
> +++ b/arch/arm/mach-at91/armv7/sama5d3_devices.c
> @@ -8,7 +8,6 @@
> #include <common.h>
> #include <asm/arch/sama5d3.h>
> #include <asm/arch/at91_common.h>
> -#include <asm/arch/at91_pmc.h>
> #include <asm/arch/clk.h>
> #include <asm/arch/gpio.h>
> #include <asm/io.h>
> @@ -208,10 +207,8 @@ void at91_lcd_hw_init(void)
> #ifdef CONFIG_USB_GADGET_ATMEL_USBA
> void at91_udp_hw_init(void)
> {
> - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> -
> /* Enable UPLL clock */
> - writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
> + at91_upll_clk_enable();
> /* Enable UDPHS clock */
> at91_periph_clk_enable(ATMEL_ID_UDPHS);
> }
> diff --git a/arch/arm/mach-at91/armv7/sama5d4_devices.c b/arch/arm/mach-at91/armv7/sama5d4_devices.c
> index ce33cd4..ebb779e 100644
> --- a/arch/arm/mach-at91/armv7/sama5d4_devices.c
> +++ b/arch/arm/mach-at91/armv7/sama5d4_devices.c
> @@ -8,7 +8,6 @@
> #include <common.h>
> #include <asm/io.h>
> #include <asm/arch/at91_common.h>
> -#include <asm/arch/at91_pmc.h>
> #include <asm/arch/clk.h>
> #include <asm/arch/sama5_sfr.h>
> #include <asm/arch/sama5d4.h>
> @@ -37,10 +36,8 @@ char *get_cpu_name()
> #ifdef CONFIG_USB_GADGET_ATMEL_USBA
> void at91_udp_hw_init(void)
> {
> - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> -
> /* Enable UPLL clock */
> - writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
> + at91_upll_clk_enable();
> /* Enable UDPHS clock */
> at91_periph_clk_enable(ATMEL_ID_UDPHS);
> }
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 3/4] drivers: usb: atmel: clean up the UTMI PLL code
2015-12-09 7:57 ` [U-Boot] [PATCH v2 3/4] drivers: usb: atmel: clean up the UTMI PLL code Wenyou Yang
@ 2015-12-10 9:37 ` Heiko Schocher
0 siblings, 0 replies; 9+ messages in thread
From: Heiko Schocher @ 2015-12-10 9:37 UTC (permalink / raw)
To: u-boot
Hello Wenyou,
Am 09.12.2015 um 08:57 schrieb Wenyou Yang:
> Due to introducing the new UTMI PLL clock handle functions,
> use these function to reduce the duplicated code.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> ---
>
> Changes in v2:
> - remain asm/io.h include.
>
> drivers/usb/host/ehci-atmel.c | 38 ++++----------------------------------
> drivers/usb/host/ohci-at91.c | 20 +++++++-------------
> 2 files changed, 11 insertions(+), 47 deletions(-)
Tested on the smartweb board, see log:
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/29/steps/shell/logs/tbotlog
Tested-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
> index a33fb49..1d7d280 100644
> --- a/drivers/usb/host/ehci-atmel.c
> +++ b/drivers/usb/host/ehci-atmel.c
> @@ -7,37 +7,18 @@
> */
>
> #include <common.h>
> -#include <watchdog.h>
> #include <usb.h>
> #include <asm/io.h>
> -#include <asm/arch/hardware.h>
> -#include <asm/arch/at91_pmc.h>
> #include <asm/arch/clk.h>
>
> #include "ehci.h"
>
> -/* Enable UTMI PLL time out 500us
> - * 10 times as datasheet specified
> - */
> -#define EN_UPLL_TIMEOUT 500UL
> -
> int ehci_hcd_init(int index, enum usb_init_type init,
> struct ehci_hccr **hccr, struct ehci_hcor **hcor)
> {
> - at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> - ulong start_time, tmp_time;
> -
> - start_time = get_timer(0);
> /* Enable UTMI PLL */
> - writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
> - while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU) {
> - WATCHDOG_RESET();
> - tmp_time = get_timer(0);
> - if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
> - printf("ERROR: failed to enable UPLL\n");
> - return -1;
> - }
> - }
> + if (at91_upll_clk_enable())
> + return -1;
>
> /* Enable USB Host clock */
> at91_periph_clk_enable(ATMEL_ID_UHPHS);
> @@ -51,23 +32,12 @@ int ehci_hcd_init(int index, enum usb_init_type init,
>
> int ehci_hcd_stop(int index)
> {
> - at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
> - ulong start_time, tmp_time;
> -
> /* Disable USB Host Clock */
> at91_periph_clk_disable(ATMEL_ID_UHPHS);
>
> - start_time = get_timer(0);
> /* Disable UTMI PLL */
> - writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
> - while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU) {
> - WATCHDOG_RESET();
> - tmp_time = get_timer(0);
> - if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
> - printf("ERROR: failed to stop UPLL\n");
> - return -1;
> - }
> - }
> + if (at91_upll_clk_disable())
> + return -1;
>
> return 0;
> }
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index da85111..6ae6959 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -24,17 +24,13 @@ int usb_cpu_init(void)
> while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
> ;
> #ifdef CONFIG_AT91SAM9N12
> - writel(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2, &pmc->usb);
> + at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
> #endif
> #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
> - /* Enable UPLL */
> - writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
> - &pmc->uckr);
> - while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU)
> - ;
> + if (at91_upll_clk_enable())
> + return -1;
>
> - /* Select PLLA as input clock of OHCI */
> - writel(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10, &pmc->usb);
> + at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
> #endif
>
> at91_periph_clk_enable(ATMEL_ID_UHP);
> @@ -60,17 +56,15 @@ int usb_cpu_stop(void)
>
> #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
> #ifdef CONFIG_AT91SAM9N12
> - writel(0, &pmc->usb);
> + at91_usb_clk_init(0);
> #endif
> /* Disable PLLB */
> writel(0, &pmc->pllbr);
> while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
> ;
> #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
> - /* Disable UPLL */
> - writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
> - while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)
> - ;
> + if (at91_upll_clk_disable())
> + return -1;
> #endif
>
> return 0;
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH v2 4/4] board: atmel: siemens: clean up UTMI PLL code
2015-12-09 7:57 ` [U-Boot] [PATCH v2 4/4] board: atmel: siemens: clean up " Wenyou Yang
@ 2015-12-10 9:37 ` Heiko Schocher
0 siblings, 0 replies; 9+ messages in thread
From: Heiko Schocher @ 2015-12-10 9:37 UTC (permalink / raw)
To: u-boot
Hello Wenyou,
Am 09.12.2015 um 08:57 schrieb Wenyou Yang:
> Due to introducing the new UTMI PLL clock handle functions,
> use the functions to reduce the duplicated code.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> ---
>
> Changes in v2: None
>
> board/siemens/corvus/board.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Tested on the smartweb board, see log:
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/29/steps/shell/logs/tbotlog
Tested-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/board/siemens/corvus/board.c b/board/siemens/corvus/board.c
> index 8729fe9..658e029 100644
> --- a/board/siemens/corvus/board.c
> +++ b/board/siemens/corvus/board.c
> @@ -207,10 +207,8 @@ int board_early_init_f(void)
> /* from ./arch/arm/mach-at91/armv7/sama5d3_devices.c */
> void at91_udp_hw_init(void)
> {
> - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> -
> /* Enable UPLL clock */
> - writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
> + at91_upll_clk_enable();
>
> /* Enable UDPHS clock */
> at91_periph_clk_enable(ATMEL_ID_UDPHS);
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-12-10 9:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-09 7:57 [U-Boot] [PATCH v2 0/4] ARM: at91: add UTMI PLL handle functions Wenyou Yang
2015-12-09 7:57 ` [U-Boot] [PATCH v2 1/4] ARM: at91: clock: add UTMI PLL enable/disable function Wenyou Yang
2015-12-10 9:36 ` Heiko Schocher
2015-12-09 7:57 ` [U-Boot] [PATCH v2 2/4] ARM: at91: armv7: clean up UTMI PLL handle code Wenyou Yang
2015-12-10 9:36 ` Heiko Schocher
2015-12-09 7:57 ` [U-Boot] [PATCH v2 3/4] drivers: usb: atmel: clean up the UTMI PLL code Wenyou Yang
2015-12-10 9:37 ` Heiko Schocher
2015-12-09 7:57 ` [U-Boot] [PATCH v2 4/4] board: atmel: siemens: clean up " Wenyou Yang
2015-12-10 9:37 ` Heiko Schocher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.