board: atmel: clean up peripheral clock code
[oweals/u-boot.git] / board / atmel / at91sam9m10g45ek / at91sam9m10g45ek.c
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;
 }