]> git.sur5r.net Git - u-boot/blobdiff - board/atmel/at91sam9261ek/at91sam9261ek.c
spi: atcspi200: avoid NULL dereference
[u-boot] / board / atmel / at91sam9261ek / at91sam9261ek.c
index a301d72e8ce46528b41df428e7d3d7eea9d52827..6f15bc677671a3b9d80321c6f0a2206573d87219 100644 (file)
@@ -1,18 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2007-2008
  * Stelian Pop <stelian@popies.net>
  * Lead Tech Design <www.leadtechdesign.com>
- *
- * 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>
@@ -22,6 +21,7 @@
 #include <net.h>
 #include <netdev.h>
 #endif
+#include <asm/mach-types.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -35,7 +35,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 +73,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 +160,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 +183,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
@@ -216,7 +213,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 );
@@ -224,6 +221,23 @@ void lcd_show_board_info(void)
 #endif /* CONFIG_LCD_INFO */
 #endif
 
+#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)
+{
+#ifdef CONFIG_DEBUG_UART
+       debug_uart_init();
+#endif
+       return 0;
+}
+#endif
+
 int board_init(void)
 {
 #ifdef CONFIG_AT91SAM9G10EK
@@ -236,13 +250,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
@@ -275,7 +285,7 @@ void reset_phy(void)
         * Initialize ethernet HW addr prior to starting Linux,
         * needed for nfsroot
         */
-       eth_init(gd->bd);
+       eth_init();
 #endif
 }
 #endif