All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/4] ARM: atmel: use pcr to control clock
@ 2014-08-06  9:24 Bo Shen
  2014-08-06  9:24 ` [U-Boot] [PATCH 1/4] ARM: atmel: use pcr to enable or disable peripheral clock Bo Shen
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Bo Shen @ 2014-08-06  9:24 UTC (permalink / raw)
  To: u-boot

When the SoC has pcr (peripheral control register), then switch
to use it to enable or disable clock.


Bo Shen (4):
  ARM: atmel: use pcr to enable or disable peripheral clock
  ARM: atmel: add pcr related definition
  USB: ohci-at91: use pcr to enable or disable clock
  USB: ehci-atmel: use pcr to enable or disable clock

 arch/arm/cpu/armv7/at91/clock.c           | 24 ++++++++++++++++++++----
 arch/arm/include/asm/arch-at91/at91_pmc.h |  6 +++++-
 arch/arm/include/asm/arch-at91/clk.h      |  1 +
 arch/arm/include/asm/arch-at91/sama5d3.h  |  1 +
 drivers/usb/host/ehci-atmel.c             |  8 ++++++++
 drivers/usb/host/ohci-at91.c              |  8 ++++----
 6 files changed, 39 insertions(+), 9 deletions(-)

-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 1/4] ARM: atmel: use pcr to enable or disable peripheral clock
  2014-08-06  9:24 [U-Boot] [PATCH 0/4] ARM: atmel: use pcr to control clock Bo Shen
@ 2014-08-06  9:24 ` Bo Shen
  2014-09-19  6:31   ` [U-Boot] [U-Boot, " Andreas Bießmann
  2014-08-06  9:24 ` [U-Boot] [PATCH 2/4] ARM: atmel: add pcr related definition Bo Shen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Bo Shen @ 2014-08-06  9:24 UTC (permalink / raw)
  To: u-boot

When use pcr (peripheral control register), then we won't need
to care about the peripheral ID.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---

 arch/arm/cpu/armv7/at91/clock.c           | 24 ++++++++++++++++++++----
 arch/arm/include/asm/arch-at91/at91_pmc.h |  4 ++++
 arch/arm/include/asm/arch-at91/clk.h      |  1 +
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv7/at91/clock.c b/arch/arm/cpu/armv7/at91/clock.c
index 1588e0c..36ed4a6 100644
--- a/arch/arm/cpu/armv7/at91/clock.c
+++ b/arch/arm/cpu/armv7/at91/clock.c
@@ -114,9 +114,25 @@ int at91_clock_init(unsigned long main_clock)
 void at91_periph_clk_enable(int id)
 {
 	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+	u32 regval;
 
-	if (id > 31)
-		writel(1 << (id - 32), &pmc->pcer1);
-	else
-		writel(1 << id, &pmc->pcer);
+	if (id > AT91_PMC_PCR_PID_MASK)
+		return;
+
+	regval = AT91_PMC_PCR_EN | AT91_PMC_PCR_CMD_WRITE | id;
+
+	writel(regval, &pmc->pcr);
+}
+
+void at91_periph_clk_disable(int id)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+	u32 regval;
+
+	if (id > AT91_PMC_PCR_PID_MASK)
+		return;
+
+	regval = AT91_PMC_PCR_CMD_WRITE | id;
+
+	writel(regval, &pmc->pcr);
 }
