]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/powerpc/cpu/mpc8xxx/cpu.c
Merge branch 'u-boot-samsung/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / arch / powerpc / cpu / mpc8xxx / cpu.c
index ab454f50dbd9a5f9a669929cdb8ee7a01370e289..bc2685544e831ddfee1023da837b6b507916e8a5 100644 (file)
@@ -77,6 +77,7 @@ static struct cpu_type cpu_type_list[] = {
        CPU_TYPE_ENTRY(P5040, P5040, 4),
        CPU_TYPE_ENTRY(T4240, T4240, 0),
        CPU_TYPE_ENTRY(T4120, T4120, 0),
+       CPU_TYPE_ENTRY(T4160, T4160, 0),
        CPU_TYPE_ENTRY(B4860, B4860, 0),
        CPU_TYPE_ENTRY(G4860, G4860, 0),
        CPU_TYPE_ENTRY(G4060, G4060, 0),
@@ -84,6 +85,12 @@ static struct cpu_type cpu_type_list[] = {
        CPU_TYPE_ENTRY(G4440, G4440, 0),
        CPU_TYPE_ENTRY(B4420, B4420, 0),
        CPU_TYPE_ENTRY(B4220, B4220, 0),
+       CPU_TYPE_ENTRY(T1040, T1040, 0),
+       CPU_TYPE_ENTRY(T1041, T1041, 0),
+       CPU_TYPE_ENTRY(T1042, T1042, 0),
+       CPU_TYPE_ENTRY(T1020, T1020, 0),
+       CPU_TYPE_ENTRY(T1021, T1021, 0),
+       CPU_TYPE_ENTRY(T1022, T1022, 0),
        CPU_TYPE_ENTRY(BSC9130, 9130, 1),
        CPU_TYPE_ENTRY(BSC9131, 9131, 1),
        CPU_TYPE_ENTRY(BSC9132, 9132, 2),
@@ -96,35 +103,70 @@ static struct cpu_type cpu_type_list[] = {
 };
 
 #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
+static inline u32 init_type(u32 cluster, int init_id)
+{
+       ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+       u32 idx = (cluster >> (init_id * 8)) & TP_CLUSTER_INIT_MASK;
+       u32 type = in_be32(&gur->tp_ityp[idx]);
+
+       if (type & TP_ITYP_AV)
+               return type;
+
+       return 0;
+}
+
 u32 compute_ppc_cpumask(void)
 {
-       ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+       ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
        int i = 0, count = 0;
-       u32 cluster, mask = 0;
+       u32 cluster, type, mask = 0;
 
        do {
                int j;
-               cluster = in_be32(&gur->tp_cluster[i++].lower);
-               for (j = 0; j < 4; j++) {
-                       u32 idx = (cluster >> (j*8)) & TP_CLUSTER_INIT_MASK;
-                       u32 type = in_be32(&gur->tp_ityp[idx]);
-
-                       if (type & TP_ITYP_AV) {
+               cluster = in_be32(&gur->tp_cluster[i].lower);
+               for (j = 0; j < TP_INIT_PER_CLUSTER; j++) {
+                       type = init_type(cluster, j);
+                       if (type) {
                                if (TP_ITYP_TYPE(type) == TP_ITYP_TYPE_PPC)
                                        mask |= 1 << count;
+                               count++;
                        }
-                       count++;
                }
+               i++;
        } while ((cluster & TP_CLUSTER_EOC) != TP_CLUSTER_EOC);
 
        return mask;
 }
+
+int fsl_qoriq_core_to_cluster(unsigned int core)
+{
+       ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+       int i = 0, count = 0;
+       u32 cluster;
+
+       do {
+               int j;
+               cluster = in_be32(&gur->tp_cluster[i].lower);
+               for (j = 0; j < TP_INIT_PER_CLUSTER; j++) {
+                       if (init_type(cluster, j)) {
+                               if (count == core)
+                                       return i;
+                               count++;
+                       }
+               }
+               i++;
+       } while ((cluster & TP_CLUSTER_EOC) != TP_CLUSTER_EOC);
+
+       return -1;      /* cannot identify the cluster */
+}
+
 #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
 /*
  * Before chassis genenration 2, the cpumask should be hard-coded.
  * In case of cpu type unknown or cpumask unset, use 1 as fail save.
  */
 #define compute_ppc_cpumask()  1
+#define fsl_qoriq_core_to_cluster(x) x
 #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
 
 static struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 0);
@@ -148,7 +190,7 @@ struct cpu_type *identify_cpu(u32 ver)
 u32 cpu_mask(void)
 {
        ccsr_pic_t __iomem *pic = (void *)CONFIG_SYS_MPC8xxx_PIC_ADDR;
-       struct cpu_type *cpu = gd->cpu;
+       struct cpu_type *cpu = gd->arch.cpu;
 
        /* better to query feature reporting register than just assume 1 */
        if (cpu == &cpu_type_unknown)
@@ -166,7 +208,7 @@ u32 cpu_mask(void)
  */
 int cpu_numcores(void)
 {
-       struct cpu_type *cpu = gd->cpu;
+       struct cpu_type *cpu = gd->arch.cpu;
 
        /*
         * Report # of cores in terms of the cpu_mask if we haven't
@@ -196,7 +238,7 @@ int probecpu (void)
        svr = get_svr();
        ver = SVR_SOC_VER(svr);
 
-       gd->cpu = identify_cpu(ver);
+       gd->arch.cpu = identify_cpu(ver);
 
        return 0;
 }
@@ -204,7 +246,7 @@ int probecpu (void)
 /* Once in memory, compute mask & # cores once and save them off */
 int fixup_cpu(void)
 {
-       struct cpu_type *cpu = gd->cpu;
+       struct cpu_type *cpu = gd->arch.cpu;
 
        if (cpu->num_cores == 0) {
                cpu->mask = cpu_mask();