]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: atmel: clean up peripheral clock code
authorWenyou Yang <wenyou.yang@atmel.com>
Wed, 3 Feb 2016 02:16:50 +0000 (10:16 +0800)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Thu, 18 Feb 2016 20:34:40 +0000 (21:34 +0100)
Due to introducing the new peripheral clock handle functions,
use these functions to reduce duplicated code.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Tested-by: Heiko Schocher <hs@denx.de>
[Rebased on current master, fixup for at91rm9200ek]
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
32 files changed:
board/atmel/at91rm9200ek/at91rm9200ek.c
board/atmel/at91rm9200ek/led.c
board/atmel/at91sam9260ek/at91sam9260ek.c
board/atmel/at91sam9261ek/at91sam9261ek.c
board/atmel/at91sam9261ek/led.c
board/atmel/at91sam9263ek/at91sam9263ek.c
board/atmel/at91sam9263ek/led.c
board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
board/atmel/at91sam9m10g45ek/led.c
board/atmel/at91sam9n12ek/at91sam9n12ek.c
board/atmel/at91sam9rlek/at91sam9rlek.c
board/atmel/at91sam9rlek/led.c
board/atmel/at91sam9x5ek/at91sam9x5ek.c
board/atmel/sama5d2_xplained/sama5d2_xplained.c
board/atmel/sama5d3_xplained/sama5d3_xplained.c
board/atmel/sama5d3xek/sama5d3xek.c
board/atmel/sama5d4_xplained/sama5d4_xplained.c
board/atmel/sama5d4ek/sama5d4ek.c
board/bluewater/snapper9260/snapper9260.c
board/calao/usb_a9263/usb_a9263.c
board/egnite/ethernut5/ethernut5.c
board/esd/meesc/meesc.c
board/mini-box/picosam9g45/led.c
board/mini-box/picosam9g45/picosam9g45.c
board/ronetix/pm9261/led.c
board/ronetix/pm9261/pm9261.c
board/ronetix/pm9263/led.c
board/ronetix/pm9263/pm9263.c
board/ronetix/pm9g45/pm9g45.c
board/siemens/corvus/board.c
board/siemens/smartweb/smartweb.c
board/siemens/taurus/taurus.c

index 64ab5726198ac11881594fd785ddd84999cf026c..4ca8106c06c8f2fe4bdc6294d4f511eebc34de27 100644 (file)
@@ -14,7 +14,6 @@
 #include <netdev.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/at91_pio.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/io.h>
 
index 6761b141fb82fd42a51f5e47896d1b9bfaed1b7d..fbe8e3d22cc40e9f210b028c4a854ddc001615f6 100644 (file)
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/at91_pio.h>
 #include <status_led.h>
 
@@ -59,11 +59,9 @@ void red_led_off(void)
 
 void coloured_LED_init (void)
 {
-       at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
        at91_pio_t *pio = (at91_pio_t *)ATMEL_BASE_PIO;
 
-       /* Enable PIOB clock */
-       writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
 
        /* Disable peripherals on LEDs */
        writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
index 7f14af10112c2df0ea2d222c6d783bb5263a5784..98193bfdc6aa89596ea67651c46ff3695f59c702 100644 (file)
@@ -11,7 +11,7 @@
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 #include <atmel_mci.h>
 
@@ -70,11 +70,9 @@ static void at91sam9260ek_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void at91sam9260ek_macb_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA;
 
-       /* Enable EMAC clock */
-       writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC0);
 
        /*
         * Disable pull-up on:
@@ -122,12 +120,9 @@ int board_mmc_init(bd_t *bd)
 
 int board_early_init_f(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clocks for all PIOs */
-       writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
-               (1 << ATMEL_ID_PIOC),
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
        return 0;
 }