diff --git a/arch/arm/include/asm/arch-at91/at91_pmc.h b/arch/arm/include/asm/arch-at91/at91_pmc.h
index 04f6239..bef5793 100644
--- a/arch/arm/include/asm/arch-at91/at91_pmc.h
+++ b/arch/arm/include/asm/arch-at91/at91_pmc.h
@@ -147,6 +147,10 @@ typedef struct at91_pmc {
 #define AT91_PMC_IXR_PCKRDY3		0x00000800
 #define AT91_PMC_IXR_MOSCSELS		0x00010000
 
+#define AT91_PMC_PCR_PID_MASK		(0x3f)
+#define AT91_PMC_PCR_CMD_WRITE		(0x1 << 12)
+#define AT91_PMC_PCR_EN			(0x1 << 28)
+
 #define		AT91_PMC_PCK		(1 <<  0)		/* Processor Clock */
 #define		AT91RM9200_PMC_UDP	(1 <<  1)		/* USB Devcice Port Clock [AT91RM9200 only] */
 #define		AT91RM9200_PMC_MCKUDP	(1 <<  2)		/* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */
diff --git a/arch/arm/include/asm/arch-at91/clk.h b/arch/arm/include/asm/arch-at91/clk.h
index ce9e28f..4076a78 100644
--- a/arch/arm/include/asm/arch-at91/clk.h
+++ b/arch/arm/include/asm/arch-at91/clk.h
@@ -80,4 +80,5 @@ static inline unsigned long get_mci_clk_rate(void)
 
 int at91_clock_init(unsigned long main_clock);
 void at91_periph_clk_enable(int id);
+void at91_periph_clk_disable(int id);
 #endif /* __ASM_ARM_ARCH_CLK_H__ */
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 2/4] ARM: atmel: add pcr related definition
  2014-08-06  9:24 [U-Boot] [PATCH 0/4] ARM: atmel: use pcr to control clock Bo Shen
  2014-08-06  9:24 ` [U-Boot] [PATCH 1/4] ARM: atmel: use pcr to enable or disable peripheral clock Bo Shen
@ 2014-08-06  9:24 ` Bo Shen
  2014-09-19  6:31   ` [U-Boot] [U-Boot,2/4] " Andreas Bießmann
  2014-08-06  9:24 ` [U-Boot] [PATCH 3/4] USB: ohci-at91: use pcr to enable or disable clock Bo Shen
  2014-08-06  9:24 ` [U-Boot] [PATCH 4/4] USB: ehci-atmel: " Bo Shen
  3 siblings, 1 reply; 9+ messages in thread
From: Bo Shen @ 2014-08-06  9:24 UTC (permalink / raw)
  To: u-boot

Using CPU_HAS_PCR micro to present the SoC has pcr
(peripheral control register).

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---

 arch/arm/include/asm/arch-at91/at91_pmc.h | 2 +-
 arch/arm/include/asm/arch-at91/sama5d3.h  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-at91/at91_pmc.h b/arch/arm/include/asm/arch-at91/at91_pmc.h
index bef5793..27331ff 100644
--- a/arch/arm/include/asm/arch-at91/at91_pmc.h
+++ b/arch/arm/include/asm/arch-at91/at91_pmc.h
@@ -54,7 +54,7 @@ typedef struct at91_pmc {
 	u32	reserved5[21];
 	u32	wpmr;		/* 0xE4 Write Protect Mode Register (CAP0) */
 	u32	wpsr;		/* 0xE8 Write Protect Status Register (CAP0) */
-#ifdef CONFIG_SAMA5D3
+#ifdef CPU_HAS_PCR
 	u32	reserved6[8];
 	u32	pcer1;		/* 0x100 Periperial Clock Enable Register 1 */
 	u32	pcdr1;		/* 0x104 Periperial Clock Disable Register 1 */
diff --git a/arch/arm/include/asm/arch-at91/sama5d3.h b/arch/arm/include/asm/arch-at91/sama5d3.h
index 6d936f4..f7bc4ad 100644
--- a/arch/arm/include/asm/arch-at91/sama5d3.h
+++ b/arch/arm/include/asm/arch-at91/sama5d3.h
@@ -188,6 +188,7 @@
 #define ATMEL_PIO_PORTS		5
 #define CPU_HAS_PIO3
 #define PIO_SCDR_DIV		0x3fff
+#define CPU_HAS_PCR
 
 /*
  * PMECC table in ROM
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 3/4] USB: ohci-at91: use pcr to enable or disable clock
  2014-08-06  9:24 [U-Boot] [PATCH 0/4] ARM: atmel: use pcr to control clock Bo Shen
  2014-08-06  9:24 ` [U-Boot] [PATCH 1/4] ARM: atmel: use pcr to enable or disable peripheral clock Bo Shen
  2014-08-06  9:24 ` [U-Boot] [PATCH 2/4] ARM: atmel: add pcr related definition Bo Shen
@ 2014-08-06  9:24 ` Bo Shen
  2014-09-19  6:32   ` [U-Boot] [U-Boot,3/4] " Andreas Bießmann
  2014-08-06  9:24 ` [U-Boot] [PATCH 4/4] USB: ehci-atmel: " Bo Shen
  3 siblings, 1 reply; 9+ messages in thread
