mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-17 22:49:02 +00:00
board/freescale/mpc8266ads/mpc8266ads.c: CodingStyle cleanup
Make (mostly) checkpatch clean. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Rune Torgersen <runet@innovsys.com>
This commit is contained in:
parent
f58902d0aa
commit
55e33279ce
1 changed files with 290 additions and 276 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* (C) Copyright 2001-2011
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* Modified during 2001 by
|
||||
|
@ -280,7 +280,10 @@ phys_size_t initdram(int board_type)
|
|||
u_char cksum;
|
||||
int j;
|
||||
|
||||
/* Keep the compiler from complaining about potentially uninitialized vars */
|
||||
/*
|
||||
* Keep the compiler from complaining about
|
||||
* potentially uninitialized vars
|
||||
*/
|
||||
data_width = rows = banks = cols = caslatency = 0;
|
||||
|
||||
/*
|
||||
|
@ -291,57 +294,72 @@ phys_size_t initdram(int board_type)
|
|||
i2c_read(SDRAM_SPD_ADDR, 0, 1, &data, 1);
|
||||
spd_size = data;
|
||||
cksum = data;
|
||||
for(j = 1; j < 64; j++)
|
||||
{ /* read only the checksummed bytes */
|
||||
for (j = 1; j < 64; j++) { /* read only the checksummed bytes */
|
||||
/* note: the I2C address autoincrements when alen == 0 */
|
||||
i2c_read(SDRAM_SPD_ADDR, 0, 0, &data, 1);
|
||||
/*printf("addr %d = 0x%02x\n", j, data); */
|
||||
if(j == 5) chipselects = data & 0x0F;
|
||||
else if(j == 6) data_width = data;
|
||||
else if(j == 7) data_width |= data << 8;
|
||||
else if(j == 3) rows = data & 0x0F;
|
||||
else if(j == 4) cols = data & 0x0F;
|
||||
else if(j == 12)
|
||||
{
|
||||
if (j == 5)
|
||||
chipselects = data & 0x0F;
|
||||
else if (j == 6)
|
||||
data_width = data;
|
||||
else if (j == 7)
|
||||
data_width |= data << 8;
|
||||
else if (j == 3)
|
||||
rows = data & 0x0F;
|
||||
else if (j == 4)
|
||||
cols = data & 0x0F;
|
||||
else if (j == 12) {
|
||||
/*
|
||||
* Refresh rate: this assumes the prescaler is set to
|
||||
* approximately 0.39uSec per tick and the target refresh period
|
||||
* is about 85% of maximum.
|
||||
* approximately 0.39uSec per tick and the target
|
||||
* refresh period is about 85% of maximum.
|
||||
*/
|
||||
switch(data & 0x7F)
|
||||
{
|
||||
switch (data & 0x7F) {
|
||||
default:
|
||||
case 0: psrt = 0x21; /* 15.625uS */ break;
|
||||
case 1: psrt = 0x07; /* 3.9uS */ break;
|
||||
case 2: psrt = 0x0F; /* 7.8uS */ break;
|
||||
case 3: psrt = 0x43; /* 31.3uS */ break;
|
||||
case 4: psrt = 0x87; /* 62.5uS */ break;
|
||||
case 5: psrt = 0xFF; /* 125uS */ break;
|
||||
case 0:
|
||||
psrt = 0x21; /* 15.625uS */
|
||||
break;
|
||||
case 1:
|
||||
psrt = 0x07; /* 3.9uS */
|
||||
break;
|
||||
case 2:
|
||||
psrt = 0x0F; /* 7.8uS */
|
||||
break;
|
||||
case 3:
|
||||
psrt = 0x43; /* 31.3uS */
|
||||
break;
|
||||
case 4:
|
||||
psrt = 0x87; /* 62.5uS */
|
||||
break;
|
||||
case 5:
|
||||
psrt = 0xFF; /* 125uS */
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(j == 17) banks = data;
|
||||
else if(j == 18)
|
||||
{
|
||||
} else if (j == 17)
|
||||
banks = data;
|
||||
else if (j == 18) {
|
||||
caslatency = 3; /* default CL */
|
||||
#if (PESSIMISTIC_SDRAM)
|
||||
if((data & 0x04) != 0) caslatency = 3;
|
||||
else if((data & 0x02) != 0) caslatency = 2;
|
||||
else if((data & 0x01) != 0) caslatency = 1;
|
||||
if ((data & 0x04) != 0)
|
||||
caslatency = 3;
|
||||
else if ((data & 0x02) != 0)
|
||||
caslatency = 2;
|
||||
else if ((data & 0x01) != 0)
|
||||
caslatency = 1;
|
||||
#else
|
||||
if((data & 0x01) != 0) caslatency = 1;
|
||||
else if((data & 0x02) != 0) caslatency = 2;
|
||||
else if((data & 0x04) != 0) caslatency = 3;
|
||||
if ((data & 0x01) != 0)
|
||||
caslatency = 1;
|
||||
else if ((data & 0x02) != 0)
|
||||
caslatency = 2;
|
||||
else if ((data & 0x04) != 0)
|
||||
caslatency = 3;
|
||||
#endif
|
||||
else
|
||||
{
|
||||
else {
|
||||
printf("WARNING: Unknown CAS latency 0x%02X, using 3\n",
|
||||
data);
|
||||
}
|
||||
}
|
||||
else if(j == 63)
|
||||
{
|
||||
if(data != cksum)
|
||||
{
|
||||
} else if (j == 63) {
|
||||
if (data != cksum) {
|
||||
printf("WARNING: Configuration data checksum failure:"
|
||||
" is 0x%02x, calculated 0x%02x\n",
|
||||
data, cksum);
|
||||
|
@ -356,16 +374,17 @@ phys_size_t initdram(int board_type)
|
|||
caslatency = 2;
|
||||
}
|
||||
if (rows > 14) {
|
||||
printf("This doesn't look good, rows = %d, should be <= 14\n", rows);
|
||||
printf("This doesn't look good, rows = %d, should be <= 14\n",
|
||||
rows);
|
||||
rows = 14;
|
||||
}
|
||||
if (cols > 11) {
|
||||
printf("This doesn't look good, columns = %d, should be <= 11\n", cols);
|
||||
printf("This doesn't look good, columns = %d, should be <= 11\n",
|
||||
cols);
|
||||
cols = 11;
|
||||
}
|
||||
|
||||
if((data_width != 64) && (data_width != 72))
|
||||
{
|
||||
if ((data_width != 64) && (data_width != 72)) {
|
||||
printf("WARNING: SDRAM width unsupported, is %d, expected 64 or 72.\n",
|
||||
data_width);
|
||||
}
|
||||
|
@ -373,9 +392,12 @@ phys_size_t initdram(int board_type)
|
|||
/*
|
||||
* Convert banks into log2(banks)
|
||||
*/
|
||||
if (banks == 2) banks = 1;
|
||||
else if(banks == 4) banks = 2;
|
||||
else if(banks == 8) banks = 3;
|
||||
if (banks == 2)
|
||||
banks = 1;
|
||||
else if (banks == 4)
|
||||
banks = 2;
|
||||
else if (banks == 8)
|
||||
banks = 3;
|
||||
|
||||
|
||||
sdram_size = 1 << (rows + cols + banks + width);
|
||||
|
@ -383,18 +405,24 @@ phys_size_t initdram(int board_type)
|
|||
/* !!!!! Will ONLY work with Page Based Interleave !!!!!
|
||||
( PSDMR[PBI] = 1 )
|
||||
*/
|
||||
/* mamory actually has 11 column addresses, but the memory controller
|
||||
doesn't really care.
|
||||
the calculations that follow will however move the rows so that
|
||||
they are muxed one bit off if you use 11 bit columns.
|
||||
The solution is to tell the memory controller the correct size of the memory
|
||||
but change the number of columns to 10 afterwards.
|
||||
The 11th column addre will still be mucxed correctly onto the bus.
|
||||
|
||||
Also be aware that the MPC8266ADS board Rev B has not connected
|
||||
Row address 13 to anything.
|
||||
|
||||
The fix is to connect ADD16 (from U37-47) to SADDR12 (U28-126)
|
||||
/*
|
||||
* memory actually has 11 column addresses, but the memory
|
||||
* controller doesn't really care.
|
||||
*
|
||||
* the calculations that follow will however move the rows so
|
||||
* that they are muxed one bit off if you use 11 bit columns.
|
||||
*
|
||||
* The solution is to tell the memory controller the correct
|
||||
* size of the memory but change the number of columns to 10
|
||||
* afterwards.
|
||||
*
|
||||
* The 11th column addre will still be mucxed correctly onto
|
||||
* the bus.
|
||||
*
|
||||
* Also be aware that the MPC8266ADS board Rev B has not
|
||||
* connected Row address 13 to anything.
|
||||
*
|
||||
* The fix is to connect ADD16 (from U37-47) to SADDR12 (U28-126)
|
||||
*/
|
||||
if (cols > 10)
|
||||
cols = 10;
|
||||
|
@ -432,33 +460,19 @@ phys_size_t initdram(int board_type)
|
|||
sda10 = sdam;
|
||||
#endif
|
||||
#if (PESSIMISTIC_SDRAM)
|
||||
psdmr = (CONFIG_PBI |\
|
||||
PSDMR_RFEN |\
|
||||
PSDMR_RFRC_16_CLK |\
|
||||
PSDMR_PRETOACT_8W |\
|
||||
PSDMR_ACTTORW_8W |\
|
||||
PSDMR_WRC_4C |\
|
||||
PSDMR_EAMUX |\
|
||||
PSDMR_BUFCMD) |\
|
||||
caslatency |\
|
||||
((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */ \
|
||||
(sdam << 24) |\
|
||||
(bsma << 21) |\
|
||||
(sda10 << 18);
|
||||
psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_16_CLK |
|
||||
PSDMR_PRETOACT_8W | PSDMR_ACTTORW_8W | PSDMR_WRC_4C |
|
||||
PSDMR_EAMUX | PSDMR_BUFCMD) | caslatency |
|
||||
((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */
|
||||
(sdam << 24) | (bsma << 21) | (sda10 << 18);
|
||||
#else
|
||||
psdmr = (CONFIG_PBI |\
|
||||
PSDMR_RFEN |\
|
||||
PSDMR_RFRC_7_CLK |\
|
||||
PSDMR_PRETOACT_3W | /* 1 for 7E parts (fast PC-133) */ \
|
||||
PSDMR_ACTTORW_2W | /* 1 for 7E parts (fast PC-133) */ \
|
||||
psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_7_CLK |
|
||||
PSDMR_PRETOACT_3W | /* 1 for 7E parts (fast PC-133) */
|
||||
PSDMR_ACTTORW_2W | /* 1 for 7E parts (fast PC-133) */
|
||||
PSDMR_WRC_1C | /* 1 clock + 7nSec */
|
||||
EAMUX |\
|
||||
BUFCMD) |\
|
||||
caslatency |\
|
||||
((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */ \
|
||||
(sdam << 24) |\
|
||||
(bsma << 21) |\
|
||||
(sda10 << 18);
|
||||
EAMUX | BUFCMD) | caslatency |
|
||||
((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */
|
||||
(sdam << 24) | (bsma << 21) | (sda10 << 18);
|
||||
#endif
|
||||
/*printf("psdmr = 0x%08x\n", psdmr); */
|
||||
|
||||
|
@ -505,8 +519,9 @@ phys_size_t initdram(int board_type)
|
|||
* The initial commands are executed by setting P/LSDMR[OP] and
|
||||
* accessing the SDRAM with a single-byte transaction."
|
||||
*
|
||||
* The appropriate BRx/ORx registers have already been set when we
|
||||
* get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
|
||||
* The appropriate BRx/ORx registers have already been set
|
||||
* when we get here. The SDRAM can be accessed at the address
|
||||
* CONFIG_SYS_SDRAM_BASE.
|
||||
*/
|
||||
|
||||
memctl->memc_mptpr = CONFIG_SYS_MPTPR;
|
||||
|
@ -532,8 +547,7 @@ phys_size_t initdram(int board_type)
|
|||
* Do it a second time for the second set of chips if the DIMM has
|
||||
* two chip selects (double sided).
|
||||
*/
|
||||
if(chipselects > 1)
|
||||
{
|
||||
if (chipselects > 1) {
|
||||
ramaddr += sdram_size;
|
||||
|
||||
memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM + sdram_size;
|
||||
|
@ -556,7 +570,8 @@ phys_size_t initdram(int board_type)
|
|||
/* print info */
|
||||
printf("SDRAM configuration read from SPD\n");
|
||||
printf("\tSize per side = %dMB\n", sdram_size >> 20);
|
||||
printf("\tOrganization: %d sides, %d banks, %d Columns, %d Rows, Data width = %d bits\n", chipselects, 1<<(banks), cols, rows, data_width);
|
||||
printf("\tOrganization: %d sides, %d banks, %d Columns, %d Rows, Data width = %d bits\n",
|
||||
chipselects, 1 << (banks), cols, rows, data_width);
|
||||
printf("\tRefresh rate = %d, CAS latency = %d", psrt, caslatency);
|
||||
#if (CONFIG_PBI == 0) /* bank-based interleaving */
|
||||
printf(", Using Bank Based Interleave\n");
|
||||
|
@ -569,10 +584,9 @@ phys_size_t initdram(int board_type)
|
|||
* Not needed for any other memory configuration */
|
||||
if ((sdram_size * chipselects) == (16 * 1024 * 1024))
|
||||
udelay(250000);
|
||||
return (sdram_size * chipselects);
|
||||
/*return (16 * 1024 * 1024);*/
|
||||
}
|
||||
|
||||
return sdram_size * chipselects;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
struct pci_controller hose;
|
||||
|
|
Loading…
Add table
Reference in a new issue