index 52504742cd9ceb69eb8655c442c6baf96437497a..7b7cd2c42627796b069bb7313f3dc9350b4a606c 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/arch/at91sam9261_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
@@ -35,7 +34,6 @@ static void at91sam9261ek_nand_hw_init(void)
 {
        struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
        struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        unsigned long csa;
 
        /* Enable CS3 */
@@ -74,7 +72,7 @@ static void at91sam9261ek_nand_hw_init(void)
                       AT91_SMC_MODE_TDF_CYCLE(2),
                       &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
        /* Configure RDY/BSY */
        at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
@@ -161,8 +159,6 @@ void lcd_disable(void)
 
 static void at91sam9261ek_lcd_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        at91_set_A_periph(AT91_PIN_PB1, 0);     /* LCDHSYNC */
        at91_set_A_periph(AT91_PIN_PB2, 0);     /* LCDDOTCK */
        at91_set_A_periph(AT91_PIN_PB3, 0);     /* LCDDEN */
@@ -186,7 +182,7 @@ static void at91sam9261ek_lcd_hw_init(void)
        at91_set_B_periph(AT91_PIN_PB27, 0);    /* LCDD22 */
        at91_set_B_periph(AT91_PIN_PB28, 0);    /* LCDD23 */
 
-       writel(AT91_PMC_HCK1, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_HCK1);
 
        /* For 9G10EK, let U-Boot allocate the framebuffer in SDRAM */
 #ifdef CONFIG_AT91SAM9261EK
index 18a68d8c59e3a526646a4b8041449800d6e74af4..485d7ea81f245a892ab5eee1d39da759b9b1b16b 100644 (file)
@@ -8,17 +8,15 @@
 
 #include <common.h>
 #include <asm/arch/at91sam9261.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/at91_pio.h>
+#include <asm/arch/clk.h>
 #include <asm/io.h>
 
 void coloured_LED_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        /* Enable clock */
-       writel(ATMEL_ID_PIOA, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
 
        at91_set_gpio_output(CONFIG_RED_LED, 1);
        at91_set_gpio_output(CONFIG_GREEN_LED, 1);
index 927adb0d3808e8db45edf515ffd114e600a6913d..af68e10390090fa27d724d5b46b3fe589a6a0a5d 100644 (file)
@@ -11,7 +11,6 @@
 #include <asm/arch/at91sam9263.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_matrix.h>
 #include <asm/arch/at91_pio.h>
 #include <asm/arch/clk.h>
@@ -39,7 +38,6 @@ static void at91sam9263ek_nand_hw_init(void)
        unsigned long csa;
        at91_smc_t    *smc    = (at91_smc_t *) ATMEL_BASE_SMC0;
        at91_matrix_t *matrix = (at91_matrix_t *) ATMEL_BASE_MATRIX;
-       at91_pmc_t    *pmc    = (at91_pmc_t *) ATMEL_BASE_PMC;
 
        /* Enable CS3 */
        csa = readl(&matrix->csa[0]) | AT91_MATRIX_CSA_EBI_CS3A;
@@ -68,8 +66,8 @@ static void at91sam9263ek_nand_hw_init(void)
                       AT91_SMC_MODE_TDF_CYCLE(2),
                &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOA | 1 << ATMEL_ID_PIOCDE,
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOCDE);
 
        /* Configure RDY/BSY */
        at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
@@ -82,11 +80,9 @@ static void at91sam9263ek_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void at91sam9263ek_macb_hw_init(void)
 {
-       at91_pmc_t      *pmc    = (at91_pmc_t *) ATMEL_BASE_PMC;
        at91_pio_t      *pio    = (at91_pio_t *) ATMEL_BASE_PIO;
 
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC);
 
        /*
         * Disable pull-up on:
@@ -139,8 +135,6 @@ void lcd_disable(void)
 
 static void at91sam9263ek_lcd_hw_init(void)
 {
-       at91_pmc_t      *pmc    = (at91_pmc_t *) ATMEL_BASE_PMC;
-
        at91_set_a_periph(AT91_PIO_PORTC, 1, 0);        /* LCDHSYNC */
        at91_set_a_periph(AT91_PIO_PORTC, 2, 0);        /* LCDDOTCK */
        at91_set_a_periph(AT91_PIO_PORTC, 3, 0);        /* LCDDEN */
@@ -164,7 +158,7 @@ static void at91sam9263ek_lcd_hw_init(void)
        at91_set_a_periph(AT91_PIO_PORTC, 26, 0);       /* LCDD22 */
        at91_set_a_periph(AT91_PIO_PORTC, 27, 0);       /* LCDD23 */
 
-       writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_LCDC);
        gd->fb_base = ATMEL_BASE_SRAM0;
 }
 
@@ -226,12 +220,9 @@ int board_mmc_init(bd_t *bd)
 
 int board_early_init_f(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clocks for all PIOs */
-       writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
-               (1 << ATMEL_ID_PIOCDE),
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOCDE);
 
        at91_seriald_hw_init();
        return 0;
