[U-Boot] [PATCH v2 0/3] ARM: at91: add PMC_PLLICPR init function

To reduce the duplicated code, add PLLICPR init function, use the function to clean up the PMC_PLLICPR directly writing code.
It is based on the following patch set. [PATCH 0/5] ARM: at91: improve peripheral and system clock handle functions [PATCH 0/4] ARM: at91: add UTMI PLL handle functions [PATCH 0/3] ARM: at91: add PLLB handle functions
Changes in v2: - move at91_pllicpr_init() definition to the common file, clock.c. - fix checkpatch errors.
Wenyou Yang (3): ARM: at91: clock: add PMC_PLLICPR init function ARM: at91: clean up the PMC_PLLICPR init code board: atmel: clean up the PMC_PLLICPR init code
arch/arm/mach-at91/clock.c | 7 +++++++ arch/arm/mach-at91/include/mach/at91_pmc.h | 7 +++++++ arch/arm/mach-at91/include/mach/clk.h | 1 + arch/arm/mach-at91/spl_at91.c | 5 +---- board/atmel/sama5d3_xplained/sama5d3_xplained.c | 4 +--- board/atmel/sama5d3xek/sama5d3xek.c | 4 +--- board/atmel/sama5d4_xplained/sama5d4_xplained.c | 4 +--- board/atmel/sama5d4ek/sama5d4ek.c | 4 +--- 8 files changed, 20 insertions(+), 16 deletions(-)

