/*
 * (C) Copyright 2003
 * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#define	DEBUG

#include <common.h>
#include <exports.h>
#include <s3c2400.h>
#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

/* 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

/* CPLD-Register for controlling TRAB hardware functions */
#define CPLD_BUTTONS            ((volatile unsigned long *)0x04020000)
#define CPLD_FILL_LEVEL         ((volatile unsigned long *)0x04008000)
#define CPLD_ROTARY_SWITCH      ((volatile unsigned long *)0x04018000)
#define CPLD_RS485_RE           ((volatile unsigned long *)0x04028000)

/* timer configuration bits for buzzer and PWM */
#define START2		(1 << 12)
#define UPDATE2         (1 << 13)
#define INVERT2         (1 << 14)
#define RELOAD2         (1 << 15)
#define START3		(1 << 16)
#define UPDATE3         (1 << 17)
#define INVERT3         (1 << 18)
#define RELOAD3         (1 << 19)

#define PCLK		66000000
#define BUZZER_FREQ     1000    /* frequency in Hz */
#define PWM_FREQ        500


/* definitions of I2C EEPROM device address */
#define I2C_EEPROM_DEV_ADDR     0x54

/* definition for touch panel calibration points */
#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 address map */
#define SERIAL_NUMBER           8
#define TOUCH_X0                52
#define TOUCH_Y0                54
#define TOUCH_X1                56
#define TOUCH_Y1                58
#define CRC16                   60

/* EEPROM stuff */
#define EEPROM_MAX_CRC_BUF      64

/* RS485 stuff */
#define RS485_MAX_RECEIVE_BUF_LEN  100

/* Bit definitions for ADCCON */
#define ADC_ENABLE_START     0x1
#define ADC_READ_START       0x2
#define ADC_STDBM            0x4
#define ADC_INP_AIN0         (0x0 << 3)
#define ADC_INP_AIN1         (0x1 << 3)
#define ADC_INP_AIN2         (0x2 << 3)
#define ADC_INP_AIN3         (0x3 << 3)
#define ADC_INP_AIN4         (0x4 << 3)
#define ADC_INP_AIN5         (0x5 << 3)
#define ADC_INP_AIN6         (0x6 << 3)
#define ADC_INP_AIN7         (0x7 << 3)
#define ADC_PRSCEN           0x4000
#define ADC_ECFLG            0x8000

/* function test functions */
int do_dip (void);
int do_info (void);
int do_vcc5v (void);
int do_vcc12v (void);
int do_buttons (void);
int do_fill_level (void);
int do_rotary_switch (void);
int do_pressure (void);
int do_v_bat (void);
int do_vfd_id (void);
int do_buzzer (char **);
int do_led (char **);
int do_full_bridge (char **);
int do_dac (char **);
int do_motor_contact (void);
int do_motor (char **);
int do_pwm (char **);
int do_thermo (char **);
int do_touch (char **);
int do_rs485 (char **);
int do_serial_number (char **);
int do_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);

#if defined(CONFIG_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

/*
 * TRAB board specific commands. Especially commands for burn-in and function
 * test.
 */

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;
	}

	debug ("argc = %d\n", argc);

	for (i=0; i<=argc; ++i) {
		debug ("argv[%d] = \"%s\"\n", i, argv[i] ? argv[i] : "<NULL>");
	}

	adc_init ();

	switch (argc) {

	case 0:
	case 1:
		break;

	case 2:
		if (strcmp (argv[1], "info") == 0) {
			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], "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));
		}
		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;
}

int do_info (void)
{
	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;

	/***********************************************************
	 DIP switch connection (according to wa4-cpu.sp.301.pdf, page 3):
	   SW1 - AIN4
	   SW2 - AIN5
	   SW3 - AIN6
	   SW4 - AIN7

	   "On" DIP switch position short-circuits the voltage from
	   the input channel (i.e. '0' conversion result means "on").
	*************************************************************/

	for (i = 7; i > 3; i--) {

		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.
		 * (Vin_High/VRef)*adc_res = (1,8V/2,5V)*1023) = 736
		 * 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");

	return 0;
}


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);

	return 0;
}


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;
}

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;

	padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
	padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
	padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);

	while (j--) {
		if ((padc->ADCCON & ADC_ENABLE_START) == 0)
			break;
		udelay (1);
	}

	if (j == 0) {
		printf("%s: ADC timeout\n", __FUNCTION__);
		padc->ADCCON |= ADC_STDBM; /* select standby mode */
		return -1;
	}

	result = padc->ADCDAT & 0x3FF;

	padc->ADCCON |= ADC_STDBM; /* select standby mode */

	debug ("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
	       (padc->ADCCON >> 3) & 0x7, result);

	/*
	 * 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);
}


static void adc_init (void)
{
	S3C2400_ADC *padc;

	padc = S3C2400_GetBase_ADC();

	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;
}


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");
	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;

	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");
	return 0;
}


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);

	*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();

	/* try to red vfd board id from the value defined by pull-ups */

	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 */
	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");
	return 0;
}