index e317d998311f267e2ae252c070af57509b83eb35..21d81def5e65117b891ed8762deb79b9616b84a1 100644 (file)
@@ -9,16 +9,13 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91sam9263.h>
+#include <asm/arch/clk.h>
 
 void coloured_LED_init(void)
 {
-       /* Enable clock */
-       at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
-
-       writel(1 << ATMEL_ID_PIOB | 1 << ATMEL_ID_PIOCDE,
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
 
        at91_set_gpio_output(CONFIG_RED_LED, 1);
        at91_set_gpio_output(CONFIG_GREEN_LED, 1);
index 0a51fcd9aa59e3685f47713c1ba05ff34c7d4dd0..4c6431266fb449b70150c374010c7d78fa891c32 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/arch/at91sam9g45_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/clk.h>
 #include <lcd.h>
@@ -36,7 +35,6 @@ void at91sam9m10g45ek_nand_hw_init(void)
 {
        struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
        struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        unsigned long csa;
 
        /* Enable CS3 */
@@ -63,7 +61,7 @@ void at91sam9m10g45ek_nand_hw_init(void)
               AT91_SMC_MODE_TDF_CYCLE(3),
               &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
        /* Configure RDY/BSY */
        at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
@@ -130,13 +128,11 @@ static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
 
 void mem_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct atmel_mpddrc_config ddr2;
 
        ddr2_conf(&ddr2);
 
-       /* enable DDR2 clock */
-       writel(AT91_PMC_DDR, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_DDR);
 
        /* DDRAM2 Controller initialize */
        ddr2_init(ATMEL_BASE_DDRSDRC0, ATMEL_BASE_CS6, &ddr2);
@@ -146,9 +142,7 @@ void mem_init(void)
 #ifdef CONFIG_CMD_USB
 static void at91sam9m10g45ek_usb_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       writel(1 << ATMEL_ID_PIODE, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIODE);
 
        at91_set_gpio_output(AT91_PIN_PD1, 0);
        at91_set_gpio_output(AT91_PIN_PD3, 0);
@@ -158,11 +152,9 @@ static void at91sam9m10g45ek_usb_hw_init(void)
 #ifdef CONFIG_MACB
 static void at91sam9m10g45ek_macb_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA;
 
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC);
 
        /*
         * Disable pull-up on:
@@ -222,8 +214,6 @@ void lcd_disable(void)
 
 static void at91sam9m10g45ek_lcd_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        at91_set_A_periph(AT91_PIN_PE0, 0);     /* LCDDPWR */
        at91_set_A_periph(AT91_PIN_PE2, 0);     /* LCDCC */
        at91_set_A_periph(AT91_PIN_PE3, 0);     /* LCDVSYNC */
@@ -255,7 +245,7 @@ static void at91sam9m10g45ek_lcd_hw_init(void)
        at91_set_A_periph(AT91_PIN_PE29, 0);    /* LCDD22 */
        at91_set_A_periph(AT91_PIN_PE30, 0);    /* LCDD23 */
 
-       writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_LCDC);
 
        gd->fb_base = CONFIG_AT91SAM9G45_LCD_BASE;
 }
index fe9872396293601b9299190b6b15a2be82d0f782..866052ee1c2a0aae16d5058a41ff5a147069dc4b 100644 (file)
@@ -9,15 +9,12 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/at91sam9g45.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 
 void coloured_LED_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clock */
-       writel(1 << ATMEL_ID_PIODE, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIODE);
 
        at91_set_gpio_output(CONFIG_RED_LED, 1);
        at91_set_gpio_output(CONFIG_GREEN_LED, 1);
index 0b0177df2b06d84ac78c80ffb3c79aa745e3e81c..d3555bbdf690e522d6f9e98541dce227b69efa8b 100644 (file)
@@ -10,7 +10,6 @@
 #include <asm/arch/at91sam9x5_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/at91_pio.h>
 #include <asm/arch/clk.h>
@@ -208,9 +207,8 @@ void at91sam9n12ek_usb_hw_init(void)
 
 int board_early_init_f(void)
 {
-       /* Enable clocks for all PIOs */
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-       writel((1 << ATMEL_ID_PIOAB) | (1 << ATMEL_ID_PIOCD), &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOAB);
+       at91_periph_clk_enable(ATMEL_ID_PIOCD);
 
        at91_seriald_hw_init();
        return 0;
index f995cef1e22221d3e5ad5d976a80f3bd9feab6e6..9ef2864bb13f14d65ed87e0ddcce6912eb7af4e1 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/arch/at91sam9rl_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
@@ -36,7 +35,6 @@ static void at91sam9rlek_nand_hw_init(void)
 {
        struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
        struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        unsigned long csa;
 
        /* Enable CS3 */
@@ -64,7 +62,7 @@ static void at91sam9rlek_nand_hw_init(void)
                AT91_SMC_MODE_TDF_CYCLE(2),
                &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOD, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOD);
 
        /* Configure RDY/BSY */
        at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
@@ -106,8 +104,6 @@ void lcd_disable(void)
 }
 static void at91sam9rlek_lcd_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        at91_set_B_periph(AT91_PIN_PC1, 0);     /* LCDPWR */
        at91_set_A_periph(AT91_PIN_PC5, 0);     /* LCDHSYNC */
        at91_set_A_periph(AT91_PIN_PC6, 0);     /* LCDDOTCK */
@@ -130,7 +126,7 @@ static void at91sam9rlek_lcd_hw_init(void)
        at91_set_B_periph(AT91_PIN_PC24, 0);    /* LCDD22 */
        at91_set_B_periph(AT91_PIN_PC25, 0);    /* LCDD23 */
 
-       writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_LCDC);
 }
 
 #ifdef CONFIG_LCD_INFO
@@ -174,12 +170,10 @@ int board_mmc_init(bd_t *bis)
 
 int board_early_init_f(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clocks for all PIOs */
-       writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
-               (1 << ATMEL_ID_PIOC) | (1 << ATMEL_ID_PIOD),
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
+       at91_periph_clk_enable(ATMEL_ID_PIOD);
 
        return 0;
 }
index fede59cd32666e3ad4564a4a36683a3ddee210a5..d593aba6e4634903970f98a62429197e748d1fce 100644 (file)
@@ -8,16 +8,13 @@
 
 #include <common.h>
 #include <asm/arch/at91sam9rl.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 #include <asm/io.h>
 
 void coloured_LED_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clock */
-       writel(ATMEL_ID_PIOD, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOD);
 
        at91_set_gpio_output(CONFIG_RED_LED, 1);
        at91_set_gpio_output(CONFIG_GREEN_LED, 1);
index 833e38335a24d151cbd888b30813d895575a747b..c14df303b222cc1e2546c21d71202d3138c901fa 100644 (file)
@@ -9,10 +9,9 @@
 #include <asm/arch/at91sam9x5_matrix.h>
 #include <asm/arch/at91sam9_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>
+#include <asm/arch/gpio.h>
 #include <lcd.h>
 #include <atmel_hlcdc.h>
 #include <atmel_mci.h>
@@ -39,7 +38,6 @@ static void at91sam9x5ek_nand_hw_init(void)
 {
        struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
        struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        unsigned long csa;
 
        /* Enable CS3 */
@@ -72,7 +70,7 @@ static void at91sam9x5ek_nand_hw_init(void)
                AT91_SMC_MODE_TDF_CYCLE(1),
                &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOCD, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOCD);
 
        /* Configure RDY/BSY */
        at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
@@ -141,8 +139,6 @@ void lcd_disable(void)
 
 static void at91sam9x5ek_lcd_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        if (has_lcdc()) {
                at91_set_a_periph(AT91_PIO_PORTC, 26, 0);       /* LCDPWM */
                at91_set_a_periph(AT91_PIO_PORTC, 27, 0);       /* LCDVSYNC */
@@ -176,7 +172,7 @@ static void at91sam9x5ek_lcd_hw_init(void)
                at91_set_a_periph(AT91_PIO_PORTC, 22, 0);       /* LCDD22 */
                at91_set_a_periph(AT91_PIO_PORTC, 23, 0);       /* LCDD23 */
 
-               writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
+               at91_periph_clk_enable(ATMEL_ID_LCDC);
        }
 }
 
index 8ed01ddbea8753889bdea524f57f93283fae96f3..10edf28a9bd684c99e41db82a8fbf21dd6c33238 100644 (file)
@@ -15,7 +15,6 @@
 #include <version.h>
 #include <asm/io.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/atmel_pio4.h>
 #include <asm/arch/atmel_mpddrc.h>
 #include <asm/arch/atmel_usba_udc.h>
index 7acb8d09748aa713eb5e98d61ca2be0cd4628b9d..c8a5795b1d9b8a8f137ffc0759e7e98513dd9092 100644 (file)
@@ -184,14 +184,13 @@ static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
 
 void mem_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct atmel_mpddrc_config ddr2;
 
        ddr2_conf(&ddr2);
 
-       /* enable MPDDR clock */
+       /* Enable MPDDR clock */
        at91_periph_clk_enable(ATMEL_ID_MPDDRC);
-       writel(AT91_PMC_DDR, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_DDR);
 
        /* DDRAM2 Controller initialize */
        ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
index 0d824fc0ba16e3c62c79d0a564083df4a3999917..8576560ee56745d17c69cc691aa4c2a7a528c897 100644 (file)
@@ -443,14 +443,13 @@ static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
 
 void mem_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct atmel_mpddrc_config ddr2;
 
        ddr2_conf(&ddr2);
 
-       /* enable MPDDR clock */
+       /* Enable MPDDR clock */
        at91_periph_clk_enable(ATMEL_ID_MPDDRC);
-       writel(AT91_PMC_DDR, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_DDR);
 
        /* DDRAM2 Controller initialize */
        ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
index e2f33a3e8b3570c12f4f2766f725b60e4e2af244..e154aa9322d7a29202240640d819eec1c6a4a371 100644 (file)
@@ -383,14 +383,13 @@ static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
 
 void mem_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct atmel_mpddrc_config ddr2;
 
        ddr2_conf(&ddr2);
 
-       /* enable MPDDR clock */
+       /* Enable MPDDR clock */
        at91_periph_clk_enable(ATMEL_ID_MPDDRC);
-       writel(AT91_PMC_DDR, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_DDR);
 
        /* DDRAM2 Controller initialize */
        ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
index 1799059f87ed236c1965ec8b6436646227df369a..f174cf5ba497d303ae78e49ee4675f8f4e8c2a5b 100644 (file)
@@ -379,14 +379,13 @@ static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
 
 void mem_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct atmel_mpddrc_config ddr2;
 
        ddr2_conf(&ddr2);
 
-       /* enable MPDDR clock */
+       /* Enable MPDDR clock */
        at91_periph_clk_enable(ATMEL_ID_MPDDRC);
-       writel(AT91_PMC_DDR, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_DDR);
 
        /* DDRAM2 Controller initialize */
        ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
index 95633b0d2e87074fd07d6f3ddb09852ac93622c5..2d1a89e102afd347dbfeb23a9ecf1572dfbf04d1 100644 (file)
@@ -15,7 +15,7 @@
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.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/arch/atmel_serial.h>
 #include <net.h>
@@ -31,11 +31,9 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static void macb_hw_init(void)
 {
-       struct at91_pmc *pmc   = (struct at91_pmc  *)ATMEL_BASE_PMC;
        struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA;
 
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC0);
 
        /* Disable pull-ups to prevent PHY going into test mode */
        writel(pin_to_mask(AT91_PIN_PA14) |
@@ -108,12 +106,9 @@ static void nand_hw_init(void)
 
 int board_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable PIO clocks */
-       writel((1 << ATMEL_ID_PIOA) |
-              (1 << ATMEL_ID_PIOB) |
-              (1 << ATMEL_ID_PIOC), &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
        /* The mach-type is the same for both Snapper 9260 and 9G20 */
        gd->bd->bi_arch_number = MACH_TYPE_SNAPPER_9260;
index 266e9507ef279ffa65880ee4a721c80f3a47de82..d627b240d029ead3f128d1afb8fd68e3367fd7e6 100644 (file)
@@ -12,7 +12,7 @@
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_matrix.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 #include <asm-generic/gpio.h>
 #include <asm/io.h>
@@ -43,7 +43,6 @@ static void usb_a9263_nand_hw_init(void)
        unsigned long csa;
        at91_smc_t *smc = (at91_smc_t *)ATMEL_BASE_SMC0;
        at91_matrix_t *matrix = (at91_matrix_t *)ATMEL_BASE_MATRIX;
-       at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
 
        /* Enable CS3 */
        csa = readl(&matrix->csa[0]) | AT91_MATRIX_CSA_EBI_CS3A;
@@ -66,7 +65,8 @@ static void usb_a9263_nand_hw_init(void)
               AT91_SMC_MODE_DBW_8 |
               AT91_SMC_MODE_TDF_CYCLE(2), &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOA | 1 << ATMEL_ID_PIOCDE, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOCDE);
 
        /* Configure RDY/BSY */
        gpio_request(CONFIG_SYS_NAND_READY_PIN, "NAND ready/busy");
@@ -81,10 +81,7 @@ static void usb_a9263_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void usb_a9263_macb_hw_init(void)
 {
-       at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
-
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC);
 
        /*
         * Disable pull-up on:
index 67d39844ac615e25edc27216e7e3b2215fb0f742..2c8e978eb3785f4c7d8391a474855b24e1bfbe78 100644 (file)
@@ -67,8 +67,8 @@
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_spi.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
@@ -151,12 +151,10 @@ static void ethernut5_nand_hw_init(void)
  */
 int board_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
-       /* Enable clocks for all PIOs */
-       writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
-               (1 << ATMEL_ID_PIOC),
-               &pmc->pcer);
        /* Set adress of boot parameters. */
        gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
        /* Initialize UARTs and power management. */
@@ -179,10 +177,9 @@ int board_eth_init(bd_t *bis)
 {
        const char *devname;
        unsigned short mode;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
-       /* Enable on-chip EMAC clock. */
-       writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC0);
+
        /* Need to reset PHY via power management. */
        ethernut5_phy_reset();
        /* Set peripheral pins. */
@@ -211,10 +208,8 @@ int board_eth_init(bd_t *bis)
 #ifdef CONFIG_GENERIC_ATMEL_MCI
 int board_mmc_init(bd_t *bd)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+       at91_periph_clk_enable(ATMEL_ID_MCI);
 