To avoid the duplicated code, add the PMC_PLLICPR init function.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com ---
Changes in v2: - move at91_pllicpr_init() definition to the common file, clock.c. - fix checkpatch errors.
arch/arm/mach-at91/clock.c | 7 +++++++ arch/arm/mach-at91/include/mach/at91_pmc.h | 7 +++++++ arch/arm/mach-at91/include/mach/clk.h | 1 + 3 files changed, 15 insertions(+)
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c index b8f8d48..885d6fe 100644 --- a/arch/arm/mach-at91/clock.c +++ b/arch/arm/mach-at91/clock.c @@ -118,3 +118,10 @@ void at91_usb_clk_init(u32 value)
writel(value, &pmc->usb); } + +void at91_pllicpr_init(u32 icpr) +{ + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; + + writel(icpr, &pmc->pllicpr); +} diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h index eb40194..7684f09 100644 --- a/arch/arm/mach-at91/include/mach/at91_pmc.h +++ b/arch/arm/mach-at91/include/mach/at91_pmc.h @@ -246,4 +246,11 @@ typedef struct at91_pmc { #define AT91_PMC_GCKRDY (1 << 24)
#define AT91_PMC_PROTKEY 0x504d4301 /* Activation Code */ + +/* PLL Charge Pump Current Register (PMC_PLLICPR) */ +#define AT91_PMC_ICP_PLLA(x) (((x) & 0x3) << 0) +#define AT91_PMC_IPLL_PLLA(x) (((x) & 0x7) << 8) +#define AT91_PMC_ICP_PLLU(x) (((x) & 0x3) << 16) +#define AT91_PMC_IVCO_PLLU(x) (((x) & 0x3) << 24) + #endif diff --git a/arch/arm/mach-at91/include/mach/clk.h b/arch/arm/mach-at91/include/mach/clk.h index 64dec52..8577c74 100644 --- a/arch/arm/mach-at91/include/mach/clk.h +++ b/arch/arm/mach-at91/include/mach/clk.h @@ -135,5 +135,6 @@ int at91_upll_clk_disable(void); void at91_usb_clk_init(u32 value); int at91_pllb_clk_enable(u32 pllbr); int at91_pllb_clk_disable(void); +void at91_pllicpr_init(u32 icpr);
#endif /* __ASM_ARM_ARCH_CLK_H__ */

Hello Wenyou,
Am 09.12.2015 um 08:38 schrieb Wenyou Yang:
To avoid the duplicated code, add the PMC_PLLICPR init function.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com
Changes in v2:
- move at91_pllicpr_init() definition to the common file, clock.c.
- fix checkpatch errors.
arch/arm/mach-at91/clock.c | 7 +++++++ arch/arm/mach-at91/include/mach/at91_pmc.h | 7 +++++++ arch/arm/mach-at91/include/mach/clk.h | 1 + 3 files changed, 15 insertions(+)
Tested on the smartweb board, see log: http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/29/steps/shell/...
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 b8f8d48..885d6fe 100644 --- a/arch/arm/mach-at91/clock.c +++ b/arch/arm/mach-at91/clock.c @@ -118,3 +118,10 @@ void at91_usb_clk_init(u32 value)
writel(value, &pmc->usb); }
+void at91_pllicpr_init(u32 icpr) +{
- struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
- writel(icpr, &pmc->pllicpr);
+} diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h index eb40194..7684f09 100644 --- a/arch/arm/mach-at91/include/mach/at91_pmc.h +++ b/arch/arm/mach-at91/include/mach/at91_pmc.h @@ -246,4 +246,11 @@ typedef struct at91_pmc { #define AT91_PMC_GCKRDY (1 << 24)
#define AT91_PMC_PROTKEY 0x504d4301 /* Activation Code */
+/* PLL Charge Pump Current Register (PMC_PLLICPR) */ +#define AT91_PMC_ICP_PLLA(x) (((x) & 0x3) << 0) +#define AT91_PMC_IPLL_PLLA(x) (((x) & 0x7) << 8) +#define AT91_PMC_ICP_PLLU(x) (((x) & 0x3) << 16) +#define AT91_PMC_IVCO_PLLU(x) (((x) & 0x3) << 24)
- #endif
diff --git a/arch/arm/mach-at91/include/mach/clk.h b/arch/arm/mach-at91/include/mach/clk.h index 64dec52..8577c74 100644 --- a/arch/arm/mach-at91/include/mach/clk.h +++ b/arch/arm/mach-at91/include/mach/clk.h @@ -135,5 +135,6 @@ int at91_upll_clk_disable(void); void at91_usb_clk_init(u32 value); int at91_pllb_clk_enable(u32 pllbr); int at91_pllb_clk_disable(void); +void at91_pllicpr_init(u32 icpr);
#endif /* __ASM_ARM_ARCH_CLK_H__ */

Due to introducing the PMC_PLLICPR init function, use this function to clean up the code.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com ---
Changes in v2: None
arch/arm/mach-at91/spl_at91.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c index b19f95b..cc3341a 100644 --- a/arch/arm/mach-at91/spl_at91.c +++ b/arch/arm/mach-at91/spl_at91.c @@ -14,7 +14,6 @@ #include <asm/arch/at91_common.h> #include <asm/arch/at91sam9_matrix.h> #include <asm/arch/at91_pit.h> -#include <asm/arch/at91_pmc.h> #include <asm/arch/at91_rstc.h> #include <asm/arch/at91_wdt.h> #include <asm/arch/clk.h> @@ -77,8 +76,6 @@ void __weak spl_board_init(void)
void board_init_f(ulong dummy) { - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; - lowlevel_clock_init(); at91_disable_wdt();
@@ -86,7 +83,7 @@ void board_init_f(ulong dummy) * At this stage the main oscillator is supposed to be enabled * PCK = MCK = MOSC */ - writel(0x00, &pmc->pllicpr); + at91_pllicpr_init(0x00);
/* Configure PLLA = MOSC * (PLL_MULA + 1) / PLL_DIVA */ at91_plla_init(CONFIG_SYS_AT91_PLLA);

Hello Wenyou,
Am 09.12.2015 um 08:38 schrieb Wenyou Yang:
Due to introducing the PMC_PLLICPR init function, use this function to clean up the code.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com
Changes in v2: None
arch/arm/mach-at91/spl_at91.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Tested on the smartweb board, see log: http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/29/steps/shell/...
Tested-by: Heiko Schocher hs@denx.de
bye, Heiko
diff --git a/arch/arm/mach-at91/spl_at91.c b/arch/arm/mach-at91/spl_at91.c index b19f95b..cc3341a 100644 --- a/arch/arm/mach-at91/spl_at91.c +++ b/arch/arm/mach-at91/spl_at91.c @@ -14,7 +14,6 @@ #include <asm/arch/at91_common.h> #include <asm/arch/at91sam9_matrix.h> #include <asm/arch/at91_pit.h> -#include <asm/arch/at91_pmc.h> #include <asm/arch/at91_rstc.h> #include <asm/arch/at91_wdt.h> #include <asm/arch/clk.h> @@ -77,8 +76,6 @@ void __weak spl_board_init(void)
void board_init_f(ulong dummy) {
- struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
- lowlevel_clock_init(); at91_disable_wdt();
@@ -86,7 +83,7 @@ void board_init_f(ulong dummy) * At this stage the main oscillator is supposed to be enabled * PCK = MCK = MOSC */
- writel(0x00, &pmc->pllicpr);
at91_pllicpr_init(0x00);
/* Configure PLLA = MOSC * (PLL_MULA + 1) / PLL_DIVA */ at91_plla_init(CONFIG_SYS_AT91_PLLA);

Due to introducing the PMC_PLLICPR init function, use this function to clean up the code.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com ---
Changes in v2: None
board/atmel/sama5d3_xplained/sama5d3_xplained.c | 4 +--- board/atmel/sama5d3xek/sama5d3xek.c | 4 +--- board/atmel/sama5d4_xplained/sama5d4_xplained.c | 4 +--- board/atmel/sama5d4ek/sama5d4ek.c | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/board/atmel/sama5d3_xplained/sama5d3_xplained.c b/board/atmel/sama5d3_xplained/sama5d3_xplained.c index d180b41..6532970 100644 --- a/board/atmel/sama5d3_xplained/sama5d3_xplained.c +++ b/board/atmel/sama5d3_xplained/sama5d3_xplained.c @@ -10,7 +10,6 @@ #include <asm/io.h> #include <asm/arch/sama5d3_smc.h> #include <asm/arch/at91_common.h> -#include <asm/arch/at91_pmc.h> #include <asm/arch/at91_rstc.h> #include <asm/arch/gpio.h> #include <asm/arch/clk.h> @@ -198,7 +197,6 @@ void mem_init(void)
void at91_pmc_init(void) { - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 | @@ -207,7 +205,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x3 << 8, &pmc->pllicpr); + at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x3));
tmp = AT91_PMC_MCKR_MDIV_4 | AT91_PMC_MCKR_CSS_PLLA; diff --git a/board/atmel/sama5d3xek/sama5d3xek.c b/board/atmel/sama5d3xek/sama5d3xek.c index 777e57e..7a804e8 100644 --- a/board/atmel/sama5d3xek/sama5d3xek.c +++ b/board/atmel/sama5d3xek/sama5d3xek.c @@ -10,7 +10,6 @@ #include <asm/io.h> #include <asm/arch/sama5d3_smc.h> #include <asm/arch/at91_common.h> -#include <asm/arch/at91_pmc.h> #include <asm/arch/at91_rstc.h> #include <asm/arch/gpio.h> #include <asm/arch/clk.h> @@ -457,7 +456,6 @@ void mem_init(void)
void at91_pmc_init(void) { - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 | @@ -466,7 +464,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x3 << 8, &pmc->pllicpr); + at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x3));
tmp = AT91_PMC_MCKR_MDIV_4 | AT91_PMC_MCKR_CSS_PLLA; diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c b/board/atmel/sama5d4_xplained/sama5d4_xplained.c index e95310c..3fec662 100644 --- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c +++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.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/at91_rstc.h> #include <asm/arch/atmel_mpddrc.h> #include <asm/arch/atmel_usba_udc.h> @@ -397,7 +396,6 @@ void mem_init(void)
void at91_pmc_init(void) { - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 | @@ -406,7 +404,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x0 << 8, &pmc->pllicpr); + at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x0));
tmp = AT91_PMC_MCKR_H32MXDIV | AT91_PMC_MCKR_PLLADIV_2 | diff --git a/board/atmel/sama5d4ek/sama5d4ek.c b/board/atmel/sama5d4ek/sama5d4ek.c index c92e2588..6ccbc64 100644 --- a/board/atmel/sama5d4ek/sama5d4ek.c +++ b/board/atmel/sama5d4ek/sama5d4ek.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/at91_rstc.h> #include <asm/arch/atmel_mpddrc.h> #include <asm/arch/atmel_usba_udc.h> @@ -393,7 +392,6 @@ void mem_init(void)
void at91_pmc_init(void) { - struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 | @@ -402,7 +400,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x0 << 8, &pmc->pllicpr); + at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x0));
tmp = AT91_PMC_MCKR_H32MXDIV | AT91_PMC_MCKR_PLLADIV_2 |