int do_buzzer (char **argv)
{
	int counter;

	S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();

	/* set prescaler for timer 2, 3 and 4 */
	timers->TCFG0 &= ~0xFF00;
	timers->TCFG0 |=  0x0F00;

	/* set divider for timer 2 */
	timers->TCFG1 &= ~0xF00;
	timers->TCFG1 |=  0x300;

	/* set frequency */
	counter = (PCLK / BUZZER_FREQ) >> 9;
	timers->ch[2].TCNTB = counter;
	timers->ch[2].TCMPB = counter / 2;

	if (strcmp (argv[2], "on") == 0) {
		debug ("%s: frequency: %d\n", __FUNCTION__,
		       BUZZER_FREQ);

		/* configure pin GPD7 as TOUT2 */
		gpio->PDCON &= ~0xC000;
		gpio->PDCON |= 0x8000;

		/* 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);
	}

	printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
	return 1;
}


int do_led (char **argv)
{
	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();

	/* 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);

	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;
}


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;
}

/* val must be in [0, 4095] */
static inline unsigned long tsc2000_to_uv (u16 val)
{
	return ((250000 * val) / 4096) * 10;
}


int do_dac (char **argv)
{
	int brightness;

	/* 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 */
	tsc2000_write(TSC2000_REG_DAC, brightness & 0xff);

	return 0;
}


int do_v_bat (void)
{
	unsigned long ret, res;

	/* initialize SPI */
	spi_init ();

	tsc2000_write(TSC2000_REG_ADC, 0x1836);

	/* 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));
	return 0;
}


int do_pressure (void)
{
	/* initialize SPI */
	spi_init ();

	tsc2000_write(TSC2000_REG_ADC, 0x2436);

	/* now wait for data available */
	adc_wait_conversion_done();

	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 do_motor (char **argv)
{
	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();

	/* Configure I/O port */
	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;
}

static void print_identifier (void)
{
	printf ("## FKT: ");
}

int do_pwm (char **argv)
{
	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;
}


int do_thermo (char **argv)
{
	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) {
#ifdef 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) {
#ifdef 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));
}

#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 defined(CONFIG_CMD_I2C)
	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,
			       (unsigned char *)&x, 2)) {
			return 1;
		}
		if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
			       (unsigned char *)&y, 2)) {
			return 1;
		}

		/* verify written values */
		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
			      (unsigned char *)&x_verify, 2)) {
			return 1;
		}
		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y0, 1,
			       (unsigned 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,
			       (unsigned char *)&x, 2)) {
			return 1;
		  }
		if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
			       (unsigned char *)&y, 2)) {
			return 1;
		}

		/* verify written values */
		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X1, 1,
				       (unsigned char *)&x_verify, 2)) {
			return 1;
		}
		if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_Y1, 1,
			       (unsigned 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 (CONFIG_CMD_I2C), could not write "
		"to EEPROM\n");
	return (1);
#endif
}


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_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 */
}


static int rs485_send_line (const char *data)
{
	rs485_init ();
	trab_rs485_enable_tx ();
	rs485_puts (data);
	rs485_putc ('\n');

	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 do_serial_number (char **argv)
{
#if defined(CONFIG_CMD_I2C)
	unsigned int serial_number;

	if (strcmp (argv[2], "read") == 0) {
		if (i2c_read (I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
			      (unsigned 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,
			      (unsigned 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 (CONFIG_CMD_I2C), could not write "
		"to EEPROM\n");
	return (1);
#endif
}


int do_crc16 (void)
{
#if defined(CONFIG_CMD_I2C)
	int crc;
	unsigned char buf[EEPROM_MAX_CRC_BUF];

	if (i2c_read (I2C_EEPROM_DEV_ADDR, 0, 1, buf, 60)) {
		printf ("could not read from eeprom\n");
		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, (unsigned char *)&crc,
		       sizeof (crc))) {
		printf ("could not read from eeprom\n");
		return (1);
	}
	return (0);
#else
	printf ("No I2C support enabled (CONFIG_CMD_I2C), could not write "
		"to EEPROM\n");
	return (1);
#endif
}


/*
 * Calculate, intelligently, the CRC of a dataset incrementally given a
 * buffer full at a time.
 * Initialize crc to 0 for XMODEM, -1 for CCITT.
 *
 * Usage:
 *   newcrc = updcrc( oldcrc, bufadr, buflen )
 *        unsigned int oldcrc, buflen;
 *        char *bufadr;
 *
 * Compile with -DTEST to generate program that prints CRC of stdin to stdout.
 * Compile with -DMAKETAB to print values for crctab to stdout
 */

    /* the CRC polynomial. This is used by XMODEM (almost CCITT).
     * If you change P, you must change crctab[]'s initial value to what is
     * printed by initcrctab()
     */
#define   P    0x1021

    /* number of bits in CRC: don't change it. */
#define W 16

    /* this the number of bits per char: don't change it. */
#define B 8

static unsigned short crctab[1<<B] = { /* as calculated by initcrctab() */
    0x0000,  0x1021,  0x2042,  0x3063,  0x4084,  0x50a5,  0x60c6,  0x70e7,
    0x8108,  0x9129,  0xa14a,  0xb16b,  0xc18c,  0xd1ad,  0xe1ce,  0xf1ef,
    0x1231,  0x0210,  0x3273,  0x2252,  0x52b5,  0x4294,  0x72f7,  0x62d6,
    0x9339,  0x8318,  0xb37b,  0xa35a,  0xd3bd,  0xc39c,  0xf3ff,  0xe3de,
    0x2462,  0x3443,  0x0420,  0x1401,  0x64e6,  0x74c7,  0x44a4,  0x5485,
    0xa56a,  0xb54b,  0x8528,  0x9509,  0xe5ee,  0xf5cf,  0xc5ac,  0xd58d,
    0x3653,  0x2672,  0x1611,  0x0630,  0x76d7,  0x66f6,  0x5695,  0x46b4,
    0xb75b,  0xa77a,  0x9719,  0x8738,  0xf7df,  0xe7fe,  0xd79d,  0xc7bc,
    0x48c4,  0x58e5,  0x6886,  0x78a7,  0x0840,  0x1861,  0x2802,  0x3823,
    0xc9cc,  0xd9ed,  0xe98e,  0xf9af,  0x8948,  0x9969,  0xa90a,  0xb92b,
    0x5af5,  0x4ad4,  0x7ab7,  0x6a96,  0x1a71,  0x0a50,  0x3a33,  0x2a12,
    0xdbfd,  0xcbdc,  0xfbbf,  0xeb9e,  0x9b79,  0x8b58,  0xbb3b,  0xab1a,
    0x6ca6,  0x7c87,  0x4ce4,  0x5cc5,  0x2c22,  0x3c03,  0x0c60,  0x1c41,
    0xedae,  0xfd8f,  0xcdec,  0xddcd,  0xad2a,  0xbd0b,  0x8d68,  0x9d49,
    0x7e97,  0x6eb6,  0x5ed5,  0x4ef4,  0x3e13,  0x2e32,  0x1e51,  0x0e70,
    0xff9f,  0xefbe,  0xdfdd,  0xcffc,  0xbf1b,  0xaf3a,  0x9f59,  0x8f78,
    0x9188,  0x81a9,  0xb1ca,  0xa1eb,  0xd10c,  0xc12d,  0xf14e,  0xe16f,
    0x1080,  0x00a1,  0x30c2,  0x20e3,  0x5004,  0x4025,  0x7046,  0x6067,
    0x83b9,  0x9398,  0xa3fb,  0xb3da,  0xc33d,  0xd31c,  0xe37f,  0xf35e,
    0x02b1,  0x1290,  0x22f3,  0x32d2,  0x4235,  0x5214,  0x6277,  0x7256,
    0xb5ea,  0xa5cb,  0x95a8,  0x8589,  0xf56e,  0xe54f,  0xd52c,  0xc50d,
    0x34e2,  0x24c3,  0x14a0,  0x0481,  0x7466,  0x6447,  0x5424,  0x4405,
    0xa7db,  0xb7fa,  0x8799,  0x97b8,  0xe75f,  0xf77e,  0xc71d,  0xd73c,
    0x26d3,  0x36f2,  0x0691,  0x16b0,  0x6657,  0x7676,  0x4615,  0x5634,
    0xd94c,  0xc96d,  0xf90e,  0xe92f,  0x99c8,  0x89e9,  0xb98a,  0xa9ab,
    0x5844,  0x4865,  0x7806,  0x6827,  0x18c0,  0x08e1,  0x3882,  0x28a3,
    0xcb7d,  0xdb5c,  0xeb3f,  0xfb1e,  0x8bf9,  0x9bd8,  0xabbb,  0xbb9a,
    0x4a75,  0x5a54,  0x6a37,  0x7a16,  0x0af1,  0x1ad0,  0x2ab3,  0x3a92,
    0xfd2e,  0xed0f,  0xdd6c,  0xcd4d,  0xbdaa,  0xad8b,  0x9de8,  0x8dc9,
    0x7c26,  0x6c07,  0x5c64,  0x4c45,  0x3ca2,  0x2c83,  0x1ce0,  0x0cc1,
    0xef1f,  0xff3e,  0xcf5d,  0xdf7c,  0xaf9b,  0xbfba,  0x8fd9,  0x9ff8,
    0x6e17,  0x7e36,  0x4e55,  0x5e74,  0x2e93,  0x3eb2,  0x0ed1,  0x1ef0
    };

static unsigned short updcrc(unsigned short icrc, unsigned char *icp,
			     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 defined(CONFIG_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 (CONFIG_CMD_I2C), could not write "
		"to EEPROM\n");
	return (1);
#endif
}

#if defined(CONFIG_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