-       /* Enable MCI clock. */
-       writel(1 << ATMEL_ID_MCI, &pmc->pcer);
        /* Initialize MCI hardware. */
        at91_mci_hw_init();
        /* Register the device. */
@@ -229,6 +224,7 @@ int board_mmc_getcd(struct mmc *mmc)
 
 #ifdef CONFIG_ATMEL_SPI
 /*
+
  * Note, that u-boot uses different code for SPI bus access. While
  * memory routines use automatic chip select control, the serial
  * flash support requires 'manual' GPIO control. Thus, we switch
index b7f9f90cde563a2f010b937c86107f49bbcbd5c7..fe781dcc923d34747124d556c27cbcb4fc128066 100644 (file)
@@ -87,9 +87,8 @@ static void meesc_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void meesc_macb_hw_init(void)
 {
-       at91_pmc_t      *pmc    = (at91_pmc_t *) ATMEL_BASE_PMC;
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC);
+
        at91_macb_hw_init();
 }
 #endif
@@ -244,12 +243,10 @@ int misc_init_r(void)
 
 int board_early_init_f(void)
 {
-       at91_pmc_t      *pmc    = (at91_pmc_t *) ATMEL_BASE_PMC;
-
-       /* enable all clocks */
-       writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
-               (1 << ATMEL_ID_PIOCDE) | (1 << ATMEL_ID_UHP),
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOCDE);
+       at91_periph_clk_enable(ATMEL_ID_UHP);
 
        at91_seriald_hw_init();
 
index dc1013ad12a90540e0549e5e2e28e9e96868bb1d..3fb6a7b7cd4b187fead6c291df44d474ebb300b9 100644 (file)
@@ -9,15 +9,12 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/at91sam9g45.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 
 void coloured_LED_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clock */
-       writel(1 << ATMEL_ID_PIODE, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIODE);
 
        at91_set_gpio_output(CONFIG_GREEN_LED, 1);
 
index 193f14d75a91d7b8be1db4791b2348a78081dc1e..32ba9c622590b959b8721e2ef2988d680268d7d1 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/arch/at91sam9g45_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/clk.h>
 #include <lcd.h>
@@ -80,15 +79,13 @@ static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
 
 void mem_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct at91_matrix *mat = (struct at91_matrix *)ATMEL_BASE_MATRIX;
        struct atmel_mpddrc_config ddr2;
        unsigned long csa;
 
        ddr2_conf(&ddr2);
 
-       /* enable DDR2 clock */
-       writel(AT91_PMC_DDR, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_DDR);
 
        /* Chip select 1 is for DDR2/SDRAM */
        csa = readl(&mat->ebicsa);
@@ -105,9 +102,7 @@ void mem_init(void)
 #ifdef CONFIG_CMD_USB
 static void picosam9g45_usb_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       writel(1 << ATMEL_ID_PIODE, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIODE);
 
        at91_set_gpio_output(AT91_PIN_PD1, 0);
        at91_set_gpio_output(AT91_PIN_PD3, 0);
@@ -117,11 +112,9 @@ static void picosam9g45_usb_hw_init(void)
 #ifdef CONFIG_MACB
 static void picosam9g45_macb_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA;
 
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC);
 
        /*
         * Disable pull-up on:
@@ -181,8 +174,6 @@ void lcd_disable(void)
 
 static void picosam9g45_lcd_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        at91_set_A_periph(AT91_PIN_PE0, 0);     /* LCDDPWR */
        at91_set_A_periph(AT91_PIN_PE2, 0);     /* LCDCC */
        at91_set_A_periph(AT91_PIN_PE3, 0);     /* LCDVSYNC */
@@ -214,7 +205,7 @@ static void picosam9g45_lcd_hw_init(void)
        at91_set_A_periph(AT91_PIN_PE29, 0);    /* LCDD22 */
        at91_set_A_periph(AT91_PIN_PE30, 0);    /* LCDD23 */
 
-       writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_LCDC);
 
        gd->fb_base = CONFIG_AT91SAM9G45_LCD_BASE;
 }
index cc4c2a072bb06298e0b8a46115b1a8e437f6b4b0..53e353a75d264c25ae457698d5e854e57e39d578 100644 (file)
@@ -9,15 +9,12 @@
 
 #include <common.h>
 #include <asm/gpio.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 
 void coloured_LED_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clock */
-       writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
        gpio_direction_output(CONFIG_RED_LED, 1);
        gpio_direction_output(CONFIG_GREEN_LED, 1);
index b96f745773128d9aa4a619deb42e24065468b7e4..3cc01cb6870ff55fecb4ea6a6101ea6e9a64d9e2 100644 (file)
@@ -14,7 +14,6 @@
 #include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/at91_matrix.h>
 #include <asm/arch/clk.h>
