ARM: atmel: use pcr to control clock
Subsystems (5)
cover ARM: atmel: use pcr to control clock
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(-)
Signature · 1 line
1.8.5.2
PATCH 1/4 ARM: atmel: use pcr to enable or disable peripheral clock
When use pcr (peripheral control register), then we won't need to care about the peripheral ID.
---
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(-)
arch/arm/cpu/armv7/at91/clock.c +20 -4
@@ -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); }
arch/arm/include/asm/arch-at91/at91_pmc.h +4 -0
@@ -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] */
arch/arm/include/asm/arch-at91/clk.h +1 -0
@@ -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__ */
Signature · 1 line
1.8.5.2
PATCH 1/4 ARM: atmel: use pcr to enable or disable peripheral clock
Dear Bo Shen,
Quoted 10 lines · Bo Shen
When use pcr (peripheral control register), then we won't need to care about the peripheral ID.
Signed-off-by Bo Shen <[email protected]>---
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
PATCH 2/4 ARM: atmel: add pcr related definition
In reply to Bo ShenUsing CPU_HAS_PCR micro to present the SoC has pcr (peripheral control register).
---
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(-)
arch/arm/include/asm/arch-at91/at91_pmc.h +1 -1
@@ -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 */
arch/arm/include/asm/arch-at91/sama5d3.h +1 -0
@@ -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
Signature · 1 line
1.8.5.2
PATCH 2/4 ARM: atmel: add pcr related definition
Dear Bo Shen,
Quoted 9 lines · Bo Shen
Using
CPU_HAS_PCRmicro to present the SoC has pcr (peripheral control register).Signed-off-by Bo Shen <[email protected]>---
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
PATCH 3/4 USB: ohci-at91: use pcr to enable or disable clock
In reply to Bo ShenIf the SoC has pcr, we use pcr (peripheral control register) to enable or disable clock.
---
drivers/usb/host/ohci-at91.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/ohci-at91.c +4 -4
@@ -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
Signature · 1 line
1.8.5.2
PATCH 3/4 USB: ohci-at91: use pcr to enable or disable clock
Dear Bo Shen,
Quoted 8 lines · Bo Shen
If the SoC has pcr, we use pcr (peripheral control register) to enable or disable clock.
Signed-off-by Bo Shen <[email protected]>---
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
PATCH 4/4 USB: ehci-atmel: use pcr to enable or disable clock
In reply to Bo ShenIf the SoC has pcr, we use pcr (peripheral control register) to enable or disable clock.
---
drivers/usb/host/ehci-atmel.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/host/ehci-atmel.c +8 -0
@@ -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 */
Signature · 1 line
1.8.5.2
PATCH 4/4 USB: ehci-atmel: use pcr to enable or disable clock
Dear Bo Shen,
Quoted 8 lines · Bo Shen
If the SoC has pcr, we use pcr (peripheral control register) to enable or disable clock.
Signed-off-by Bo Shen <[email protected]>---
drivers/usb/host/ehci-atmel.c| 8 ++++++++1 file changed, 8 insertions(+)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann