]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - board/freescale/ls1021aqds/ls1021aqds.c
arm: ls1021a: merge SoC specific code in a separate file
[people/ms/u-boot.git] / board / freescale / ls1021aqds / ls1021aqds.c
index f08e54f178605f8ee7b867aea2eaf3988cb9917c..be3358a564a8195b5ed3b511f34e200dd878f0e8 100644 (file)
@@ -8,18 +8,22 @@
 #include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/immap_ls102xa.h>
-#include <asm/arch/ns_access.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/fsl_serdes.h>
 #include <asm/arch/ls102xa_stream_id.h>
-#include <asm/pcie_layerscape.h>
+#include <asm/arch/ls102xa_soc.h>
+#include <asm/arch/ls102xa_devdis.h>
+#include <asm/arch/ls102xa_sata.h>
 #include <hwconfig.h>
 #include <mmc.h>
+#include <fsl_csu.h>
 #include <fsl_esdhc.h>
 #include <fsl_ifc.h>
 #include <fsl_sec.h>
 #include <spl.h>
+#include <fsl_devdis.h>
 
+#include "../common/sleep.h"
 #include "../common/qixis.h"
 #include "ls1021aqds_qixis.h"
 #ifdef CONFIG_U_QE
@@ -48,6 +52,12 @@ enum {
        MUX_TYPE_SD_PC_SG_SG,
 };
 
+enum {
+       GE0_CLK125,
+       GE2_CLK125,
+       GE1_CLK125,
+};
+
 int checkboard(void)
 {
 #ifndef CONFIG_QSPI_BOOT
@@ -173,27 +183,22 @@ int board_mmc_init(bd_t *bis)
 int board_early_init_f(void)
 {
        struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
-       struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
 
 #ifdef CONFIG_TSEC_ENET
-       out_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
-       out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
+       /* clear BD & FR bits for BE BD's and frame data */
+       clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
 #endif
 
 #ifdef CONFIG_FSL_IFC
        init_early_memctl_regs();
 #endif
 
-#ifdef CONFIG_FSL_QSPI
-       out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
-#endif
+       arch_soc_init();
 
-       /* Workaround for the issue that DDR could not respond to
-        * barrier transaction which is generated by executing DSB/ISB
-        * instruction. Set CCI-400 control override register to
-        * terminate the barrier transaction. After DDR is initialized,
-        * allow barrier transaction to DDR again */
-       out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
+#if defined(CONFIG_DEEP_SLEEP)
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
 
        return 0;
 }
@@ -202,6 +207,7 @@ int board_early_init_f(void)
 void board_init_f(ulong dummy)
 {
        struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
+       unsigned int major;
 
 #ifdef CONFIG_NAND_BOOT
        struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
@@ -219,9 +225,6 @@ void board_init_f(ulong dummy)
                 pinctl);
 #endif
 
-       /* Set global data pointer */
-       gd = &gdata;
-
        /* Clear the BSS */
        memset(__bss_start, 0, __bss_end - __bss_start);
 
@@ -231,19 +234,58 @@ void board_init_f(ulong dummy)
 
        get_clocks();
 
+#if defined(CONFIG_DEEP_SLEEP)
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
+
        preloader_console_init();
 
 #ifdef CONFIG_SPL_I2C_SUPPORT
        i2c_init_all();
 #endif
-       out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
+
+       major = get_soc_major_rev();
+       if (major == SOC_MAJOR_VER_1_0)
+               out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
 
        dram_init();
 
+       /* Allow OCRAM access permission as R/W */
+#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
+       enable_layerscape_ns_access();
+#endif
+
        board_init_r(NULL, 0);
 }
 #endif
 
+void config_etseccm_source(int etsec_gtx_125_mux)
+{
+       struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
+
+       switch (etsec_gtx_125_mux) {
+       case GE0_CLK125:
+               out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE0_CLK125);
+               debug("etseccm set to GE0_CLK125\n");
+               break;
+
+       case GE2_CLK125:
+               out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
+               debug("etseccm set to GE2_CLK125\n");
+               break;
+
+       case GE1_CLK125:
+               out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE1_CLK125);
+               debug("etseccm set to GE1_CLK125\n");
+               break;
+
+       default:
+               printf("Error! trying to set etseccm to invalid value\n");
+               break;
+       }
+}
+
 int config_board_mux(int ctrl_type)
 {
        u8 reg12, reg14;
@@ -253,6 +295,7 @@ int config_board_mux(int ctrl_type)
 
        switch (ctrl_type) {
        case MUX_TYPE_CAN:
+               config_etseccm_source(GE2_CLK125);
                reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_CAN);
                break;
        case MUX_TYPE_IIC2:
@@ -262,6 +305,7 @@ int config_board_mux(int ctrl_type)
                reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_RGMII);
                break;
        case MUX_TYPE_SAI:
+               config_etseccm_source(GE2_CLK125);
                reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_SAI);
                break;
        case MUX_TYPE_SDHC:
@@ -319,6 +363,17 @@ int config_serdes_mux(void)
        return 0;
 }
 
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+#ifdef CONFIG_SCSI_AHCI_PLAT
+       ls1021a_sata_init();
+#endif
+
+       return 0;
+}
+#endif
+
 int misc_init_r(void)
 {
        int conflict_flag;
@@ -358,97 +413,33 @@ int misc_init_r(void)
        else if (hwconfig("sdhc"))
                config_board_mux(MUX_TYPE_SDHC);
 
+#ifdef CONFIG_FSL_DEVICE_DISABLE
+       device_disable(devdis_tbl, ARRAY_SIZE(devdis_tbl));
+#endif
 #ifdef CONFIG_FSL_CAAM
        return sec_init();
 #endif
        return 0;
 }
 
-#ifdef CONFIG_LS102XA_NS_ACCESS
-static struct csu_ns_dev ns_dev[] = {
-       { CSU_CSLX_PCIE2_IO, CSU_ALL_RW },
-       { CSU_CSLX_PCIE1_IO, CSU_ALL_RW },
-       { CSU_CSLX_MG2TPR_IP, CSU_ALL_RW },
-       { CSU_CSLX_IFC_MEM, CSU_ALL_RW },
-       { CSU_CSLX_OCRAM, CSU_ALL_RW },
-       { CSU_CSLX_GIC, CSU_ALL_RW },
-       { CSU_CSLX_PCIE1, CSU_ALL_RW },
-       { CSU_CSLX_OCRAM2, CSU_ALL_RW },
-       { CSU_CSLX_QSPI_MEM, CSU_ALL_RW },
-       { CSU_CSLX_PCIE2, CSU_ALL_RW },
-       { CSU_CSLX_SATA, CSU_ALL_RW },
-       { CSU_CSLX_USB3, CSU_ALL_RW },
-       { CSU_CSLX_SERDES, CSU_ALL_RW },
-       { CSU_CSLX_QDMA, CSU_ALL_RW },
-       { CSU_CSLX_LPUART2, CSU_ALL_RW },
-       { CSU_CSLX_LPUART1, CSU_ALL_RW },
-       { CSU_CSLX_LPUART4, CSU_ALL_RW },
-       { CSU_CSLX_LPUART3, CSU_ALL_RW },
-       { CSU_CSLX_LPUART6, CSU_ALL_RW },
-       { CSU_CSLX_LPUART5, CSU_ALL_RW },
-       { CSU_CSLX_DSPI2, CSU_ALL_RW },
-       { CSU_CSLX_DSPI1, CSU_ALL_RW },
-       { CSU_CSLX_QSPI, CSU_ALL_RW },
-       { CSU_CSLX_ESDHC, CSU_ALL_RW },
-       { CSU_CSLX_2D_ACE, CSU_ALL_RW },
-       { CSU_CSLX_IFC, CSU_ALL_RW },
-       { CSU_CSLX_I2C1, CSU_ALL_RW },
-       { CSU_CSLX_USB2, CSU_ALL_RW },
-       { CSU_CSLX_I2C3, CSU_ALL_RW },
-       { CSU_CSLX_I2C2, CSU_ALL_RW },
-       { CSU_CSLX_DUART2, CSU_ALL_RW },
-       { CSU_CSLX_DUART1, CSU_ALL_RW },
-       { CSU_CSLX_WDT2, CSU_ALL_RW },
-       { CSU_CSLX_WDT1, CSU_ALL_RW },
-       { CSU_CSLX_EDMA, CSU_ALL_RW },
-       { CSU_CSLX_SYS_CNT, CSU_ALL_RW },
-       { CSU_CSLX_DMA_MUX2, CSU_ALL_RW },
-       { CSU_CSLX_DMA_MUX1, CSU_ALL_RW },
-       { CSU_CSLX_DDR, CSU_ALL_RW },
-       { CSU_CSLX_QUICC, CSU_ALL_RW },
-       { CSU_CSLX_DCFG_CCU_RCPM, CSU_ALL_RW },
-       { CSU_CSLX_SECURE_BOOTROM, CSU_ALL_RW },
-       { CSU_CSLX_SFP, CSU_ALL_RW },
-       { CSU_CSLX_TMU, CSU_ALL_RW },
-       { CSU_CSLX_SECURE_MONITOR, CSU_ALL_RW },
-       { CSU_CSLX_RESERVED0, CSU_ALL_RW },
-       { CSU_CSLX_ETSEC1, CSU_ALL_RW },
-       { CSU_CSLX_SEC5_5, CSU_ALL_RW },
-       { CSU_CSLX_ETSEC3, CSU_ALL_RW },
-       { CSU_CSLX_ETSEC2, CSU_ALL_RW },
-       { CSU_CSLX_GPIO2, CSU_ALL_RW },
-       { CSU_CSLX_GPIO1, CSU_ALL_RW },
-       { CSU_CSLX_GPIO4, CSU_ALL_RW },
-       { CSU_CSLX_GPIO3, CSU_ALL_RW },
-       { CSU_CSLX_PLATFORM_CONT, CSU_ALL_RW },
-       { CSU_CSLX_CSU, CSU_ALL_RW },
-       { CSU_CSLX_ASRC, CSU_ALL_RW },
-       { CSU_CSLX_SPDIF, CSU_ALL_RW },
-       { CSU_CSLX_FLEXCAN2, CSU_ALL_RW },
-       { CSU_CSLX_FLEXCAN1, CSU_ALL_RW },
-       { CSU_CSLX_FLEXCAN4, CSU_ALL_RW },
-       { CSU_CSLX_FLEXCAN3, CSU_ALL_RW },
-       { CSU_CSLX_SAI2, CSU_ALL_RW },
-       { CSU_CSLX_SAI1, CSU_ALL_RW },
-       { CSU_CSLX_SAI4, CSU_ALL_RW },
-       { CSU_CSLX_SAI3, CSU_ALL_RW },
-       { CSU_CSLX_FTM2, CSU_ALL_RW },
-       { CSU_CSLX_FTM1, CSU_ALL_RW },
-       { CSU_CSLX_FTM4, CSU_ALL_RW },
-       { CSU_CSLX_FTM3, CSU_ALL_RW },
-       { CSU_CSLX_FTM6, CSU_ALL_RW },
-       { CSU_CSLX_FTM5, CSU_ALL_RW },
-       { CSU_CSLX_FTM8, CSU_ALL_RW },
-       { CSU_CSLX_FTM7, CSU_ALL_RW },
-       { CSU_CSLX_COP_DCSR, CSU_ALL_RW },
-       { CSU_CSLX_EPU, CSU_ALL_RW },
-       { CSU_CSLX_GDI, CSU_ALL_RW },
-       { CSU_CSLX_DDI, CSU_ALL_RW },
-       { CSU_CSLX_RESERVED1, CSU_ALL_RW },
-       { CSU_CSLX_USB3_PHY, CSU_ALL_RW },
-       { CSU_CSLX_RESERVED2, CSU_ALL_RW },
+struct liodn_id_table sec_liodn_tbl[] = {
+       SET_SEC_JR_LIODN_ENTRY(0, 0x10, 0x10),
+       SET_SEC_JR_LIODN_ENTRY(1, 0x10, 0x10),
+       SET_SEC_JR_LIODN_ENTRY(2, 0x10, 0x10),
+       SET_SEC_JR_LIODN_ENTRY(3, 0x10, 0x10),
+       SET_SEC_RTIC_LIODN_ENTRY(a, 0x10),
+       SET_SEC_RTIC_LIODN_ENTRY(b, 0x10),
+       SET_SEC_RTIC_LIODN_ENTRY(c, 0x10),
+       SET_SEC_RTIC_LIODN_ENTRY(d, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(0, 0x10, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(1, 0x10, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(2, 0x10, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(3, 0x10, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(4, 0x10, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(5, 0x10, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(6, 0x10, 0x10),
+       SET_SEC_DECO_LIODN_ENTRY(7, 0x10, 0x10),
 };
-#endif
 
 struct smmu_stream_id dev_stream_id[] = {
        { 0x100, 0x01, "ETSEC MAC1" },
@@ -470,17 +461,14 @@ struct smmu_stream_id dev_stream_id[] = {
 int board_init(void)
 {
        struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
+       unsigned int major;
 
-       /* Set CCI-400 control override register to
-        * enable barrier transaction */
-       out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
-       /*
-        * Set CCI-400 Slave interface S0, S1, S2 Shareable Override Register
-        * All transactions are treated as non-shareable
-        */
-       out_le32(&cci->slave[0].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
-       out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
-       out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
+       major = get_soc_major_rev();
+       if (major == SOC_MAJOR_VER_1_0) {
+               /* Set CCI-400 control override register to
+                * enable barrier transaction */
+               out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
+       }
 
        select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
 
@@ -489,11 +477,13 @@ int board_init(void)
        config_serdes_mux();
 #endif
 
+       ls1021x_config_caam_stream_id(sec_liodn_tbl,
+                                     ARRAY_SIZE(sec_liodn_tbl));
        ls102xa_config_smmu_stream_id(dev_stream_id,
                                      ARRAY_SIZE(dev_stream_id));
 
-#ifdef CONFIG_LS102XA_NS_ACCESS
-       enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev));
+#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
+       enable_layerscape_ns_access();
 #endif
 
 #ifdef CONFIG_U_QE
@@ -503,12 +493,32 @@ int board_init(void)
        return 0;
 }
 
+#if defined(CONFIG_DEEP_SLEEP)
+void board_sleep_prepare(void)
+{
+       struct ccsr_cci400 __iomem *cci = (void *)CONFIG_SYS_CCI400_ADDR;
+       unsigned int major;
+
+       major = get_soc_major_rev();
+       if (major == SOC_MAJOR_VER_1_0) {
+               /* Set CCI-400 control override register to
+                * enable barrier transaction */
+               out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
+       }
+
+
+#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
+       enable_layerscape_ns_access();
+#endif
+}
+#endif
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCIE_LAYERSCAPE
-       ft_pcie_setup(blob, bd);
+#ifdef CONFIG_PCI
+       ft_pci_setup(blob, bd);
 #endif
 
        return 0;