]> git.sur5r.net Git - u-boot/blobdiff - board/atmel/at91sam9261ek/at91sam9261ek.c
board: at91sam9261ek: Update to support DT and DM
[u-boot] / board / atmel / at91sam9261ek / at91sam9261ek.c
index 47ab83967dc5122efb01cba059bb76a2c37bb1d0..c11bb2cd105ce08a5411b031ec0c27d8f41f03bd 100644 (file)
@@ -3,32 +3,16 @@
  * Stelian Pop <stelian@popies.net>
  * Lead Tech Design <www.leadtechdesign.com>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <debug_uart.h>
 #include <asm/io.h>
 #include <asm/arch/at91sam9261.h>
 #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>
@@ -38,6 +22,7 @@
 #include <net.h>
 #include <netdev.h>
 #endif
+#include <asm/mach-types.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -51,7 +36,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 */
@@ -90,7 +74,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);
@@ -149,20 +133,20 @@ static void at91sam9261ek_dm9000_hw_init(void)
 
 #ifdef CONFIG_LCD
 vidinfo_t panel_info = {
-       vl_col:         240,
-       vl_row:         320,
-       vl_clk:         4965000,
-       vl_sync:        ATMEL_LCDC_INVLINE_INVERTED |
-                       ATMEL_LCDC_INVFRAME_INVERTED,
-       vl_bpix:        3,
-       vl_tft:         1,
-       vl_hsync_len:   5,
-       vl_left_margin: 1,
-       vl_right_margin:33,
-       vl_vsync_len:   1,
-       vl_upper_margin:1,
-       vl_lower_margin:0,
-       mmio:           ATMEL_BASE_LCDC,
+       .vl_col =               240,
+       .vl_row =               320,
+       .vl_clk =               4965000,
+       .vl_sync =              ATMEL_LCDC_INVLINE_INVERTED |
+                               ATMEL_LCDC_INVFRAME_INVERTED,
+       .vl_bpix =              3,
+       .vl_tft =               1,
+       .vl_hsync_len =         5,
+       .vl_left_margin =       1,
+       .vl_right_margin =      33,
+       .vl_vsync_len =         1,
+       .vl_upper_margin =      1,
+       .vl_lower_margin =      0,
+       .mmio =                 ATMEL_BASE_LCDC,
 };
 
 void lcd_enable(void)
@@ -177,8 +161,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 */
@@ -202,7 +184,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
@@ -232,7 +214,7 @@ void lcd_show_board_info(void)
                dram_size += gd->bd->bi_dram[i].size;
        nand_size = 0;
        for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
-               nand_size += nand_info[i].size;
+               nand_size += get_nand_dev_by_index(i)->size;
        lcd_printf ("  %ld MB SDRAM, %ld MB NAND\n",
                dram_size >> 20,
                nand_size >> 20 );
@@ -240,11 +222,25 @@ void lcd_show_board_info(void)
 #endif /* CONFIG_LCD_INFO */
 #endif
 
-int board_init(void)
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+void board_debug_uart_init(void)
+{
+       at91_seriald_hw_init();
+}
+#endif
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+int board_early_init_f(void)
 {
-       /* Enable Ctrlc */
-       console_init_f();
+#ifdef CONFIG_DEBUG_UART
+       debug_uart_init();
+#endif
+       return 0;
+}
+#endif
 
+int board_init(void)
+{
 #ifdef CONFIG_AT91SAM9G10EK
        /* arch number of AT91SAM9G10EK-Board */
        gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9G10EK;
@@ -255,13 +251,9 @@ int board_init(void)
        /* adress of boot parameters */
        gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
-       at91_seriald_hw_init();
 #ifdef CONFIG_CMD_NAND
        at91sam9261ek_nand_hw_init();
 #endif
-#ifdef CONFIG_HAS_DATAFLASH
-       at91_spi0_hw_init(1 << 0);
-#endif
 #ifdef CONFIG_DRIVER_DM9000
        at91sam9261ek_dm9000_hw_init();
 #endif
@@ -294,7 +286,7 @@ void reset_phy(void)
         * Initialize ethernet HW addr prior to starting Linux,
         * needed for nfsroot
         */
-       eth_init(gd->bd);
+       eth_init();
 #endif
 }
 #endif