board/sacsng/sacsng.c: CodingStyle cleanup

Make (mostly) checkpatch clean.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Jerry Van Baren <gerald.vanbaren@smiths-aerospace.com>
This commit is contained in:
Wolfgang Denk 2011-11-05 05:13:14 +00:00
parent 7b490cf34a
commit e615de0ab3

View File

@ -142,21 +142,17 @@ extern void eth_loopback_test(void);
#define DAC_REG5_MCLK_DIV 0x02 /* MCLK divide by 2 */
#define DAC_REG5_RESERVED 0x01 /* Reserved */
/* ------------------------------------------------------------------------- */
/*
* Check Board Identity:
*/
int checkboard(void)
{
printf ("SACSng\n");
printf("SACSng\n");
return 0;
}
/* ------------------------------------------------------------------------- */
phys_size_t initdram(int board_type)
{
volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
@ -169,6 +165,7 @@ phys_size_t initdram(int board_type)
uint chipselects = 1; /* for no SPD */
uint sdram_size = CONFIG_SYS_SDRAM0_SIZE * 1024 * 1024; /* for no SPD */
uint or = CONFIG_SYS_OR2_PRELIM; /* for no SPD */
#ifdef SDRAM_SPD_ADDR
uint data_width;
uint rows;
@ -188,7 +185,8 @@ phys_size_t initdram(int board_type)
#ifdef SDRAM_SPD_ADDR
/* Keep the compiler from complaining about potentially uninitialized vars */
data_width = chipselects = rows = banks = cols = caslatency = psrt = 0;
data_width = chipselects = rows = banks = cols = caslatency = psrt =
0;
/*
* Read the SDRAM SPD EEPROM via I2C.
@ -196,72 +194,92 @@ 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);
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 1uSec per tick.
*/
switch(data & 0x7F) {
switch (data & 0x7F) {
default:
case 0: psrt = 14 ; /* 15.625uS */ break;
case 1: psrt = 2; /* 3.9uS */ break;
case 2: psrt = 6; /* 7.8uS */ break;
case 3: psrt = 29; /* 31.3uS */ break;
case 4: psrt = 60; /* 62.5uS */ break;
case 5: psrt = 120; /* 125uS */ break;
case 0:
psrt = 14; /* 15.625uS */
break;
case 1:
psrt = 2; /* 3.9uS */
break;
case 2:
psrt = 6; /* 7.8uS */
break;
case 3:
psrt = 29; /* 31.3uS */
break;
case 4:
psrt = 60; /* 62.5uS */
break;
case 5:
psrt = 120; /* 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 {
printf ("WARNING: Unknown CAS latency 0x%02X, using 3\n",
data);
printf("WARNING: Unknown CAS latency 0x%02X, using 3\n", data);
}
}
else if(j == 63) {
if(data != cksum) {
printf ("WARNING: Configuration data checksum failure:"
" is 0x%02x, calculated 0x%02x\n",
data, cksum);
} else if (j == 63) {
if (data != cksum) {
printf("WARNING: Configuration data checksum failure:" " is 0x%02x, calculated 0x%02x\n", data, cksum);
}
}
cksum += data;
}
/* We don't trust CL less than 2 (only saw it on an old 16MByte DIMM) */
if(caslatency < 2) {
if (caslatency < 2) {
printf("WARNING: CL was %d, forcing to 2\n", caslatency);
caslatency = 2;
}
if(rows > 14) {
printf("WARNING: This doesn't look good, rows = %d, should be <= 14\n", rows);
if (rows > 14) {
printf("WARNING: This doesn't look good, rows = %d, should be <= 14\n",
rows);
rows = 14;
}
if(cols > 11) {
printf("WARNING: This doesn't look good, columns = %d, should be <= 11\n", cols);
if (cols > 11) {
printf("WARNING: 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);
}
@ -269,9 +287,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);
@ -282,7 +303,7 @@ phys_size_t initdram(int board_type)
#endif
or = ~(sdram_size - 1) | /* SDAM address mask */
((banks-1) << 13) | /* banks per device */
((banks - 1) << 13) | /* banks per device */
(rowst << 9) | /* rowst */
((rows - 9) << 6); /* numr */
@ -307,33 +328,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
#endif
@ -404,7 +411,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;
@ -431,7 +438,7 @@ phys_size_t initdram(int board_type)
/*-----------------------------------------------------------------------
* Board Control Functions
*/
void board_poweroff (void)
void board_poweroff(void)
{
while (1); /* hang forever */
}
@ -444,12 +451,14 @@ int misc_init_r(void)
/*
* Note: iop is used by the I2C macros, and iopa by the ADC/DAC initialization.
*/
volatile ioport_t *iopa = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 0 /* port A */);
volatile ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT);
volatile ioport_t *iopa =
ioport_addr((immap_t *)CONFIG_SYS_IMMR, 0 /* port A */ );
volatile ioport_t *iop =
ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT);
int reg; /* I2C register value */
char *ep; /* Environment pointer */
char str_buf[12] ; /* sprintf output buffer */
char str_buf[12]; /* sprintf output buffer */
int sample_rate; /* ADC/DAC sample rate */
int sample_64x; /* Use 64/4 clocking for the ADC/DAC */
int sample_128x; /* Use 128/4 clocking for the ADC/DAC */
@ -458,12 +467,11 @@ int misc_init_r(void)
int quiet; /* Quiet or minimal output mode */
quiet = 0;
if ((ep = getenv("quiet")) != NULL) {
if ((ep = getenv("quiet")) != NULL)
quiet = simple_strtol(ep, NULL, 10);
}
else {
else
setenv("quiet", "0");
}
/*
* SACSng custom initialization:
@ -472,32 +480,26 @@ int misc_init_r(void)
*/
sample_rate = INITIAL_SAMPLE_RATE;
if ((ep = getenv("DaqSampleRate")) != NULL) {
if ((ep = getenv("DaqSampleRate")) != NULL)
sample_rate = simple_strtol(ep, NULL, 10);
}
sample_64x = INITIAL_SAMPLE_64X;
sample_128x = INITIAL_SAMPLE_128X;
if ((ep = getenv("Daq64xSampling")) != NULL) {
sample_64x = simple_strtol(ep, NULL, 10);
if (sample_64x) {
if (sample_64x)
sample_128x = 0;
}
else {
else
sample_128x = 1;
}
}
else {
} else {
if ((ep = getenv("Daq128xSampling")) != NULL) {
sample_128x = simple_strtol(ep, NULL, 10);
if (sample_128x) {
if (sample_128x)
sample_64x = 0;
}
else {
else
sample_64x = 1;
}
}
}
/*
* Stop the clocks and wait for at least 1 LRCLK period
@ -525,8 +527,7 @@ int misc_init_r(void)
if (sample_64x) {
setenv("Daq64xSampling", "1");
setenv("Daq128xSampling", NULL);
}
else {
} else {
setenv("Daq64xSampling", NULL);
setenv("Daq128xSampling", "1");
}
@ -534,18 +535,16 @@ int misc_init_r(void)
/*
* Display the ADC/DAC clocking information
*/
if (!quiet) {
if (!quiet)
Daq_Display_Clocks();
}
/*
* Determine the DAC data justification
*/
right_just = INITIAL_RIGHT_JUST;
if ((ep = getenv("DaqDACRightJustified")) != NULL) {
if ((ep = getenv("DaqDACRightJustified")) != NULL)
right_just = simple_strtol(ep, NULL, 10);
}
sprintf(str_buf, "%d", right_just);
setenv("DaqDACRightJustified", str_buf);
@ -555,9 +554,8 @@ int misc_init_r(void)
*/
mclk_divide = INITIAL_MCLK_DIVIDE;
if ((ep = getenv("DaqDACMClockDivide")) != NULL) {
if ((ep = getenv("DaqDACMClockDivide")) != NULL)
mclk_divide = simple_strtol(ep, NULL, 10);
}
sprintf(str_buf, "%d", mclk_divide);
setenv("DaqDACMClockDivide", str_buf);
@ -571,9 +569,9 @@ int misc_init_r(void)
* 4) Enable address matching by setting the MSB in register 7
*/
if (!quiet) {
if (!quiet)
printf("Initializing the ADC...\n");
}
udelay(ADC_INITIAL_DELAY); /* 10uSec per uF of VREF cap */
iopa->pdat &= ~ADC_SDATA1_MASK; /* release SDATA1 */
@ -585,38 +583,37 @@ int misc_init_r(void)
i2c_reg_write(I2C_ADC_1_ADDR, 0x02, /* 128x, slave mode, !HPEN */
(sample_64x ? 0 : ADC_REG2_128x) |
ADC_REG2_HIGH_PASS_DIS |
ADC_REG2_SLAVE_MODE);
ADC_REG2_HIGH_PASS_DIS | ADC_REG2_SLAVE_MODE);
reg = i2c_reg_read(I2C_ADC_1_ADDR, 0x06) & 0x7F;
if(reg != I2C_ADC_1_ADDR)
if (reg != I2C_ADC_1_ADDR) {
printf("Init of ADC U10 failed: address is 0x%02X should be 0x%02X\n",
reg, I2C_ADC_1_ADDR);
}
iopa->pdat &= ~ADC_SDATA2_MASK; /* release SDATA2 */
udelay(ADC_SDATA_DELAY); /* arbitrary settling time */
i2c_reg_write(0x00, 0x06, I2C_ADC_2_ADDR); /* set address (do not set ADDREN yet) */
/* set address (do not set ADDREN yet) */
i2c_reg_write(0x00, 0x06, I2C_ADC_2_ADDR);
i2c_reg_write(I2C_ADC_2_ADDR, 0x02, /* 64x, slave mode, !HPEN */
(sample_64x ? 0 : ADC_REG2_128x) |
ADC_REG2_HIGH_PASS_DIS |
ADC_REG2_SLAVE_MODE);
ADC_REG2_HIGH_PASS_DIS | ADC_REG2_SLAVE_MODE);
reg = i2c_reg_read(I2C_ADC_2_ADDR, 0x06) & 0x7F;
if(reg != I2C_ADC_2_ADDR)
if (reg != I2C_ADC_2_ADDR) {
printf("Init of ADC U15 failed: address is 0x%02X should be 0x%02X\n",
reg, I2C_ADC_2_ADDR);
}
i2c_reg_write(I2C_ADC_1_ADDR, 0x01, /* set FSTART and GNDCAL */
ADC_REG1_FRAME_START |
ADC_REG1_GROUND_CAL);
ADC_REG1_FRAME_START | ADC_REG1_GROUND_CAL);
i2c_reg_write(I2C_ADC_1_ADDR, 0x02, /* Start calibration */
(sample_64x ? 0 : ADC_REG2_128x) |
ADC_REG2_CAL |
ADC_REG2_HIGH_PASS_DIS |
ADC_REG2_SLAVE_MODE);
ADC_REG2_HIGH_PASS_DIS | ADC_REG2_SLAVE_MODE);
udelay(ADC_CAL_DELAY); /* a minimum of 4100 LRCLKs */
i2c_reg_write(I2C_ADC_1_ADDR, 0x01, 0x00); /* remove GNDCAL */
@ -635,9 +632,8 @@ int misc_init_r(void)
* sending an I2C "start" sequence. When we bring the I2C back to
* the normal state, we send an I2C "stop" sequence.
*/
if (!quiet) {
if (!quiet)
printf("Initializing the DAC...\n");
}
/*
* Bring the I2C clock and data lines low for initialization
@ -662,8 +658,7 @@ int misc_init_r(void)
* Going into power down
*/
i2c_reg_write(I2C_DAC_ADDR, 0x05,
DAC_REG5_I2C_MODE |
DAC_REG5_POWER_DOWN);
DAC_REG5_I2C_MODE | DAC_REG5_POWER_DOWN);
/*
* Cause the DAC to:
@ -690,7 +685,8 @@ int misc_init_r(void)
(right_just ? DAC_REG1_RIGHT_JUST_24BIT :
DAC_REG1_LEFT_JUST_24_BIT) |
DAC_REG1_DEM_NO |
(sample_rate >= 50000 ? DAC_REG1_DOUBLE : DAC_REG1_SINGLE));
(sample_rate >=
50000 ? DAC_REG1_DOUBLE : DAC_REG1_SINGLE));
sprintf(str_buf, "%d",
sample_rate >= 50000 ? DAC_REG1_DOUBLE : DAC_REG1_SINGLE);
@ -717,15 +713,13 @@ int misc_init_r(void)
I2C_DELAY;
I2C_TRISTATE;
if (!quiet) {
if (!quiet)
printf("\n");
}
#ifdef CONFIG_ETHER_LOOPBACK_TEST
/*
* Run the Ethernet loopback test
*/
eth_loopback_test ();
eth_loopback_test();
#endif /* CONFIG_ETHER_LOOPBACK_TEST */
#ifdef CONFIG_SHOW_BOOT_PROGRESS
@ -754,16 +748,15 @@ static void flash_code(uchar number, uchar modulo, uchar digits)
/*
* Recursively do upper digits.
*/
if(digits > 1) {
if (digits > 1)
flash_code(number / modulo, modulo, digits - 1);
}
number = number % modulo;
/*
* Zero is indicated by one long flash (dash).
*/
if(number == 0) {
if (number == 0) {
status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
udelay(1000000);
status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
@ -772,7 +765,7 @@ static void flash_code(uchar number, uchar modulo, uchar digits)
/*
* Non-zero is indicated by short flashes, one per count.
*/
for(j = 0; j < number; j++) {
for (j = 0; j < number; j++) {
status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
udelay(100000);
status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
@ -787,23 +780,24 @@ static void flash_code(uchar number, uchar modulo, uchar digits)
static int last_boot_progress;
void show_boot_progress (int status)
void show_boot_progress(int status)
{
int i,j;
if(status > 0) {
int i, j;
if (status > 0) {
last_boot_progress = status;
} else {
/*
* If a specific failure code is given, flash this code
* else just use the last success code we've seen
*/
if(status < -1)
if (status < -1)
last_boot_progress = -status;
/*
* Flash this code 5 times
*/
for(j=0; j<5; j++) {
for (j = 0; j < 5; j++) {
/*
* Houston, we have a problem.
* Blink the last OK status which indicates where things failed.
@ -815,8 +809,9 @@ void show_boot_progress (int status)
* Delay 5 seconds between repetitions,
* with the fault LED blinking
*/
for(i=0; i<5; i++) {
status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
for (i = 0; i < 5; i++) {
status_led_set(STATUS_LED_RED,
STATUS_LED_OFF);
udelay(500000);
status_led_set(STATUS_LED_RED, STATUS_LED_ON);
udelay(500000);
@ -826,7 +821,7 @@ void show_boot_progress (int status)
/*
* Reset the board to retry initialization.
*/
do_reset (NULL, 0, 0, NULL);
do_reset(NULL, 0, 0, NULL);
}
}
#endif /* CONFIG_SHOW_BOOT_PROGRESS */
@ -852,14 +847,16 @@ int spi_cs_is_valid(unsigned int bus, unsigned int cs)
void spi_cs_activate(struct spi_slave *slave)
{
volatile ioport_t *iopd = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3 /* port D */);
volatile ioport_t *iopd =
ioport_addr((immap_t *) CONFIG_SYS_IMMR, 3 /* port D */ );
iopd->pdat &= ~cs_mask[slave->cs];
}
void spi_cs_deactivate(struct spi_slave *slave)
{
volatile ioport_t *iopd = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3 /* port D */);
volatile ioport_t *iopd =
ioport_addr((immap_t *) CONFIG_SYS_IMMR, 3 /* port D */ );
iopd->pdat |= cs_mask[slave->cs];
}