Hello Wenyou,
Am 09.12.2015 um 08:38 schrieb Wenyou Yang:
Due to introducing the PMC_PLLICPR init function, use this function to clean up the code.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com
Changes in v2: None
board/atmel/sama5d3_xplained/sama5d3_xplained.c | 4 +--- board/atmel/sama5d3xek/sama5d3xek.c | 4 +--- board/atmel/sama5d4_xplained/sama5d4_xplained.c | 4 +--- board/atmel/sama5d4ek/sama5d4ek.c | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-)
Tested on the smartweb board, see log: http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/29/steps/shell/...
Tested-by: Heiko Schocher hs@denx.de
bye, Heiko
diff --git a/board/atmel/sama5d3_xplained/sama5d3_xplained.c b/board/atmel/sama5d3_xplained/sama5d3_xplained.c index d180b41..6532970 100644 --- a/board/atmel/sama5d3_xplained/sama5d3_xplained.c +++ b/board/atmel/sama5d3_xplained/sama5d3_xplained.c @@ -10,7 +10,6 @@ #include <asm/io.h> #include <asm/arch/sama5d3_smc.h> #include <asm/arch/at91_common.h> -#include <asm/arch/at91_pmc.h> #include <asm/arch/at91_rstc.h> #include <asm/arch/gpio.h> #include <asm/arch/clk.h> @@ -198,7 +197,6 @@ void mem_init(void)
void at91_pmc_init(void) {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 |
@@ -207,7 +205,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x3 << 8, &pmc->pllicpr);
at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x3));
tmp = AT91_PMC_MCKR_MDIV_4 | AT91_PMC_MCKR_CSS_PLLA;
diff --git a/board/atmel/sama5d3xek/sama5d3xek.c b/board/atmel/sama5d3xek/sama5d3xek.c index 777e57e..7a804e8 100644 --- a/board/atmel/sama5d3xek/sama5d3xek.c +++ b/board/atmel/sama5d3xek/sama5d3xek.c @@ -10,7 +10,6 @@ #include <asm/io.h> #include <asm/arch/sama5d3_smc.h> #include <asm/arch/at91_common.h> -#include <asm/arch/at91_pmc.h> #include <asm/arch/at91_rstc.h> #include <asm/arch/gpio.h> #include <asm/arch/clk.h> @@ -457,7 +456,6 @@ void mem_init(void)
void at91_pmc_init(void) {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 |
@@ -466,7 +464,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x3 << 8, &pmc->pllicpr);
at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x3));
tmp = AT91_PMC_MCKR_MDIV_4 | AT91_PMC_MCKR_CSS_PLLA;
diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c b/board/atmel/sama5d4_xplained/sama5d4_xplained.c index e95310c..3fec662 100644 --- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c +++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.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/at91_rstc.h> #include <asm/arch/atmel_mpddrc.h> #include <asm/arch/atmel_usba_udc.h> @@ -397,7 +396,6 @@ void mem_init(void)
void at91_pmc_init(void) {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 |
@@ -406,7 +404,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x0 << 8, &pmc->pllicpr);
at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x0));
tmp = AT91_PMC_MCKR_H32MXDIV | AT91_PMC_MCKR_PLLADIV_2 |
diff --git a/board/atmel/sama5d4ek/sama5d4ek.c b/board/atmel/sama5d4ek/sama5d4ek.c index c92e2588..6ccbc64 100644 --- a/board/atmel/sama5d4ek/sama5d4ek.c +++ b/board/atmel/sama5d4ek/sama5d4ek.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/at91_rstc.h> #include <asm/arch/atmel_mpddrc.h> #include <asm/arch/atmel_usba_udc.h> @@ -393,7 +392,6 @@ void mem_init(void)
void at91_pmc_init(void) {
struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; u32 tmp;
tmp = AT91_PMC_PLLAR_29 |
@@ -402,7 +400,7 @@ void at91_pmc_init(void) AT91_PMC_PLLXR_DIV(1); at91_plla_init(tmp);
- writel(0x0 << 8, &pmc->pllicpr);
at91_pllicpr_init(AT91_PMC_IPLL_PLLA(0x0));
tmp = AT91_PMC_MCKR_H32MXDIV | AT91_PMC_MCKR_PLLADIV_2 |
participants (2)
-
Heiko Schocher
-
Wenyou Yang