mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-04-03 13:01:31 +00:00
* 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
This commit is contained in:
parent
4a5517094d
commit
a0ff7f2eda
7 changed files with 1356 additions and 1000 deletions
12
CHANGELOG
12
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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
@ -193,6 +195,12 @@ int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||
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 */
|
||||
|
@ -481,6 +489,7 @@ static int test_vcc5v (void)
|
|||
}
|
||||
|
||||
if ((vcc5v > VCC5V_MAX) || (vcc5v < VCC5V_MIN)) {
|
||||
printf ("%s: vcc5v[V/100]=%d\n", __FUNCTION__, vcc5v);
|
||||
return (1);
|
||||
} else {
|
||||
return (0);
|
||||
|
@ -633,6 +642,7 @@ int i2c_read_multiple ( uchar chip, uint addr, int alen,
|
|||
static int adc_read (unsigned int channel)
|
||||
{
|
||||
int j = 1000; /* timeout value for wait loop in us */
|
||||
int result;
|
||||
S3C2400_ADC *padc;
|
||||
|
||||
padc = S3C2400_GetBase_ADC();
|
||||
|
@ -640,15 +650,10 @@ static int adc_read (unsigned int channel)
|
|||
|
||||
adc_init ();
|
||||
|
||||
debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
|
||||
|
||||
padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
|
||||
padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
|
||||
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;
|
||||
|
@ -661,12 +666,20 @@ static int adc_read (unsigned int channel)
|
|||
return -1;
|
||||
}
|
||||
|
||||
result = padc->ADCDAT & 0x3FF;
|
||||
|
||||
padc->ADCCON |= ADC_STDBM; /* select standby mode */
|
||||
|
||||
debug ("%s: return %#x, adccon %#x\n", __FUNCTION__,
|
||||
padc->ADCDAT & 0x3FF, padc->ADCCON);
|
||||
debug ("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
|
||||
(padc->ADCCON >> 3) & 0x7, result);
|
||||
|
||||
return (padc->ADCDAT & 0x3FF);
|
||||
/*
|
||||
* 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 (result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -679,6 +692,14 @@ static void adc_init (void)
|
|||
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
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static void rs485_setbrg (void)
|
|||
|
||||
/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
|
||||
/* reg = (33000000 / (16 * gd->baudrate)) - 1; */
|
||||
reg = (33000000 / (16 * 38.400)) - 1;
|
||||
reg = (33000000 / (16 * 38400)) - 1;
|
||||
|
||||
/* FIFO enable, Tx/Rx FIFO clear */
|
||||
uart->UFCON = 0x07;
|
||||
|
|
|
@ -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,12 +126,21 @@ 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);
|
||||
|
@ -127,6 +148,14 @@ static int rs485_receive_chars (char *data, int timeout);
|
|||
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);
|
||||
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
|
||||
|
@ -191,15 +220,15 @@ int trab_fkt (int argc, char *argv[])
|
|||
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 ());
|
||||
}
|
||||
if (strcmp (argv[1], "power_switch") == 0) {
|
||||
return (do_power_switch ());
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
@ -224,6 +253,12 @@ int trab_fkt (int argc, char *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:
|
||||
|
@ -238,6 +273,18 @@ int trab_fkt (int argc, char *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;
|
||||
}
|
||||
|
@ -351,20 +398,16 @@ int do_vcc12v (void)
|
|||
static int adc_read (unsigned int channel)
|
||||
{
|
||||
int j = 1000; /* timeout value for wait loop in us */
|
||||
int result;
|
||||
S3C2400_ADC *padc;
|
||||
|
||||
padc = S3C2400_GetBase_ADC();
|
||||
channel &= 0x7;
|
||||
|
||||
debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
|
||||
|
||||
padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
|
||||
padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
|
||||
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;
|
||||
|
@ -377,12 +420,20 @@ static int adc_read (unsigned int channel)
|
|||
return -1;
|
||||
}
|
||||
|
||||
result = padc->ADCDAT & 0x3FF;
|
||||
|
||||
padc->ADCCON |= ADC_STDBM; /* select standby mode */
|
||||
|
||||
debug ("%s: return %#x, adccon %#x\n", __FUNCTION__, padc->ADCDAT & 0x3FF,
|
||||
padc->ADCCON);
|
||||
debug ("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
|
||||
(padc->ADCCON >> 3) & 0x7, result);
|
||||
|
||||
return (padc->ADCDAT & 0x3FF);
|
||||
/*
|
||||
* 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 (result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -392,12 +443,17 @@ static void adc_init (void)
|
|||
|
||||
padc = S3C2400_GetBase_ADC();
|
||||
|
||||
debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
|
||||
|
||||
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);
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -423,6 +479,24 @@ int do_buttons (void)
|
|||
}
|
||||
|
||||
|
||||
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;
|
||||
|
@ -443,6 +517,12 @@ int do_fill_level (void)
|
|||
int do_rotary_switch (void)
|
||||
{
|
||||
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);
|
||||
|
@ -498,17 +578,13 @@ int do_vfd_id (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int do_buzzer (void)
|
||||
int do_buzzer (char **argv)
|
||||
{
|
||||
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;
|
||||
|
||||
/* set prescaler for timer 2, 3 and 4 */
|
||||
timers->TCFG0 &= ~0xFF00;
|
||||
timers->TCFG0 |= 0x0F00;
|
||||
|
@ -522,23 +598,33 @@ int do_buzzer (void)
|
|||
timers->ch[2].TCNTB = counter;
|
||||
timers->ch[2].TCMPB = counter / 2;
|
||||
|
||||
debug ("%s: frequency: %d, duration: %d\n", __FUNCTION__, BUZZER_FREQ,
|
||||
BUZZER_TIME);
|
||||
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;
|
||||
|
||||
/* start */
|
||||
timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) & ~INVERT2;
|
||||
timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) &
|
||||
~INVERT2;
|
||||
timers->TCON = (timers->TCON | START2) & ~UPDATE2;
|
||||
|
||||
udelay (BUZZER_TIME);
|
||||
|
||||
return (0);
|
||||
}
|
||||
else if (strcmp (argv[2], "off") == 0) {
|
||||
/* stop */
|
||||
timers->TCON &= ~(START2 | RELOAD2);
|
||||
|
||||
/* port pin configuration */
|
||||
/* configure GPD7 as output and set to low */
|
||||
gpio->PDCON &= ~0xC000;
|
||||
gpio->PDCON |= 0x4000;
|
||||
gpio->PDDAT &= ~0x80;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -781,7 +867,6 @@ int do_thermo (char **argv)
|
|||
int channel, res;
|
||||
|
||||
tsc2000_reg_init ();
|
||||
tsc2000_set_range (3);
|
||||
|
||||
if (strcmp (argv[2], "all") == 0) {
|
||||
int i;
|
||||
|
@ -806,7 +891,24 @@ int do_touch (char **argv)
|
|||
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 ();
|
||||
|
@ -814,7 +916,24 @@ int do_touch (char **argv)
|
|||
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 ();
|
||||
|
@ -822,49 +941,81 @@ int do_touch (char **argv)
|
|||
|
||||
return touch_write_clibration_values (CALIB_DR, x, y);
|
||||
}
|
||||
return 1; /* return error */
|
||||
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));
|
||||
}
|
||||
|
||||
#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)
|
||||
int x_verify = 0;
|
||||
int y_verify = 0;
|
||||
|
||||
tsc2000_reg_init ();
|
||||
|
||||
if (calib_point == CALIB_TL) {
|
||||
if (i2c_write (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
|
||||
if (i2c_write_multiple (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,
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
|
||||
(char *)&y, 2)) {
|
||||
printf ("could not write to eeprom\n");
|
||||
return 1;
|
||||
}
|
||||
udelay(11000);
|
||||
return 0;
|
||||
|
||||
/* 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 (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
|
||||
if (i2c_write_multiple (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,
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
|
||||
(char *)&y, 2)) {
|
||||
printf ("could not write to eeprom\n");
|
||||
return 1;
|
||||
}
|
||||
udelay(11000);
|
||||
|
||||
/* 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;
|
||||
|
@ -1091,3 +1242,172 @@ static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
|
|||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
#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 */
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue