common: Drop linux/delay.h from common header
[oweals/u-boot.git] / board / freescale / mpc837xemds / mpc837xemds.c
index 51dd692c2e41b93b8e17ce7e3cecacd44c8cbd7b..d53c8618076957f2bbdf0157e1d17e0d47957189 100644 (file)
@@ -1,29 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2007,2010 Freescale Semiconductor, Inc.
  * Dave Liu <daveliu@freescale.com>
- *
- * CREDITS: Kim Phillips contribute to LIBFDT code
- *
- * 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.
  */
 
 #include <common.h>
 #include <hwconfig.h>
 #include <i2c.h>
+#include <init.h>
+#include <net.h>
 #include <asm/io.h>
 #include <asm/fsl_mpc83xx_serdes.h>
-#include <asm/fsl_enet.h>
 #include <spd_sdram.h>
 #include <tsec.h>
-#include <libfdt.h>
+#include <linux/delay.h>
+#include <linux/libfdt.h>
 #include <fdt_support.h>
 #include <fsl_esdhc.h>
+#include <fsl_mdio.h>
+#include <phy.h>
 #include "pci.h"
 #include "../common/pq-mds-pib.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int board_early_init_f(void)
 {
        u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
@@ -86,6 +86,7 @@ int board_mmc_init(bd_t *bd)
 #if defined(CONFIG_TSEC1) || defined(CONFIG_TSEC2)
 int board_eth_init(bd_t *bd)
 {
+       struct fsl_pq_mdio_info mdio_info;
        struct tsec_info_struct tsec_info[2];
        struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR;
        u32 rcwh = in_be32(&im->reset.rcwh);
@@ -131,6 +132,11 @@ int board_eth_init(bd_t *bd)
        }
        num++;
 #endif
+
+       mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
+       mdio_info.name = DEFAULT_MII_NAME;
+       fsl_pq_mdio_init(bd, &mdio_info);
+
        return tsec_eth_init(bd, tsec_info, num);
 }
 
@@ -148,7 +154,7 @@ static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias,
                return;
        }
 
-       err = fdt_fixup_phy_connection(blob, off, SGMII);
+       err = fdt_fixup_phy_connection(blob, off, PHY_INTERFACE_MODE_SGMII);
 
        if (err) {
                printf("WARNING: could not set phy-connection-type for %s: "
@@ -214,13 +220,13 @@ extern void ddr_enable_ecc(unsigned int dram_size);
 #endif
 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;
 
 #if defined(CONFIG_SPD_EEPROM)
        msize = spd_sdram();
@@ -234,7 +240,9 @@ phys_size_t initdram(int board_type)
 #endif
 
        /* return total bus DDR size(bytes) */
-       return (msize * 1024 * 1024);
+       gd->ram_size = msize * 1024 * 1024;
+
+       return 0;
 }
 
 #if !defined(CONFIG_SPD_EEPROM)
@@ -247,7 +255,7 @@ int fixed_sdram(void)
        u32 msize = CONFIG_SYS_DDR_SIZE * 1024 * 1024;
        u32 msize_log2 = __ilog2(msize);
 
-       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
+       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_SDRAM_BASE & 0xfffff000;
        im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
 
 #if (CONFIG_SYS_DDR_SIZE != 512)
@@ -326,11 +334,11 @@ static void ft_pci_fixup(void *blob, bd_t *bd)
 #endif
 
 #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);
        ft_tsec_fixup(blob, bd);
-       fdt_fixup_dr_usb(blob, bd);
+       fsl_fdt_fixup_dr_usb(blob, bd);
        fdt_fixup_esdhc(blob, bd);
 #ifdef CONFIG_PCI
        ft_pci_setup(blob, bd);
@@ -338,5 +346,7 @@ void ft_board_setup(void *blob, bd_t *bd)
                ft_pci_fixup(blob, bd);
        ft_pcie_fixup(blob, bd);
 #endif
+
+       return 0;
 }
 #endif /* CONFIG_OF_BOARD_SETUP */