Coding Style cleanup

This commit is contained in:
Wolfgang Denk 2006-05-03 01:24:04 +02:00
parent da4849fb30
commit 610cf3676e
6 changed files with 462 additions and 451 deletions

View File

@ -2,6 +2,8 @@
Changes since U-Boot 1.1.4: Changes since U-Boot 1.1.4:
====================================================================== ======================================================================
* Coding Style cleanup
* Write RTC seconds first to maintain settings integrity per * Write RTC seconds first to maintain settings integrity per
Maxim/Dallas DS1306 data sheet. Maxim/Dallas DS1306 data sheet.
Patch by Alan J. Luse, 02 May 2006 Patch by Alan J. Luse, 02 May 2006

View File

@ -1,6 +1,4 @@
/* /*
* -- Version 1.1 --
*
* (C) Copyright 2003-2004 * (C) Copyright 2003-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
* *
@ -13,9 +11,6 @@
* (C) Copyright 2006 * (C) Copyright 2006
* Stefan Strobl, GERSYS GmbH, stefan.strobl@gersys.de * Stefan Strobl, GERSYS GmbH, stefan.strobl@gersys.de
* *
* History:
* 1.1 - improved SM501 init to meet spec timing
*
* See file CREDITS for list of people who contributed to this * See file CREDITS for list of people who contributed to this
* project. * project.
* *

View File

@ -134,22 +134,32 @@ int sm501_gpio_init(void)
} }
/* enable SM501 GPIO control (in both power modes) */ /* enable SM501 GPIO control (in both power modes) */
*(vu_long *) (SM501_MMIO_BASE + SM501_POWER_MODE0_GATE) |= POWER_MODE_GATE_GPIO_PWM_I2C; *(vu_long *) (SM501_MMIO_BASE + SM501_POWER_MODE0_GATE) |=
*(vu_long *) (SM501_MMIO_BASE + SM501_POWER_MODE1_GATE) |= POWER_MODE_GATE_GPIO_PWM_I2C; POWER_MODE_GATE_GPIO_PWM_I2C;
*(vu_long *) (SM501_MMIO_BASE + SM501_POWER_MODE1_GATE) |=
POWER_MODE_GATE_GPIO_PWM_I2C;
/* set up default O/Ps */ /* set up default O/Ps */
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) &= ~(DS1620_RES | DS1620_CLK); *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) &=
~(DS1620_RES | DS1620_CLK);
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) |= DS1620_DQ; *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) |= DS1620_DQ;
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) &= ~(FP_DATA_TRI); *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) &=
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) |= (BUZZER | PWR_OFF); ~(FP_DATA_TRI);
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) |=
(BUZZER | PWR_OFF);
/* configure directions for SM501 GPIO pins */ /* configure directions for SM501 GPIO pins */
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_CTRL_LOW) &= ~(0xFF << 24); *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_CTRL_LOW) &= ~(0xFF << 24);
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_CTRL_HIGH) &= ~(0x3F << 14); *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_CTRL_HIGH) &=
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_LOW) &= ~(DIP | DS1620_DQ); ~(0x3F << 14);
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_LOW) |= (DS1620_RES | DS1620_CLK); *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_LOW) &=
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_HIGH) &= ~DS1620_TLOW; ~(DIP | DS1620_DQ);
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_HIGH) |= (PWR_OFF | BUZZER | FP_DATA_TRI); *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_LOW) |=
(DS1620_RES | DS1620_CLK);
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_HIGH) &=
~DS1620_TLOW;
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_DIR_HIGH) |=
(PWR_OFF | BUZZER | FP_DATA_TRI);
init_done = 1; init_done = 1;
/* dprintf("sm501_gpio_init: done.\n"); */ /* dprintf("sm501_gpio_init: done.\n"); */
@ -183,14 +193,12 @@ int cmd_dip (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0; return 0;
} }
U_BOOT_CMD( U_BOOT_CMD (dip, 1, 1, cmd_dip,
dip , 1, 1, cmd_dip,
"dip - read dip switch and config inputs\n", "dip - read dip switch and config inputs\n",
"\n" "\n"
" - prints the state of the dip switch and/or\n" " - prints the state of the dip switch and/or\n"
" external configuration inputs as hex value.\n" " external configuration inputs as hex value.\n"
" - \"Config 1\" is the LSB\n" " - \"Config 1\" is the LSB\n");
);
/* /*
@ -207,24 +215,21 @@ static int cmd_buz (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
sm501_gpio_init (); sm501_gpio_init ();
if (strncmp (argv[1], "on", 2) == 0) { if (strncmp (argv[1], "on", 2) == 0) {
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) &= ~(BUZZER); *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) &=
~(BUZZER);
return 0; return 0;
} } else if (strncmp (argv[1], "off", 3) == 0) {
else if (strncmp (argv[1], "off", 3) == 0) { *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) |=
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) |= BUZZER; BUZZER;
return 0; return 0;
} }
printf ("Usage:\nspecify one argument: \"on\" or \"off\"\n"); printf ("Usage:\nspecify one argument: \"on\" or \"off\"\n");
return 1; return 1;
} }
U_BOOT_CMD( U_BOOT_CMD (buz, 2, 1, cmd_buz,
buz , 2, 1, cmd_buz,
"buz - turns buzzer on/off\n", "buz - turns buzzer on/off\n",
"\n" "\n" "buz <on/off>\n" " - turns the buzzer on or off\n");
"buz <on/off>\n"
" - turns the buzzer on or off\n"
);
#endif /* CONFIG_BC3450_BUZZER */ #endif /* CONFIG_BC3450_BUZZER */
@ -237,42 +242,56 @@ static int cmd_fp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (strncmp (argv[1], "on", 2) == 0) { if (strncmp (argv[1], "on", 2) == 0) {
/* turn on VDD first */ /* turn on VDD first */
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_VDDEN; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_VDDEN;
udelay (1000); udelay (1000);
/* then put data on */ /* then put data on */
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_DATA; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_DATA;
/* wait some time and enable backlight */ /* wait some time and enable backlight */
udelay (1000); udelay (1000);
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_BIAS; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_BIAS;
udelay (1000); udelay (1000);
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_FPEN; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_FPEN;
return 0; return 0;
} } else if (strncmp (argv[1], "off", 3) == 0) {
else if (strncmp (argv[1], "off", 3) == 0) {
/* turn off the backlight first */ /* turn off the backlight first */
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_FPEN; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_FPEN;
udelay (1000); udelay (1000);
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_BIAS; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_BIAS;
udelay (200000); udelay (200000);
/* wait some time, then remove data */ /* wait some time, then remove data */
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_DATA; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_DATA;
udelay (1000); udelay (1000);
/* and remove VDD last */ /* and remove VDD last */
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_VDDEN; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) &=
~SM501_PDC_VDDEN;
return 0; return 0;
} } else if (strncmp (argv[1], "bl", 2) == 0) {
else if (strncmp (argv[1], "bl", 2) == 0) {
/* turn on/off backlight only */ /* turn on/off backlight only */
if (strncmp (argv[2], "on", 2) == 0) { if (strncmp (argv[2], "on", 2) == 0) {
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_BIAS; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) |=
SM501_PDC_BIAS;
udelay (1000); udelay (1000);
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) |= SM501_PDC_FPEN; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) |=
SM501_PDC_FPEN;
return 0; return 0;
} } else if (strncmp (argv[2], "off", 3) == 0) {
else if (strncmp (argv[2], "off", 3) == 0) { *(vu_long *) (SM501_MMIO_BASE +
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_FPEN; SM501_PANEL_DISPLAY_CONTROL) &=
~SM501_PDC_FPEN;
udelay (1000); udelay (1000);
*(vu_long *)(SM501_MMIO_BASE + SM501_PANEL_DISPLAY_CONTROL) &= ~SM501_PDC_BIAS; *(vu_long *) (SM501_MMIO_BASE +
SM501_PANEL_DISPLAY_CONTROL) &=
~SM501_PDC_BIAS;
return 0; return 0;
} }
} }
@ -280,16 +299,19 @@ static int cmd_fp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
else if (strncmp (argv[1], "crt", 3) == 0) { else if (strncmp (argv[1], "crt", 3) == 0) {
/* enables/disables the crt output (debug only) */ /* enables/disables the crt output (debug only) */
if (strncmp (argv[2], "on", 2) == 0) { if (strncmp (argv[2], "on", 2) == 0) {
*(vu_long *)(SM501_MMIO_BASE + SM501_CRT_DISPLAY_CONTROL) |= *(vu_long *) (SM501_MMIO_BASE +
SM501_CRT_DISPLAY_CONTROL) |=
(SM501_CDC_TE | SM501_CDC_E); (SM501_CDC_TE | SM501_CDC_E);
*(vu_long *)(SM501_MMIO_BASE + SM501_CRT_DISPLAY_CONTROL) &= *(vu_long *) (SM501_MMIO_BASE +
SM501_CRT_DISPLAY_CONTROL) &=
~SM501_CDC_SEL; ~SM501_CDC_SEL;
return 0; return 0;
} } else if (strncmp (argv[2], "off", 3) == 0) {
else if (strncmp (argv[2], "off", 3) == 0) { *(vu_long *) (SM501_MMIO_BASE +
*(vu_long *)(SM501_MMIO_BASE + SM501_CRT_DISPLAY_CONTROL) &= SM501_CRT_DISPLAY_CONTROL) &=
~(SM501_CDC_TE | SM501_CDC_E); ~(SM501_CDC_TE | SM501_CDC_E);
*(vu_long *)(SM501_MMIO_BASE + SM501_CRT_DISPLAY_CONTROL) |= *(vu_long *) (SM501_MMIO_BASE +
SM501_CRT_DISPLAY_CONTROL) |=
SM501_CDC_SEL; SM501_CDC_SEL;
return 0; return 0;
} }
@ -299,14 +321,12 @@ static int cmd_fp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1; return 1;
} }
U_BOOT_CMD( U_BOOT_CMD (fp, 3, 1, cmd_fp,
fp , 3, 1, cmd_fp,
"fp - front panes access functions\n", "fp - front panes access functions\n",
"\n" "\n"
"fp bl <on/off>\n" "fp bl <on/off>\n"
" - turns the CCFL backlight of the display on/off\n" " - turns the CCFL backlight of the display on/off\n"
"fp <on/off>\n" "fp <on/off>\n" " - turns the whole display on/off\n"
" - turns the whole display on/off\n"
#ifdef CONFIG_BC3450_CRT #ifdef CONFIG_BC3450_CRT
"fp crt <on/off>\n" "fp crt <on/off>\n"
" - enables/disables the crt output (debug only)\n" " - enables/disables the crt output (debug only)\n"
@ -321,22 +341,27 @@ U_BOOT_CMD(
static inline void bc_ds1620_set_clk (int clk) static inline void bc_ds1620_set_clk (int clk)
{ {
if (clk) if (clk)
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) |= DS1620_CLK; *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) |=
DS1620_CLK;
else else
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) &= ~DS1620_CLK; *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) &=
~DS1620_CLK;
} }
static inline void bc_ds1620_set_data (int dat) static inline void bc_ds1620_set_data (int dat)
{ {
if (dat) if (dat)
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) |= DS1620_DQ; *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) |=
DS1620_DQ;
else else
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) &= ~DS1620_DQ; *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW) &=
~DS1620_DQ;
} }
static inline int bc_ds1620_get_data (void) static inline int bc_ds1620_get_data (void)
{ {
vu_long rc; vu_long rc;
rc = *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW); rc = *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_LOW);
rc &= DS1620_DQ; rc &= DS1620_DQ;
if (rc != 0) if (rc != 0)
@ -497,13 +522,9 @@ static int cmd_temp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1; return 1;
} }
U_BOOT_CMD( U_BOOT_CMD (temp, 3, 1, cmd_temp,
temp , 3, 1, cmd_temp,
"temp - print current temperature\n", "temp - print current temperature\n",
"\n" "\n" "temp\n" " - print current temperature\n");
"temp\n"
" - print current temperature\n"
);
#ifdef CONFIG_BC3450_CAN #ifdef CONFIG_BC3450_CAN
/* /*
@ -685,8 +706,7 @@ int do_can(char *argv[])
i++; i++;
if (i == 10) { if (i == 10) {
printf ("%s: CAN1 send timeout, " printf ("%s: CAN1 send timeout, "
"can not send message!\n", "can not send message!\n", __FUNCTION__);
__FUNCTION__);
return 1; return 1;
} }
udelay (1000); udelay (1000);
@ -698,8 +718,7 @@ int do_can(char *argv[])
i++; i++;
if (i == 10) { if (i == 10) {
printf ("%s: CAN2 receive timeout, " printf ("%s: CAN2 receive timeout, "
"no message received!\n", "no message received!\n", __FUNCTION__);
__FUNCTION__);
return 1; return 1;
} }
udelay (1000); udelay (1000);
@ -707,8 +726,7 @@ int do_can(char *argv[])
if (can2->canrxfg.dsr[0] != 0xCC) { if (can2->canrxfg.dsr[0] != 0xCC) {
printf ("%s: CAN2 receive error, " printf ("%s: CAN2 receive error, "
"data mismatch!\n", "data mismatch!\n", __FUNCTION__);
__FUNCTION__);
return 1; return 1;
} }
@ -728,8 +746,7 @@ int do_can(char *argv[])
i++; i++;
if (i == 10) { if (i == 10) {
printf ("%s: CAN2 send error, " printf ("%s: CAN2 send error, "
"can not send message!\n", "can not send message!\n", __FUNCTION__);
__FUNCTION__);
return 1; return 1;
} }
udelay (1000); udelay (1000);
@ -741,8 +758,7 @@ int do_can(char *argv[])
i++; i++;
if (i == 10) { if (i == 10) {
printf ("%s: CAN1 receive timeout, " printf ("%s: CAN1 receive timeout, "
"no message received!\n", "no message received!\n", __FUNCTION__);
__FUNCTION__);
return 1; return 1;
} }
udelay (1000); udelay (1000);
@ -765,6 +781,7 @@ int cmd_test(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{ {
#ifdef CONFIG_BC3450_CAN #ifdef CONFIG_BC3450_CAN
int rcode; int rcode;
can_init (); can_init ();
#endif /* CONFIG_BC3450_CAN */ #endif /* CONFIG_BC3450_CAN */
@ -778,7 +795,8 @@ int cmd_test(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (strncmp (argv[1], "unit-off", 8) == 0) { if (strncmp (argv[1], "unit-off", 8) == 0) {
printf ("waiting 2 seconds...\n"); printf ("waiting 2 seconds...\n");
udelay (2000000); udelay (2000000);
*(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) &= ~PWR_OFF; *(vu_long *) (SM501_MMIO_BASE + SM501_GPIO_DATA_HIGH) &=
~PWR_OFF;
return 0; return 0;
} }
#ifdef CONFIG_BC3450_CAN #ifdef CONFIG_BC3450_CAN
@ -798,16 +816,12 @@ int cmd_test(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1; return 1;
} }
U_BOOT_CMD( U_BOOT_CMD (test, 2, 1, cmd_test, "test - unit test routines\n", "\n"
test , 2, 1, cmd_test,
"test - unit test routines\n",
"\n"
#ifdef CONFIG_BC3450_CAN #ifdef CONFIG_BC3450_CAN
"test can\n" "test can\n"
" - connect CAN1 (X8) with CAN2 (X9) for this test\n" " - connect CAN1 (X8) with CAN2 (X9) for this test\n"
#endif /* CONFIG_BC3450_CAN */ #endif /* CONFIG_BC3450_CAN */
"test unit-off\n" "test unit-off\n"
" - turns off the BC3450 unit\n" " - turns off the BC3450 unit\n"
" WARNING: Unsaved environment variables will be lost!\n" " WARNING: Unsaved environment variables will be lost!\n");
);
#endif /* CFG_CMD_BSP */ #endif /* CFG_CMD_BSP */