Home | History | Annotate | Download | only in misc
      1 // SPDX-License-Identifier: GPL-2.0+
      2 /*
      3  * Copyright 2010-2011 Freescale Semiconductor, Inc.
      4  * Author: Dipen Dudhat <dipen.dudhat (at) freescale.com>
      5  */
      6 
      7 #include <common.h>
      8 #include <fsl_ifc.h>
      9 
     10 void print_ifc_regs(void)
     11 {
     12 	int i, j;
     13 
     14 	printf("IFC Controller Registers\n");
     15 	for (i = 0; i < CONFIG_SYS_FSL_IFC_BANK_COUNT; i++) {
     16 		printf("CSPR%d:0x%08X\tAMASK%d:0x%08X\tCSOR%d:0x%08X\n",
     17 			i, get_ifc_cspr(i), i, get_ifc_amask(i),
     18 			i, get_ifc_csor(i));
     19 		for (j = 0; j < 4; j++)
     20 			printf("IFC_FTIM%d:0x%08X\n", j, get_ifc_ftim(i, j));
     21 	}
     22 }
     23 
     24 void init_early_memctl_regs(void)
     25 {
     26 #if defined(CONFIG_SYS_CSPR0) && defined(CONFIG_SYS_CSOR0)
     27 	set_ifc_ftim(IFC_CS0, IFC_FTIM0, CONFIG_SYS_CS0_FTIM0);
     28 	set_ifc_ftim(IFC_CS0, IFC_FTIM1, CONFIG_SYS_CS0_FTIM1);
     29 	set_ifc_ftim(IFC_CS0, IFC_FTIM2, CONFIG_SYS_CS0_FTIM2);
     30 	set_ifc_ftim(IFC_CS0, IFC_FTIM3, CONFIG_SYS_CS0_FTIM3);
     31 
     32 #ifndef CONFIG_A003399_NOR_WORKAROUND
     33 #ifdef CONFIG_SYS_CSPR0_EXT
     34 	set_ifc_cspr_ext(IFC_CS0, CONFIG_SYS_CSPR0_EXT);
     35 #endif
     36 #ifdef CONFIG_SYS_CSOR0_EXT
     37 	set_ifc_csor_ext(IFC_CS0, CONFIG_SYS_CSOR0_EXT);
     38 #endif
     39 	set_ifc_cspr(IFC_CS0, CONFIG_SYS_CSPR0);
     40 	set_ifc_amask(IFC_CS0, CONFIG_SYS_AMASK0);
     41 	set_ifc_csor(IFC_CS0, CONFIG_SYS_CSOR0);
     42 #endif
     43 #endif
     44 
     45 #ifdef CONFIG_SYS_CSPR1_EXT
     46 	set_ifc_cspr_ext(IFC_CS1, CONFIG_SYS_CSPR1_EXT);
     47 #endif
     48 #ifdef CONFIG_SYS_CSOR1_EXT
     49 	set_ifc_csor_ext(IFC_CS1, CONFIG_SYS_CSOR1_EXT);
     50 #endif
     51 #if defined(CONFIG_SYS_CSPR1) && defined(CONFIG_SYS_CSOR1)
     52 	set_ifc_ftim(IFC_CS1, IFC_FTIM0, CONFIG_SYS_CS1_FTIM0);
     53 	set_ifc_ftim(IFC_CS1, IFC_FTIM1, CONFIG_SYS_CS1_FTIM1);
     54 	set_ifc_ftim(IFC_CS1, IFC_FTIM2, CONFIG_SYS_CS1_FTIM2);
     55 	set_ifc_ftim(IFC_CS1, IFC_FTIM3, CONFIG_SYS_CS1_FTIM3);
     56 
     57 	set_ifc_csor(IFC_CS1, CONFIG_SYS_CSOR1);
     58 	set_ifc_amask(IFC_CS1, CONFIG_SYS_AMASK1);
     59 	set_ifc_cspr(IFC_CS1, CONFIG_SYS_CSPR1);
     60 #endif
     61 
     62 #ifdef CONFIG_SYS_CSPR2_EXT
     63 	set_ifc_cspr_ext(IFC_CS2, CONFIG_SYS_CSPR2_EXT);
     64 #endif
     65 #ifdef CONFIG_SYS_CSOR2_EXT
     66 	set_ifc_csor_ext(IFC_CS2, CONFIG_SYS_CSOR2_EXT);
     67 #endif
     68 #if defined(CONFIG_SYS_CSPR2) && defined(CONFIG_SYS_CSOR2)
     69 	set_ifc_ftim(IFC_CS2, IFC_FTIM0, CONFIG_SYS_CS2_FTIM0);
     70 	set_ifc_ftim(IFC_CS2, IFC_FTIM1, CONFIG_SYS_CS2_FTIM1);
     71 	set_ifc_ftim(IFC_CS2, IFC_FTIM2, CONFIG_SYS_CS2_FTIM2);
     72 	set_ifc_ftim(IFC_CS2, IFC_FTIM3, CONFIG_SYS_CS2_FTIM3);
     73 
     74 	set_ifc_csor(IFC_CS2, CONFIG_SYS_CSOR2);
     75 	set_ifc_amask(IFC_CS2, CONFIG_SYS_AMASK2);
     76 	set_ifc_cspr(IFC_CS2, CONFIG_SYS_CSPR2);
     77 #endif
     78 
     79 #ifdef CONFIG_SYS_CSPR3_EXT
     80 	set_ifc_cspr_ext(IFC_CS3, CONFIG_SYS_CSPR3_EXT);
     81 #endif
     82 #ifdef CONFIG_SYS_CSOR3_EXT
     83 	set_ifc_csor_ext(IFC_CS3, CONFIG_SYS_CSOR3_EXT);
     84 #endif
     85 #if defined(CONFIG_SYS_CSPR3) && defined(CONFIG_SYS_CSOR3)
     86 	set_ifc_ftim(IFC_CS3, IFC_FTIM0, CONFIG_SYS_CS3_FTIM0);
     87 	set_ifc_ftim(IFC_CS3, IFC_FTIM1, CONFIG_SYS_CS3_FTIM1);
     88 	set_ifc_ftim(IFC_CS3, IFC_FTIM2, CONFIG_SYS_CS3_FTIM2);
     89 	set_ifc_ftim(IFC_CS3, IFC_FTIM3, CONFIG_SYS_CS3_FTIM3);
     90 
     91 	set_ifc_cspr(IFC_CS3, CONFIG_SYS_CSPR3);
     92 	set_ifc_amask(IFC_CS3, CONFIG_SYS_AMASK3);
     93 	set_ifc_csor(IFC_CS3, CONFIG_SYS_CSOR3);
     94 #endif
     95 
     96 #ifdef CONFIG_SYS_CSPR4_EXT
     97 	set_ifc_cspr_ext(IFC_CS4, CONFIG_SYS_CSPR4_EXT);
     98 #endif
     99 #ifdef CONFIG_SYS_CSOR4_EXT
    100 	set_ifc_csor_ext(IFC_CS4, CONFIG_SYS_CSOR4_EXT);
    101 #endif
    102 #if defined(CONFIG_SYS_CSPR4) && defined(CONFIG_SYS_CSOR4)
    103 	set_ifc_ftim(IFC_CS4, IFC_FTIM0, CONFIG_SYS_CS4_FTIM0);
    104 	set_ifc_ftim(IFC_CS4, IFC_FTIM1, CONFIG_SYS_CS4_FTIM1);
    105 	set_ifc_ftim(IFC_CS4, IFC_FTIM2, CONFIG_SYS_CS4_FTIM2);
    106 	set_ifc_ftim(IFC_CS4, IFC_FTIM3, CONFIG_SYS_CS4_FTIM3);
    107 
    108 	set_ifc_cspr(IFC_CS4, CONFIG_SYS_CSPR4);
    109 	set_ifc_amask(IFC_CS4, CONFIG_SYS_AMASK4);
    110 	set_ifc_csor(IFC_CS4, CONFIG_SYS_CSOR4);
    111 #endif
    112 
    113 #ifdef CONFIG_SYS_CSPR5_EXT
    114 	set_ifc_cspr_ext(IFC_CS5, CONFIG_SYS_CSPR5_EXT);
    115 #endif
    116 #ifdef CONFIG_SYS_CSOR5_EXT
    117 	set_ifc_csor_ext(IFC_CS5, CONFIG_SYS_CSOR5_EXT);
    118 #endif
    119 #if defined(CONFIG_SYS_CSPR5) && defined(CONFIG_SYS_CSOR5)
    120 	set_ifc_ftim(IFC_CS5, IFC_FTIM0, CONFIG_SYS_CS5_FTIM0);
    121 	set_ifc_ftim(IFC_CS5, IFC_FTIM1, CONFIG_SYS_CS5_FTIM1);
    122 	set_ifc_ftim(IFC_CS5, IFC_FTIM2, CONFIG_SYS_CS5_FTIM2);
    123 	set_ifc_ftim(IFC_CS5, IFC_FTIM3, CONFIG_SYS_CS5_FTIM3);
    124 
    125 	set_ifc_cspr(IFC_CS5, CONFIG_SYS_CSPR5);
    126 	set_ifc_amask(IFC_CS5, CONFIG_SYS_AMASK5);
    127 	set_ifc_csor(IFC_CS5, CONFIG_SYS_CSOR5);
    128 #endif
    129 
    130 #ifdef CONFIG_SYS_CSPR6_EXT
    131 	set_ifc_cspr_ext(IFC_CS6, CONFIG_SYS_CSPR6_EXT);
    132 #endif
    133 #ifdef CONFIG_SYS_CSOR6_EXT
    134 	set_ifc_csor_ext(IFC_CS6, CONFIG_SYS_CSOR6_EXT);
    135 #endif
    136 #if defined(CONFIG_SYS_CSPR6) && defined(CONFIG_SYS_CSOR6)
    137 	set_ifc_ftim(IFC_CS6, IFC_FTIM0, CONFIG_SYS_CS6_FTIM0);
    138 	set_ifc_ftim(IFC_CS6, IFC_FTIM1, CONFIG_SYS_CS6_FTIM1);
    139 	set_ifc_ftim(IFC_CS6, IFC_FTIM2, CONFIG_SYS_CS6_FTIM2);
    140 	set_ifc_ftim(IFC_CS6, IFC_FTIM3, CONFIG_SYS_CS6_FTIM3);
    141 
    142 	set_ifc_cspr(IFC_CS6, CONFIG_SYS_CSPR6);
    143 	set_ifc_amask(IFC_CS6, CONFIG_SYS_AMASK6);
    144 	set_ifc_csor(IFC_CS6, CONFIG_SYS_CSOR6);
    145 #endif
    146 
    147 #ifdef CONFIG_SYS_CSPR7_EXT
    148 	set_ifc_cspr_ext(IFC_CS7, CONFIG_SYS_CSPR7_EXT);
    149 #endif
    150 #ifdef CONFIG_SYS_CSOR7_EXT
    151 	set_ifc_csor_ext(IFC_CS7, CONFIG_SYS_CSOR7_EXT);
    152 #endif
    153 #if defined(CONFIG_SYS_CSPR7) && defined(CONFIG_SYS_CSOR7)
    154 	set_ifc_ftim(IFC_CS7, IFC_FTIM0, CONFIG_SYS_CS7_FTIM0);
    155 	set_ifc_ftim(IFC_CS7, IFC_FTIM1, CONFIG_SYS_CS7_FTIM1);
    156 	set_ifc_ftim(IFC_CS7, IFC_FTIM2, CONFIG_SYS_CS7_FTIM2);
    157 	set_ifc_ftim(IFC_CS7, IFC_FTIM3, CONFIG_SYS_CS7_FTIM3);
    158 
    159 	set_ifc_cspr(IFC_CS7, CONFIG_SYS_CSPR7);
    160 	set_ifc_amask(IFC_CS7, CONFIG_SYS_AMASK7);
    161 	set_ifc_csor(IFC_CS7, CONFIG_SYS_CSOR7);
    162 #endif
    163 }
    164 
    165 void init_final_memctl_regs(void)
    166 {
    167 #ifdef CONFIG_SYS_CSPR0_FINAL
    168 	set_ifc_cspr(IFC_CS0, CONFIG_SYS_CSPR0_FINAL);
    169 #endif
    170 #ifdef CONFIG_SYS_AMASK0_FINAL
    171 	set_ifc_amask(IFC_CS0, CONFIG_SYS_AMASK0);
    172 #endif
    173 #ifdef CONFIG_SYS_CSPR1_FINAL
    174 	set_ifc_cspr(IFC_CS1, CONFIG_SYS_CSPR1_FINAL);
    175 #endif
    176 #ifdef CONFIG_SYS_AMASK1_FINAL
    177 	set_ifc_amask(IFC_CS1, CONFIG_SYS_AMASK1_FINAL);
    178 #endif
    179 #ifdef CONFIG_SYS_CSPR2_FINAL
    180 	set_ifc_cspr(IFC_CS2, CONFIG_SYS_CSPR2_FINAL);
    181 #endif
    182 #ifdef CONFIG_SYS_AMASK2_FINAL
    183 	set_ifc_amask(IFC_CS2, CONFIG_SYS_AMASK2);
    184 #endif
    185 #ifdef CONFIG_SYS_CSPR3_FINAL
    186 	set_ifc_cspr(IFC_CS3, CONFIG_SYS_CSPR3_FINAL);
    187 #endif
    188 #ifdef CONFIG_SYS_AMASK3_FINAL
    189 	set_ifc_amask(IFC_CS3, CONFIG_SYS_AMASK3);
    190 #endif
    191 }
    192