]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/freescale/mpc837xemds/mpc837xemds.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[karo-tx-uboot.git] / board / freescale / mpc837xemds / mpc837xemds.c
index acf8ada7b2e6c5b3b79704df7a361620a404e638..0a3c9720d6cd4785741225f24a37d66f773bcdc8 100644 (file)
@@ -1,23 +1,24 @@
 /*
- * Copyright (C) 2007 Freescale Semiconductor, Inc.
+ * 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.
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <hwconfig.h>
 #include <i2c.h>
 #include <asm/io.h>
-#include <asm/fsl_serdes.h>
+#include <asm/fsl_mpc83xx_serdes.h>
+#include <asm/fsl_enet.h>
 #include <spd_sdram.h>
 #include <tsec.h>
 #include <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"
 
 int board_early_init_f(void)
@@ -37,34 +38,52 @@ int board_early_init_f(void)
        switch (PARTID_NO_E(spridr)) {
        case SPR_8377:
                fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
-                                FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
-               fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
-                                FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
+                               FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
                break;
        case SPR_8378:
                fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SGMII,
-                                FSL_SERDES_CLK_125, FSL_SERDES_VDD_1V);
-               fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_PEX,
-                                FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
+                               FSL_SERDES_CLK_125, FSL_SERDES_VDD_1V);
                break;
        case SPR_8379:
                fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
-                                FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
+                               FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
                fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_SATA,
-                                FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
+                               FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
                break;
        default:
                printf("serdes not configured: unknown CPU part number: "
-                      "%04x\n", spridr >> 16);
+                               "%04x\n", spridr >> 16);
                break;
        }
 #endif /* CONFIG_FSL_SERDES */
        return 0;
 }
 
+#ifdef CONFIG_FSL_ESDHC
+int board_mmc_init(bd_t *bd)
+{
+       struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR;
+       u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
+
+       if (!hwconfig("esdhc"))
+               return 0;
+
+       /* Set SPI_SD, SER_SD, and IRQ4_WP so that SD signals go through */
+       bcsr[0xc] |= 0x4c;
+
+       /* Set proper bits in SICR to allow SD signals through */
+       clrsetbits_be32(&im->sysconf.sicrl, SICRL_USB_B, SICRL_USB_B_SD);
+       clrsetbits_be32(&im->sysconf.sicrh, SICRH_GPIO2_E | SICRH_SPI,
+                       SICRH_GPIO2_E_SD | SICRH_SPI_SD);
+
+       return fsl_esdhc_mmc_init(bd);
+}
+#endif
+
 #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);
@@ -110,13 +129,17 @@ 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);
 }
 
 static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias,
                            int phy_addr)
 {
-       const char *phy_type = "sgmii";
        const u32 *ph;
        int off;
        int err;
@@ -128,8 +151,8 @@ static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias,
                return;
        }
 
-       err = fdt_setprop(blob, off, "phy-connection-type", phy_type,
-                         strlen(phy_type) + 1);
+       err = fdt_fixup_phy_connection(blob, off, PHY_INTERFACE_MODE_SGMII);
+
        if (err) {
                printf("WARNING: could not set phy-connection-type for %s: "
                        "%s.\n", alias, fdt_strerror(err));
@@ -189,7 +212,7 @@ int board_early_init_r(void)
        return 0;
 }
 
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
+#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
 extern void ddr_enable_ecc(unsigned int dram_size);
 #endif
 int fixed_sdram(void);
@@ -208,7 +231,7 @@ phys_size_t initdram(int board_type)
        msize = fixed_sdram();
 #endif
 
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
+#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
        /* Initialize DDR ECC byte */
        ddr_enable_ecc(msize * 1024 * 1024);
 #endif
@@ -272,10 +295,9 @@ int board_pci_host_broken(void)
 {
        struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR;
        const u32 rcw_mask = HRCWH_PCI1_ARBITER_ENABLE | HRCWH_PCI_HOST;
-       const char *pci_ea = getenv("pci_external_arbiter");
 
        /* It's always OK in case of external arbiter. */
-       if (pci_ea && !strcmp(pci_ea, "yes"))
+       if (hwconfig_subarg_cmp("pci", "arbiter", "external"))
                return 0;
 
        if ((in_be32(&im->reset.rcwh) & rcw_mask) != rcw_mask)
@@ -312,10 +334,12 @@ void ft_board_setup(void *blob, bd_t *bd)
        ft_cpu_setup(blob, bd);
        ft_tsec_fixup(blob, bd);
        fdt_fixup_dr_usb(blob, bd);
+       fdt_fixup_esdhc(blob, bd);
 #ifdef CONFIG_PCI
        ft_pci_setup(blob, bd);
        if (board_pci_host_broken())
                ft_pci_fixup(blob, bd);
+       ft_pcie_fixup(blob, bd);
 #endif
 }
 #endif /* CONFIG_OF_BOARD_SETUP */