common: Drop linux/delay.h from common header
[oweals/u-boot.git] / board / freescale / mpc8323erdb / mpc8323erdb.c
index 8680a19a6f5d10b3e74fe361613dadbcfd719a51..1dc1c98ad67161186a02d0cee8d56a5a4d25fea2 100644 (file)
  */
 
 #include <common.h>
+#include <eeprom.h>
+#include <env.h>
+#include <fdt_support.h>
+#include <init.h>
 #include <ioports.h>
 #include <mpc83xx.h>
 #include <i2c.h>
 #include <miiphy.h>
 #include <command.h>
-#include <libfdt.h>
+#include <linux/delay.h>
+#include <linux/libfdt.h>
+#include <u-boot/crc.h>
 #if defined(CONFIG_PCI)
 #include <pci.h>
 #endif
 #include <asm/mmu.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 const qe_iop_conf_t qe_iop_conf_tab[] = {
        /* UCC3 */
        {1,  0, 1, 0, 1}, /* TxD0 */
@@ -66,28 +74,25 @@ const qe_iop_conf_t qe_iop_conf_tab[] = {
        {0,  0, 0, 0, QE_IOP_TAB_END}, /* END of table */
 };
 
-int board_early_init_f(void)
-{
-       return 0;
-}
-
 int fixed_sdram(void);
 
-phys_size_t initdram(int board_type)
+int dram_init(void)
 {
        volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
        u32 msize = 0;
 
        if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
-               return -1;
+               return -ENXIO;
 
        /* DDR SDRAM - Main SODIMM */
-       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
+       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_SDRAM_BASE & LAWBAR_BAR;
 
        msize = fixed_sdram();
 
-       /* return total bus SDRAM size(bytes)  -- DDR */
-       return (msize * 1024 * 1024);
+       /* set total bus SDRAM size(bytes)  -- DDR */
+       gd->ram_size = msize * 1024 * 1024;
+
+       return 0;
 }
 
 /*************************************************************************
@@ -173,16 +178,18 @@ void pci_init_board(void)
        pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
        pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
 
-       mpc83xx_pci_init(1, reg, 0);
+       mpc83xx_pci_init(1, reg);
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP)
-void ft_board_setup(void *blob, bd_t *bd)
+int ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 #ifdef CONFIG_PCI
        ft_pci_setup(blob, bd);
 #endif
+
+       return 0;
 }
 #endif
 
@@ -200,7 +207,11 @@ int mac_read_from_eeprom(void)
                printf("\nEEPROM @ 0x%02x read FAILED!!!\n",
                       CONFIG_SYS_I2C_EEPROM_ADDR);
        } else {
-               if (crc32(crc, buf, 24) == *(unsigned int *)&buf[24]) {
+               uint32_t crc_buf;
+
+               memcpy(&crc_buf, &buf[24], sizeof(uint32_t));
+
+               if (crc32(crc, buf, 24) == crc_buf) {
                        printf("Reading MAC from EEPROM\n");
                        for (i = 0; i < 4; i++) {
                                if (memcmp(&buf[i * 6], "\0\0\0\0\0\0", 6)) {
@@ -211,7 +222,7 @@ int mac_read_from_eeprom(void)
                                                buf[i * 6 + 4], buf[i * 6 + 5]);
                                        sprintf((char *)enetvar,
                                                i ? "eth%daddr" : "ethaddr", i);
-                                       setenv((char *)enetvar, str);
+                                       env_set((char *)enetvar, str);
                                }
                        }
                }