@@ -41,7 +40,6 @@ static void pm9261_nand_hw_init(void)
        unsigned long csa;
        struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
        struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
        /* Enable CS3 */
        csa = readl(&matrix->csa) | AT91_MATRIX_CSA_EBI_CS3A;
@@ -69,9 +67,8 @@ static void pm9261_nand_hw_init(void)
                AT91_SMC_MODE_TDF_CYCLE(2),
                &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOA |
-               1 << ATMEL_ID_PIOC,
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
        /* Configure RDY/BSY */
        gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
@@ -89,7 +86,6 @@ static void pm9261_nand_hw_init(void)
 static void pm9261_dm9000_hw_init(void)
 {
        struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
        /* Configure SMC CS2 for DM9000 */
        writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
@@ -110,7 +106,7 @@ static void pm9261_dm9000_hw_init(void)
                &smc->cs[2].mode);
 
        /* Configure Interrupt pin as input, no pull-up */
-       writel(1 << ATMEL_ID_PIOA, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
        at91_set_pio_input(AT91_PIO_PORTA, 24, 0);
 }
 #endif
@@ -145,8 +141,6 @@ void lcd_disable(void)
 
 static void pm9261_lcd_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        at91_set_a_periph(AT91_PIO_PORTB, 1, 0);        /* LCDHSYNC */
        at91_set_a_periph(AT91_PIO_PORTB, 2, 0);        /* LCDDOTCK */
        at91_set_a_periph(AT91_PIO_PORTB, 3, 0);        /* LCDDEN */
@@ -170,7 +164,7 @@ static void pm9261_lcd_hw_init(void)
        at91_set_b_periph(AT91_PIO_PORTB, 27, 0);       /* LCDD22 */
        at91_set_b_periph(AT91_PIO_PORTB, 28, 0);       /* LCDD23 */
 
-       writel(1 << 17, &pmc->scer); /* LCD controller Clock, AT91SAM9261 only */
+       at91_system_clk_enable(AT91_PMC_HCK1);
 
        gd->fb_base = ATMEL_BASE_SRAM;
 }
@@ -224,12 +218,8 @@ void lcd_show_board_info(void)
 
 int board_early_init_f(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clocks for some PIOs */
-       writel(1 << ATMEL_ID_PIOA |
-               1 << ATMEL_ID_PIOC,
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
        at91_seriald_hw_init();
 
index bfc2310b0e22343510da499c2bb979ff0ca4d842..8025a20a6a92a99c01843da492c08df6f401bdc7 100644 (file)
@@ -9,15 +9,12 @@
 
 #include <common.h>
 #include <asm/gpio.h>
-#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/gpio.h>
 
 void coloured_LED_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clock */
-       writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
 
        gpio_direction_output(CONFIG_RED_LED, 1);
        gpio_direction_output(CONFIG_GREEN_LED, 1);
index 1b00f08835cce0f8929d20847fe0b85b02776722..276ff80943ed3d63845e424d5fe5dfb2fa22c310 100644 (file)
@@ -14,7 +14,6 @@
 #include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/at91_matrix.h>
 #include <asm/arch/clk.h>
@@ -78,8 +77,6 @@ static void pm9263_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void pm9263_macb_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        /*
         * PB27 enables the 50MHz oscillator for Ethernet PHY
         * 1 - enable
@@ -88,8 +85,7 @@ static void pm9263_macb_hw_init(void)
        at91_set_pio_output(AT91_PIO_PORTB, 27, 1);
        at91_set_pio_value(AT91_PIO_PORTB, 27, 1); /* 1- enable, 0 - disable */
 
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC);
 
        /*
         * Disable pull-up on:
@@ -231,8 +227,6 @@ static int pm9263_lcd_hw_psram_init(void)
 
 static void pm9263_lcd_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        at91_set_a_periph(AT91_PIO_PORTC, 0, 0);        /* LCDVSYNC */
        at91_set_a_periph(AT91_PIO_PORTC, 1, 0);        /* LCDHSYNC */
        at91_set_a_periph(AT91_PIO_PORTC, 2, 0);        /* LCDDOTCK */
@@ -257,7 +251,7 @@ static void pm9263_lcd_hw_init(void)
        at91_set_a_periph(AT91_PIO_PORTC, 26, 0);       /* LCDD22 */
        at91_set_a_periph(AT91_PIO_PORTC, 27, 0);       /* LCDD23 */
 
-       writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_LCDC);
 
        /* Power Control */
        at91_set_pio_output(AT91_PIO_PORTA, 22, 1);
