summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwdenk <wdenk>2003-10-09 13:16:55 +0000
committerwdenk <wdenk>2003-10-09 13:16:55 +0000
commita0ff7f2eda50de4d4096265a086c94ac640fab7c (patch)
treec2ba69315440760faf7192b07df02c72745983e6
parent4a5517094dd30bb1f271403b62e23053301668e6 (diff)
* Patch by Martin Krause, 09 Oct 2003:LABEL_2003_10_09_1515
Fixes for TRAB board - /board/trab/rs485.c: correct baudrate - /board/trab/cmd_trab.c: bug fix for problem with timer overflow in udelay(); fix some timing problems with adc controller - /board/trab/trab_fkt.c: add new commands: gain, eeprom and power; modify commands: touch and buzzer * Disable CONFIG_SUPPORT_VFAT when used with CONFIG_AUTO_UPDATE (quick & dirty workaround for rogue pointer problem in get_vfatname()); Use direct function calls for auto_update instead of hush commands
-rw-r--r--CHANGELOG12
-rw-r--r--board/trab/auto_update.c44
-rw-r--r--board/trab/cmd_trab.c883
-rw-r--r--board/trab/rs485.c36
-rw-r--r--board/trab/trab_fkt.c1528
-rw-r--r--fs/fat/fat.c5
-rw-r--r--include/configs/trab.h10
7 files changed, 1437 insertions, 1081 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 6ea62a404fa..b607f874fff 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,18 @@
Changes for U-Boot 1.0.0:
======================================================================
+* Patch by Martin Krause, 09 Oct 2003:
+ Fixes for TRAB board
+ - /board/trab/rs485.c: correct baudrate
+ - /board/trab/cmd_trab.c: bug fix for problem with timer overflow in
+ udelay(); fix some timing problems with adc controller
+ - /board/trab/trab_fkt.c: add new commands: gain, eeprom and power;
+ modify commands: touch and buzzer
+
+* Disable CONFIG_SUPPORT_VFAT when used with CONFIG_AUTO_UPDATE
+ (quick & dirty workaround for rogue pointer problem in get_vfatname());
+ Use direct function calls for auto_update instead of hush commands
+
* Patch by Scott McNutt, 04 Oct 2003:
- add support for Altera Nios-32 CPU
- add support for Nios Cyclone Development Kit (DK-1C20)
diff --git a/board/trab/auto_update.c b/board/trab/auto_update.c
index f44b9bf5944..345d2d47a3c 100644
--- a/board/trab/auto_update.c
+++ b/board/trab/auto_update.c
@@ -183,9 +183,7 @@ struct flash_layout aufl_layout[AU_MAXFILES - 3] = { \
#define FIDX_TO_LIDX(idx) ((idx) - 2)
/* where to load files into memory */
-#define LOAD_ADDR ((unsigned char *)0x0C100100)
-/* where to build strings in memory - 256 bytes should be enough */
-#define STRING_ADDR ((char *)0x0C100000)
+#define LOAD_ADDR ((unsigned char *)0x0C100000)
/* the app is the largest image */
#define MAX_LOADSZ ausize[IDX_APP]
@@ -199,6 +197,9 @@ extern int i2c_write (uchar, uint, int , uchar* , int);
extern int trab_vfd (ulong);
extern int transfer_pic(unsigned char, unsigned char *, int, int);
#endif
+extern int flash_sect_erase(ulong, ulong);
+extern int flash_sect_protect (int, ulong, ulong);
+extern int flash_write (uchar *, ulong, ulong);
/* change char* to void* to shutup the compiler */
extern int i2c_write_multiple (uchar, uint, int, void *, int);
extern int i2c_read_multiple (uchar, uint, int, void *, int);
@@ -305,13 +306,12 @@ au_check_valid(int idx, long nbytes)
#define POWER_OFF (1 << 1)
int
-au_do_update(int idx, long sz, int repeat)
+au_do_update(int idx, long sz)
{
image_header_t *hdr;
char *addr;
long start, end;
- char *strbuf = STRING_ADDR;
- int off;
+ int off, rc;
uint nbytes;
hdr = (image_header_t *)LOAD_ADDR;
@@ -342,20 +342,14 @@ au_do_update(int idx, long sz, int repeat)
start = aufl_layout[1].start;
end = aufl_layout[1].end;
#endif
- debug ("protect off %lx %lx\n", start, end);
- sprintf(strbuf, "protect off %lx %lx\n", start, end);
- parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
+ flash_sect_protect(0, start, end);
}
/*
- * erase the address range. Multiple erases seem to cause
- * problems.
+ * erase the address range.
*/
- if (repeat == 0) {
- debug ("erase %lx %lx\n", start, end);
- sprintf(strbuf, "erase %lx %lx\n", start, end);
- parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
- }
+ debug ("flash_sect_erase(%lx, %lx);\n", start, end);
+ flash_sect_erase(start, end);
wait_ms(100);
/* strip the header - except for the kernel and app */
if (idx == IDX_FIRMWARE || idx == IDX_DISK) {
@@ -374,9 +368,12 @@ au_do_update(int idx, long sz, int repeat)
}
/* copy the data from RAM to FLASH */
- debug ("cp.b %p %lx %x\n", addr, start, nbytes);
- sprintf(strbuf, "cp.b %p %lx %x\n", addr, start, nbytes);
- parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
+ debug ("flash_write(%p, %lx %x)\n", addr, start, nbytes);
+ rc = flash_write(addr, start, nbytes);
+ if (rc != 0) {
+ printf("Flashing failed due to error %d\n", rc);
+ return -1;
+ }
/* check the dcrc of the copy */
if (crc32 (0, (char *)(start + off), ntohl(hdr->ih_size)) != ntohl(hdr->ih_dcrc)) {
@@ -386,11 +383,8 @@ au_do_update(int idx, long sz, int repeat)
/* protect the address range */
/* this assumes that ONLY the firmware is protected! */
- if (idx == IDX_FIRMWARE) {
- debug ("protect on %lx %lx\n", start, end);
- sprintf(strbuf, "protect on %lx %lx\n", start, end);
- parse_string_outer(strbuf, FLAG_PARSE_SEMICOLON);
- }
+ if (idx == IDX_FIRMWARE)
+ flash_sect_protect(1, start, end);
return 0;
}
@@ -587,7 +581,7 @@ do_auto_update(void)
cnt = 0;
got_ctrlc = 0;
do {
- res = au_do_update(i, sz, cnt);
+ res = au_do_update(i, sz);
/* let the user break out of the loop */
if (ctrlc() || had_ctrlc()) {
clear_ctrlc();
diff --git a/board/trab/cmd_trab.c b/board/trab/cmd_trab.c
index 78e14bdadf9..509e071f4de 100644
--- a/board/trab/cmd_trab.c
+++ b/board/trab/cmd_trab.c
@@ -21,6 +21,8 @@
* MA 02111-1307 USA
*/
+#undef DEBUG
+
#include <common.h>
#include <command.h>
#include <s3c2400.h>
@@ -71,7 +73,7 @@
#define I2C_EEPROM_DEV_ADDR 0x54
/* EEPROM address map */
-#define EE_ADDR_TEST 128
+#define EE_ADDR_TEST 192
#define EE_ADDR_MAX_CYCLES 256
#define EE_ADDR_STATUS 258
#define EE_ADDR_PASS_CYCLES 259
@@ -148,7 +150,7 @@ u16 act_cycle;
typedef struct test_function_s {
unsigned char *name;
- int (*pf)(void);
+ int (*pf)(void);
} test_function_t;
/* max number of Burn In Functions */
@@ -160,245 +162,251 @@ test_function_t test_function[BIF_MAX];
int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- int i;
- int cycle_status;
+ int i;
+ int cycle_status;
- if (argc > 1) {
+ if (argc > 1) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
- led_init ();
- global_vars_init ();
- test_function_table_init ();
-
- if (global_vars_write_to_eeprom () != 0) {
- printf ("%s: error writing global_vars to eeprom\n",
- __FUNCTION__);
- return (1);
- }
-
- if (read_max_cycles () != 0) {
- printf ("%s: error reading max_cycles from eeprom\n",
- __FUNCTION__);
- return (1);
- }
-
- if (max_cycles == 0) {
- printf ("%s: error, burn in max_cycles = 0\n", __FUNCTION__);
- return (1);
- }
-
- status = 0;
- for (act_cycle = 1; act_cycle <= max_cycles; act_cycle++) {
-
- cycle_status = 0;
- for (i = 0; i < BIF_MAX; i++) {
-
- /* call test function */
- if ((*test_function[i].pf)() != 0) {
- printf ("error in %s test\n",
- test_function[i].name);
-
- /* is it the first error? */
- if (status == 0) {
- status = 1;
- first_error_cycle = act_cycle;
-
- /* do not use error_num 0 */
- first_error_num = i+1;
- strncpy (first_error_name,
- test_function[i].name,
- sizeof (first_error_name));
- led_set (0);
- }
- cycle_status = 1;
- }
- }
- /* were all tests of actual cycle OK? */
- if (cycle_status == 0)
- pass_cycles++;
-
- /* set status LED if no error is occoured since yet */
- if (status == 0)
- led_set (1);
-
- printf ("%s: cycle %d finished\n", __FUNCTION__, act_cycle);
-
- /* pause between cycles */
- sdelay (BURN_IN_CYCLE_DELAY);
- }
-
- if (global_vars_write_to_eeprom () != 0) {
- led_set (0);
- printf ("%s: error writing global_vars to eeprom\n",
- __FUNCTION__);
- status = 1;
- }
-
- if (status == 0) {
- led_blink (); /* endless loop!! */
- return (0);
- } else {
- led_set (0);
- return (1);
- }
+ led_init ();
+ global_vars_init ();
+ test_function_table_init ();
+
+ if (global_vars_write_to_eeprom () != 0) {
+ printf ("%s: error writing global_vars to eeprom\n",
+ __FUNCTION__);
+ return (1);
+ }
+
+ if (read_max_cycles () != 0) {
+ printf ("%s: error reading max_cycles from eeprom\n",
+ __FUNCTION__);
+ return (1);
+ }
+
+ if (max_cycles == 0) {
+ printf ("%s: error, burn in max_cycles = 0\n", __FUNCTION__);
+ return (1);
+ }
+
+ status = 0;
+ for (act_cycle = 1; act_cycle <= max_cycles; act_cycle++) {
+
+ cycle_status = 0;
+
+ /*
+ * avoid timestamp overflow problem after about 68 minutes of
+ * udelay() time.
+ */
+ reset_timer_masked ();
+ for (i = 0; i < BIF_MAX; i++) {
+
+ /* call test function */
+ if ((*test_function[i].pf)() != 0) {
+ printf ("error in %s test\n",
+ test_function[i].name);
+
+ /* is it the first error? */
+ if (status == 0) {
+ status = 1;
+ first_error_cycle = act_cycle;
+
+ /* do not use error_num 0 */
+ first_error_num = i+1;
+ strncpy (first_error_name,
+ test_function[i].name,
+ sizeof (first_error_name));
+ led_set (0);
+ }
+ cycle_status = 1;
+ }
+ }
+ /* were all tests of actual cycle OK? */
+ if (cycle_status == 0)
+ pass_cycles++;
+
+ /* set status LED if no error is occoured since yet */
+ if (status == 0)
+ led_set (1);
+
+ printf ("%s: cycle %d finished\n", __FUNCTION__, act_cycle);
+
+ /* pause between cycles */
+ sdelay (BURN_IN_CYCLE_DELAY);
+ }
+
+ if (global_vars_write_to_eeprom () != 0) {
+ led_set (0);
+ printf ("%s: error writing global_vars to eeprom\n",
+ __FUNCTION__);
+ status = 1;
+ }
+
+ if (status == 0) {
+ led_blink (); /* endless loop!! */
+ return (0);
+ } else {
+ led_set (0);
+ return (1);
+ }
}
U_BOOT_CMD(
- burn_in, 1, 1, do_burn_in,
- "burn_in - start burn-in test application on TRAB\n",
- "\n"
- " - start burn-in test application\n"
- " The burn-in test could took a while to finish!\n"
- " The content of the onboard EEPROM is modified!\n"
+ burn_in, 1, 1, do_burn_in,
+ "burn_in - start burn-in test application on TRAB\n",
+ "\n"
+ " - start burn-in test application\n"
+ " The burn-in test could took a while to finish!\n"
+ " The content of the onboard EEPROM is modified!\n"
);
int do_dip (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- int i, dip;
+ int i, dip;
- if (argc > 1) {
+ if (argc > 1) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
- if ((dip = read_dip ()) == -1) {
- return 1;
- }
+ if ((dip = read_dip ()) == -1) {
+ return 1;
+ }
- for (i = 0; i < 4; i++) {
- if ((dip & (1 << i)) == 0)
- printf("0");
- else
- printf("1");
- }
- printf("\n");
+ for (i = 0; i < 4; i++) {
+ if ((dip & (1 << i)) == 0)
+ printf("0");
+ else
+ printf("1");
+ }
+ printf("\n");
return 0;
}
U_BOOT_CMD(
- dip, 1, 1, do_dip,
- "dip - read dip switch on TRAB\n",
- "\n"
- " - read state of dip switch (S1) on TRAB board\n"
- " read sequence: 1-2-3-4; ON=1; OFF=0; e.g.: \"0100\"\n"
+ dip, 1, 1, do_dip,
+ "dip - read dip switch on TRAB\n",
+ "\n"
+ " - read state of dip switch (S1) on TRAB board\n"
+ " read sequence: 1-2-3-4; ON=1; OFF=0; e.g.: \"0100\"\n"
);
int do_vcc5v (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- int vcc5v;
+ int vcc5v;
- if (argc > 1) {
+ if (argc > 1) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
- if ((vcc5v = read_vcc5v ()) == -1) {
- return (1);
- }
+ if ((vcc5v = read_vcc5v ()) == -1) {
+ return (1);
+ }
- printf ("%d", (vcc5v / 1000));
- printf (".%d", (vcc5v % 1000) / 100);
- printf ("%d V\n", (vcc5v % 100) / 10) ;
+ printf ("%d", (vcc5v / 1000));
+ printf (".%d", (vcc5v % 1000) / 100);
+ printf ("%d V\n", (vcc5v % 100) / 10) ;
return 0;
}
U_BOOT_CMD(
- vcc5v, 1, 1, do_vcc5v,
- "vcc5v - read VCC5V on TRAB\n",
- "\n"
- " - read actual value of voltage VCC5V\n"
+ vcc5v, 1, 1, do_vcc5v,
+ "vcc5v - read VCC5V on TRAB\n",
+ "\n"
+ " - read actual value of voltage VCC5V\n"
);
int do_contact_temp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- int contact_temp;
+ int contact_temp;
- if (argc > 1) {
+ if (argc > 1) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
- spi_init ();
- tsc2000_reg_init ();
+ spi_init ();
+ tsc2000_reg_init ();
- contact_temp = tsc2000_contact_temp();
- printf ("%d degree C * 100\n", contact_temp) ;
+ contact_temp = tsc2000_contact_temp();
+ printf ("%d degree C * 100\n", contact_temp) ;
return 0;
}
U_BOOT_CMD(
- c_temp, 1, 1, do_contact_temp,
- "c_temp - read contact temperature on TRAB\n",
- "\n"
- " - reads the onboard temperature (=contact temperature)\n"
+ c_temp, 1, 1, do_contact_temp,
+ "c_temp - read contact temperature on TRAB\n",
+ "\n"
+ " - reads the onboard temperature (=contact temperature)\n"
);
int do_burn_in_status (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- if (argc > 1) {
+ if (argc > 1) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
- (unsigned char*) &status, 1)) {
- return (1);
- }
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
- (unsigned char*) &pass_cycles, 2)) {
- return (1);
- }
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
- 1, (unsigned char*) &first_error_cycle, 2)) {
- return (1);
- }
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
- 1, (unsigned char*) &first_error_num, 1)) {
- return (1);
- }
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
- 1, first_error_name,
- sizeof (first_error_name))) {
- return (1);
- }
-
- if (read_max_cycles () != 0) {
- return (1);
- }
-
- printf ("max_cycles = %d\n", max_cycles);
- printf ("status = %d\n", status);
- printf ("pass_cycles = %d\n", pass_cycles);
- printf ("first_error_cycle = %d\n", first_error_cycle);
- printf ("first_error_num = %d\n", first_error_num);
- printf ("first_error_name = %.*s\n",(int) sizeof(first_error_name),
- first_error_name);
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
+ (unsigned char*) &status, 1)) {
+ return (1);
+ }
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
+ (unsigned char*) &pass_cycles, 2)) {
+ return (1);
+ }
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
+ 1, (unsigned char*) &first_error_cycle, 2)) {
+ return (1);
+ }
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
+ 1, (unsigned char*) &first_error_num, 1)) {
+ return (1);
+ }
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
+ 1, first_error_name,
+ sizeof (first_error_name))) {
+ return (1);
+ }
+
+ if (read_max_cycles () != 0) {
+ return (1);
+ }
+
+ printf ("max_cycles = %d\n", max_cycles);
+ printf ("status = %d\n", status);
+ printf ("pass_cycles = %d\n", pass_cycles);
+ printf ("first_error_cycle = %d\n", first_error_cycle);
+ printf ("first_error_num = %d\n", first_error_num);
+ printf ("first_error_name = %.*s\n",(int) sizeof(first_error_name),
+ first_error_name);
return 0;
}
U_BOOT_CMD(
- bis, 1, 1, do_burn_in_status,
- "bis - print burn in status on TRAB\n",
- "\n"
- " - prints the status variables of the last burn in test\n"
- " stored in the onboard EEPROM on TRAB board\n"
+ bis, 1, 1, do_burn_in_status,
+ "bis - print burn in status on TRAB\n",
+ "\n"
+ " - prints the status variables of the last burn in test\n"
+ " stored in the onboard EEPROM on TRAB board\n"
);
static int read_dip (void)
{
- unsigned int result = 0;
- int adc_val;
- int i;
+ unsigned int result = 0;
+ int adc_val;
+ int i;
/***********************************************************
DIP switch connection (according to wa4-cpu.sp.301.pdf, page 3):
@@ -413,11 +421,11 @@ static int read_dip (void)
for (i = 7; i > 3; i--) {
- if ((adc_val = adc_read (i)) == -1) {
- printf ("%s: Channel %d could not be read\n",
- __FUNCTION__, i);
- return (-1);
- }
+ if ((adc_val = adc_read (i)) == -1) {
+ printf ("%s: Channel %d could not be read\n",
+ __FUNCTION__, i);
+ return (-1);
+ }
/*
* Input voltage (switch open) is 1.8 V.
@@ -425,397 +433,410 @@ static int read_dip (void)
* Set trigger at halve that value.
*/
if (adc_val < 368)
- result |= (1 << (i-4));
- }
- return (result);
+ result |= (1 << (i-4));
+ }
+ return (result);
}
static int read_vcc5v (void)
{
- s32 result;
-
- /* VCC5V is connected to channel 2 */
-
- if ((result = adc_read (2)) == -1) {
- printf ("%s: VCC5V could not be read\n", __FUNCTION__);
- return (-1);
- }
- /*
- * Calculate voltage value. Split in two parts because there is no
- * floating point support. VCC5V is connected over an resistor divider:
- * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
- */
- result = result * 10 * 1000 / 1023; /* result in mV */
-
- return (result);
+ s32 result;
+
+ /* VCC5V is connected to channel 2 */
+
+ if ((result = adc_read (2)) == -1) {
+ printf ("%s: VCC5V could not be read\n", __FUNCTION__);
+ return (-1);
+ }
+ /*
+ * Calculate voltage value. Split in two parts because there is no
+ * floating point support. VCC5V is connected over an resistor divider:
+ * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
+ */
+ result = result * 10 * 1000 / 1023; /* result in mV */
+
+ return (result);
}
static int test_dip (void)
{
- static int first_run = 1;
- static int first_dip;
-
- if (first_run) {
- if ((first_dip = read_dip ()) == -1) {
- return (1);
- }
- first_run = 0;
- debug ("%s: first_dip=%d\n", __FUNCTION__, first_dip);
- }
- if (first_dip != read_dip ()) {
- return (1);
- } else {
- return (0);
- }
+ static int first_run = 1;
+ static int first_dip;
+
+ if (first_run) {
+ if ((first_dip = read_dip ()) == -1) {
+ return (1);
+ }
+ first_run = 0;
+ debug ("%s: first_dip=%d\n", __FUNCTION__, first_dip);
+ }
+ if (first_dip != read_dip ()) {
+ return (1);
+ } else {
+ return (0);
+ }
}
static int test_vcc5v (void)
{
- int vcc5v;
+ int vcc5v;
- if ((vcc5v = read_vcc5v ()) == -1) {
- return (1);
- }
+ if ((vcc5v = read_vcc5v ()) == -1) {
+ return (1);
+ }
- if ((vcc5v > VCC5V_MAX) || (vcc5v < VCC5V_MIN)) {
- return (1);
- } else {
- return (0);
- }
+ if ((vcc5v > VCC5V_MAX) || (vcc5v < VCC5V_MIN)) {
+ printf ("%s: vcc5v[V/100]=%d\n", __FUNCTION__, vcc5v);
+ return (1);
+ } else {
+ return (0);
+ }
}
static int test_rotary_switch (void)
{
- static int first_run = 1;
- static int first_rs;
-
- if (first_run) {
- /*
- * clear bits in CPLD, because they have random values after
- * power-up or reset.
- */
- *CPLD_ROTARY_SWITCH |= (1 << 16) | (1 << 17);
-
- first_rs = ((*CPLD_ROTARY_SWITCH >> 16) & 0x7);
- first_run = 0;
- debug ("%s: first_rs=%d\n", __FUNCTION__, first_rs);
- }
-
- if (first_rs != ((*CPLD_ROTARY_SWITCH >> 16) & 0x7)) {
- return (1);
- } else {
- return (0);
- }
+ static int first_run = 1;
+ static int first_rs;
+
+ if (first_run) {
+ /*
+ * clear bits in CPLD, because they have random values after
+ * power-up or reset.
+ */
+ *CPLD_ROTARY_SWITCH |= (1 << 16) | (1 << 17);
+
+ first_rs = ((*CPLD_ROTARY_SWITCH >> 16) & 0x7);
+ first_run = 0;
+ debug ("%s: first_rs=%d\n", __FUNCTION__, first_rs);
+ }
+
+ if (first_rs != ((*CPLD_ROTARY_SWITCH >> 16) & 0x7)) {
+ return (1);
+ } else {
+ return (0);
+ }
}
static int test_sram (void)
{
- return (memory_post_tests (SRAM_ADDR, SRAM_SIZE));
+ return (memory_post_tests (SRAM_ADDR, SRAM_SIZE));
}
static int test_eeprom (void)
{
- unsigned char temp[sizeof (EEPROM_TEST_STRING_1)];
- int result = 0;
-
- /* write test string 1, read back and verify */
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
- EEPROM_TEST_STRING_1,
- sizeof (EEPROM_TEST_STRING_1))) {
- return (1);
- }
-
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
- temp, sizeof (EEPROM_TEST_STRING_1))) {
- return (1);
- }
-
- if (strcmp (temp, EEPROM_TEST_STRING_1) != 0) {
- result = 1;
- printf ("%s: error; read_str = \"%s\"\n", __FUNCTION__, temp);
- }
-
- /* write test string 2, read back and verify */
- if (result == 0) {
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
- EEPROM_TEST_STRING_2,
- sizeof (EEPROM_TEST_STRING_2))) {
- return (1);
- }
-
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
- temp, sizeof (EEPROM_TEST_STRING_2))) {
- return (1);
- }
-
- if (strcmp (temp, EEPROM_TEST_STRING_2) != 0) {
- result = 1;
- printf ("%s: error; read str = \"%s\"\n",
- __FUNCTION__, temp);
- }
- }
- return (result);
+ unsigned char temp[sizeof (EEPROM_TEST_STRING_1)];
+ int result = 0;
+
+ /* write test string 1, read back and verify */
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+ EEPROM_TEST_STRING_1,
+ sizeof (EEPROM_TEST_STRING_1))) {
+ return (1);
+ }
+
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+ temp, sizeof (EEPROM_TEST_STRING_1))) {
+ return (1);
+ }
+
+ if (strcmp (temp, EEPROM_TEST_STRING_1) != 0) {
+ result = 1;
+ printf ("%s: error; read_str = \"%s\"\n", __FUNCTION__, temp);
+ }
+
+ /* write test string 2, read back and verify */
+ if (result == 0) {
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+ EEPROM_TEST_STRING_2,
+ sizeof (EEPROM_TEST_STRING_2))) {
+ return (1);
+ }
+
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
+ temp, sizeof (EEPROM_TEST_STRING_2))) {
+ return (1);
+ }
+
+ if (strcmp (temp, EEPROM_TEST_STRING_2) != 0) {
+ result = 1;
+ printf ("%s: error; read str = \"%s\"\n",
+ __FUNCTION__, temp);
+ }
+ }
+ return (result);
}
static int test_contact_temp (void)
{
- int contact_temp;
+ int contact_temp;
- spi_init ();
- contact_temp = tsc2000_contact_temp ();
+ spi_init ();
+ contact_temp = tsc2000_contact_temp ();
- if ((contact_temp < MIN_CONTACT_TEMP)
- || (contact_temp > MAX_CONTACT_TEMP))
- return (1);
- else
- return (0);
+ if ((contact_temp < MIN_CONTACT_TEMP)
+ || (contact_temp > MAX_CONTACT_TEMP))
+ return (1);
+ else
+ return (0);
}
int i2c_write_multiple (uchar chip, uint addr, int alen,
uchar *buffer, int len)
{
- int i;
-
- if (alen != 1) {
- printf ("%s: addr len other than 1 not supported\n",
- __FUNCTION__);
- return (1);
- }
-
- for (i = 0; i < len; i++) {
- if (i2c_write (chip, addr+i, alen, buffer+i, 1)) {
- printf ("%s: could not write to i2c device %d"
- ", addr %d\n", __FUNCTION__, chip, addr);
- return (1);
- }
+ int i;
+
+ if (alen != 1) {
+ printf ("%s: addr len other than 1 not supported\n",
+ __FUNCTION__);
+ return (1);
+ }
+
+ for (i = 0; i < len; i++) {
+ if (i2c_write (chip, addr+i, alen, buffer+i, 1)) {
+ printf ("%s: could not write to i2c device %d"
+ ", addr %d\n", __FUNCTION__, chip, addr);
+ return (1);
+ }
#if 0
- printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
- "%#x+%d=%p=\"%.1s\"\n", chip, addr, i, addr+i,
- alen, buffer, i, buffer+i, buffer+i);
+ printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
+ "%#x+%d=%p=\"%.1s\"\n", chip, addr, i, addr+i,
+ alen, buffer, i, buffer+i, buffer+i);
#endif
- udelay (30000);
- }
- return (0);
+ udelay (30000);
+ }
+ return (0);
}
int i2c_read_multiple ( uchar chip, uint addr, int alen,
uchar *buffer, int len)
{
- int i;
-
- if (alen != 1) {
- printf ("%s: addr len other than 1 not supported\n",
- __FUNCTION__);
- return (1);
- }
-
- for (i = 0; i < len; i++) {
- if (i2c_read (chip, addr+i, alen, buffer+i, 1)) {
- printf ("%s: could not read from i2c device %#x"
- ", addr %d\n", __FUNCTION__, chip, addr);
- return (1);
- }
- }
- return (0);
+ int i;
+
+ if (alen != 1) {
+ printf ("%s: addr len other than 1 not supported\n",
+ __FUNCTION__);
+ return (1);
+ }
+
+ for (i = 0; i < len; i++) {
+ if (i2c_read (chip, addr+i, alen, buffer+i, 1)) {
+ printf ("%s: could not read from i2c device %#x"
+ ", addr %d\n", __FUNCTION__, chip, addr);
+ return (1);
+ }
+ }
+ return (0);
}
static int adc_read (unsigned int channel)
{
- int j = 1000; /* timeout value for wait loop in us */
- S3C2400_ADC *padc;
-
- padc = S3C2400_GetBase_ADC();
- channel &= 0x7;
+ int j = 1000; /* timeout value for wait loop in us */
+ int result;
+ S3C2400_ADC *padc;
- adc_init ();
+ padc = S3C2400_GetBase_ADC();
+ channel &= 0x7;
- debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
+ adc_init ();
- padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
+ padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
- padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+ padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
- debug ("%s: reading ch %d, addcon %#x\n", __FUNCTION__,
- (padc->ADCCON >> 3) & 0x7, padc->ADCCON);
+ while (j--) {
+ 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 */
+ return -1;
+ }
- while (j--) {
- if ((padc->ADCCON & ADC_ENABLE_START) == 0)
- break;
- udelay (1);
- }
+ result = padc->ADCDAT & 0x3FF;
- if (j == 0) {
- printf("%s: ADC timeout\n", __FUNCTION__);
- padc->ADCCON |= ADC_STDBM; /* select standby mode */
- return -1;
- }
+ 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);
- debug ("%s: return %#x, adccon %#x\n", __FUNCTION__,
- padc->ADCDAT & 0x3FF, padc->ADCCON);
+ /*
+ * Wait for ADC to be ready for next conversion. This delay value was
+ * estimated, because the datasheet does not specify a value.
+ */
+ udelay (1000);
- return (padc->ADCDAT & 0x3FF);
+ return (result);
}
static void adc_init (void)
{
- S3C2400_ADC *padc;
+ S3C2400_ADC *padc;
- padc = S3C2400_GetBase_ADC();
+ padc = S3C2400_GetBase_ADC();
padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
- return;
+ /*
+ * Wait some time to avoid problem with very first call of
+ * adc_read(). Without this delay, sometimes the first read
+ * adc value is 0. Perhaps because the adjustment of prescaler
+ * takes some clock cycles?
+ */
+ udelay (1000);
+
+ return;
}
static void led_set (unsigned int state)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-
- led_init ();
-
- switch (state) {
- case 0: /* turn LED off */
- gpio->PADAT |= (1 << 12);
- break;
- case 1: /* turn LED on */
- gpio->PADAT &= ~(1 << 12);
- break;
- default:
- }
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ led_init ();
+
+ switch (state) {
+ case 0: /* turn LED off */
+ gpio->PADAT |= (1 << 12);
+ break;
+ case 1: /* turn LED on */
+ gpio->PADAT &= ~(1 << 12);
+ break;
+ default:
+ }
}
static void led_blink (void)
{
- led_init ();
-
- /* blink LED. This function does not return! */
- while (1) {
- led_set (1);
- udelay (1000000 / LED_BLINK_FREQ / 2);
- led_set (0);
- udelay (1000000 / LED_BLINK_FREQ / 2);
- }
+ led_init ();
+
+ /* blink LED. This function does not return! */
+ while (1) {
+ led_set (1);
+ udelay (1000000 / LED_BLINK_FREQ / 2);
+ led_set (0);
+ udelay (1000000 / LED_BLINK_FREQ / 2);
+ }
}
static void led_init (void)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
- /* configure GPA12 as output and set to High -> LED off */
- gpio->PACON &= ~(1 << 12);
- gpio->PADAT |= (1 << 12);
+ /* configure GPA12 as output and set to High -> LED off */
+ gpio->PACON &= ~(1 << 12);
+ gpio->PADAT |= (1 << 12);
}
static void sdelay (unsigned long seconds)
{
- unsigned long i;
+ unsigned long i;
- for (i = 0; i < seconds; i++) {
- udelay (1000000);
- }
+ for (i = 0; i < seconds; i++) {
+ udelay (1000000);
+ }
}
static int global_vars_write_to_eeprom (void)
{
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
- (unsigned char*) &status, 1)) {
- return (1);
- }
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
- (unsigned char*) &pass_cycles, 2)) {
- return (1);
- }
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
- 1, (unsigned char*) &first_error_cycle, 2)) {
- return (1);
- }
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
- 1, (unsigned char*) &first_error_num, 1)) {
- return (1);
- }
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
- 1, first_error_name,
- sizeof(first_error_name))) {
- return (1);
- }
- return (0);
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
+ (unsigned char*) &status, 1)) {
+ return (1);
+ }
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
+ (unsigned char*) &pass_cycles, 2)) {
+ return (1);
+ }
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
+ 1, (unsigned char*) &first_error_cycle, 2)) {
+ return (1);
+ }
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
+ 1, (unsigned char*) &first_error_num, 1)) {
+ return (1);
+ }
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
+ 1, first_error_name,
+ sizeof(first_error_name))) {
+ return (1);
+ }
+ return (0);
}
static void global_vars_init (void)
{
- status = 1; /* error */
- pass_cycles = 0;
- first_error_cycle = 0;
- first_error_num = 0;
- first_error_name[0] = '\0';
- act_cycle = 0;
- max_cycles = 0;
+ status = 1; /* error */
+ pass_cycles = 0;
+ first_error_cycle = 0;
+ first_error_num = 0;
+ first_error_name[0] = '\0';
+ act_cycle = 0;
+ max_cycles = 0;
}
static void test_function_table_init (void)
{
- int i;
+ int i;
- for (i = 0; i < BIF_MAX; i++)
+ for (i = 0; i < BIF_MAX; i++)
test_function[i].pf = dummy;
- /*
- * the length of "name" must not exceed 16, including the '\0'
- * termination. See also the EEPROM address map.
- */
- test_function[0].pf = test_dip;
- test_function[0].name = "dip";
+ /*
+ * the length of "name" must not exceed 16, including the '\0'
+ * termination. See also the EEPROM address map.
+ */
+ test_function[0].pf = test_dip;
+ test_function[0].name = "dip";
- test_function[1].pf = test_vcc5v;
- test_function[1].name = "vcc5v";
+ test_function[1].pf = test_vcc5v;
+ test_function[1].name = "vcc5v";
- test_function[2].pf = test_rotary_switch;
- test_function[2].name = "rotary_switch";
+ test_function[2].pf = test_rotary_switch;
+ test_function[2].name = "rotary_switch";
- test_function[3].pf = test_sram;
- test_function[3].name = "sram";
+ test_function[3].pf = test_sram;
+ test_function[3].name = "sram";
- test_function[4].pf = test_eeprom;
- test_function[4].name = "eeprom";
+ test_function[4].pf = test_eeprom;
+ test_function[4].name = "eeprom";
- test_function[5].pf = test_contact_temp;
- test_function[5].name = "contact_temp";
+ test_function[5].pf = test_contact_temp;
+ test_function[5].name = "contact_temp";
}
static int read_max_cycles (void)
{
- if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_MAX_CYCLES, 1,
- (unsigned char *) &max_cycles, 2) != 0) {
- return (1);
- }
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_MAX_CYCLES, 1,
+ (unsigned char *) &max_cycles, 2) != 0) {
+ return (1);
+ }
- return (0);
+ return (0);
}
static int dummy(void)
{
- return (0);
+ return (0);
}
#endif /* CFG_CMD_BSP */
diff --git a/board/trab/rs485.c b/board/trab/rs485.c
index 774fd59a49a..2aedd2dc537 100644
--- a/board/trab/rs485.c
+++ b/board/trab/rs485.c
@@ -47,8 +47,8 @@ static void rs485_setbrg (void)
unsigned int reg = 0;
/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
- /* reg = (33000000 / (16 * gd->baudrate)) - 1; */
- reg = (33000000 / (16 * 38.400)) - 1;
+ /* reg = (33000000 / (16 * gd->baudrate)) - 1; */
+ reg = (33000000 / (16 * 38400)) - 1;
/* FIFO enable, Tx/Rx FIFO clear */
uart->UFCON = 0x07;
@@ -67,18 +67,18 @@ static void rs485_setbrg (void)
static void rs485_cfgio (void)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
- gpio->PFCON &= ~(0x3 << 2);
- gpio->PFCON |= (0x2 << 2); /* configure GPF1 as RXD1 */
+ gpio->PFCON &= ~(0x3 << 2);
+ gpio->PFCON |= (0x2 << 2); /* configure GPF1 as RXD1 */
- gpio->PFCON &= ~(0x3 << 6);
- gpio->PFCON |= (0x2 << 6); /* configure GPF3 as TXD1 */
+ gpio->PFCON &= ~(0x3 << 6);
+ gpio->PFCON |= (0x2 << 6); /* configure GPF3 as TXD1 */
- gpio->PFUP |= (1 << 1); /* disable pullup on GPF1 */
- gpio->PFUP |= (1 << 3); /* disable pullup on GPF3 */
+ gpio->PFUP |= (1 << 1); /* disable pullup on GPF1 */
+ gpio->PFUP |= (1 << 3); /* disable pullup on GPF3 */
- gpio->PACON &= ~(1 << 11); /* set GPA11 (RS485_DE) to output */
+ gpio->PACON &= ~(1 << 11); /* set GPA11 (RS485_DE) to output */
}
/*
@@ -88,8 +88,8 @@ static void rs485_cfgio (void)
*/
int rs485_init (void)
{
- rs485_cfgio ();
- rs485_setbrg ();
+ rs485_cfgio ();
+ rs485_setbrg ();
return (0);
}
@@ -168,13 +168,13 @@ static void set_rs485re(unsigned char rs485re_state)
static void set_rs485de(unsigned char rs485de_state)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
- /* This is on PORT A bit 11 */
- if(rs485de_state)
- gpio->PADAT |= (1 << 11);
- else
- gpio->PADAT &= ~(1 << 11);
+ /* This is on PORT A bit 11 */
+ if(rs485de_state)
+ gpio->PADAT |= (1 << 11);
+ else
+ gpio->PADAT &= ~(1 << 11);
}
diff --git a/board/trab/trab_fkt.c b/board/trab/trab_fkt.c
index c147353033c..56132818a9b 100644
--- a/board/trab/trab_fkt.c
+++ b/board/trab/trab_fkt.c
@@ -29,6 +29,19 @@
#include "tsc2000.h"
#include "rs485.h"
+/*
+ * define, to wait for the touch to be pressed, before reading coordinates in
+ * command do_touch. If not defined, an error message is printed, when the
+ * command do_touch is invoked and the touch is not pressed within an specific
+ * interval.
+ */
+#undef CONFIG_TOUCH_WAIT_PRESSED 1
+
+/* max time to wait for touch is pressed */
+#ifndef CONFIG_TOUCH_WAIT_PRESSED
+#define TOUCH_TIMEOUT 5
+#endif /* !CONFIG_TOUCH_WAIT_PRESSED */
+
/* assignment of CPU internal ADC channels with TRAB hardware */
#define VCC5V 2
#define VCC12V 3
@@ -51,7 +64,6 @@
#define PCLK 66000000
#define BUZZER_FREQ 1000 /* frequency in Hz */
-#define BUZZER_TIME 1000000 /* time in us */
#define PWM_FREQ 500
@@ -62,7 +74,7 @@
#define CALIB_TL 0 /* calibration point in (T)op (L)eft corner */
#define CALIB_DR 1 /* calibration point in (D)own (R)ight corner */
-/* EEPROM addresse map */
+/* EEPROM address map */
#define SERIAL_NUMBER 8
#define TOUCH_X0 52
#define TOUCH_Y0 54
@@ -102,7 +114,7 @@ int do_rotary_switch (void);
int do_pressure (void);
int do_v_bat (void);
int do_vfd_id (void);
-int do_buzzer (void);
+int do_buzzer (char **);
int do_led (char **);
int do_full_bridge (char **);
int do_dac (char **);
@@ -114,19 +126,36 @@ int do_touch (char **);
int do_rs485 (char **);
int do_serial_number (char **);
int do_crc16 (void);
+int do_power_switch (void);
+int do_gain (char **);
+int do_eeprom (char **);
/* helper functions */
static void adc_init (void);
static int adc_read (unsigned int channel);
static void print_identifier (void);
+
+#ifdef CONFIG_TOUCH_WAIT_PRESSED
static void touch_wait_pressed (void);
+#else
+static int touch_check_pressed (void);
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
+
static void touch_read_x_y (int *x, int *y);
static int touch_write_clibration_values (int calib_point, int x, int y);
static int rs485_send_line (const char *data);
static int rs485_receive_chars (char *data, int timeout);
static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
- unsigned int icnt);
+ unsigned int icnt);
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+static int trab_eeprom_read (char **argv);
+static int trab_eeprom_write (char **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 */
/*
* TRAB board specific commands. Especially commands for burn-in and function
@@ -135,24 +164,24 @@ static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
int trab_fkt (int argc, char *argv[])
{
- int i;
-
- app_startup(argv);
- if (get_version () != XF_VERSION) {
- printf ("Wrong XF_VERSION. Please re-compile with actual "
- "u-boot sources\n");
- printf ("Example expects ABI version %d\n", XF_VERSION);
- printf ("Actual U-Boot ABI version %d\n", (int)get_version());
- return 1;
- }
+ int i;
+
+ app_startup(argv);
+ if (get_version () != XF_VERSION) {
+ printf ("Wrong XF_VERSION. Please re-compile with actual "
+ "u-boot sources\n");
+ printf ("Example expects ABI version %d\n", XF_VERSION);
+ printf ("Actual U-Boot ABI version %d\n", (int)get_version());
+ return 1;
+ }
- debug ("argc = %d\n", argc);
+ debug ("argc = %d\n", argc);
for (i=0; i<=argc; ++i) {
debug ("argv[%d] = \"%s\"\n", i, argv[i] ? argv[i] : "<NULL>");
- }
+ }
- adc_init ();
+ adc_init ();
switch (argc) {
@@ -162,103 +191,121 @@ int trab_fkt (int argc, char *argv[])
case 2:
if (strcmp (argv[1], "info") == 0) {
- return (do_info ());
+ return (do_info ());
+ }
+ if (strcmp (argv[1], "dip") == 0) {
+ return (do_dip ());
+ }
+ if (strcmp (argv[1], "vcc5v") == 0) {
+ return (do_vcc5v ());
}
- if (strcmp (argv[1], "dip") == 0) {
- return (do_dip ());
- }
- if (strcmp (argv[1], "vcc5v") == 0) {
- return (do_vcc5v ());
- }
- if (strcmp (argv[1], "vcc12v") == 0) {
- return (do_vcc12v ());
- }
- if (strcmp (argv[1], "buttons") == 0) {
- return (do_buttons ());
- }
- if (strcmp (argv[1], "fill_level") == 0) {
- return (do_fill_level ());
- }
- if (strcmp (argv[1], "rotary_switch") == 0) {
- return (do_rotary_switch ());
- }
- if (strcmp (argv[1], "pressure") == 0) {
- return (do_pressure ());
- }
- if (strcmp (argv[1], "v_bat") == 0) {
- return (do_v_bat ());
- }
- if (strcmp (argv[1], "vfd_id") == 0) {
- return (do_vfd_id ());
- }
- if (strcmp (argv[1], "buzzer") == 0) {
- return (do_buzzer ());
- }
- if (strcmp (argv[1], "motor_contact") == 0) {
- return (do_motor_contact ());
- }
- if (strcmp (argv[1], "crc16") == 0) {
- return (do_crc16 ());
- }
- break;
+ if (strcmp (argv[1], "vcc12v") == 0) {
+ return (do_vcc12v ());
+ }
+ if (strcmp (argv[1], "buttons") == 0) {
+ return (do_buttons ());
+ }
+ if (strcmp (argv[1], "fill_level") == 0) {
+ return (do_fill_level ());
+ }
+ if (strcmp (argv[1], "rotary_switch") == 0) {
+ return (do_rotary_switch ());
+ }
+ if (strcmp (argv[1], "pressure") == 0) {
+ return (do_pressure ());
+ }
+ if (strcmp (argv[1], "v_bat") == 0) {
+ return (do_v_bat ());
+ }
+ if (strcmp (argv[1], "vfd_id") == 0) {
+ return (do_vfd_id ());
+ }
+ if (strcmp (argv[1], "motor_contact") == 0) {
+ return (do_motor_contact ());
+ }
+ if (strcmp (argv[1], "crc16") == 0) {
+ return (do_crc16 ());
+ }
+ if (strcmp (argv[1], "power_switch") == 0) {
+ return (do_power_switch ());
+ }
+ break;
case 3:
- if (strcmp (argv[1], "full_bridge") == 0) {
- return (do_full_bridge (argv));
- }
- if (strcmp (argv[1], "dac") == 0) {
- return (do_dac (argv));
- }
- if (strcmp (argv[1], "motor") == 0) {
- return (do_motor (argv));
- }
- if (strcmp (argv[1], "pwm") == 0) {
- return (do_pwm (argv));
- }
- if (strcmp (argv[1], "thermo") == 0) {
- return (do_thermo (argv));
- }
- if (strcmp (argv[1], "touch") == 0) {
- return (do_touch (argv));
- }
- if (strcmp (argv[1], "serial_number") == 0) {
- return (do_serial_number (argv));
- }
- break;
-
- case 4:
- if (strcmp (argv[1], "led") == 0) {
- return (do_led (argv));
- }
- if (strcmp (argv[1], "rs485") == 0) {
- return (do_rs485 (argv));
- }
- if (strcmp (argv[1], "serial_number") == 0) {
- return (do_serial_number (argv));
- }
- break;
+ if (strcmp (argv[1], "full_bridge") == 0) {
+ return (do_full_bridge (argv));
+ }
+ if (strcmp (argv[1], "dac") == 0) {
+ return (do_dac (argv));
+ }
+ if (strcmp (argv[1], "motor") == 0) {
+ return (do_motor (argv));
+ }
+ if (strcmp (argv[1], "pwm") == 0) {
+ return (do_pwm (argv));
+ }
+ if (strcmp (argv[1], "thermo") == 0) {
+ return (do_thermo (argv));
+ }
+ if (strcmp (argv[1], "touch") == 0) {
+ return (do_touch (argv));
+ }
+ if (strcmp (argv[1], "serial_number") == 0) {
+ return (do_serial_number (argv));
+ }
+ if (strcmp (argv[1], "buzzer") == 0) {
+ return (do_buzzer (argv));
+ }
+ if (strcmp (argv[1], "gain") == 0) {
+ return (do_gain (argv));
+ }
+ break;
+
+ case 4:
+ if (strcmp (argv[1], "led") == 0) {
+ return (do_led (argv));
+ }
+ if (strcmp (argv[1], "rs485") == 0) {
+ return (do_rs485 (argv));
+ }
+ if (strcmp (argv[1], "serial_number") == 0) {
+ return (do_serial_number (argv));
+ }
+ break;
+
+ case 5:
+ if (strcmp (argv[1], "eeprom") == 0) {
+ return (do_eeprom (argv));
+ }
+ break;
+
+ case 6:
+ if (strcmp (argv[1], "eeprom") == 0) {
+ return (do_eeprom (argv));
+ }
+ break;
default:
break;
}
printf ("Usage:\n<command> <parameter1> <parameter2> ...\n");
- return 1;
+ return 1;
}
int do_info (void)
{
- printf ("Stand-alone application for TRAB board function test\n");
- printf ("Built: %s at %s\n", __DATE__ , __TIME__ );
+ printf ("Stand-alone application for TRAB board function test\n");
+ printf ("Built: %s at %s\n", __DATE__ , __TIME__ );
return 0;
}
int do_dip (void)
{
- unsigned int result = 0;
- int adc_val;
- int i;
+ unsigned int result = 0;
+ int adc_val;
+ int i;
/***********************************************************
DIP switch connection (according to wa4-cpu.sp.301.pdf, page 3):
@@ -273,10 +320,10 @@ int do_dip (void)
for (i = 7; i > 3; i--) {
- if ((adc_val = adc_read (i)) == -1) {
- printf ("Channel %d could not be read\n", i);
- return 1;
- }
+ if ((adc_val = adc_read (i)) == -1) {
+ printf ("Channel %d could not be read\n", i);
+ return 1;
+ }
/*
* Input voltage (switch open) is 1.8 V.
@@ -284,18 +331,18 @@ int do_dip (void)
* Set trigger at halve that value.
*/
if (adc_val < 368)
- result |= (1 << (i-4));
- }
-
- /* print result to console */
- print_identifier ();
- for (i = 0; i < 4; i++) {
- if ((result & (1 << i)) == 0)
- printf("0");
- else
- printf("1");
- }
- printf("\n");
+ result |= (1 << (i-4));
+ }
+
+ /* print result to console */
+ print_identifier ();
+ for (i = 0; i < 4; i++) {
+ if ((result & (1 << i)) == 0)
+ printf("0");
+ else
+ printf("1");
+ }
+ printf("\n");
return 0;
}
@@ -303,25 +350,25 @@ int do_dip (void)
int do_vcc5v (void)
{
- int result;
-
- /* VCC5V is connected to channel 2 */
-
- if ((result = adc_read (VCC5V)) == -1) {
- printf ("VCC5V could not be read\n");
- return 1;
- }
-
- /*
- * Calculate voltage value. Split in two parts because there is no
- * floating point support. VCC5V is connected over an resistor divider:
- * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
- */
- print_identifier ();
- printf ("%d", (result & 0x3FF)* 10 / 1023);
- printf (".%d", ((result & 0x3FF)* 10 % 1023)* 10 / 1023);
- printf ("%d V\n", (((result & 0x3FF) * 10 % 1023 ) * 10 % 1023)
- * 10 / 1024);
+ int result;
+
+ /* VCC5V is connected to channel 2 */
+
+ if ((result = adc_read (VCC5V)) == -1) {
+ printf ("VCC5V could not be read\n");
+ return 1;
+ }
+
+ /*
+ * Calculate voltage value. Split in two parts because there is no
+ * floating point support. VCC5V is connected over an resistor divider:
+ * VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
+ */
+ print_identifier ();
+ printf ("%d", (result & 0x3FF)* 10 / 1023);
+ printf (".%d", ((result & 0x3FF)* 10 % 1023)* 10 / 1023);
+ printf ("%d V\n", (((result & 0x3FF) * 10 % 1023 ) * 10 % 1023)
+ * 10 / 1024);
return 0;
}
@@ -329,299 +376,338 @@ int do_vcc5v (void)
int do_vcc12v (void)
{
- int result;
-
- if ((result = adc_read (VCC12V)) == -1) {
- printf ("VCC12V could not be read\n");
- return 1;
- }
-
- /*
- * Calculate voltage value. Split in two parts because there is no
- * floating point support. VCC5V is connected over an resistor divider:
- * VCC12V=ADCval*2,5V/1023*(30K+270K)/30K.
- */
- print_identifier ();
- printf ("%d", (result & 0x3FF)* 25 / 1023);
- printf (".%d V\n", ((result & 0x3FF)* 25 % 1023) * 10 / 1023);
-
- return 0;
+ int result;
+
+ if ((result = adc_read (VCC12V)) == -1) {
+ printf ("VCC12V could not be read\n");
+ return 1;
+ }
+
+ /*
+ * Calculate voltage value. Split in two parts because there is no
+ * floating point support. VCC5V is connected over an resistor divider:
+ * VCC12V=ADCval*2,5V/1023*(30K+270K)/30K.
+ */
+ print_identifier ();
+ printf ("%d", (result & 0x3FF)* 25 / 1023);
+ printf (".%d V\n", ((result & 0x3FF)* 25 % 1023) * 10 / 1023);
+
+ return 0;
}
static int adc_read (unsigned int channel)
{
- int j = 1000; /* timeout value for wait loop in us */
- S3C2400_ADC *padc;
+ int j = 1000; /* timeout value for wait loop in us */
+ int result;
+ S3C2400_ADC *padc;
- padc = S3C2400_GetBase_ADC();
- channel &= 0x7;
+ padc = S3C2400_GetBase_ADC();
+ channel &= 0x7;
- debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
-
- padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
+ padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
- padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+ padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+
+ while (j--) {
+ if ((padc->ADCCON & ADC_ENABLE_START) == 0)
+ break;
+ udelay (1);
+ }
- debug ("%s: reading ch %d, addcon %#x\n", __FUNCTION__,
- (padc->ADCCON >> 3) & 0x7, padc->ADCCON);
+ if (j == 0) {
+ printf("%s: ADC timeout\n", __FUNCTION__);
+ padc->ADCCON |= ADC_STDBM; /* select standby mode */
+ return -1;
+ }
- while (j--) {
- if ((padc->ADCCON & ADC_ENABLE_START) == 0)
- break;
- udelay (1);
- }
+ result = padc->ADCDAT & 0x3FF;
- if (j == 0) {
- printf("%s: ADC timeout\n", __FUNCTION__);
- padc->ADCCON |= ADC_STDBM; /* select standby mode */
- return -1;
- }
+ 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);
- debug ("%s: return %#x, adccon %#x\n", __FUNCTION__, padc->ADCDAT & 0x3FF,
- padc->ADCCON);
+ /*
+ * Wait for ADC to be ready for next conversion. This delay value was
+ * estimated, because the datasheet does not specify a value.
+ */
+ udelay (1000);
- return (padc->ADCDAT & 0x3FF);
+ return (result);
}
static void adc_init (void)
{
- S3C2400_ADC *padc;
-
- padc = S3C2400_GetBase_ADC();
+ S3C2400_ADC *padc;
- debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
+ padc = S3C2400_GetBase_ADC();
padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
- debug ("%s: init completed: adccon %#x\n", __FUNCTION__, padc->ADCCON);
- return;
+ /*
+ * Wait some time to avoid problem with very first call of
+ * adc_read(). Without * this delay, sometimes the first read adc
+ * value is 0. Perhaps because the * adjustment of prescaler takes
+ * some clock cycles?
+ */
+ udelay (1000);
+
+ return;
}
int do_buttons (void)
{
- int result;
- int i;
-
- result = *CPLD_BUTTONS; /* read CPLD */
- debug ("%s: cpld_taster (32 bit) %#x\n", __FUNCTION__, result);
-
- /* print result to console */
- print_identifier ();
- for (i = 16; i <= 19; i++) {
- if ((result & (1 << i)) == 0)
- printf("0");
- else
- printf("1");
- }
- printf("\n");
+ int result;
+ int i;
+
+ result = *CPLD_BUTTONS; /* read CPLD */
+ debug ("%s: cpld_taster (32 bit) %#x\n", __FUNCTION__, result);
+
+ /* print result to console */
+ print_identifier ();
+ for (i = 16; i <= 19; i++) {
+ if ((result & (1 << i)) == 0)
+ printf("0");
+ else
+ printf("1");
+ }
+ printf("\n");
+ return 0;
+}
+
+
+int do_power_switch (void)
+{
+ int result;
+
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* configure GPE7 as input */
+ 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;
+
+ print_identifier ();
+ printf("%d\n", result);
return 0;
}
int do_fill_level (void)
{
- int result;
+ int result;
- result = *CPLD_FILL_LEVEL; /* read CPLD */
- debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
+ result = *CPLD_FILL_LEVEL; /* read CPLD */
+ debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
- /* print result to console */
- print_identifier ();
- if ((result & (1 << 16)) == 0)
- printf("0\n");
- else
- printf("1\n");
+ /* print result to console */
+ print_identifier ();
+ if ((result & (1 << 16)) == 0)
+ printf("0\n");
+ else
+ printf("1\n");
return 0;
}
int do_rotary_switch (void)
{
- int result;
-
- result = *CPLD_ROTARY_SWITCH; /* read CPLD */
- debug ("%s: cpld_inc (32 bit) %#x\n", __FUNCTION__, result);
-
- *CPLD_ROTARY_SWITCH |= (3 << 16); /* clear direction bits in CPLD */
-
- /* print result to console */
- print_identifier ();
- if ((result & (1 << 16)) == (1 << 16))
- printf("R");
- if ((result & (1 << 17)) == (1 << 17))
- printf("L");
- if (((result & (1 << 16)) == 0) && ((result & (1 << 17)) == 0))
- printf("0");
- if ((result & (1 << 18)) == 0)
- printf("0\n");
- else
- printf("1\n");
+ int result;
+ /*
+ * Please note, that the default values of the direction bits are
+ * undefined after reset. So it is a good idea, to make first a dummy
+ * call to this function, to clear the direction bits and set so to
+ * proper values.
+ */
+
+ result = *CPLD_ROTARY_SWITCH; /* read CPLD */
+ debug ("%s: cpld_inc (32 bit) %#x\n", __FUNCTION__, result);
+
+ *CPLD_ROTARY_SWITCH |= (3 << 16); /* clear direction bits in CPLD */
+
+ /* print result to console */
+ print_identifier ();
+ if ((result & (1 << 16)) == (1 << 16))
+ printf("R");
+ if ((result & (1 << 17)) == (1 << 17))
+ printf("L");
+ if (((result & (1 << 16)) == 0) && ((result & (1 << 17)) == 0))
+ printf("0");
+ if ((result & (1 << 18)) == 0)
+ printf("0\n");
+ else
+ printf("1\n");
return 0;
}
int do_vfd_id (void)
{
- int i;
- long int pcup_old, pccon_old;
- int vfd_board_id;
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ int i;
+ long int pcup_old, pccon_old;
+ int vfd_board_id;
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_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
- * inputs */
+ * inputs */
udelay (10); /* allow signals to settle */
vfd_board_id = (~gpio->PCDAT) & 0x000F; /* read GPC0...GPC3 port pins */
- gpio->PCCON = pccon_old;
- gpio->PCUP = pcup_old;
-
- /* print vfd_board_id to console */
- print_identifier ();
- for (i = 0; i < 4; i++) {
- if ((vfd_board_id & (1 << i)) == 0)
- printf("0");
- else
- printf("1");
- }
- printf("\n");
+ gpio->PCCON = pccon_old;
+ gpio->PCUP = pcup_old;
+
+ /* print vfd_board_id to console */
+ print_identifier ();
+ for (i = 0; i < 4; i++) {
+ if ((vfd_board_id & (1 << i)) == 0)
+ printf("0");
+ else
+ printf("1");
+ }
+ printf("\n");
return 0;
}
-int do_buzzer (void)
+int do_buzzer (char **argv)
{
- int counter;
+ int counter;
S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-
- /* configure pin GPD7 as TOUT2 */
- gpio->PDCON &= ~0xC000;
- gpio->PDCON |= 0x8000;
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
- /* set prescaler for timer 2, 3 and 4 */
- timers->TCFG0 &= ~0xFF00;
+ /* set prescaler for timer 2, 3 and 4 */
+ timers->TCFG0 &= ~0xFF00;
timers->TCFG0 |= 0x0F00;
- /* set divider for timer 2 */
+ /* set divider for timer 2 */
timers->TCFG1 &= ~0xF00;
timers->TCFG1 |= 0x300;
- /* set frequency */
- counter = (PCLK / BUZZER_FREQ) >> 9;
- timers->ch[2].TCNTB = counter;
+ /* set frequency */
+ counter = (PCLK / BUZZER_FREQ) >> 9;
+ timers->ch[2].TCNTB = counter;
timers->ch[2].TCMPB = counter / 2;
- debug ("%s: frequency: %d, duration: %d\n", __FUNCTION__, BUZZER_FREQ,
- BUZZER_TIME);
-
- /* start */
- timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) & ~INVERT2;
- timers->TCON = (timers->TCON | START2) & ~UPDATE2;
+ if (strcmp (argv[2], "on") == 0) {
+ debug ("%s: frequency: %d\n", __FUNCTION__,
+ BUZZER_FREQ);
- udelay (BUZZER_TIME);
+ /* configure pin GPD7 as TOUT2 */
+ gpio->PDCON &= ~0xC000;
+ gpio->PDCON |= 0x8000;
- /* stop */
- timers->TCON &= ~(START2 | RELOAD2);
+ /* start */
+ timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) &
+ ~INVERT2;
+ timers->TCON = (timers->TCON | START2) & ~UPDATE2;
+ return (0);
+ }
+ else if (strcmp (argv[2], "off") == 0) {
+ /* stop */
+ timers->TCON &= ~(START2 | RELOAD2);
+
+ /* configure GPD7 as output and set to low */
+ gpio->PDCON &= ~0xC000;
+ gpio->PDCON |= 0x4000;
+ gpio->PDDAT &= ~0x80;
+ return (0);
+ }
- /* port pin configuration */
- gpio->PDCON &= ~0xC000;
- gpio->PDCON |= 0x4000;
- gpio->PDDAT &= ~0x80;
- return 0;
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
}
int do_led (char **argv)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
- /* configure PC14 and PC15 as output */
- gpio->PCCON &= ~(0xF << 28);
- gpio->PCCON |= (0x5 << 28);
+ /* configure PC14 and PC15 as output */
+ gpio->PCCON &= ~(0xF << 28);
+ gpio->PCCON |= (0x5 << 28);
- /* configure PD0 and PD4 as output */
- gpio->PDCON &= ~((0x3 << 8) | 0x3);
- gpio->PDCON |= ((0x1 << 8) | 0x1);
+ /* configure PD0 and PD4 as output */
+ gpio->PDCON &= ~((0x3 << 8) | 0x3);
+ gpio->PDCON |= ((0x1 << 8) | 0x1);
- switch (simple_strtoul(argv[2], NULL, 10)) {
+ switch (simple_strtoul(argv[2], NULL, 10)) {
case 0:
case 1:
break;
- case 2:
- if (strcmp (argv[3], "on") == 0)
- gpio->PCDAT |= (1 << 14);
- else
- gpio->PCDAT &= ~(1 << 14);
- return 0;
-
- case 3:
- if (strcmp (argv[3], "on") == 0)
- gpio->PCDAT |= (1 << 15);
- else
- gpio->PCDAT &= ~(1 << 15);
- return 0;
-
- case 4:
- if (strcmp (argv[3], "on") == 0)
- gpio->PDDAT |= (1 << 0);
- else
- gpio->PDDAT &= ~(1 << 0);
- return 0;
-
- case 5:
- if (strcmp (argv[3], "on") == 0)
- gpio->PDDAT |= (1 << 4);
- else
- gpio->PDDAT &= ~(1 << 4);
- return 0;
-
- default:
- break;
-
- }
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
- return 1;
+ case 2:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PCDAT |= (1 << 14);
+ else
+ gpio->PCDAT &= ~(1 << 14);
+ return 0;
+
+ case 3:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PCDAT |= (1 << 15);
+ else
+ gpio->PCDAT &= ~(1 << 15);
+ return 0;
+
+ case 4:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PDDAT |= (1 << 0);
+ else
+ gpio->PDDAT &= ~(1 << 0);
+ return 0;
+
+ case 5:
+ if (strcmp (argv[3], "on") == 0)
+ gpio->PDDAT |= (1 << 4);
+ else
+ gpio->PDDAT &= ~(1 << 4);
+ return 0;
+
+ default:
+ break;
+
+ }
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
}
int do_full_bridge (char **argv)
{
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-
- /* configure PD5 and PD6 as output */
- 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);
- return 0;
- }
- else if (strcmp (argv[2], "-") == 0) {
- 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);
- return 0;
- }
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
- return 1;
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+ /* configure PD5 and PD6 as output */
+ 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);
+ return 0;
+ }
+ else if (strcmp (argv[2], "-") == 0) {
+ 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);
+ return 0;
+ }
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
}
/* val must be in [0, 4095] */
@@ -633,77 +719,77 @@ static inline unsigned long tsc2000_to_uv (u16 val)
int do_dac (char **argv)
{
- int brightness;
+ int brightness;
- /* initialize SPI */
- spi_init ();
+ /* initialize SPI */
+ spi_init ();
- if (((brightness = simple_strtoul (argv[2], NULL, 10)) < 0) ||
- (brightness > 255)) {
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
- return 1;
- }
- tsc2000_write(TSC2000_REG_DACCTL, 0x0); /* Power up DAC */
+ if (((brightness = simple_strtoul (argv[2], NULL, 10)) < 0) ||
+ (brightness > 255)) {
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
+ }
+ tsc2000_write(TSC2000_REG_DACCTL, 0x0); /* Power up DAC */
tsc2000_write(TSC2000_REG_DAC, brightness & 0xff);
- return 0;
+ return 0;
}
int do_v_bat (void)
{
- unsigned long ret, res;
+ unsigned long ret, res;
- /* initialize SPI */
- spi_init ();
+ /* initialize SPI */
+ spi_init ();
tsc2000_write(TSC2000_REG_ADC, 0x1836);
- /* now wait for data available */
- adc_wait_conversion_done();
+ /* now wait for data available */
+ adc_wait_conversion_done();
ret = tsc2000_read(TSC2000_REG_BAT1);
res = (tsc2000_to_uv(ret) + 1250) / 2500;
res += (ERROR_BATTERY * res) / 1000;
- print_identifier ();
- printf ("%ld", (res / 100));
- printf (".%ld", ((res % 100) / 10));
- printf ("%ld V\n", (res % 10));
+ print_identifier ();
+ printf ("%ld", (res / 100));
+ printf (".%ld", ((res % 100) / 10));
+ printf ("%ld V\n", (res % 10));
return 0;
}
int do_pressure (void)
{
- /* initialize SPI */
- spi_init ();
+ /* initialize SPI */
+ spi_init ();
- tsc2000_write(TSC2000_REG_ADC, 0x2436);
+ tsc2000_write(TSC2000_REG_ADC, 0x2436);
- /* now wait for data available */
- adc_wait_conversion_done();
+ /* now wait for data available */
+ adc_wait_conversion_done();
- print_identifier ();
- printf ("%d\n", tsc2000_read(TSC2000_REG_AUX2));
+ print_identifier ();
+ printf ("%d\n", tsc2000_read(TSC2000_REG_AUX2));
return 0;
}
int do_motor_contact (void)
{
- int result;
-
- result = *CPLD_FILL_LEVEL; /* read CPLD */
- debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
-
- /* print result to console */
- print_identifier ();
- if ((result & (1 << 17)) == 0)
- printf("0\n");
- else
- printf("1\n");
- return 0;
+ int result;
+
+ result = *CPLD_FILL_LEVEL; /* read CPLD */
+ debug ("%s: cpld_fuellstand (32 bit) %#x\n", __FUNCTION__, result);
+
+ /* print result to console */
+ print_identifier ();
+ if ((result & (1 << 17)) == 0)
+ printf("0\n");
+ else
+ printf("1\n");
+ return 0;
}
int do_motor (char **argv)
@@ -714,276 +800,341 @@ int do_motor (char **argv)
gpio->PGCON &= ~(0x3 << 0);
gpio->PGCON |= (0x1 << 0);
- if (strcmp (argv[2], "on") == 0) {
- gpio->PGDAT &= ~(1 << 0);
- return 0;
- }
- if (strcmp (argv[2], "off") == 0) {
- gpio->PGDAT |= (1 << 0);
- return 0;
- }
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
- return 1;
+ if (strcmp (argv[2], "on") == 0) {
+ gpio->PGDAT &= ~(1 << 0);
+ return 0;
+ }
+ if (strcmp (argv[2], "off") == 0) {
+ gpio->PGDAT |= (1 << 0);
+ return 0;
+ }
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
}
static void print_identifier (void)
{
- printf ("## FKT: ");
+ printf ("## FKT: ");
}
int do_pwm (char **argv)
{
- int counter;
- S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+ int counter;
+ S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
- if (strcmp (argv[2], "on") == 0) {
- /* configure pin GPD8 as TOUT3 */
- gpio->PDCON &= ~(0x3 << 8*2);
- gpio->PDCON |= (0x2 << 8*2);
-
- /* set prescaler for timer 2, 3 and 4 */
- timers->TCFG0 &= ~0xFF00;
- timers->TCFG0 |= 0x0F00;
-
- /* set divider for timer 3 */
- 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;
-
- /* start timer */
- 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);
-
- /* configure pin GPD8 as output and set to 0 */
- 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]);
- return 1;
+ if (strcmp (argv[2], "on") == 0) {
+ /* configure pin GPD8 as TOUT3 */
+ gpio->PDCON &= ~(0x3 << 8*2);
+ gpio->PDCON |= (0x2 << 8*2);
+
+ /* set prescaler for timer 2, 3 and 4 */
+ timers->TCFG0 &= ~0xFF00;
+ timers->TCFG0 |= 0x0F00;
+
+ /* set divider for timer 3 */
+ 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;
+
+ /* start timer */
+ 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);
+
+ /* configure pin GPD8 as output and set to 0 */
+ 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]);
+ return 1;
}
int do_thermo (char **argv)
{
- int channel, res;
-
- tsc2000_reg_init ();
- tsc2000_set_range (3);
-
- if (strcmp (argv[2], "all") == 0) {
- int i;
- for (i=0; i <= 15; i++) {
- res = tsc2000_read_channel(i);
- print_identifier ();
- printf ("c%d: %d\n", i, res);
- }
- return 0;
- }
- channel = simple_strtoul (argv[2], NULL, 10);
- res = tsc2000_read_channel(channel);
- print_identifier ();
- printf ("%d\n", res);
- return 0; /* return OK */
+ int channel, res;
+
+ tsc2000_reg_init ();
+
+ if (strcmp (argv[2], "all") == 0) {
+ int i;
+ for (i=0; i <= 15; i++) {
+ res = tsc2000_read_channel(i);
+ print_identifier ();
+ printf ("c%d: %d\n", i, res);
+ }
+ return 0;
+ }
+ channel = simple_strtoul (argv[2], NULL, 10);
+ res = tsc2000_read_channel(channel);
+ print_identifier ();
+ printf ("%d\n", res);
+ return 0; /* return OK */
}
int do_touch (char **argv)
{
- int x, y;
-
- if (strcmp (argv[2], "tl") == 0) {
- touch_wait_pressed();
- touch_read_x_y (&x, &y);
-
- print_identifier ();
- printf ("x=%d y=%d\n", x, y);
- return touch_write_clibration_values (CALIB_TL, x, y);
- }
- else if (strcmp (argv[2], "dr") == 0) {
- touch_wait_pressed();
- touch_read_x_y (&x, &y);
-
- print_identifier ();
- printf ("x=%d y=%d\n", x, y);
-
- return touch_write_clibration_values (CALIB_DR, x, y);
- }
- return 1; /* return error */
+ int x, y;
+
+ if (strcmp (argv[2], "tl") == 0) {
+#if CONFIG_TOUCH_WAIT_PRESSED
+ touch_wait_pressed();
+#else
+ {
+ int i;
+ for (i = 0; i < (TOUCH_TIMEOUT * 1000); i++) {
+ if (touch_check_pressed ()) {
+ break;
+ }
+ udelay (1000); /* pause 1 ms */
+ }
+ }
+ if (!touch_check_pressed()) {
+ print_identifier ();
+ printf ("error: touch not pressed\n");
+ return 1;
+ }
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
+ touch_read_x_y (&x, &y);
+
+ print_identifier ();
+ printf ("x=%d y=%d\n", x, y);
+ return touch_write_clibration_values (CALIB_TL, x, y);
+ }
+ else if (strcmp (argv[2], "dr") == 0) {
+#if CONFIG_TOUCH_WAIT_PRESSED
+ touch_wait_pressed();
+#else
+ {
+ int i;
+ for (i = 0; i < (TOUCH_TIMEOUT * 1000); i++) {
+ if (touch_check_pressed ()) {
+ break;
+ }
+ udelay (1000); /* pause 1 ms */
+ }
+ }
+ if (!touch_check_pressed()) {
+ print_identifier ();
+ printf ("error: touch not pressed\n");
+ return 1;
+ }
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
+ touch_read_x_y (&x, &y);
+
+ print_identifier ();
+ printf ("x=%d y=%d\n", x, y);
+
+ return touch_write_clibration_values (CALIB_DR, x, y);
+ }
+ return 1; /* not "tl", nor "dr", so return error */
}
+#ifdef CONFIG_TOUCH_WAIT_PRESSED
static void touch_wait_pressed (void)
{
- while (!(tsc2000_read(TSC2000_REG_ADC) & TC_PSM));
+ while (!(tsc2000_read(TSC2000_REG_ADC) & TC_PSM));
}
+#else
+static int touch_check_pressed (void)
+{
+ return (tsc2000_read(TSC2000_REG_ADC) & TC_PSM);
+}
+#endif /* CONFIG_TOUCH_WAIT_PRESSED */
static int touch_write_clibration_values (int calib_point, int x, int y)
{
#if (CONFIG_COMMANDS & CFG_CMD_I2C)
- tsc2000_reg_init ();
-
- if (calib_point == CALIB_TL) {
- if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
- (char *)&x, 2)) {
- printf ("could not write to eeprom\n");
- return 1;
- }
- udelay(11000);
- if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
- (char *)&y, 2)) {
- printf ("could not write to eeprom\n");
- return 1;
- }
- udelay(11000);
- return 0;
- }
- else if (calib_point == CALIB_DR) {
- if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
- (char *)&x, 2)) {
- printf ("could not write to eeprom\n");
- return 1;
- }
- udelay(11000);
- if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
- (char *)&y, 2)) {
- printf ("could not write to eeprom\n");
- return 1;
- }
- udelay(11000);
- return 0;
- }
- return 1;
+ int x_verify = 0;
+ int y_verify = 0;
+
+ tsc2000_reg_init ();
+
+ if (calib_point == CALIB_TL) {
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
+ (char *)&x, 2)) {
+ return 1;
+ }
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
+ (char *)&y, 2)) {
+ return 1;
+ }
+
+ /* verify written values */
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
+ (char *)&x_verify, 2)) {
+ return 1;
+ }
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
+ (char *)&y_verify, 2)) {
+ return 1;
+ }
+ if ((y != y_verify) || (x != x_verify)) {
+ print_identifier ();
+ printf ("error: verify error\n");
+ return 1;
+ }
+ return 0; /* no error */
+ }
+ else if (calib_point == CALIB_DR) {
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
+ (char *)&x, 2)) {
+ return 1;
+ }
+ if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
+ (char *)&y, 2)) {
+ return 1;
+ }
+
+ /* verify written values */
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
+ (char *)&x_verify, 2)) {
+ return 1;
+ }
+ if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
+ (char *)&y_verify, 2)) {
+ return 1;
+ }
+ if ((y != y_verify) || (x != x_verify)) {
+ print_identifier ();
+ printf ("error: verify error\n");
+ return 1;
+ }
+ return 0;
+ }
+ return 1;
#else
- printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
- "to EEPROM\n");
- return (1);
+ printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ "to EEPROM\n");
+ return (1);
#endif /* CFG_CMD_I2C */
}
static void touch_read_x_y (int *px, int *py)
{
- tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD0 | TC_AD1);
- adc_wait_conversion_done();
- *px = tsc2000_read(TSC2000_REG_X);
+ tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD0 | TC_AD1);
+ adc_wait_conversion_done();
+ *px = tsc2000_read(TSC2000_REG_X);
- tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD2);
- adc_wait_conversion_done();
- *py = tsc2000_read(TSC2000_REG_Y);
+ tsc2000_write(TSC2000_REG_ADC, DEFAULT_ADC | TC_AD2);
+ adc_wait_conversion_done();
+ *py = tsc2000_read(TSC2000_REG_Y);
}
int do_rs485 (char **argv)
{
- int timeout;
- char data[RS485_MAX_RECEIVE_BUF_LEN];
-
- if (strcmp (argv[2], "send") == 0) {
- return (rs485_send_line (argv[3]));
- }
- else if (strcmp (argv[2], "receive") == 0) {
- timeout = simple_strtoul(argv[3], NULL, 10);
- if (rs485_receive_chars (data, timeout) != 0) {
- print_identifier ();
- printf ("## nothing received\n");
- return (1);
- }
- else {
- print_identifier ();
- printf ("%s\n", data);
- return (0);
- }
- }
- printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
- return (1); /* unknown command, return error */
+ int timeout;
+ char data[RS485_MAX_RECEIVE_BUF_LEN];
+
+ if (strcmp (argv[2], "send") == 0) {
+ return (rs485_send_line (argv[3]));
+ }
+ else if (strcmp (argv[2], "receive") == 0) {
+ timeout = simple_strtoul(argv[3], NULL, 10);
+ if (rs485_receive_chars (data, timeout) != 0) {
+ print_identifier ();
+ printf ("## nothing received\n");
+ return (1);
+ }
+ else {
+ print_identifier ();
+ printf ("%s\n", data);
+ return (0);
+ }
+ }
+ printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
+ return (1); /* unknown command, return error */
}
static int rs485_send_line (const char *data)
{
- rs485_init ();
- trab_rs485_enable_tx ();
- rs485_puts (data);
- rs485_putc ('\n');
+ rs485_init ();
+ trab_rs485_enable_tx ();
+ rs485_puts (data);
+ rs485_putc ('\n');
- return (0);
+ return (0);
}
static int rs485_receive_chars (char *data, int timeout)
{
- int i;
- int receive_count = 0;
-
- rs485_init ();
- trab_rs485_enable_rx ();
-
- /* test every 1 ms for received characters to avoid a receive FIFO
- * overrun (@ 38.400 Baud) */
- for (i = 0; i < (timeout * 1000); i++) {
- while (rs485_tstc ()) {
- if (receive_count >= RS485_MAX_RECEIVE_BUF_LEN-1)
- break;
- *data++ = rs485_getc ();
- receive_count++;
- }
- udelay (1000); /* pause 1 ms */
- }
- *data = '\0'; /* terminate string */
-
- if (receive_count == 0)
- return (1);
- else
- return (0);
+ int i;
+ int receive_count = 0;
+
+ rs485_init ();
+ trab_rs485_enable_rx ();
+
+ /* test every 1 ms for received characters to avoid a receive FIFO
+ * overrun (@ 38.400 Baud) */
+ for (i = 0; i < (timeout * 1000); i++) {
+ while (rs485_tstc ()) {
+ if (receive_count >= RS485_MAX_RECEIVE_BUF_LEN-1)
+ break;
+ *data++ = rs485_getc ();
+ receive_count++;
+ }
+ udelay (1000); /* pause 1 ms */
+ }
+ *data = '\0'; /* terminate string */
+
+ if (receive_count == 0)
+ return (1);
+ else
+ return (0);
}
int do_serial_number (char **argv)
{
#if (CONFIG_COMMANDS & CFG_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)) {
- printf ("could not read from eeprom\n");
- return (1);
- }
- print_identifier ();
- printf ("%08d\n", serial_number);
- return (0);
- }
- 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)) {
- printf ("could not write to eeprom\n");
- return (1);
- }
- return (0);
- }
- printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
- return (1); /* unknown command, return error */
+ unsigned int serial_number;
+
+ if (strcmp (argv[2], "read") == 0) {
+ if (i2c_read (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
+ (char *)&serial_number, 4)) {
+ printf ("could not read from eeprom\n");
+ return (1);
+ }
+ print_identifier ();
+ printf ("%08d\n", serial_number);
+ return (0);
+ }
+ 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)) {
+ printf ("could not write to eeprom\n");
+ return (1);
+ }
+ return (0);
+ }
+ 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 "
- "to EEPROM\n");
- return (1);
+ printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ "to EEPROM\n");
+ return (1);
#endif /* CFG_CMD_I2C */
}
@@ -991,29 +1142,29 @@ int do_serial_number (char **argv)
int do_crc16 (void)
{
#if (CONFIG_COMMANDS & CFG_CMD_I2C)
- int crc;
- char buf[EEPROM_MAX_CRC_BUF];
-
- if (i2c_read (I2C_EEPROM_DEV_ADDR, 0, 1, buf, 60)) {
- printf ("could not read from eeprom\n");
- return (1);
- }
- crc = 0; /* start value of crc calculation */
- crc = updcrc (crc, buf, 60);
-
- print_identifier ();
- printf ("crc16=%#04x\n", crc);
-
- if (i2c_write (I2C_EEPROM_DEV_ADDR, CRC16, 1, (char *)&crc,
- sizeof (crc))) {
- printf ("could not read from eeprom\n");
- return (1);
- }
- return (0);
+ int crc;
+ char buf[EEPROM_MAX_CRC_BUF];
+
+ if (i2c_read (I2C_EEPROM_DEV_ADDR, 0, 1, buf, 60)) {
+ printf ("could not read from eeprom\n");
+ return (1);
+ }
+ crc = 0; /* start value of crc calculation */
+ crc = updcrc (crc, buf, 60);
+
+ print_identifier ();
+ printf ("crc16=%#04x\n", crc);
+
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, CRC16, 1, (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 "
- "to EEPROM\n");
- return (1);
+ printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ "to EEPROM\n");
+ return (1);
#endif /* CFG_CMD_I2C */
}
@@ -1080,14 +1231,183 @@ static unsigned short crctab[1<<B] = { /* as calculated by initcrctab() */
};
static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
- unsigned int icnt )
+ unsigned int icnt )
+{
+ register unsigned short crc = icrc;
+ register unsigned char *cp = icp;
+ register unsigned int cnt = icnt;
+
+ while (cnt--)
+ crc = (crc<<B) ^ crctab[(crc>>(W-B)) ^ *cp++];
+
+ return (crc);
+}
+
+
+int do_gain (char **argv)
+{
+ int range;
+
+ range = simple_strtoul (argv[2], NULL, 10);
+ if ((range < 1) || (range > 3))
+ {
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return 1;
+ }
+
+ tsc2000_set_range (range);
+ return (0);
+}
+
+
+int do_eeprom (char **argv)
+{
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+ if (strcmp (argv[2], "read") == 0) {
+ return (trab_eeprom_read (argv));
+ }
+
+ else if (strcmp (argv[2], "write") == 0) {
+ return (trab_eeprom_write (argv));
+ }
+
+ printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ return (1);
+#else
+ printf ("No I2C support enabled (CFG_CMD_I2C), could not write "
+ "to EEPROM\n");
+ return (1);
+#endif /* CFG_CMD_I2C */
+}
+
+#if (CONFIG_COMMANDS & CFG_CMD_I2C)
+static int trab_eeprom_read (char **argv)
{
- register unsigned short crc = icrc;
- register unsigned char *cp = icp;
- register unsigned int cnt = icnt;
+ int i;
+ int len;
+ unsigned int addr;
+ long int value = 0;
+ uchar *buffer;
+
+ buffer = (uchar *) &value;
+ addr = simple_strtoul (argv[3], NULL, 10);
+ addr &= 0xfff;
+ len = simple_strtoul (argv[4], NULL, 10);
+ if ((len < 1) || (len > 4)) {
+ printf ("%s: invalid parameter %s\n", __FUNCTION__,
+ argv[4]);
+ return (1);
+ }
+ for (i = 0; i < len; i++) {
+ if (i2c_read (I2C_EEPROM_DEV_ADDR, addr+i, 1, buffer+i, 1)) {
+ printf ("%s: could not read from i2c device %#x"
+ ", addr %d\n", __FUNCTION__,
+ I2C_EEPROM_DEV_ADDR, addr);
+ return (1);
+ }
+ }
+ print_identifier ();
+ if (strcmp (argv[5], "-") == 0) {
+ if (len == 1)
+ printf ("%d\n", (signed char) value);
+ else if (len == 2)
+ printf ("%d\n", (signed short int) value);
+ else
+ printf ("%ld\n", value);
+ }
+ else {
+ if (len == 1)
+ printf ("%d\n", (unsigned char) value);
+ else if (len == 2)
+ printf ("%d\n", (unsigned short int) value);
+ else
+ printf ("%ld\n", (unsigned long int) value);
+ }
+ return (0);
+}
+
+static int trab_eeprom_write (char **argv)
+{
+ int i;
+ int len;
+ unsigned int addr;
+ long int value = 0;
+ uchar *buffer;
+
+ buffer = (uchar *) &value;
+ addr = simple_strtoul (argv[3], NULL, 10);
+ addr &= 0xfff;
+ len = simple_strtoul (argv[4], NULL, 10);
+ if ((len < 1) || (len > 4)) {
+ printf ("%s: invalid parameter %s\n", __FUNCTION__,
+ argv[4]);
+ return (1);
+ }
+ value = simple_strtol (argv[5], NULL, 10);
+ debug ("value=%ld\n", value);
+ for (i = 0; i < len; i++) {
+ if (i2c_write (I2C_EEPROM_DEV_ADDR, addr+i, 1, buffer+i, 1)) {
+ printf ("%s: could not write to i2c device %d"
+ ", addr %d\n", __FUNCTION__,
+ I2C_EEPROM_DEV_ADDR, addr);
+ return (1);
+ }
+#if 0
+ printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
+ "%#x+%d=%p=%#x \n",I2C_EEPROM_DEV_ADDR_DEV_ADDR , addr,
+ i, addr+i, 1, buffer, i, buffer+i, *(buffer+i));
+#endif
+ udelay (30000); /* wait for EEPROM ready */
+ }
+ return (0);
+}
- while (cnt--)
- crc = (crc<<B) ^ crctab[(crc>>(W-B)) ^ *cp++];
+int i2c_write_multiple (uchar chip, uint addr, int alen,
+ uchar *buffer, int len)
+{
+ int i;
- return (crc);
+ if (alen != 1) {
+ printf ("%s: addr len other than 1 not supported\n",
+ __FUNCTION__);
+ return (1);
+ }
+
+ for (i = 0; i < len; i++) {
+ if (i2c_write (chip, addr+i, alen, buffer+i, 1)) {
+ printf ("%s: could not write to i2c device %d"
+ ", addr %d\n", __FUNCTION__, chip, addr);
+ return (1);
+ }
+#if 0
+ printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
+ "%#x+%d=%p=\"%.1s\"\n", chip, addr, i, addr+i,
+ alen, buffer, i, buffer+i, buffer+i);
+#endif
+
+ udelay (30000);
+ }
+ return (0);
}
+
+int i2c_read_multiple ( uchar chip, uint addr, int alen,
+ uchar *buffer, int len)
+{
+ int i;
+
+ if (alen != 1) {
+ printf ("%s: addr len other than 1 not supported\n",
+ __FUNCTION__);
+ return (1);
+ }
+
+ for (i = 0; i < len; i++) {
+ if (i2c_read (chip, addr+i, alen, buffer+i, 1)) {
+ printf ("%s: could not read from i2c device %#x"
+ ", addr %d\n", __FUNCTION__, chip, addr);
+ return (1);
+ }
+ }
+ return (0);
+}
+#endif /* CFG_CMD_I2C */
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 972ef33d03c..1f271332681 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -33,6 +33,11 @@
#if (CONFIG_COMMANDS & CFG_CMD_FAT)
+#ifdef CONFIG_AUTO_UPDATE
+/* the VFAT code has a bug which breaks auto update */
+#undef CONFIG_SUPPORT_VFAT
+#endif
+
/*
* Convert a string to lowercase.
*/
diff --git a/include/configs/trab.h b/include/configs/trab.h
index e6b43d6605f..86c3f83f099 100644
--- a/include/configs/trab.h
+++ b/include/configs/trab.h
@@ -182,7 +182,7 @@
#define CONFIG_IPADDR 192.168.3.68
#define CONFIG_HOSTNAME trab
#define CONFIG_SERVERIP 192.168.3.1
-#define CONFIG_BOOTCOMMAND "run flash_nfs"
+#define CONFIG_BOOTCOMMAND "burn_in"
#ifndef CONFIG_FLASH_8MB /* current config: 16 MB flash */
#ifdef CFG_HUSH_PARSER
@@ -331,9 +331,13 @@
#define CONFIG_MISC_INIT_R /* have misc_init_r() function */
/*-----------------------------------------------------------------------
- * burn-in test stuff
+ * burn-in test stuff.
+ *
+ * BURN_IN_CYCLE_DELAY defines the seconds to wait between each burn-in cycle
+ * Because the burn-in test itself causes also an delay of about 4 seconds,
+ * this time must be subtracted from the desired overall burn-in cycle time.
*/
-#define BURN_IN_CYCLE_DELAY 20 /* delay in sec between burn-in test cycles */
+#define BURN_IN_CYCLE_DELAY 296 /* seconds between burn-in cycles */
/*-----------------------------------------------------------------------
* Stack sizes