From: Bo Shen @ 2014-08-06  9:24 UTC (permalink / raw)
  To: u-boot

If the SoC has pcr, we use pcr (peripheral control register)
to enable or disable clock.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---

 drivers/usb/host/ohci-at91.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index c24505e..820e2e5 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -38,8 +38,8 @@ int usb_cpu_init(void)
 #endif
 
 	/* Enable USB host clock. */
-#ifdef CONFIG_SAMA5D3
-	writel(1 << (ATMEL_ID_UHP - 32), &pmc->pcer1);
+#ifdef CPU_HAS_PCR
+	at91_periph_clk_enable(ATMEL_ID_UHP);
 #else
 	writel(1 << ATMEL_ID_UHP, &pmc->pcer);
 #endif
@@ -58,8 +58,8 @@ int usb_cpu_stop(void)
 	at91_pmc_t *pmc	= (at91_pmc_t *)ATMEL_BASE_PMC;
 
 	/* Disable USB host clock. */
-#ifdef CONFIG_SAMA5D3
-	writel(1 << (ATMEL_ID_UHP - 32), &pmc->pcdr1);
+#ifdef CPU_HAS_PCR
+	at91_periph_clk_disable(ATMEL_ID_UHP);
 #else
 	writel(1 << ATMEL_ID_UHP, &pmc->pcdr);
 #endif
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 4/4] USB: ehci-atmel: use pcr to enable or disable clock
  2014-08-06  9:24 [U-Boot] [PATCH 0/4] ARM: atmel: use pcr to control clock Bo Shen
                   ` (2 preceding siblings ...)
  2014-08-06  9:24 ` [U-Boot] [PATCH 3/4] USB: ohci-at91: use pcr to enable or disable clock Bo Shen
@ 2014-08-06  9:24 ` Bo Shen
  2014-09-19  6:32   ` [U-Boot] [U-Boot,4/4] " Andreas Bießmann
  3 siblings, 1 reply; 9+ messages in thread
From: Bo Shen @ 2014-08-06  9:24 UTC (permalink / raw)
  To: u-boot

If the SoC has pcr, we use pcr (peripheral control register)
to enable or disable clock.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---

 drivers/usb/host/ehci-atmel.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 9ffe501..9a8f004 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -40,7 +40,11 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	}
 
 	/* Enable USB Host clock */
+#ifdef CPU_HAS_PCR
+	at91_periph_clk_enable(ATMEL_ID_UHPHS);
+#else
 	writel(1 << ATMEL_ID_UHPHS, &pmc->pcer);
+#endif
 
 	*hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI;
 	*hcor = (struct ehci_hcor *)((uint32_t)*hccr +
@@ -55,7 +59,11 @@ int ehci_hcd_stop(int index)
 	ulong start_time, tmp_time;
 
 	/* Disable USB Host Clock */
+#ifdef CPU_HAS_PCR
+	at91_periph_clk_disable(ATMEL_ID_UHPHS);
+#else
 	writel(1 << ATMEL_ID_UHPHS, &pmc->pcdr);
+#endif
 
 	start_time = get_timer(0);
 	/* Disable UTMI PLL */
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [U-Boot, 1/4] ARM: atmel: use pcr to enable or disable peripheral clock
  2014-08-06  9:24 ` [U-Boot] [PATCH 1/4] ARM: atmel: use pcr to enable or disable peripheral clock Bo Shen
@ 2014-09-19  6:31   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2014-09-19  6:31 UTC (permalink / raw)
  To: u-boot

Dear Bo Shen,

Bo Shen <voice.shen@atmel.com> writes:
>When use pcr (peripheral control register), then we won't need
>to care about the peripheral ID.
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>---
>
> arch/arm/cpu/armv7/at91/clock.c           | 24 ++++++++++++++++++++----
> arch/arm/include/asm/arch-at91/at91_pmc.h |  4 ++++
> arch/arm/include/asm/arch-at91/clk.h      |  1 +
> 3 files changed, 25 insertions(+), 4 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] [U-Boot,2/4] ARM: atmel: add pcr related definition
  2014-08-06  9:24 ` [U-Boot] [PATCH 2/4] ARM: atmel: add pcr related definition Bo Shen
@ 2014-09-19  6:31   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2014-09-19  6:31 UTC (permalink / raw)
  To: u-boot

Dear Bo Shen,

Bo Shen <voice.shen@atmel.com> writes:
>Using CPU_HAS_PCR micro to present the SoC has pcr
>(peripheral control register).
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>---
>
> arch/arm/include/asm/arch-at91/at91_pmc.h | 2 +-
> arch/arm/include/asm/arch-at91/sama5d3.h  | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] [U-Boot,3/4] USB: ohci-at91: use pcr to enable or disable clock
  2014-08-06  9:24 ` [U-Boot] [PATCH 3/4] USB: ohci-at91: use pcr to enable or disable clock Bo Shen
@ 2014-09-19  6:32   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2014-09-19  6:32 UTC (permalink / raw)
  To: u-boot

Dear Bo Shen,

Bo Shen <voice.shen@atmel.com> writes:
>If the SoC has pcr, we use pcr (peripheral control register)
>to enable or disable clock.
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>---
>
> drivers/usb/host/ohci-at91.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [U-Boot] [U-Boot,4/4] USB: ehci-atmel: use pcr to enable or disable clock
  2014-08-06  9:24 ` [U-Boot] [PATCH 4/4] USB: ehci-atmel: " Bo Shen
@ 2014-09-19  6:32   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2014-09-19  6:32 UTC (permalink / raw)
  To: u-boot

Dear Bo Shen,

Bo Shen <voice.shen@atmel.com> writes:
>If the SoC has pcr, we use pcr (peripheral control register)
>to enable or disable clock.
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>---
>
> drivers/usb/host/ehci-atmel.c | 8 ++++++++
> 1 file changed, 8 insertions(+)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-09-19  6:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06  9:24 [U-Boot] [PATCH 0/4] ARM: atmel: use pcr to control clock Bo Shen
2014-08-06  9:24 ` [U-Boot] [PATCH 1/4] ARM: atmel: use pcr to enable or disable peripheral clock Bo Shen
2014-09-19  6:31   ` [U-Boot] [U-Boot, " Andreas Bießmann
2014-08-06  9:24 ` [U-Boot] [PATCH 2/4] ARM: atmel: add pcr related definition Bo Shen
2014-09-19  6:31   ` [U-Boot] [U-Boot,2/4] " Andreas Bießmann
2014-08-06  9:24 ` [U-Boot] [PATCH 3/4] USB: ohci-at91: use pcr to enable or disable clock Bo Shen
2014-09-19  6:32   ` [U-Boot] [U-Boot,3/4] " Andreas Bießmann
2014-08-06  9:24 ` [U-Boot] [PATCH 4/4] USB: ehci-atmel: " Bo Shen
2014-09-19  6:32   ` [U-Boot] [U-Boot,4/4] " Andreas Bießmann

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.