···158159#define DDR_GET_VAL(val, mask, shift) (((val) >> (shift)) & (mask))1600000000000000000000000000000000000000000161void ibm4xx_denali_fixup_memsize(void)162{163 u32 val, max_cs, max_col, max_row;···213 max_col = DDR_GET_VAL(val, DDR_MAX_COL_REG, DDR_MAX_COL_REG_SHIFT);214 max_row = DDR_GET_VAL(val, DDR_MAX_ROW_REG, DDR_MAX_ROW_REG_SHIFT);215216- /* get CS value */217- val = SDRAM0_READ(DDR0_10);218-219- val = DDR_GET_VAL(val, DDR_CS_MAP, DDR_CS_MAP_SHIFT);220- cs = 0;221- while (val) {222- if (val & 0x1)223- cs++;224- val = val >> 1;225- }226-227 if (!cs)228 fatal("No memory installed\n");229 if (cs > max_cs)···223 val = SDRAM0_READ(DDR0_14);224225 if (DDR_GET_VAL(val, DDR_REDUC, DDR_REDUC_SHIFT))226- dpath = 8; /* 64 bits */227- else228 dpath = 4; /* 32 bits */00229230 /* get address pins (rows) */231 val = SDRAM0_READ(DDR0_42);
···158159#define DDR_GET_VAL(val, mask, shift) (((val) >> (shift)) & (mask))160161+/*162+ * Some U-Boot versions set the number of chipselects to two163+ * for Sequoia/Rainier boards while they only have one chipselect164+ * hardwired. Hardcode the number of chipselects to one165+ * for sequioa/rainer board models or read the actual value166+ * from the memory controller register DDR0_10 otherwise.167+ */168+static inline u32 ibm4xx_denali_get_cs(void)169+{170+ void *devp;171+ char model[64];172+ u32 val, cs;173+174+ devp = finddevice("/");175+ if (!devp)176+ goto read_cs;177+178+ if (getprop(devp, "model", model, sizeof(model)) <= 0)179+ goto read_cs;180+181+ model[sizeof(model)-1] = 0;182+183+ if (!strcmp(model, "amcc,sequoia") ||184+ !strcmp(model, "amcc,rainier"))185+ return 1;186+187+read_cs:188+ /* get CS value */189+ val = SDRAM0_READ(DDR0_10);190+191+ val = DDR_GET_VAL(val, DDR_CS_MAP, DDR_CS_MAP_SHIFT);192+ cs = 0;193+ while (val) {194+ if (val & 0x1)195+ cs++;196+ val = val >> 1;197+ }198+ return cs;199+}200+201void ibm4xx_denali_fixup_memsize(void)202{203 u32 val, max_cs, max_col, max_row;···173 max_col = DDR_GET_VAL(val, DDR_MAX_COL_REG, DDR_MAX_COL_REG_SHIFT);174 max_row = DDR_GET_VAL(val, DDR_MAX_ROW_REG, DDR_MAX_ROW_REG_SHIFT);175176+ cs = ibm4xx_denali_get_cs();0000000000177 if (!cs)178 fatal("No memory installed\n");179 if (cs > max_cs)···193 val = SDRAM0_READ(DDR0_14);194195 if (DDR_GET_VAL(val, DDR_REDUC, DDR_REDUC_SHIFT))00196 dpath = 4; /* 32 bits */197+ else198+ dpath = 8; /* 64 bits */199200 /* get address pins (rows) */201 val = SDRAM0_READ(DDR0_42);