@@ -323,12 +317,9 @@ void lcd_show_board_info(void)
 
 int board_early_init_f(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clocks for all PIOs */
-       writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
-               (1 << ATMEL_ID_PIOCDE),
-               &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOCDE);
 
        at91_seriald_hw_init();
 
index efc4133bbfe9d78f6048781efba3340dc186982d..c2707e0015ddd433e5f806fecc1b50c55c96fc1a 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/at91_matrix.h>
 #include <asm/arch/gpio.h>
@@ -39,7 +38,6 @@ static void pm9g45_nand_hw_init(void)
        unsigned long csa;
        struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
        struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
        /* Enable CS3 */
        csa = readl(&matrix->ccr[6]) | AT91_MATRIX_CSA_EBI_CS3A;
@@ -63,7 +61,7 @@ static void pm9g45_nand_hw_init(void)
                AT91_SMC_MODE_TDF_CYCLE(3),
                &smc->cs[3].mode);
 
-       writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
 
 #ifdef CONFIG_SYS_NAND_READY_PIN
        /* Configure RDY/BSY */
@@ -78,8 +76,6 @@ static void pm9g45_nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void pm9g45_macb_hw_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
        /*
         * PD2 enables the 50MHz oscillator for Ethernet PHY
         * 1 - enable
@@ -88,8 +84,7 @@ static void pm9g45_macb_hw_init(void)
        at91_set_pio_output(AT91_PIO_PORTD, 2, 1);
        at91_set_pio_value(AT91_PIO_PORTD, 2, 1); /* 1- enable, 0 - disable */
 
-       /* Enable clock */
-       writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_EMAC);
 
        /*
         * Disable pull-up on:
@@ -114,13 +109,10 @@ static void pm9g45_macb_hw_init(void)
 
 int board_early_init_f(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
-
-       /* Enable clocks for all PIOs */
-       writel((1 << ATMEL_ID_PIOA) |
-               (1 << ATMEL_ID_PIOB) |
-               (1 << ATMEL_ID_PIOC) |
-               (1 << ATMEL_ID_PIODE), &pmc->pcer);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
+       at91_periph_clk_enable(ATMEL_ID_PIOB);
+       at91_periph_clk_enable(ATMEL_ID_PIOC);
+       at91_periph_clk_enable(ATMEL_ID_PIODE);
 
        at91_seriald_hw_init();
 
index 38c0ca3aaeb40822b5b37702929f6755826befea..ba70819347af15ff61321e45b33aa1ad91fec298 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/arch/at91sam9g45_matrix.h>
 #include <asm/arch/at91sam9_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>
@@ -147,13 +146,11 @@ static void ddr2_conf(struct atmel_mpddrc_config *ddr2)
 
 void mem_init(void)
 {
-       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
        struct atmel_mpddrc_config ddr2;
 
        ddr2_conf(&ddr2);
 
-       /* enable DDR2 clock */
-       writel(AT91_PMC_DDR, &pmc->scer);
+       at91_system_clk_enable(AT91_PMC_DDR);
 
        /* DDRAM2 Controller initialize */
        ddr2_init(ATMEL_BASE_DDRSDRC0, ATMEL_BASE_CS6, &ddr2);
@@ -214,6 +211,7 @@ void at91_udp_hw_init(void)
 
        /* Enable UPLL clock */
        writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+
        /* Enable UDPHS clock */
        at91_periph_clk_enable(ATMEL_ID_UDPHS);
 }
index d82f1b73a712db93fe610faf7f9ceb5831936088..e7ee65cd8d3845263a6dd2c025ebc5999bd68c84 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
-#include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_spi.h>
 #include <spi.h>
 #include <asm/arch/clk.h>
@@ -126,7 +125,7 @@ void at91_udp_hw_init(void)
        /* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
        at91_periph_clk_enable(ATMEL_ID_UDP);
 
-       writel(AT91SAM926x_PMC_UDP, &pmc->scer);
+       at91_system_clk_enable(AT91SAM926x_PMC_UDP);
 }
 
 struct at91_udc_data board_udc_data  = {
index 72c5e6083d53fec4cee1cd53da5cd6642131ffda..9374064df51216da8cafaa1efba35cbc7034b908 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_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/at91sam9_sdramc.h>
@@ -300,7 +299,7 @@ void at91_udp_hw_init(void)
        /* Enable UDPCK clock, MCK is enabled in at91_clock_init() */
        at91_periph_clk_enable(ATMEL_ID_UDP);
 
-       writel(AT91SAM926x_PMC_UDP, &pmc->scer);
+       at91_system_clk_enable(AT91SAM926x_PMC_UDP);
 }
 
 struct at91_udc_data board_udc_data  = {