#include <common.h>
#include <exports.h>
-#include <s3c2400.h>
+#include <timestamp.h>
+#include <asm/arch/s3c24x0_cpu.h>
#include "tsc2000.h"
#include "rs485.h"
* command do_touch is invoked and the touch is not pressed within an specific
* interval.
*/
-#undef CONFIG_TOUCH_WAIT_PRESSED 1
+#undef CONFIG_TOUCH_WAIT_PRESSED
/* max time to wait for touch is pressed */
#ifndef CONFIG_TOUCH_WAIT_PRESSED
int do_pressure (void);
int do_v_bat (void);
int do_vfd_id (void);
-int do_buzzer (char **);
-int do_led (char **);
-int do_full_bridge (char **);
-int do_dac (char **);
+int do_buzzer (char * const *);
+int do_led (char * const *);
+int do_full_bridge (char * const *);
+int do_dac (char * const *);
int do_motor_contact (void);
-int do_motor (char **);
-int do_pwm (char **);
-int do_thermo (char **);
-int do_touch (char **);
-int do_rs485 (char **);
-int do_serial_number (char **);
+int do_motor (char * const *);
+int do_pwm (char * const *);
+int do_thermo (char * const *);
+int do_touch (char * const *);
+int do_rs485 (char * const *);
+int do_serial_number (char * const *);
int do_crc16 (void);
int do_power_switch (void);
-int do_gain (char **);
-int do_eeprom (char **);
+int do_gain (char * const *);
+int do_eeprom (char * const *);
/* helper functions */
static void adc_init (void);
static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
unsigned int icnt);
-#if (CONFIG_COMMANDS & CFG_CMD_I2C)
-static int trab_eeprom_read (char **argv);
-static int trab_eeprom_write (char **argv);
+#if defined(CONFIG_CMD_I2C)
+static int trab_eeprom_read (char * const *argv);
+static int trab_eeprom_write (char * const *argv);
int i2c_write_multiple (uchar chip, uint addr, int alen, uchar *buffer,
int len);
int i2c_read_multiple ( uchar chip, uint addr, int alen, uchar *buffer,
int len);
-#endif /* CFG_CMD_I2C */
+#endif
/*
* TRAB board specific commands. Especially commands for burn-in and function
* test.
*/
-int trab_fkt (int argc, char *argv[])
+int trab_fkt (int argc, char * const argv[])
{
int i;
return 1;
}
+void hang (void)
+{
+ puts ("### ERROR ### Please RESET the board ###\n");
+ for (;;);
+}
+
int do_info (void)
{
printf ("Stand-alone application for TRAB board function test\n");
- printf ("Built: %s at %s\n", __DATE__ , __TIME__ );
+ printf ("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
return 0;
}
{
int j = 1000; /* timeout value for wait loop in us */
int result;
- S3C2400_ADC *padc;
+ struct s3c2400_adc *padc;
- padc = S3C2400_GetBase_ADC();
+ padc = s3c2400_get_base_adc();
channel &= 0x7;
- padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
- padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
- padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+ padc->adccon &= ~ADC_STDBM; /* select normal mode */
+ padc->adccon &= ~(0x7 << 3); /* clear the channel bits */
+ padc->adccon |= ((channel << 3) | ADC_ENABLE_START);
while (j--) {
- if ((padc->ADCCON & ADC_ENABLE_START) == 0)
+ if ((padc->adccon & ADC_ENABLE_START) == 0)
break;
udelay (1);
}
if (j == 0) {
printf("%s: ADC timeout\n", __FUNCTION__);
- padc->ADCCON |= ADC_STDBM; /* select standby mode */
+ padc->adccon |= ADC_STDBM; /* select standby mode */
return -1;
}
- result = padc->ADCDAT & 0x3FF;
+ result = padc->adcdat & 0x3FF;
- padc->ADCCON |= ADC_STDBM; /* select standby mode */
+ padc->adccon |= ADC_STDBM; /* select standby mode */
debug ("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
- (padc->ADCCON >> 3) & 0x7, result);
+ (padc->adccon >> 3) & 0x7, result);
/*
* Wait for ADC to be ready for next conversion. This delay value was
static void adc_init (void)
{
- S3C2400_ADC *padc;
+ struct s3c2400_adc *padc;
- padc = S3C2400_GetBase_ADC();
+ padc = s3c2400_get_base_adc();
- padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
- padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
+ padc->adccon &= ~(0xff << 6); /* clear prescaler bits */
+ padc->adccon |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
/*
* Wait some time to avoid problem with very first call of
{
int result;
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
/* configure GPE7 as input */
- gpio->PECON &= ~(0x3 << (2 * 7));
+ gpio->pecon &= ~(0x3 << (2 * 7));
/* signal GPE7 from power switch is low active: 0=on , 1=off */
- result = ((gpio->PEDAT & (1 << 7)) == (1 << 7)) ? 0 : 1;
+ result = ((gpio->pedat & (1 << 7)) == (1 << 7)) ? 0 : 1;
print_identifier ();
printf("%d\n", result);
int i;
long int pcup_old, pccon_old;
int vfd_board_id;
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
/* try to red vfd board id from the value defined by pull-ups */
- pcup_old = gpio->PCUP;
- pccon_old = gpio->PCCON;
+ pcup_old = gpio->pcup;
+ pccon_old = gpio->pccon;
- gpio->PCUP = (gpio->PCUP & 0xFFF0); /* activate GPC0...GPC3 pull-ups */
- gpio->PCCON = (gpio->PCCON & 0xFFFFFF00); /* configure GPC0...GPC3 as
+ gpio->pcup = (gpio->pcup & 0xFFF0); /* activate GPC0...GPC3 pull-ups */
+ gpio->pccon = (gpio->pccon & 0xFFFFFF00); /* configure GPC0...GPC3 as
* inputs */
udelay (10); /* allow signals to settle */
- vfd_board_id = (~gpio->PCDAT) & 0x000F; /* read GPC0...GPC3 port pins */
+ vfd_board_id = (~gpio->pcdat) & 0x000F; /* read GPC0...GPC3 port pins */
- gpio->PCCON = pccon_old;
- gpio->PCUP = pcup_old;
+ gpio->pccon = pccon_old;
+ gpio->pcup = pcup_old;
/* print vfd_board_id to console */
print_identifier ();
return 0;
}
-int do_buzzer (char **argv)
+int do_buzzer (char * const *argv)
{
int counter;
- S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ struct s3c24x0_timers * const timers = s3c24x0_get_base_timers();
+ struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
/* set prescaler for timer 2, 3 and 4 */
- timers->TCFG0 &= ~0xFF00;
- timers->TCFG0 |= 0x0F00;
+ timers->tcfg0 &= ~0xFF00;
+ timers->tcfg0 |= 0x0F00;
/* set divider for timer 2 */
- timers->TCFG1 &= ~0xF00;
- timers->TCFG1 |= 0x300;
+ timers->tcfg1 &= ~0xF00;
+ timers->tcfg1 |= 0x300;
/* set frequency */
counter = (PCLK / BUZZER_FREQ) >> 9;
- timers->ch[2].TCNTB = counter;
- timers->ch[2].TCMPB = counter / 2;
+ timers->ch[2].tcntb = counter;
+ timers->ch[2].tcmpb = counter / 2;
if (strcmp (argv[2], "on") == 0) {
debug ("%s: frequency: %d\n", __FUNCTION__,
BUZZER_FREQ);
/* configure pin GPD7 as TOUT2 */
- gpio->PDCON &= ~0xC000;
- gpio->PDCON |= 0x8000;
+ gpio->pdcon &= ~0xC000;
+ gpio->pdcon |= 0x8000;
/* start */
- timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) &
+ timers->tcon = (timers->tcon | UPDATE2 | RELOAD2) &
~INVERT2;
- timers->TCON = (timers->TCON | START2) & ~UPDATE2;
+ timers->tcon = (timers->tcon | START2) & ~UPDATE2;
return (0);
}
else if (strcmp (argv[2], "off") == 0) {
/* stop */
- timers->TCON &= ~(START2 | RELOAD2);
+ timers->tcon &= ~(START2 | RELOAD2);
/* configure GPD7 as output and set to low */
- gpio->PDCON &= ~0xC000;
- gpio->PDCON |= 0x4000;
- gpio->PDDAT &= ~0x80;
+ gpio->pdcon &= ~0xC000;
+ gpio->pdcon |= 0x4000;
+ gpio->pddat &= ~0x80;
return (0);
}
}
-int do_led (char **argv)
+int do_led (char * const *argv)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
/* configure PC14 and PC15 as output */
- gpio->PCCON &= ~(0xF << 28);
- gpio->PCCON |= (0x5 << 28);
+ gpio->pccon &= ~(0xF << 28);
+ gpio->pccon |= (0x5 << 28);
/* configure PD0 and PD4 as output */
- gpio->PDCON &= ~((0x3 << 8) | 0x3);
- gpio->PDCON |= ((0x1 << 8) | 0x1);
+ gpio->pdcon &= ~((0x3 << 8) | 0x3);
+ gpio->pdcon |= ((0x1 << 8) | 0x1);
switch (simple_strtoul(argv[2], NULL, 10)) {
case 2:
if (strcmp (argv[3], "on") == 0)
- gpio->PCDAT |= (1 << 14);
+ gpio->pcdat |= (1 << 14);
else
- gpio->PCDAT &= ~(1 << 14);
+ gpio->pcdat &= ~(1 << 14);
return 0;
case 3:
if (strcmp (argv[3], "on") == 0)
- gpio->PCDAT |= (1 << 15);
+ gpio->pcdat |= (1 << 15);
else
- gpio->PCDAT &= ~(1 << 15);
+ gpio->pcdat &= ~(1 << 15);
return 0;
case 4:
if (strcmp (argv[3], "on") == 0)
- gpio->PDDAT |= (1 << 0);
+ gpio->pddat |= (1 << 0);
else
- gpio->PDDAT &= ~(1 << 0);
+ gpio->pddat &= ~(1 << 0);
return 0;
case 5:
if (strcmp (argv[3], "on") == 0)
- gpio->PDDAT |= (1 << 4);
+ gpio->pddat |= (1 << 4);
else
- gpio->PDDAT &= ~(1 << 4);
+ gpio->pddat &= ~(1 << 4);
return 0;
default:
}
-int do_full_bridge (char **argv)
+int do_full_bridge (char * const *argv)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
/* configure PD5 and PD6 as output */
- gpio->PDCON &= ~((0x3 << 5*2) | (0x3 << 6*2));
- gpio->PDCON |= ((0x1 << 5*2) | (0x1 << 6*2));
+ gpio->pdcon &= ~((0x3 << 5*2) | (0x3 << 6*2));
+ gpio->pdcon |= ((0x1 << 5*2) | (0x1 << 6*2));
if (strcmp (argv[2], "+") == 0) {
- gpio->PDDAT |= (1 << 5);
- gpio->PDDAT |= (1 << 6);
+ gpio->pddat |= (1 << 5);
+ gpio->pddat |= (1 << 6);
return 0;
}
else if (strcmp (argv[2], "-") == 0) {
- gpio->PDDAT &= ~(1 << 5);
- gpio->PDDAT |= (1 << 6);
+ gpio->pddat &= ~(1 << 5);
+ gpio->pddat |= (1 << 6);
return 0;
}
else if (strcmp (argv[2], "off") == 0) {
- gpio->PDDAT &= ~(1 << 5);
- gpio->PDDAT &= ~(1 << 6);
+ gpio->pddat &= ~(1 << 5);
+ gpio->pddat &= ~(1 << 6);
return 0;
}
printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
}
-int do_dac (char **argv)
+int do_dac (char * const *argv)
{
int brightness;
/* initialize SPI */
- spi_init ();
+ tsc2000_spi_init ();
if (((brightness = simple_strtoul (argv[2], NULL, 10)) < 0) ||
(brightness > 255)) {
return 0;
}
-int do_motor (char **argv)
+int do_motor (char * const *argv)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
/* Configure I/O port */
- gpio->PGCON &= ~(0x3 << 0);
- gpio->PGCON |= (0x1 << 0);
+ gpio->pgcon &= ~(0x3 << 0);
+ gpio->pgcon |= (0x1 << 0);
if (strcmp (argv[2], "on") == 0) {
- gpio->PGDAT &= ~(1 << 0);
+ gpio->pgdat &= ~(1 << 0);
return 0;
}
if (strcmp (argv[2], "off") == 0) {
- gpio->PGDAT |= (1 << 0);
+ gpio->pgdat |= (1 << 0);
return 0;
}
printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
printf ("## FKT: ");
}
-int do_pwm (char **argv)
+int do_pwm (char * const *argv)
{
int counter;
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
- S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
+ struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_timers * const timers = s3c24x0_get_base_timers();
if (strcmp (argv[2], "on") == 0) {
/* configure pin GPD8 as TOUT3 */
- gpio->PDCON &= ~(0x3 << 8*2);
- gpio->PDCON |= (0x2 << 8*2);
+ gpio->pdcon &= ~(0x3 << 8*2);
+ gpio->pdcon |= (0x2 << 8*2);
/* set prescaler for timer 2, 3 and 4 */
- timers->TCFG0 &= ~0xFF00;
- timers->TCFG0 |= 0x0F00;
+ timers->tcfg0 &= ~0xFF00;
+ timers->tcfg0 |= 0x0F00;
/* set divider for timer 3 */
- timers->TCFG1 &= ~(0xf << 12);
- timers->TCFG1 |= (0x3 << 12);
+ timers->tcfg1 &= ~(0xf << 12);
+ timers->tcfg1 |= (0x3 << 12);
/* set frequency */
counter = (PCLK / PWM_FREQ) >> 9;
- timers->ch[3].TCNTB = counter;
- timers->ch[3].TCMPB = counter / 2;
+ timers->ch[3].tcntb = counter;
+ timers->ch[3].tcmpb = counter / 2;
/* start timer */
- timers->TCON = (timers->TCON | UPDATE3 | RELOAD3) & ~INVERT3;
- timers->TCON = (timers->TCON | START3) & ~UPDATE3;
+ timers->tcon = (timers->tcon | UPDATE3 | RELOAD3) & ~INVERT3;
+ timers->tcon = (timers->tcon | START3) & ~UPDATE3;
return 0;
}
if (strcmp (argv[2], "off") == 0) {
/* stop timer */
- timers->TCON &= ~(START2 | RELOAD2);
+ timers->tcon &= ~(START2 | RELOAD2);
/* configure pin GPD8 as output and set to 0 */
- gpio->PDCON &= ~(0x3 << 8*2);
- gpio->PDCON |= (0x1 << 8*2);
- gpio->PDDAT &= ~(1 << 8);
+ gpio->pdcon &= ~(0x3 << 8*2);
+ gpio->pdcon |= (0x1 << 8*2);
+ gpio->pddat &= ~(1 << 8);
return 0;
}
printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
}
-int do_thermo (char **argv)
+int do_thermo (char * const *argv)
{
int channel, res;
}
-int do_touch (char **argv)
+int do_touch (char * const *argv)
{
int x, y;
static int touch_write_clibration_values (int calib_point, int x, int y)
{
-#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+#if defined(CONFIG_CMD_I2C)
int x_verify = 0;
int y_verify = 0;
if (calib_point == CALIB_TL) {
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
- (char *)&x, 2)) {
+ (unsigned char *)&x, 2)) {
return 1;
}
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
- (char *)&y, 2)) {
+ (unsigned char *)&y, 2)) {
return 1;
}
/* verify written values */
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
- (char *)&x_verify, 2)) {
+ (unsigned char *)&x_verify, 2)) {
return 1;
}
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
- (char *)&y_verify, 2)) {
+ (unsigned char *)&y_verify, 2)) {
return 1;
}
if ((y != y_verify) || (x != x_verify)) {
}
else if (calib_point == CALIB_DR) {
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
- (char *)&x, 2)) {
+ (unsigned char *)&x, 2)) {
return 1;
}
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
- (char *)&y, 2)) {
+ (unsigned char *)&y, 2)) {
return 1;
}
/* verify written values */
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
- (char *)&x_verify, 2)) {
+ (unsigned char *)&x_verify, 2)) {
return 1;
}
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
- (char *)&y_verify, 2)) {
+ (unsigned char *)&y_verify, 2)) {
return 1;
}
if ((y != y_verify) || (x != x_verify)) {
}
return 1;
#else
- printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ printf ("No I2C support enabled (CONFIG_CMD_I2C), could not write "
"to EEPROM\n");
return (1);
-#endif /* CFG_CMD_I2C */
+#endif
}
}
-int do_rs485 (char **argv)
+int do_rs485 (char * const *argv)
{
int timeout;
char data[RS485_MAX_RECEIVE_BUF_LEN];
}
-int do_serial_number (char **argv)
+int do_serial_number (char * const *argv)
{
-#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+#if defined(CONFIG_CMD_I2C)
unsigned int serial_number;
if (strcmp (argv[2], "read") == 0) {
if (i2c_read (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
- (char *)&serial_number, 4)) {
+ (unsigned char *)&serial_number, 4)) {
printf ("could not read from eeprom\n");
return (1);
}
else if (strcmp (argv[2], "write") == 0) {
serial_number = simple_strtoul(argv[3], NULL, 10);
if (i2c_write (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
- (char *)&serial_number, 4)) {
+ (unsigned char *)&serial_number, 4)) {
printf ("could not write to eeprom\n");
return (1);
}
printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
return (1); /* unknown command, return error */
#else
- printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ printf ("No I2C support enabled (CONFIG_CMD_I2C), could not write "
"to EEPROM\n");
return (1);
-#endif /* CFG_CMD_I2C */
+#endif
}
int do_crc16 (void)
{
-#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+#if defined(CONFIG_CMD_I2C)
int crc;
- char buf[EEPROM_MAX_CRC_BUF];
+ unsigned char buf[EEPROM_MAX_CRC_BUF];
if (i2c_read (I2C_EEPROM_DEV_ADDR, 0, 1, buf, 60)) {
printf ("could not read from eeprom\n");
print_identifier ();
printf ("crc16=%#04x\n", crc);
- if (i2c_write (I2C_EEPROM_DEV_ADDR, CRC16, 1, (char *)&crc,
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, CRC16, 1, (unsigned char *)&crc,
sizeof (crc))) {
printf ("could not read from eeprom\n");
return (1);
}
return (0);
#else
- printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ printf ("No I2C support enabled (CONFIG_CMD_I2C), could not write "
"to EEPROM\n");
return (1);
-#endif /* CFG_CMD_I2C */
+#endif
}
}
-int do_gain (char **argv)
+int do_gain (char * const *argv)
{
int range;
}
-int do_eeprom (char **argv)
+int do_eeprom (char * const *argv)
{
-#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+#if defined(CONFIG_CMD_I2C)
if (strcmp (argv[2], "read") == 0) {
return (trab_eeprom_read (argv));
}
printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
return (1);
#else
- printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ printf ("No I2C support enabled (CONFIG_CMD_I2C), could not write "
"to EEPROM\n");
return (1);
-#endif /* CFG_CMD_I2C */
+#endif
}
-#if (CONFIG_COMMANDS & CFG_CMD_I2C)
-static int trab_eeprom_read (char **argv)
+#if defined(CONFIG_CMD_I2C)
+static int trab_eeprom_read (char * const *argv)
{
int i;
int len;
return (0);
}
-static int trab_eeprom_write (char **argv)
+static int trab_eeprom_write (char * const *argv)
{
int i;
int len;
}
return (0);
}
-#endif /* CFG_CMD_I2C */
+#endif