From: kevin.morfitt at fearnside-systems.co.uk <kevin.morfitt@fearnside-systems.co.uk>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH ARM 3/3] s3c24x0 code style changes
Date: Sun, 13 Dec 2009 20:05:19 +0000 [thread overview]
Message-ID: <4B2548FF.6040103@fearnside-systems.co.uk> (raw)
Cleans up the s3c24x0 header files by changing the upper case members
of the s3c24x0 register structures to lower case and changing all code
that uses these register structures.
Signed-off-by: Kevin Morfitt <kevin.morfitt@fearnside-systems.co.uk>
---
board/trab/trab.c | 83 +++--
board/trab/trab_fkt.c | 1055 ++++++++++++++++++++++++-------------------------
board/trab/tsc2000.c | 234 ++++++-----
board/trab/tsc2000.h | 90 ++---
board/trab/vfd.c | 550 +++++++++++++++-----------
5 files changed, 1038 insertions(+), 974 deletions(-)
diff --git a/board/trab/trab.c b/board/trab/trab.c
index 71fd22c..31f425f 100644
--- a/board/trab/trab.c
+++ b/board/trab/trab.c
@@ -27,6 +27,7 @@
#include <netdev.h>
#include <malloc.h>
#include <asm/arch/s3c24x0_cpu.h>
+#include <asm/io.h>
#include <command.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -77,36 +78,39 @@ int board_init ()
#ifdef CONFIG_TRAB_50MHZ
/* change the clock to be 50 MHz 1:1:1 */
/* MDIV:0x5c PDIV:4 SDIV:2 */
- clk_power->MPLLCON = 0x5c042;
- clk_power->CLKDIVN = 0;
+ writel(0x5c042, &clk_power->mpllcon);
+ writel(0, &clk_power->clkdivn);
#else
/* change the clock to be 133 MHz 1:2:4 */
/* MDIV:0x7d PDIV:4 SDIV:1 */
- clk_power->MPLLCON = 0x7d041;
- clk_power->CLKDIVN = 3;
+ writel(0x7d041, &clk_power->mpllcon);
+ writel(3, &clk_power->clkdivn);
#endif
/* set up the I/O ports */
- gpio->PACON = 0x3ffff;
- gpio->PBCON = 0xaaaaaaaa;
- gpio->PBUP = 0xffff;
+ writel(0x3ffff, &gpio->pacon);
+ writel(0xaaaaaaaa, &gpio->pbcon);
+ writel(0xffff, &gpio->pbup);
/* INPUT nCTS0 nRTS0 TXD[1] TXD[0] RXD[1] RXD[0] */
/* 00, 10, 10, 10, 10, 10, 10 */
- gpio->PFCON = (2<<0) | (2<<2) | (2<<4) | (2<<6) | (2<<8) | (2<<10);
+ writel((2<<0) | (2<<2) | (2<<4) | (2<<6) | (2<<8) | (2<<10),
+ &gpio->pfcon);
#ifdef CONFIG_HWFLOW
/* do not pull up RXD0, RXD1, TXD0, TXD1, CTS0, RTS0 */
- gpio->PFUP = (1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5);
+ writel((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5),
+ &gpio->pfup);
#else
/* do not pull up RXD0, RXD1, TXD0, TXD1 */
- gpio->PFUP = (1<<0) | (1<<1) | (1<<2) | (1<<3);
+ writel((1<<0) | (1<<1) | (1<<2) | (1<<3),
+ &gpio->pfup);
#endif
- gpio->PGCON = 0x0;
- gpio->PGUP = 0x0;
- gpio->OPENCR= 0x0;
+ writel(0x0, &gpio->pgcon);
+ writel(0x0, &gpio->pgup);
+ writel(0x0, &gpio->opencr);
/* suppress flicker of the VFDs */
- gpio->MISCCR = 0x40;
- gpio->PFCON |= (2<<12);
+ writel(0x40, &gpio->misccr);
+ writel(readl(&gpio->pfcon) | (2 << 12), &gpio->pfcon);
gd->bd->bi_arch_number = MACH_TYPE_TRAB;
@@ -114,8 +118,8 @@ int board_init ()
gd->bd->bi_boot_params = 0x0c000100;
/* Make sure both buzzers are turned off */
- gpio->PDCON |= 0x5400;
- gpio->PDDAT &= ~0xE0;
+ writel(readl(&gpio->pdcon) | 0x5400, &gpio->pdcon);
+ writel(readl(&gpio->pddat) & ~0xE0, &gpio->pddat);
#ifdef CONFIG_VFD
vfd_init_clocks();
@@ -132,7 +136,7 @@ int board_init ()
#ifdef CONFIG_DRIVER_S3C24X0_I2C
/* Configure I/O ports PG5 und PG6 for I2C */
- gpio->PGCON = (gpio->PGCON & 0x003c00) | 0x003c00;
+ writel((readl(&gpio->pgcon) & 0x003c00) | 0x003c00, &gpio->pgcon);
#endif /* CONFIG_DRIVER_S3C24X0_I2C */
return 0;
@@ -337,18 +341,18 @@ static int key_pressed(void)
#ifdef CONFIG_SYS_BRIGHTNESS
-static inline void SET_CS_TOUCH(void)
+static inline void set_cs_touch(void)
{
struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- gpio->PDDAT &= 0x5FF;
+ writel(readl(&gpio->pddat) & 0x5FF, &gpio->pddat);
}
-static inline void CLR_CS_TOUCH(void)
+static inline void clr_cs_touch(void)
{
struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- gpio->PDDAT |= 0x200;
+ writel(readl(&gpio->pddat) | 0x200, &gpio->pddat);
}
static void spi_init(void)
@@ -358,20 +362,23 @@ static void spi_init(void)
int i;
/* Configure I/O ports. */
- gpio->PDCON = (gpio->PDCON & 0xF3FFFF) | 0x040000;
- gpio->PGCON = (gpio->PGCON & 0x0F3FFF) | 0x008000;
- gpio->PGCON = (gpio->PGCON & 0x0CFFFF) | 0x020000;
- gpio->PGCON = (gpio->PGCON & 0x03FFFF) | 0x080000;
+ writel((readl(&gpio->pdcon) & 0xF3FFFF) | 0x040000, &gpio->pdcon);
+ writel((readl(&gpio->pgcon) & 0x0F3FFF) | 0x008000, &gpio->pgcon);
+ writel((readl(&gpio->pgcon) & 0x0CFFFF) | 0x020000, &gpio->pgcon);
+ writel((readl(&gpio->pgcon) & 0x03FFFF) | 0x080000, &gpio->pgcon);
- CLR_CS_TOUCH();
+ clr_cs_touch();
- spi->ch[0].SPPRE = 0x1F; /* Baudrate ca. 514kHz */
- spi->ch[0].SPPIN = 0x01; /* SPI-MOSI holds Level after last bit */
- spi->ch[0].SPCON = 0x1A; /* Polling, Prescaler, Master, CPOL=0, CPHA=1 */
+ /* Baudrate ca. 514kHz */
+ writel(0x1F, &spi->ch[0].sppre);
+ /* SPI-MOSI holds Level after last bit */
+ writel(0x01, &spi->ch[0].sppin);
+ /* Polling, Prescaler, Master, CPOL=0, CPHA=1 */
+ writel(0x1A, &spi->ch[0].spcon);
/* Dummy byte ensures clock to be low. */
for (i = 0; i < 10; i++) {
- spi->ch[0].SPTDAT = 0xFF;
+ writel(0xFF, &spi->ch[0].sptdat);
}
wait_transmit_done();
}
@@ -380,7 +387,7 @@ static void wait_transmit_done(void)
{
struct s3c24x0_spi * const spi = s3c24x0_get_base_spi();
- while (!(spi->ch[0].SPSTA & 0x01)); /* wait until transfer is done */
+ while (!(readl(&spi->ch[0].spsta) & 0x01)); /* wait until transfer is done */
}
static void tsc2000_write(unsigned int page, unsigned int reg,
@@ -389,21 +396,21 @@ static void tsc2000_write(unsigned int page, unsigned int reg,
struct s3c24x0_spi * const spi = s3c24x0_get_base_spi();
unsigned int command;
- SET_CS_TOUCH();
+ set_cs_touch();
command = 0x0000;
command |= (page << 11);
command |= (reg << 5);
- spi->ch[0].SPTDAT = (command & 0xFF00) >> 8;
+ writel((command & 0xFF00) >> 8, &spi->ch[0].sptdat);
wait_transmit_done();
- spi->ch[0].SPTDAT = (command & 0x00FF);
+ writel(command & 0x00FF, &spi->ch[0].sptdat);
wait_transmit_done();
- spi->ch[0].SPTDAT = (data & 0xFF00) >> 8;
+ writel((data & 0xFF00) >> 8, &spi->ch[0].sptdat);
wait_transmit_done();
- spi->ch[0].SPTDAT = (data & 0x00FF);
+ writel(data & 0x00FF, &spi->ch[0].sptdat);
wait_transmit_done();
- CLR_CS_TOUCH();
+ clr_cs_touch();
}
static void tsc2000_set_brightness(void)
diff --git a/board/trab/trab_fkt.c b/board/trab/trab_fkt.c
index 2df9a04..ddf8280 100644
--- a/board/trab/trab_fkt.c
+++ b/board/trab/trab_fkt.c
@@ -27,6 +27,7 @@
#include <exports.h>
#include <timestamp.h>
#include <asm/arch/s3c24x0_cpu.h>
+#include <asm/io.h>
#include "tsc2000.h"
#include "rs485.h"
@@ -64,16 +65,15 @@
#define RELOAD3 (1 << 19)
#define PCLK 66000000
-#define BUZZER_FREQ 1000 /* frequency in Hz */
+#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 */
+#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
@@ -105,57 +105,56 @@
#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 **);
+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);
+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);
+static void touch_wait_pressed(void);
#else
-static int touch_check_pressed (void);
+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 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);
+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
/*
@@ -163,26 +162,26 @@ int i2c_read_multiple ( uchar chip, uint addr, int alen, uchar *buffer,
* test.
*/
-int trab_fkt (int argc, char *argv[])
+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());
+ 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>");
+ for (i = 0; i <= argc; ++i) {
+ debug("argv[%d] = \"%s\"\n", i, argv[i] ? argv[i] : "<NULL>");
}
- adc_init ();
+ adc_init();
switch (argc) {
@@ -191,98 +190,98 @@ int trab_fkt (int argc, char *argv[])
break;
case 2:
- if (strcmp (argv[1], "info") == 0) {
- return (do_info ());
+ if (strcmp(argv[1], "info") == 0) {
+ return (do_info());
}
- if (strcmp (argv[1], "dip") == 0) {
- return (do_dip ());
+ if (strcmp(argv[1], "dip") == 0) {
+ return (do_dip());
}
- if (strcmp (argv[1], "vcc5v") == 0) {
- return (do_vcc5v ());
+ if (strcmp(argv[1], "vcc5v") == 0) {
+ return (do_vcc5v());
}
- if (strcmp (argv[1], "vcc12v") == 0) {
- return (do_vcc12v ());
+ if (strcmp(argv[1], "vcc12v") == 0) {
+ return (do_vcc12v());
}
- if (strcmp (argv[1], "buttons") == 0) {
- return (do_buttons ());
+ if (strcmp(argv[1], "buttons") == 0) {
+ return (do_buttons());
}
- if (strcmp (argv[1], "fill_level") == 0) {
- return (do_fill_level ());
+ 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], "rotary_switch") == 0) {
+ return (do_rotary_switch());
}
- if (strcmp (argv[1], "pressure") == 0) {
- return (do_pressure ());
+ if (strcmp(argv[1], "pressure") == 0) {
+ return (do_pressure());
}
- if (strcmp (argv[1], "v_bat") == 0) {
- return (do_v_bat ());
+ 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], "vfd_id") == 0) {
+ return (do_vfd_id());
}
- if (strcmp (argv[1], "motor_contact") == 0) {
- return (do_motor_contact ());
+ if (strcmp(argv[1], "motor_contact") == 0) {
+ return (do_motor_contact());
}
- if (strcmp (argv[1], "crc16") == 0) {
- return (do_crc16 ());
+ if (strcmp(argv[1], "crc16") == 0) {
+ return (do_crc16());
}
- if (strcmp (argv[1], "power_switch") == 0) {
- return (do_power_switch ());
+ 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], "full_bridge") == 0) {
+ return (do_full_bridge(argv));
}
- if (strcmp (argv[1], "dac") == 0) {
- return (do_dac (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], "motor") == 0) {
+ return (do_motor(argv));
}
- if (strcmp (argv[1], "pwm") == 0) {
- return (do_pwm (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], "thermo") == 0) {
+ return (do_thermo(argv));
}
- if (strcmp (argv[1], "touch") == 0) {
- return (do_touch (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], "serial_number") == 0) {
+ return (do_serial_number(argv));
}
- if (strcmp (argv[1], "buzzer") == 0) {
- return (do_buzzer (argv));
+ if (strcmp(argv[1], "buzzer") == 0) {
+ return (do_buzzer(argv));
}
- if (strcmp (argv[1], "gain") == 0) {
- return (do_gain (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], "led") == 0) {
+ return (do_led(argv));
}
- if (strcmp (argv[1], "rs485") == 0) {
- return (do_rs485 (argv));
+ if (strcmp(argv[1], "rs485") == 0) {
+ return (do_rs485(argv));
}
- if (strcmp (argv[1], "serial_number") == 0) {
- return (do_serial_number (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));
+ if (strcmp(argv[1], "eeprom") == 0) {
+ return (do_eeprom(argv));
}
break;
case 6:
- if (strcmp (argv[1], "eeprom") == 0) {
- return (do_eeprom (argv));
+ if (strcmp(argv[1], "eeprom") == 0) {
+ return (do_eeprom(argv));
}
break;
@@ -290,25 +289,25 @@ int trab_fkt (int argc, char *argv[])
break;
}
- printf ("Usage:\n<command> <parameter1> <parameter2> ...\n");
+ printf("Usage:\n<command> <parameter1> <parameter2> ...\n");
return 1;
}
-void hang (void)
+void hang(void)
{
- puts ("### ERROR ### Please RESET the board ###\n");
- for (;;);
+ puts("### ERROR ### Please RESET the board ###\n");
+ for (;;) ;
}
-int do_info (void)
+int do_info(void)
{
- printf ("Stand-alone application for TRAB board function test\n");
- printf ("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
+ printf("Stand-alone application for TRAB board function test\n");
+ printf("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
return 0;
}
-int do_dip (void)
+int do_dip(void)
{
unsigned int result = 0;
int adc_val;
@@ -327,8 +326,8 @@ 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);
+ if ((adc_val = adc_read(i)) == -1) {
+ printf("Channel %d could not be read\n", i);
return 1;
}
@@ -338,11 +337,11 @@ int do_dip (void)
* Set trigger at halve that value.
*/
if (adc_val < 368)
- result |= (1 << (i-4));
+ result |= (1 << (i - 4));
}
/* print result to console */
- print_identifier ();
+ print_identifier();
for (i = 0; i < 4; i++) {
if ((result & (1 << i)) == 0)
printf("0");
@@ -354,15 +353,14 @@ int do_dip (void)
return 0;
}
-
-int do_vcc5v (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");
+ if ((result = adc_read(VCC5V)) == -1) {
+ printf("VCC5V could not be read\n");
return 1;
}
@@ -371,22 +369,21 @@ int do_vcc5v (void)
* 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);
+ 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 do_vcc12v(void)
{
int result;
- if ((result = adc_read (VCC12V)) == -1) {
- printf ("VCC12V could not be read\n");
+ if ((result = adc_read(VCC12V)) == -1) {
+ printf("VCC12V could not be read\n");
return 1;
}
@@ -395,63 +392,69 @@ int do_vcc12v (void)
* 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);
+ 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)
+static int adc_read(unsigned int channel)
{
- int j = 1000; /* timeout value for wait loop in us */
+ int j = 1000; /* timeout value for wait loop in us */
int result;
struct s3c2400_adc *padc;
padc = s3c2400_get_base_adc();
channel &= 0x7;
- padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
- padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
- padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
+ /* select normal mode */
+ writel(readl(&padc->adccon) & ~ADC_STDBM, &padc->adccon);
+ /* clear the channel bits */
+ writel(readl(&padc->adccon) & ~(0x7 << 3), &padc->adccon);
+ writel(readl(&padc->adccon) | ((channel << 3) | ADC_ENABLE_START),
+ &padc->adccon);
while (j--) {
- if ((padc->ADCCON & ADC_ENABLE_START) == 0)
+ if ((readl(&padc->adccon) & ADC_ENABLE_START) == 0)
break;
- udelay (1);
+ udelay(1);
}
if (j == 0) {
printf("%s: ADC timeout\n", __FUNCTION__);
- padc->ADCCON |= ADC_STDBM; /* select standby mode */
+ /* select standby mode */
+ writel(readl(&padc->adccon) | ADC_STDBM, &padc->adccon);
return -1;
}
- result = padc->ADCDAT & 0x3FF;
+ result = readl(&padc->adcdat) & 0x3FF;
- padc->ADCCON |= ADC_STDBM; /* select standby mode */
+ /* select standby mode */
+ writel(readl(&padc->adccon) | ADC_STDBM, &padc->adccon);
- debug ("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
- (padc->ADCCON >> 3) & 0x7, result);
+ debug("%s: channel %d, result[DIGIT]=%d\n", __FUNCTION__,
+ (readl(&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);
+ udelay(1000);
return (result);
}
-
-static void adc_init (void)
+static void adc_init(void)
{
struct s3c2400_adc *padc;
padc = s3c2400_get_base_adc();
- padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
- padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
+ /* clear prescaler bits */
+ writel(readl(&padc->adccon) & ~(0xff << 6), &padc->adccon);
+ /* set prescaler */
+ writel(readl(&padc->adccon) | ((65 << 6) | ADC_PRSCEN), &padc->adccon);
/*
* Wait some time to avoid problem with very first call of
@@ -459,22 +462,21 @@ static void adc_init (void)
* value is 0. Perhaps because the * adjustment of prescaler takes
* some clock cycles?
*/
- udelay (1000);
+ udelay(1000);
return;
}
-
-int do_buttons (void)
+int do_buttons(void)
{
int result;
int i;
- result = *CPLD_BUTTONS; /* read CPLD */
- debug ("%s: cpld_taster (32 bit) %#x\n", __FUNCTION__, result);
+ result = *CPLD_BUTTONS; /* read CPLD */
+ debug("%s: cpld_taster (32 bit) %#x\n", __FUNCTION__, result);
/* print result to console */
- print_identifier ();
+ print_identifier();
for (i = 16; i <= 19; i++) {
if ((result & (1 << i)) == 0)
printf("0");
@@ -485,34 +487,32 @@ int do_buttons (void)
return 0;
}
-
-int do_power_switch (void)
+int do_power_switch(void)
{
int result;
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
/* configure GPE7 as input */
- gpio->PECON &= ~(0x3 << (2 * 7));
+ writel(readl(&gpio->pecon) & ~(0x3 << (2 * 7)), &gpio->pecon);
/* signal GPE7 from power switch is low active: 0=on , 1=off */
- result = ((gpio->PEDAT & (1 << 7)) == (1 << 7)) ? 0 : 1;
+ result = ((readl(&gpio->pedat) & (1 << 7)) == (1 << 7)) ? 0 : 1;
- print_identifier ();
+ print_identifier();
printf("%d\n", result);
return 0;
}
-
-int do_fill_level (void)
+int do_fill_level(void)
{
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 ();
+ print_identifier();
if ((result & (1 << 16)) == 0)
printf("0\n");
else
@@ -520,8 +520,7 @@ int do_fill_level (void)
return 0;
}
-
-int do_rotary_switch (void)
+int do_rotary_switch(void)
{
int result;
/*
@@ -531,13 +530,13 @@ int do_rotary_switch (void)
* proper values.
*/
- result = *CPLD_ROTARY_SWITCH; /* read CPLD */
- debug ("%s: cpld_inc (32 bit) %#x\n", __FUNCTION__, 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 */
+ *CPLD_ROTARY_SWITCH |= (3 << 16); /* clear direction bits in CPLD */
/* print result to console */
- print_identifier ();
+ print_identifier();
if ((result & (1 << 16)) == (1 << 16))
printf("R");
if ((result & (1 << 17)) == (1 << 17))
@@ -551,30 +550,29 @@ int do_rotary_switch (void)
return 0;
}
-
-int do_vfd_id (void)
+int do_vfd_id(void)
{
int i;
long int pcup_old, pccon_old;
int vfd_board_id;
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
/* try to red vfd board id from the value defined by pull-ups */
- pcup_old = gpio->PCUP;
- pccon_old = gpio->PCCON;
+ pcup_old = gpio->pcup;
+ pccon_old = gpio->pccon;
- gpio->PCUP = (gpio->PCUP & 0xFFF0); /* activate GPC0...GPC3 pull-ups */
- gpio->PCCON = (gpio->PCCON & 0xFFFFFF00); /* configure GPC0...GPC3 as
- * inputs */
- udelay (10); /* allow signals to settle */
- vfd_board_id = (~gpio->PCDAT) & 0x000F; /* read GPC0...GPC3 port pins */
+ 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;
+ gpio->pccon = pccon_old;
+ gpio->pcup = pcup_old;
/* print vfd_board_id to console */
- print_identifier ();
+ print_identifier();
for (i = 0; i < 4; i++) {
if ((vfd_board_id & (1 << i)) == 0)
printf("0");
@@ -585,67 +583,66 @@ int do_vfd_id (void)
return 0;
}
-int do_buzzer (char **argv)
+int do_buzzer(char **argv)
{
int counter;
- struct s3c24x0_timers * const timers = s3c24x0_get_base_timers();
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_timers *const timers = s3c24x0_get_base_timers();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
/* set prescaler for timer 2, 3 and 4 */
- timers->TCFG0 &= ~0xFF00;
- timers->TCFG0 |= 0x0F00;
+ writel(readl(&timers->tcfg0) & ~0xFF00, &timers->tcfg0);
+ writel(readl(&timers->tcfg0) | 0x0F00, &timers->tcfg0);
/* set divider for timer 2 */
- timers->TCFG1 &= ~0xF00;
- timers->TCFG1 |= 0x300;
+ writel(readl(&timers->tcfg1) & ~0xF00, &timers->tcfg1);
+ writel(readl(&timers->tcfg1) | 0x300, &timers->tcfg1);
/* set frequency */
counter = (PCLK / BUZZER_FREQ) >> 9;
- timers->ch[2].TCNTB = counter;
- timers->ch[2].TCMPB = counter / 2;
+ writel(counter, &timers->ch[2].tcntb);
+ writel(counter / 2, &timers->ch[2].tcmpb);
- if (strcmp (argv[2], "on") == 0) {
- debug ("%s: frequency: %d\n", __FUNCTION__,
- BUZZER_FREQ);
+ 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;
+ writel(readl(&gpio->pdcon) & ~0xC000, &gpio->pdcon);
+ writel(readl(&gpio->pdcon) | 0x8000, &gpio->pdcon);
/* start */
- timers->TCON = (timers->TCON | UPDATE2 | RELOAD2) &
- ~INVERT2;
- timers->TCON = (timers->TCON | START2) & ~UPDATE2;
+ writel((readl(&timers->tcon) | UPDATE2 | RELOAD2) & ~INVERT2,
+ &timers->tcon);
+ writel((readl(&timers->tcon) | START2) & ~UPDATE2,
+ &timers->tcon);
return (0);
- }
- else if (strcmp (argv[2], "off") == 0) {
+ } else if (strcmp(argv[2], "off") == 0) {
/* stop */
- timers->TCON &= ~(START2 | RELOAD2);
+ writel(readl(&timers->tcon) & ~(START2 | RELOAD2),
+ &timers->tcon);
/* configure GPD7 as output and set to low */
- gpio->PDCON &= ~0xC000;
- gpio->PDCON |= 0x4000;
- gpio->PDDAT &= ~0x80;
+ writel(readl(&gpio->pdcon) & ~0xC000, &gpio->pdcon);
+ writel(readl(&gpio->pdcon) | 0x4000, &gpio->pdcon);
+ writel(readl(&gpio->pddat) & ~0x80, &gpio->pddat);
return (0);
}
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ printf("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
return 1;
}
-
-int do_led (char **argv)
+int do_led(char **argv)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
/* configure PC14 and PC15 as output */
- gpio->PCCON &= ~(0xF << 28);
- gpio->PCCON |= (0x5 << 28);
+ writel(readl(&gpio->pccon) & ~(0xF << 28), &gpio->pccon);
+ writel(readl(&gpio->pccon) | (0x5 << 28), &gpio->pccon);
/* configure PD0 and PD4 as output */
- gpio->PDCON &= ~((0x3 << 8) | 0x3);
- gpio->PDCON |= ((0x1 << 8) | 0x1);
+ writel(readl(&gpio->pccon) & ~((0x3 << 8) | 0x3), &gpio->pdcon);
+ writel(readl(&gpio->pccon) | ((0x1 << 8) | 0x1), &gpio->pdcon);
switch (simple_strtoul(argv[2], NULL, 10)) {
@@ -654,101 +651,98 @@ int do_led (char **argv)
break;
case 2:
- if (strcmp (argv[3], "on") == 0)
- gpio->PCDAT |= (1 << 14);
+ if (strcmp(argv[3], "on") == 0)
+ writel(readl(&gpio->pcdat) | (1 << 14), &gpio->pcdat);
else
- gpio->PCDAT &= ~(1 << 14);
+ writel(readl(&gpio->pcdat) & ~(1 << 14), &gpio->pcdat);
return 0;
case 3:
- if (strcmp (argv[3], "on") == 0)
- gpio->PCDAT |= (1 << 15);
+ if (strcmp(argv[3], "on") == 0)
+ writel(readl(&gpio->pcdat) | (1 << 15), &gpio->pcdat);
else
- gpio->PCDAT &= ~(1 << 15);
+ writel(readl(&gpio->pcdat) & ~(1 << 15), &gpio->pcdat);
return 0;
case 4:
- if (strcmp (argv[3], "on") == 0)
- gpio->PDDAT |= (1 << 0);
+ if (strcmp(argv[3], "on") == 0)
+ writel(readl(&gpio->pddat) | (1 << 0), &gpio->pddat);
else
- gpio->PDDAT &= ~(1 << 0);
+ writel(readl(&gpio->pddat) & ~(1 << 0), &gpio->pddat);
return 0;
case 5:
- if (strcmp (argv[3], "on") == 0)
- gpio->PDDAT |= (1 << 4);
+ if (strcmp(argv[3], "on") == 0)
+ writel(readl(&gpio->pddat) | (1 << 4), &gpio->pddat);
else
- gpio->PDDAT &= ~(1 << 4);
+ writel(readl(&gpio->pddat) & ~(1 << 4), &gpio->pddat);
return 0;
default:
break;
}
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ printf("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
return 1;
}
-
-int do_full_bridge (char **argv)
+int do_full_bridge(char **argv)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
/* configure PD5 and PD6 as output */
- gpio->PDCON &= ~((0x3 << 5*2) | (0x3 << 6*2));
- gpio->PDCON |= ((0x1 << 5*2) | (0x1 << 6*2));
-
- 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);
+ writel(readl(&gpio->pdcon) & ~((0x3 << 5 * 2) | (0x3 << 6 * 2)),
+ &gpio->pdcon);
+ writel(readl(&gpio->pdcon) | ((0x1 << 5 * 2) | (0x1 << 6 * 2)),
+ &gpio->pdcon);
+
+ if (strcmp(argv[2], "+") == 0) {
+ writel(readl(&gpio->pddat) | (1 << 5), &gpio->pddat);
+ writel(readl(&gpio->pddat) | (1 << 6), &gpio->pddat);
return 0;
- }
- else if (strcmp (argv[2], "off") == 0) {
- gpio->PDDAT &= ~(1 << 5);
- gpio->PDDAT &= ~(1 << 6);
+ } else if (strcmp(argv[2], "-") == 0) {
+ writel(readl(&gpio->pddat) & ~(1 << 5), &gpio->pddat);
+ writel(readl(&gpio->pddat) | (1 << 6), &gpio->pddat);
+ return 0;
+ } else if (strcmp(argv[2], "off") == 0) {
+ writel(readl(&gpio->pddat) & ~(1 << 5), &gpio->pddat);
+ writel(readl(&gpio->pddat) & ~(1 << 6), &gpio->pddat);
return 0;
}
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ 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)
+static inline unsigned long tsc2000_to_uv(u16 val)
{
return ((250000 * val) / 4096) * 10;
}
-
-int do_dac (char **argv)
+int do_dac(char **argv)
{
int brightness;
/* initialize SPI */
- tsc2000_spi_init ();
+ tsc2000_spi_init();
- if (((brightness = simple_strtoul (argv[2], NULL, 10)) < 0) ||
- (brightness > 255)) {
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ 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_DACCTL, 0x0); /* Power up DAC */
tsc2000_write(TSC2000_REG_DAC, brightness & 0xff);
return 0;
}
-
-int do_v_bat (void)
+int do_v_bat(void)
{
unsigned long ret, res;
/* initialize SPI */
- spi_init ();
+ spi_init();
tsc2000_write(TSC2000_REG_ADC, 0x1836);
@@ -759,39 +753,37 @@ int do_v_bat (void)
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)
+int do_pressure(void)
{
/* initialize SPI */
- spi_init ();
+ 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));
+ print_identifier();
+ printf("%d\n", tsc2000_read(TSC2000_REG_AUX2));
return 0;
}
-
-int do_motor_contact (void)
+int do_motor_contact(void)
{
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 ();
+ print_identifier();
if ((result & (1 << 17)) == 0)
printf("0\n");
else
@@ -799,241 +791,235 @@ int do_motor_contact (void)
return 0;
}
-int do_motor (char **argv)
+int do_motor(char **argv)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
/* Configure I/O port */
- gpio->PGCON &= ~(0x3 << 0);
- gpio->PGCON |= (0x1 << 0);
+ writel(readl(&gpio->pgcon) & ~(0x3 << 0), &gpio->pgcon);
+ writel(readl(&gpio->pgcon) | (0x1 << 0), &gpio->pgcon);
- if (strcmp (argv[2], "on") == 0) {
- gpio->PGDAT &= ~(1 << 0);
+ if (strcmp(argv[2], "on") == 0) {
+ writel(readl(&gpio->pgdat) & ~(1 << 0), &gpio->pgdat);
return 0;
}
- if (strcmp (argv[2], "off") == 0) {
- gpio->PGDAT |= (1 << 0);
+ if (strcmp(argv[2], "off") == 0) {
+ writel(readl(&gpio->pgdat) | (1 << 0), &gpio->pgdat);
return 0;
}
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ printf("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
return 1;
}
-static void print_identifier (void)
+static void print_identifier(void)
{
- printf ("## FKT: ");
+ printf("## FKT: ");
}
-int do_pwm (char **argv)
+int do_pwm(char **argv)
{
int counter;
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- struct s3c24x0_timers * const timers = s3c24x0_get_base_timers();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_timers *const timers = s3c24x0_get_base_timers();
- if (strcmp (argv[2], "on") == 0) {
+ if (strcmp(argv[2], "on") == 0) {
/* configure pin GPD8 as TOUT3 */
- gpio->PDCON &= ~(0x3 << 8*2);
- gpio->PDCON |= (0x2 << 8*2);
+ writel(readl(&gpio->pdcon) & ~(0x3 << 8 * 2), &gpio->pdcon);
+ writel(readl(&gpio->pdcon) | (0x2 << 8 * 2), &gpio->pdcon);
/* set prescaler for timer 2, 3 and 4 */
- timers->TCFG0 &= ~0xFF00;
- timers->TCFG0 |= 0x0F00;
+ writel(readl(&timers->tcfg0) & ~0xFF00, &timers->tcfg0);
+ writel(readl(&timers->tcfg0) | 0x0F00, &timers->tcfg0);
/* set divider for timer 3 */
- timers->TCFG1 &= ~(0xf << 12);
- timers->TCFG1 |= (0x3 << 12);
+ writel(readl(&timers->tcfg1) & ~(0xf << 12), &timers->tcfg1);
+ writel(readl(&timers->tcfg1) | (0x3 << 12), &timers->tcfg1);
/* set frequency */
counter = (PCLK / PWM_FREQ) >> 9;
- timers->ch[3].TCNTB = counter;
- timers->ch[3].TCMPB = counter / 2;
+ writel(counter, &timers->ch[3].tcntb);
+ writel(counter / 2, &timers->ch[3].tcmpb);
/* start timer */
- timers->TCON = (timers->TCON | UPDATE3 | RELOAD3) & ~INVERT3;
- timers->TCON = (timers->TCON | START3) & ~UPDATE3;
+ writel((readl(&timers->tcon) | UPDATE3 | RELOAD3) & ~INVERT3, &timers->tcon);
+ writel((readl(&timers->tcon) | START3) & ~UPDATE3, &timers->tcon);
return 0;
}
- if (strcmp (argv[2], "off") == 0) {
+ if (strcmp(argv[2], "off") == 0) {
/* stop timer */
- timers->TCON &= ~(START2 | RELOAD2);
+ writel(readl(&timers->tcon) & ~(START2 | RELOAD2), &timers->tcon);
/* configure pin GPD8 as output and set to 0 */
- gpio->PDCON &= ~(0x3 << 8*2);
- gpio->PDCON |= (0x1 << 8*2);
- gpio->PDDAT &= ~(1 << 8);
+ writel(readl(&gpio->pdcon) & ~(0x3 << 8 * 2), &gpio->pdcon);
+ writel(readl(&gpio->pdcon) | (0x1 << 8 * 2), &gpio->pdcon);
+ writel(readl(&gpio->pddat) & ~(1 << 8), &gpio->pddat);
return 0;
}
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ printf("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
return 1;
}
-
-int do_thermo (char **argv)
+int do_thermo(char **argv)
{
- int channel, res;
+ int channel, res;
- tsc2000_reg_init ();
+ tsc2000_reg_init();
- if (strcmp (argv[2], "all") == 0) {
+ if (strcmp(argv[2], "all") == 0) {
int i;
- for (i=0; i <= 15; i++) {
+ for (i = 0; i <= 15; i++) {
res = tsc2000_read_channel(i);
- print_identifier ();
- printf ("c%d: %d\n", i, res);
+ print_identifier();
+ printf("c%d: %d\n", i, res);
}
return 0;
}
- channel = simple_strtoul (argv[2], NULL, 10);
+ channel = simple_strtoul(argv[2], NULL, 10);
res = tsc2000_read_channel(channel);
- print_identifier ();
- printf ("%d\n", res);
- return 0; /* return OK */
+ print_identifier();
+ printf("%d\n", res);
+ return 0; /* return OK */
}
-
-int do_touch (char **argv)
+int do_touch(char **argv)
{
- int x, y;
+ int x, y;
- if (strcmp (argv[2], "tl") == 0) {
+ 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 ()) {
+ if (touch_check_pressed()) {
break;
}
- udelay (1000); /* pause 1 ms */
+ udelay(1000); /* pause 1 ms */
}
}
if (!touch_check_pressed()) {
- print_identifier ();
- printf ("error: touch not pressed\n");
+ print_identifier();
+ printf("error: touch not pressed\n");
return 1;
}
#endif /* CONFIG_TOUCH_WAIT_PRESSED */
- touch_read_x_y (&x, &y);
+ 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) {
+ 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 ()) {
+ if (touch_check_pressed()) {
break;
}
- udelay (1000); /* pause 1 ms */
+ udelay(1000); /* pause 1 ms */
}
}
if (!touch_check_pressed()) {
- print_identifier ();
- printf ("error: touch not pressed\n");
+ print_identifier();
+ printf("error: touch not pressed\n");
return 1;
}
#endif /* CONFIG_TOUCH_WAIT_PRESSED */
- touch_read_x_y (&x, &y);
+ touch_read_x_y(&x, &y);
- print_identifier ();
- printf ("x=%d y=%d\n", x, y);
+ print_identifier();
+ printf("x=%d y=%d\n", x, y);
- return touch_write_clibration_values (CALIB_DR, x, y);
+ return touch_write_clibration_values(CALIB_DR, x, y);
}
- return 1; /* not "tl", nor "dr", so return error */
+ return 1; /* not "tl", nor "dr", so return error */
}
-
#ifdef CONFIG_TOUCH_WAIT_PRESSED
-static void touch_wait_pressed (void)
+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)
+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)
+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 ();
+ tsc2000_reg_init();
if (calib_point == CALIB_TL) {
- if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, TOUCH_X0, 1,
- (unsigned char *)&x, 2)) {
+ 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)) {
+ 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)) {
+ 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)) {
+ 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");
+ 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 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)) {
+ }
+ 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)) {
+ 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)) {
+ 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");
+ 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");
+ 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)
+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();
@@ -1044,64 +1030,59 @@ static void touch_read_x_y (int *px, int *py)
*py = tsc2000_read(TSC2000_REG_Y);
}
-
-int do_rs485 (char **argv)
+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) {
+ 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");
+ if (rs485_receive_chars(data, timeout) != 0) {
+ print_identifier();
+ printf("## nothing received\n");
return (1);
- }
- else {
- print_identifier ();
- printf ("%s\n", data);
+ } else {
+ print_identifier();
+ printf("%s\n", data);
return (0);
}
}
- printf ("%s: unknown command %s\n", __FUNCTION__, argv[2]);
- return (1); /* unknown command, return error */
+ printf("%s: unknown command %s\n", __FUNCTION__, argv[2]);
+ return (1); /* unknown command, return error */
}
-
-static int rs485_send_line (const char *data)
+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);
}
-
-static int rs485_receive_chars (char *data, int timeout)
+static int rs485_receive_chars(char *data, int timeout)
{
int i;
int receive_count = 0;
- rs485_init ();
- trab_rs485_enable_rx ();
+ 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)
+ while (rs485_tstc()) {
+ if (receive_count >= RS485_MAX_RECEIVE_BUF_LEN - 1)
break;
- *data++ = rs485_getc ();
+ *data++ = rs485_getc();
receive_count++;
}
- udelay (1000); /* pause 1 ms */
+ udelay(1000); /* pause 1 ms */
}
- *data = '\0'; /* terminate string */
+ *data = '\0'; /* terminate string */
if (receive_count == 0)
return (1);
@@ -1109,71 +1090,67 @@ static int rs485_receive_chars (char *data, int timeout)
return (0);
}
-
-int do_serial_number (char **argv)
+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");
+ 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);
+ print_identifier();
+ printf("%08d\n", serial_number);
return (0);
- }
- else if (strcmp (argv[2], "write") == 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,
+ if (i2c_write(I2C_EEPROM_DEV_ADDR, SERIAL_NUMBER, 1,
(unsigned char *)&serial_number, 4)) {
- printf ("could not write to eeprom\n");
+ 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 */
+ 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");
+ printf("No I2C support enabled (CONFIG_CMD_I2C), could not write "
+ "to EEPROM\n");
return (1);
#endif
}
-
-int do_crc16 (void)
+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");
+ 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);
+ crc = 0; /* start value of crc calculation */
+ crc = updcrc(crc, buf, 60);
- print_identifier ();
- printf ("crc16=%#04x\n", crc);
+ 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");
+ 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");
+ 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.
@@ -1200,93 +1177,90 @@ int do_crc16 (void)
/* 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 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 )
+ 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++];
+ crc = (crc << B) ^ crctab[(crc >> (W - B)) ^ *cp++];
return (crc);
}
-
-int do_gain (char **argv)
+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]);
+ 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);
+ tsc2000_set_range(range);
return (0);
}
-
-int do_eeprom (char **argv)
+int do_eeprom(char **argv)
{
#if defined(CONFIG_CMD_I2C)
- if (strcmp (argv[2], "read") == 0) {
- return (trab_eeprom_read (argv));
+ if (strcmp(argv[2], "read") == 0) {
+ return (trab_eeprom_read(argv));
}
- else if (strcmp (argv[2], "write") == 0) {
- return (trab_eeprom_write (argv));
+ else if (strcmp(argv[2], "write") == 0) {
+ return (trab_eeprom_write(argv));
}
- printf ("%s: invalid parameter %s\n", __FUNCTION__, argv[2]);
+ 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");
+ 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)
+static int trab_eeprom_read(char **argv)
{
int i;
int len;
@@ -1294,44 +1268,42 @@ static int trab_eeprom_read (char **argv)
long int value = 0;
uchar *buffer;
- buffer = (uchar *) &value;
- addr = simple_strtoul (argv[3], NULL, 10);
+ buffer = (uchar *) & value;
+ addr = simple_strtoul(argv[3], NULL, 10);
addr &= 0xfff;
- len = simple_strtoul (argv[4], NULL, 10);
+ len = simple_strtoul(argv[4], NULL, 10);
if ((len < 1) || (len > 4)) {
- printf ("%s: invalid parameter %s\n", __FUNCTION__,
- argv[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);
+ 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) {
+ print_identifier();
+ if (strcmp(argv[5], "-") == 0) {
if (len == 1)
- printf ("%d\n", (signed char) value);
+ printf("%d\n", (signed char)value);
else if (len == 2)
- printf ("%d\n", (signed short int) value);
+ printf("%d\n", (signed short int)value);
else
- printf ("%ld\n", value);
- }
- else {
+ printf("%ld\n", value);
+ } else {
if (len == 1)
- printf ("%d\n", (unsigned char) value);
+ printf("%d\n", (unsigned char)value);
else if (len == 2)
- printf ("%d\n", (unsigned short int) value);
+ printf("%d\n", (unsigned short int)value);
else
- printf ("%ld\n", (unsigned long int) value);
+ printf("%ld\n", (unsigned long int)value);
}
return (0);
}
-static int trab_eeprom_write (char **argv)
+static int trab_eeprom_write(char **argv)
{
int i;
int len;
@@ -1339,77 +1311,74 @@ static int trab_eeprom_write (char **argv)
long int value = 0;
uchar *buffer;
- buffer = (uchar *) &value;
- addr = simple_strtoul (argv[3], NULL, 10);
+ buffer = (uchar *) & value;
+ addr = simple_strtoul(argv[3], NULL, 10);
addr &= 0xfff;
- len = simple_strtoul (argv[4], NULL, 10);
+ len = simple_strtoul(argv[4], NULL, 10);
if ((len < 1) || (len > 4)) {
- printf ("%s: invalid parameter %s\n", __FUNCTION__,
- argv[4]);
+ printf("%s: invalid parameter %s\n", __FUNCTION__, argv[4]);
return (1);
}
- value = simple_strtol (argv[5], NULL, 10);
- debug ("value=%ld\n", value);
+ 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);
+ 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));
+ 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 */
+ udelay(30000); /* wait for EEPROM ready */
}
return (0);
}
-int i2c_write_multiple (uchar chip, uint addr, int alen,
- uchar *buffer, int len)
+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__);
+ 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);
+ 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);
+ udelay(30000);
}
return (0);
}
-int i2c_read_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)
{
int i;
if (alen != 1) {
- printf ("%s: addr len other than 1 not supported\n",
- __FUNCTION__);
+ 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);
+ 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);
}
}
diff --git a/board/trab/tsc2000.c b/board/trab/tsc2000.c
index 5890624..db6387a 100644
--- a/board/trab/tsc2000.c
+++ b/board/trab/tsc2000.c
@@ -45,182 +45,203 @@
void tsc2000_spi_init(void)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- struct s3c24x0_spi * const spi = s3c24x0_get_base_spi();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_spi *const spi = s3c24x0_get_base_spi();
int i;
/* Configure I/O ports. */
- gpio->PDCON = (gpio->PDCON & 0xF3FFFF) | 0x040000;
- gpio->PGCON = (gpio->PGCON & 0x0F3FFF) | 0x008000;
- gpio->PGCON = (gpio->PGCON & 0x0CFFFF) | 0x020000;
- gpio->PGCON = (gpio->PGCON & 0x03FFFF) | 0x080000;
+ writel((readl(&gpio->pdcon) & 0xF3FFFF) | 0x040000, &gpio->pdcon);
+ writel((readl(&gpio->pgcon) & 0x0F3FFF) | 0x008000, &gpio->pgcon);
+ writel((readl(&gpio->pgcon) & 0x0CFFFF) | 0x020000, &gpio->pgcon);
+ writel((readl(&gpio->pgcon) & 0x03FFFF) | 0x080000, &gpio->pgcon);
- CLR_CS_TOUCH();
+ clr_cs_touch();
- spi->ch[0].SPPRE = 0x1F; /* Baud-rate ca. 514kHz */
- spi->ch[0].SPPIN = 0x01; /* SPI-MOSI holds Level after last bit */
- spi->ch[0].SPCON = 0x1A; /* Polling, Prescaler, Master, CPOL=0,
- CPHA=1 */
+ /* Baud-rate ca. 514kHz */
+ writel(0x1F, &spi->ch[0].sppre);
+ /* SPI-MOSI holds Level after last bit */
+ writel(0x01, &spi->ch[0].sppin);
+ /* Polling, Prescaler, Master, CPOL=0, CPHA=1 */
+ writel(0x1A, &spi->ch[0].spcon);
/* Dummy byte ensures clock to be low. */
for (i = 0; i < 10; i++) {
- spi->ch[0].SPTDAT = 0xFF;
+ writel(0xFF, &spi->ch[0].sptdat);
}
spi_wait_transmit_done();
}
-
void spi_wait_transmit_done(void)
{
- struct s3c24x0_spi * const spi = s3c24x0_get_base_spi();
+ struct s3c24x0_spi *const spi = s3c24x0_get_base_spi();
- while (!(spi->ch[0].SPSTA & 0x01)); /* wait until transfer is done */
+ while (!(spi->ch[0].spsta & 0x01)) ; /* wait until transfer is done */
}
-
void tsc2000_write(unsigned short reg, unsigned short data)
{
- struct s3c24x0_spi * const spi = s3c24x0_get_base_spi();
+ struct s3c24x0_spi *const spi = s3c24x0_get_base_spi();
unsigned int command;
- SET_CS_TOUCH();
+ set_cs_touch();
command = reg;
- spi->ch[0].SPTDAT = (command & 0xFF00) >> 8;
+ writel((command & 0xFF00) >> 8, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- spi->ch[0].SPTDAT = (command & 0x00FF);
+ writel(command & 0x00FF, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- spi->ch[0].SPTDAT = (data & 0xFF00) >> 8;
+ writel((data & 0xFF00) >> 8, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- spi->ch[0].SPTDAT = (data & 0x00FF);
+ writel(data & 0x00FF, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- CLR_CS_TOUCH();
+ clr_cs_touch();
}
-
-unsigned short tsc2000_read (unsigned short reg)
+unsigned short tsc2000_read(unsigned short reg)
{
unsigned short command, data;
- struct s3c24x0_spi * const spi = s3c24x0_get_base_spi();
+ struct s3c24x0_spi *const spi = s3c24x0_get_base_spi();
- SET_CS_TOUCH();
+ set_cs_touch();
command = 0x8000 | reg;
- spi->ch[0].SPTDAT = (command & 0xFF00) >> 8;
+ writel((command & 0xFF00) >> 8, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- spi->ch[0].SPTDAT = (command & 0x00FF);
+ writel(command & 0x00FF, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- spi->ch[0].SPTDAT = 0xFF;
+ writel(0xFF, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- data = spi->ch[0].SPRDAT;
- spi->ch[0].SPTDAT = 0xFF;
+ data = readl(&spi->ch[0].sprdat);
+ writel(0xFF, &spi->ch[0].sptdat);
spi_wait_transmit_done();
- CLR_CS_TOUCH();
- return (spi->ch[0].SPRDAT & 0x0FF) | (data << 8);
+ clr_cs_touch();
+ return (readl(&spi->ch[0].sprdat) & 0x0FF) | (data << 8);
}
-
-void tsc2000_set_mux (unsigned int channel)
+void tsc2000_set_mux(unsigned int channel)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
- CLR_MUX1_ENABLE; CLR_MUX2_ENABLE;
- CLR_MUX3_ENABLE; CLR_MUX4_ENABLE;
+ CLR_MUX1_ENABLE;
+ CLR_MUX2_ENABLE;
+ CLR_MUX3_ENABLE;
+ CLR_MUX4_ENABLE;
switch (channel) {
case 0:
- CLR_MUX0; CLR_MUX1;
+ CLR_MUX0;
+ CLR_MUX1;
SET_MUX1_ENABLE;
break;
case 1:
- SET_MUX0; CLR_MUX1;
+ SET_MUX0;
+ CLR_MUX1;
SET_MUX1_ENABLE;
break;
case 2:
- CLR_MUX0; SET_MUX1;
+ CLR_MUX0;
+ SET_MUX1;
SET_MUX1_ENABLE;
break;
case 3:
- SET_MUX0; SET_MUX1;
+ SET_MUX0;
+ SET_MUX1;
SET_MUX1_ENABLE;
break;
case 4:
- CLR_MUX0; CLR_MUX1;
+ CLR_MUX0;
+ CLR_MUX1;
SET_MUX2_ENABLE;
break;
case 5:
- SET_MUX0; CLR_MUX1;
+ SET_MUX0;
+ CLR_MUX1;
SET_MUX2_ENABLE;
break;
case 6:
- CLR_MUX0; SET_MUX1;
+ CLR_MUX0;
+ SET_MUX1;
SET_MUX2_ENABLE;
break;
case 7:
- SET_MUX0; SET_MUX1;
+ SET_MUX0;
+ SET_MUX1;
SET_MUX2_ENABLE;
break;
case 8:
- CLR_MUX0; CLR_MUX1;
+ CLR_MUX0;
+ CLR_MUX1;
SET_MUX3_ENABLE;
break;
case 9:
- SET_MUX0; CLR_MUX1;
+ SET_MUX0;
+ CLR_MUX1;
SET_MUX3_ENABLE;
break;
case 10:
- CLR_MUX0; SET_MUX1;
+ CLR_MUX0;
+ SET_MUX1;
SET_MUX3_ENABLE;
break;
case 11:
- SET_MUX0; SET_MUX1;
+ SET_MUX0;
+ SET_MUX1;
SET_MUX3_ENABLE;
break;
case 12:
- CLR_MUX0; CLR_MUX1;
+ CLR_MUX0;
+ CLR_MUX1;
SET_MUX4_ENABLE;
break;
case 13:
- SET_MUX0; CLR_MUX1;
+ SET_MUX0;
+ CLR_MUX1;
SET_MUX4_ENABLE;
break;
case 14:
- CLR_MUX0; SET_MUX1;
+ CLR_MUX0;
+ SET_MUX1;
SET_MUX4_ENABLE;
break;
case 15:
- SET_MUX0; SET_MUX1;
+ SET_MUX0;
+ SET_MUX1;
SET_MUX4_ENABLE;
break;
default:
- CLR_MUX0; CLR_MUX1;
+ CLR_MUX0;
+ CLR_MUX1;
}
}
-
-void tsc2000_set_range (unsigned int range)
+void tsc2000_set_range(unsigned int range)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
switch (range) {
case 1:
- CLR_SEL_TEMP_V_0; SET_SEL_TEMP_V_1;
- CLR_SEL_TEMP_V_2; CLR_SEL_TEMP_V_3;
+ CLR_SEL_TEMP_V_0;
+ SET_SEL_TEMP_V_1;
+ CLR_SEL_TEMP_V_2;
+ CLR_SEL_TEMP_V_3;
break;
case 2:
- CLR_SEL_TEMP_V_0; CLR_SEL_TEMP_V_1;
- CLR_SEL_TEMP_V_2; SET_SEL_TEMP_V_3;
+ CLR_SEL_TEMP_V_0;
+ CLR_SEL_TEMP_V_1;
+ CLR_SEL_TEMP_V_2;
+ SET_SEL_TEMP_V_3;
break;
case 3:
- SET_SEL_TEMP_V_0; CLR_SEL_TEMP_V_1;
- SET_SEL_TEMP_V_2; CLR_SEL_TEMP_V_3;
+ SET_SEL_TEMP_V_0;
+ CLR_SEL_TEMP_V_1;
+ SET_SEL_TEMP_V_2;
+ CLR_SEL_TEMP_V_3;
break;
}
}
-
-u16 tsc2000_read_channel (unsigned int channel)
+u16 tsc2000_read_channel(unsigned int channel)
{
u16 res;
@@ -228,21 +249,20 @@ u16 tsc2000_read_channel (unsigned int channel)
udelay(20 * TSC2000_DELAY_BASE);
tsc2000_write(TSC2000_REG_ADC, 0x2036);
- adc_wait_conversion_done ();
+ adc_wait_conversion_done();
res = tsc2000_read(TSC2000_REG_AUX1);
return res;
}
-
-s32 tsc2000_contact_temp (void)
+s32 tsc2000_contact_temp(void)
{
long adc_pt1000, offset;
long u_pt1000;
long contact_temp;
long temp1, temp2;
- tsc2000_reg_init ();
- tsc2000_set_range (3);
+ tsc2000_reg_init();
+ tsc2000_set_range(3);
/*
* Because of sporadic "jumps" in the measured adc values every
@@ -251,37 +271,37 @@ s32 tsc2000_contact_temp (void)
* measurement, because it is very unlikely that a successive third
* measurement goes also wrong.
*/
- temp1 = tsc2000_read_channel (14);
- temp2 = tsc2000_read_channel (14);
+ temp1 = tsc2000_read_channel(14);
+ temp2 = tsc2000_read_channel(14);
if (abs(temp2 - temp1) < MAX_DEVIATION)
adc_pt1000 = temp2;
else {
- printf ("%s: read adc value (channel 14) exceeded max allowed "
- "deviation: %d * 0.0276 ?C\n",
- __FUNCTION__, MAX_DEVIATION);
- printf ("adc value 1: %ld DIGITs\nadc value 2: %ld DIGITs\n",
- temp1, temp2);
- adc_pt1000 = tsc2000_read_channel (14);
- printf ("use (third read) adc value: adc_pt1000 = "
- "%ld DIGITs\n", adc_pt1000);
+ printf("%s: read adc value (channel 14) exceeded max allowed "
+ "deviation: %d * 0.0276 ?C\n",
+ __FUNCTION__, MAX_DEVIATION);
+ printf("adc value 1: %ld DIGITs\nadc value 2: %ld DIGITs\n",
+ temp1, temp2);
+ adc_pt1000 = tsc2000_read_channel(14);
+ printf("use (third read) adc value: adc_pt1000 = "
+ "%ld DIGITs\n", adc_pt1000);
}
- debug ("read channel 14 (pt1000 adc value): %ld\n", adc_pt1000);
+ debug("read channel 14 (pt1000 adc value): %ld\n", adc_pt1000);
- temp1 = tsc2000_read_channel (15);
- temp2 = tsc2000_read_channel (15);
+ temp1 = tsc2000_read_channel(15);
+ temp2 = tsc2000_read_channel(15);
if (abs(temp2 - temp1) < MAX_DEVIATION)
offset = temp2;
else {
- printf ("%s: read adc value (channel 15) exceeded max allowed "
- "deviation: %d * 0.0276 ?C\n",
- __FUNCTION__, MAX_DEVIATION);
- printf ("adc value 1: %ld DIGITs\nadc value 2: %ld DIGITs\n",
- temp1, temp2);
- offset = tsc2000_read_channel (15);
- printf ("use (third read) adc value: offset = %ld DIGITs\n",
- offset);
+ printf("%s: read adc value (channel 15) exceeded max allowed "
+ "deviation: %d * 0.0276 ?C\n",
+ __FUNCTION__, MAX_DEVIATION);
+ printf("adc value 1: %ld DIGITs\nadc value 2: %ld DIGITs\n",
+ temp1, temp2);
+ offset = tsc2000_read_channel(15);
+ printf("use (third read) adc value: offset = %ld DIGITs\n",
+ offset);
}
- debug ("read channel 15 (offset): %ld\n", offset);
+ debug("read channel 15 (offset): %ld\n", offset);
/*
* Formula for calculating voltage drop on PT1000 resistor: u_pt1000 =
@@ -291,23 +311,21 @@ s32 tsc2000_contact_temp (void)
* u-boot, because this could cause only a very small error (< 1%).
*/
u_pt1000 = (101750 * (adc_pt1000 - offset)) / 10;
- debug ("u_pt1000: %ld\n", u_pt1000);
+ debug("u_pt1000: %ld\n", u_pt1000);
if (tsc2000_interpolate(u_pt1000, Pt1000_temp_table,
&contact_temp) == -1) {
- printf ("%s: error interpolating PT1000 vlaue\n",
- __FUNCTION__);
+ printf("%s: error interpolating PT1000 vlaue\n", __FUNCTION__);
return (-1000);
}
- debug ("contact_temp: %ld\n", contact_temp);
+ debug("contact_temp: %ld\n", contact_temp);
return contact_temp;
}
-
-void tsc2000_reg_init (void)
+void tsc2000_reg_init(void)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
tsc2000_write(TSC2000_REG_ADC, 0x2036);
tsc2000_write(TSC2000_REG_REF, 0x0011);
@@ -330,7 +348,6 @@ void tsc2000_reg_init (void)
tsc2000_set_range(0);
}
-
int tsc2000_interpolate(long value, long data[][2], long *result)
{
int i;
@@ -348,18 +365,17 @@ int tsc2000_interpolate(long value, long data[][2], long *result)
/* To prevent overflow we have to store the intermediate
result in 'long long'.
- */
+ */
- val = ((unsigned long long)(data[i][1] - data[i-1][1])
- * (unsigned long long)(value - data[i-1][0]));
- do_div(val, (data[i][0] - data[i-1][0]));
- *result = data[i-1][1] + val;
+ val = ((unsigned long long)(data[i][1] - data[i - 1][1])
+ * (unsigned long long)(value - data[i - 1][0]));
+ do_div(val, (data[i][0] - data[i - 1][0]));
+ *result = data[i - 1][1] + val;
return 0;
}
-
void adc_wait_conversion_done(void)
{
- while (!(tsc2000_read(TSC2000_REG_ADC) & (1 << 14)));
+ while (!(tsc2000_read(TSC2000_REG_ADC) & (1 << 14))) ;
}
diff --git a/board/trab/tsc2000.h b/board/trab/tsc2000.h
index 0b6253f..f597398 100644
--- a/board/trab/tsc2000.h
+++ b/board/trab/tsc2000.h
@@ -29,45 +29,45 @@
#define _TSC2000_H_
/* temperature channel multiplexer definitions */
-#define CON_MUX0 (gpio->PCCON = (gpio->PCCON & 0x0FFFFFCFF) | 0x00000100)
-#define CLR_MUX0 (gpio->PCDAT &= 0x0FFEF)
-#define SET_MUX0 (gpio->PCDAT |= 0x00010)
+#define CON_MUX0 writel((readl(&gpio->pccon) & 0x0FFFFFCFF) | 0x00000100, &gpio->pccon)
+#define CLR_MUX0 writel(readl(&gpio->pcdat) & 0x0FFEF, &gpio->pcdat)
+#define SET_MUX0 writel(readl(&gpio->pcdat) | 0x00010, &gpio->pcdat)
-#define CON_MUX1 (gpio->PCCON = (gpio->PCCON & 0x0FFFFF3FF) | 0x00000400)
-#define CLR_MUX1 (gpio->PCDAT &= 0x0FFDF)
-#define SET_MUX1 (gpio->PCDAT |= 0x00020)
+#define CON_MUX1 writel((readl(&gpio->pccon) & 0x0FFFFF3FF) | 0x00000400, &gpio->pccon)
+#define CLR_MUX1 writel(readl(&gpio->pcdat) & 0x0FFDF, &gpio->pcdat)
+#define SET_MUX1 writel(readl(&gpio->pcdat) | 0x00020, &gpio->pcdat)
-#define CON_MUX1_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFFFCFFF) | 0x00001000)
-#define CLR_MUX1_ENABLE (gpio->PCDAT |= 0x00040)
-#define SET_MUX1_ENABLE (gpio->PCDAT &= 0x0FFBF)
+#define CON_MUX1_ENABLE writel((readl(&gpio->pccon) & 0x0FFFFCFFF) | 0x00001000, &gpio->pccon)
+#define CLR_MUX1_ENABLE writel(readl(&gpio->pcdat) | 0x00040, &gpio->pcdat)
+#define SET_MUX1_ENABLE writel(readl(&gpio->pcdat) & 0x0FFBF, &gpio->pcdat)
-#define CON_MUX2_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFFF3FFF) | 0x00004000)
-#define CLR_MUX2_ENABLE (gpio->PCDAT |= 0x00080)
-#define SET_MUX2_ENABLE (gpio->PCDAT &= 0x0FF7F)
+#define CON_MUX2_ENABLE writel((readl(&gpio->pccon) & 0x0FFFF3FFF) | 0x00004000, &gpio->pccon)
+#define CLR_MUX2_ENABLE writel(readl(&gpio->pcdat) | 0x00080, &gpio->pcdat)
+#define SET_MUX2_ENABLE writel(readl(&gpio->pcdat) & 0x0FF7F, &gpio->pcdat)
-#define CON_MUX3_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFFCFFFF) | 0x00010000)
-#define CLR_MUX3_ENABLE (gpio->PCDAT |= 0x00100)
-#define SET_MUX3_ENABLE (gpio->PCDAT &= 0x0FEFF)
+#define CON_MUX3_ENABLE writel((readl(&gpio->pccon) & 0x0FFFCFFFF) | 0x00010000, &gpio->pccon)
+#define CLR_MUX3_ENABLE writel(readl(&gpio->pcdat) | 0x00100, &gpio->pcdat)
+#define SET_MUX3_ENABLE writel(readl(&gpio->pcdat) & 0x0FEFF, &gpio->pcdat)
-#define CON_MUX4_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFF3FFFF) | 0x00040000)
-#define CLR_MUX4_ENABLE (gpio->PCDAT |= 0x00200)
-#define SET_MUX4_ENABLE (gpio->PCDAT &= 0x0FDFF)
+#define CON_MUX4_ENABLE writel((readl(&gpio->pccon) & 0x0FFF3FFFF) | 0x00040000, &gpio->pccon)
+#define CLR_MUX4_ENABLE writel(readl(&gpio->pcdat) | 0x00200, &gpio->pcdat)
+#define SET_MUX4_ENABLE writel(readl(&gpio->pcdat) & 0x0FDFF, &gpio->pcdat)
-#define CON_SEL_TEMP_V_0 (gpio->PCCON = (gpio->PCCON & 0x0FFCFFFFF) | 0x00100000)
-#define CLR_SEL_TEMP_V_0 (gpio->PCDAT &= 0x0FBFF)
-#define SET_SEL_TEMP_V_0 (gpio->PCDAT |= 0x00400)
+#define CON_SEL_TEMP_V_0 writel((readl(&gpio->pccon) & 0x0FFCFFFFF) | 0x00100000, &gpio->pccon)
+#define CLR_SEL_TEMP_V_0 writel(readl(&gpio->pcdat) & 0x0FBFF, &gpio->pcdat)
+#define SET_SEL_TEMP_V_0 writel(readl(&gpio->pcdat) | 0x00400, &gpio->pcdat)
-#define CON_SEL_TEMP_V_1 (gpio->PCCON = (gpio->PCCON & 0x0FF3FFFFF) | 0x00400000)
-#define CLR_SEL_TEMP_V_1 (gpio->PCDAT &= 0x0F7FF)
-#define SET_SEL_TEMP_V_1 (gpio->PCDAT |= 0x00800)
+#define CON_SEL_TEMP_V_1 writel((readl(&gpio->pccon) & 0x0FF3FFFFF) | 0x00400000, &gpio->pccon)
+#define CLR_SEL_TEMP_V_1 writel(readl(&gpio->pcdat) & 0x0F7FF, &gpio->pcdat)
+#define SET_SEL_TEMP_V_1 writel(readl(&gpio->pcdat) | 0x00800, &gpio->pcdat)
-#define CON_SEL_TEMP_V_2 (gpio->PCCON = (gpio->PCCON & 0x0FCFFFFFF) | 0x01000000)
-#define CLR_SEL_TEMP_V_2 (gpio->PCDAT &= 0x0EFFF)
-#define SET_SEL_TEMP_V_2 (gpio->PCDAT |= 0x01000)
+#define CON_SEL_TEMP_V_2 writel((readl(&gpio->pccon) & 0x0FCFFFFFF) | 0x01000000, &gpio->pccon)
+#define CLR_SEL_TEMP_V_2 writel(readl(&gpio->pcdat) & 0x0EFFF, &gpio->pcdat)
+#define SET_SEL_TEMP_V_2 writel(readl(&gpio->pcdat) | 0x01000, &gpio->pcdat)
-#define CON_SEL_TEMP_V_3 (gpio->PCCON = (gpio->PCCON & 0x0F3FFFFFF) | 0x04000000)
-#define CLR_SEL_TEMP_V_3 (gpio->PCDAT &= 0x0DFFF)
-#define SET_SEL_TEMP_V_3 (gpio->PCDAT |= 0x02000)
+#define CON_SEL_TEMP_V_3 writel((readl(&gpio->pccon) & 0x0F3FFFFFF) | 0x04000000, &gpio->pccon)
+#define CLR_SEL_TEMP_V_3 writel(readl(&gpio->pcdat) & 0x0DFFF, &gpio->pcdat)
+#define SET_SEL_TEMP_V_3 writel(readl(&gpio->pcdat) | 0x02000, &gpio->pcdat)
/* TSC2000 register definition */
#define TSC2000_REG_X ((0 << 11) | (0 << 5))
@@ -114,31 +114,29 @@
#define ERROR_BATTERY 220 /* must be adjusted, if R68 is changed on TRAB */
void tsc2000_write(unsigned short, unsigned short);
-unsigned short tsc2000_read (unsigned short);
-u16 tsc2000_read_channel (unsigned int);
-void tsc2000_set_mux (unsigned int);
-void tsc2000_set_range (unsigned int);
-void tsc2000_reg_init (void);
-s32 tsc2000_contact_temp (void);
-void spi_wait_transmit_done (void);
+unsigned short tsc2000_read(unsigned short);
+u16 tsc2000_read_channel(unsigned int);
+void tsc2000_set_mux(unsigned int);
+void tsc2000_set_range(unsigned int);
+void tsc2000_reg_init(void);
+s32 tsc2000_contact_temp(void);
+void spi_wait_transmit_done(void);
void tsc2000_spi_init(void);
int tsc2000_interpolate(long value, long data[][2], long *result);
void adc_wait_conversion_done(void);
-
-static inline void SET_CS_TOUCH(void)
+static inline void set_cs_touch(void)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
- gpio->PDDAT &= 0x5FF;
+ writel(readl(&gpio->pddat) & 0x5FF, &gpio->pddat);
}
-
-static inline void CLR_CS_TOUCH(void)
+static inline void clr_cs_touch(void)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
- gpio->PDDAT |= 0x200;
+ writel(readl(&gpio->pddat) | 0x200, &gpio->pddat);
}
-#endif /* _TSC2000_H_ */
+#endif /* _TSC2000_H_ */
diff --git a/board/trab/vfd.c b/board/trab/vfd.c
index b7eb8cc..6e6b68f 100644
--- a/board/trab/vfd.c
+++ b/board/trab/vfd.c
@@ -38,6 +38,7 @@
#include <linux/types.h>
#include <stdio_dev.h>
#include <asm/arch/s3c24x0_cpu.h>
+#include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -95,75 +96,95 @@ void init_grid_ctrl(void)
/*
* clear frame buffer (logical clear => set to "black")
*/
- memset ((void *)(gd->fb_base), 0, FRAME_BUF_SIZE);
+ memset((void *)(gd->fb_base), 0, FRAME_BUF_SIZE);
switch (gd->vfd_type) {
case VFD_TYPE_T119C:
- for (display=0; display<4; display++) {
- for(grid_cycle=0; grid_cycle<56; grid_cycle++) {
- bit = grid_cycle * 256 * 4 +
- (grid_cycle + 200) * 4 +
- frame_buf_offs + display;
- /* wrap arround if offset (see manual S3C2400) */
- if (bit>=FRAME_BUF_SIZE*8)
- bit = bit - (FRAME_BUF_SIZE * 8);
- adr = gd->fb_base + (bit/32) * 4 + (3 - (bit%32) / 8);
- bit_nr = bit % 8;
- bit_nr = (bit_nr > 3) ? bit_nr-4 : bit_nr+4;
- temp=(*(volatile unsigned char*)(adr));
- temp |= (1<<bit_nr);
- (*(volatile unsigned char*)(adr))=temp;
-
- if(grid_cycle<55)
- bit = grid_cycle*256*4+(grid_cycle+201)*4+frame_buf_offs+display;
- else
- bit = grid_cycle*256*4+200*4+frame_buf_offs+display-4; /* grid nr. 0 */
- /* wrap arround if offset (see manual S3C2400) */
- if (bit>=FRAME_BUF_SIZE*8)
- bit = bit-(FRAME_BUF_SIZE*8);
- adr = gd->fb_base+(bit/32)*4+(3-(bit%32)/8);
- bit_nr = bit%8;
- bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;
- temp=(*(volatile unsigned char*)(adr));
- temp |= (1<<bit_nr);
- (*(volatile unsigned char*)(adr))=temp;
+ for (display = 0; display < 4; display++) {
+ for (grid_cycle = 0; grid_cycle < 56; grid_cycle++) {
+ bit = grid_cycle * 256 * 4 +
+ (grid_cycle + 200) * 4 +
+ frame_buf_offs + display;
+ /* wrap around if offset (see manual S3C2400) */
+ if (bit >= FRAME_BUF_SIZE * 8)
+ bit = bit - (FRAME_BUF_SIZE * 8);
+ adr =
+ gd->fb_base + (bit / 32) * 4 + (3 -
+ (bit % 32) /
+ 8);
+ bit_nr = bit % 8;
+ bit_nr = (bit_nr > 3) ? bit_nr - 4 : bit_nr + 4;
+ temp = (*(volatile unsigned char *)(adr));
+ temp |= (1 << bit_nr);
+ (*(volatile unsigned char *)(adr)) = temp;
+
+ if (grid_cycle < 55)
+ bit =
+ grid_cycle * 256 * 4 + (grid_cycle +
+ 201) * 4 +
+ frame_buf_offs + display;
+ else
+ /* grid nr. 0 */
+ bit = grid_cycle * 256 * 4 + 200 * 4 +
+ frame_buf_offs + display - 4;
+ /* wrap around if offset (see manual S3C2400) */
+ if (bit >= FRAME_BUF_SIZE * 8)
+ bit = bit - (FRAME_BUF_SIZE * 8);
+ adr =
+ gd->fb_base + (bit / 32) * 4 + (3 -
+ (bit % 32) /
+ 8);
+ bit_nr = bit % 8;
+ bit_nr = (bit_nr > 3) ? bit_nr - 4 : bit_nr + 4;
+ temp = (*(volatile unsigned char *)(adr));
+ temp |= (1 << bit_nr);
+ (*(volatile unsigned char *)(adr)) = temp;
+ }
}
- }
- break;
+ break;
case VFD_TYPE_MN11236:
- for (display=0; display<4; display++) {
- for (grid_cycle=0; grid_cycle<38; grid_cycle++) {
- bit = grid_cycle * 256 * 4 +
- (253 - grid_cycle) * 4 +
- frame_buf_offs + display;
- /* wrap arround if offset (see manual S3C2400) */
- if (bit>=FRAME_BUF_SIZE*8)
- bit = bit - (FRAME_BUF_SIZE * 8);
- adr = gd->fb_base + (bit/32) * 4 + (3 - (bit%32) / 8);
- bit_nr = bit % 8;
- bit_nr = (bit_nr > 3) ? bit_nr-4 : bit_nr+4;
- temp=(*(volatile unsigned char*)(adr));
- temp |= (1<<bit_nr);
- (*(volatile unsigned char*)(adr))=temp;
-
- if(grid_cycle<37)
- bit = grid_cycle*256*4+(252-grid_cycle)*4+frame_buf_offs+display;
-
- /* wrap arround if offset (see manual S3C2400) */
- if (bit>=FRAME_BUF_SIZE*8)
- bit = bit-(FRAME_BUF_SIZE*8);
- adr = gd->fb_base+(bit/32)*4+(3-(bit%32)/8);
- bit_nr = bit%8;
- bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;
- temp=(*(volatile unsigned char*)(adr));
- temp |= (1<<bit_nr);
- (*(volatile unsigned char*)(adr))=temp;
+ for (display = 0; display < 4; display++) {
+ for (grid_cycle = 0; grid_cycle < 38; grid_cycle++) {
+ bit = grid_cycle * 256 * 4 +
+ (253 - grid_cycle) * 4 +
+ frame_buf_offs + display;
+ /* wrap around if offset (see manual S3C2400) */
+ if (bit >= FRAME_BUF_SIZE * 8)
+ bit = bit - (FRAME_BUF_SIZE * 8);
+ adr =
+ gd->fb_base + (bit / 32) * 4 + (3 -
+ (bit % 32) /
+ 8);
+ bit_nr = bit % 8;
+ bit_nr = (bit_nr > 3) ? bit_nr - 4 : bit_nr + 4;
+ temp = (*(volatile unsigned char *)(adr));
+ temp |= (1 << bit_nr);
+ (*(volatile unsigned char *)(adr)) = temp;
+
+ if (grid_cycle < 37)
+ bit =
+ grid_cycle * 256 * 4 + (252 -
+ grid_cycle)
+ * 4 + frame_buf_offs + display;
+
+ /* wrap around if offset (see manual S3C2400) */
+ if (bit >= FRAME_BUF_SIZE * 8)
+ bit = bit - (FRAME_BUF_SIZE * 8);
+ adr =
+ gd->fb_base + (bit / 32) * 4 + (3 -
+ (bit % 32) /
+ 8);
+ bit_nr = bit % 8;
+ bit_nr = (bit_nr > 3) ? bit_nr - 4 : bit_nr + 4;
+ temp = (*(volatile unsigned char *)(adr));
+ temp |= (1 << bit_nr);
+ (*(volatile unsigned char *)(adr)) = temp;
+ }
}
- }
- break;
+ break;
default:
- printf ("Warning: unknown display type\n");
- break;
+ printf("Warning: unknown display type\n");
+ break;
}
}
@@ -179,63 +200,93 @@ void create_vfd_table(void)
switch (gd->vfd_type) {
case VFD_TYPE_T119C:
- for(y=0; y<=17; y++) { /* Line */
- for(x=0; x<=111; x++) { /* Column */
- for(display=0; display <=3; display++) {
-
- /* Display 0 blue pixels */
- vfd_table[x][y][0][display][0] =
- (x==0) ? y*16+display
- : (x%4)*4+y*16+((x-1)/2)*1024+display;
- /* Display 0 red pixels */
- vfd_table[x][y][1][display][0] =
- (x==0) ? y*16+512+display
- : (x%4)*4+y*16+((x-1)/2)*1024+512+display;
- }
+ for (y = 0; y <= 17; y++) { /* Line */
+ for (x = 0; x <= 111; x++) { /* Column */
+ for (display = 0; display <= 3; display++) {
+
+ /* Display 0 blue pixels */
+ vfd_table[x][y][0][display][0] =
+ (x == 0) ? y * 16 + display
+ : (x % 4) * 4 + y * 16 +
+ ((x - 1) / 2) * 1024 + display;
+ /* Display 0 red pixels */
+ vfd_table[x][y][1][display][0] =
+ (x == 0) ? y * 16 + 512 + display
+ : (x % 4) * 4 + y * 16 +
+ ((x - 1) / 2) * 1024 + 512 +
+ display;
+ }
+ }
}
- }
- break;
+ break;
case VFD_TYPE_MN11236:
- for(y=0; y<=17; y++) { /* Line */
- for(x=0; x<=111; x++) { /* Column */
- for(display=0; display <=3; display++) {
-
- vfd_table[x][y][0][display][0]=0;
- vfd_table[x][y][0][display][1]=0;
- vfd_table[x][y][1][display][0]=0;
- vfd_table[x][y][1][display][1]=0;
-
- switch (x%6) {
- case 0: x_abcdef=0; break; /* a -> a */
- case 1: x_abcdef=2; break; /* b -> c */
- case 2: x_abcdef=4; break; /* c -> e */
- case 3: x_abcdef=5; break; /* d -> f */
- case 4: x_abcdef=3; break; /* e -> d */
- case 5: x_abcdef=1; break; /* f -> b */
- }
-
- /* blue pixels */
- vfd_table[x][y][0][display][0] =
- (x>1) ? x_abcdef*4+((x-1)/3)*1024+y*48+display
- : x_abcdef*4+ 0+y*48+display;
- /* blue pixels */
- if (x>1 && (x-1)%3)
- vfd_table[x][y][0][display][1] = x_abcdef*4+((x-1)/3+1)*1024+y*48+display;
-
- /* red pixels */
- vfd_table[x][y][1][display][0] =
- (x>1) ? x_abcdef*4+24+((x-1)/3)*1024+y*48+display
- : x_abcdef*4+24+ 0+y*48+display;
- /* red pixels */
- if (x>1 && (x-1)%3)
- vfd_table[x][y][1][display][1] = x_abcdef*4+24+((x-1)/3+1)*1024+y*48+display;
- }
+ for (y = 0; y <= 17; y++) { /* Line */
+ for (x = 0; x <= 111; x++) { /* Column */
+ for (display = 0; display <= 3; display++) {
+
+ vfd_table[x][y][0][display][0] = 0;
+ vfd_table[x][y][0][display][1] = 0;
+ vfd_table[x][y][1][display][0] = 0;
+ vfd_table[x][y][1][display][1] = 0;
+
+ switch (x % 6) {
+ case 0:
+ x_abcdef = 0;
+ break; /* a -> a */
+ case 1:
+ x_abcdef = 2;
+ break; /* b -> c */
+ case 2:
+ x_abcdef = 4;
+ break; /* c -> e */
+ case 3:
+ x_abcdef = 5;
+ break; /* d -> f */
+ case 4:
+ x_abcdef = 3;
+ break; /* e -> d */
+ case 5:
+ x_abcdef = 1;
+ break; /* f -> b */
+ }
+
+ /* blue pixels */
+ vfd_table[x][y][0][display][0] =
+ (x >
+ 1) ? x_abcdef * 4 + ((x -
+ 1) / 3) *
+ 1024 + y * 48 +
+ display : x_abcdef * 4 + 0 +
+ y * 48 + display;
+ /* blue pixels */
+ if (x > 1 && (x - 1) % 3)
+ vfd_table[x][y][0][display][1] =
+ x_abcdef * 4 +
+ ((x - 1) / 3 + 1) * 1024 +
+ y * 48 + display;
+
+ /* red pixels */
+ vfd_table[x][y][1][display][0] =
+ (x >
+ 1) ? x_abcdef * 4 + 24 + ((x -
+ 1) /
+ 3) *
+ 1024 + y * 48 +
+ display : x_abcdef * 4 + 24 + 0 +
+ y * 48 + display;
+ /* red pixels */
+ if (x > 1 && (x - 1) % 3)
+ vfd_table[x][y][1][display][1] =
+ x_abcdef * 4 + 24 +
+ ((x - 1) / 3 + 1) * 1024 +
+ y * 48 + display;
+ }
+ }
}
- }
- break;
+ break;
default:
- /* do nothing */
- return;
+ /* do nothing */
+ return;
}
/*
@@ -243,31 +294,45 @@ void create_vfd_table(void)
* bit-number within the byte
* from table with bit-numbers within the total framebuffer
*/
- for(y=0;y<18;y++) {
- for(x=0;x<112;x++) {
- for(color=0;color<2;color++) {
- for(display=0;display<4;display++) {
- for(entry=0;entry<2;entry++) {
- unsigned long adr = gd->fb_base;
- unsigned int bit_nr = 0;
-
- pixel = vfd_table[x][y][color][display][entry] + frame_buf_offs;
- /*
- * wrap arround if offset
- * (see manual S3C2400)
- */
- if (pixel>=FRAME_BUF_SIZE*8)
- pixel = pixel-(FRAME_BUF_SIZE*8);
- adr = gd->fb_base+(pixel/32)*4+(3-(pixel%32)/8);
- bit_nr = pixel%8;
- bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;
-
- adr_vfd_table[x][y][color][display][entry] = adr;
- bit_vfd_table[x][y][color][display][entry] = bit_nr;
+ for (y = 0; y < 18; y++) {
+ for (x = 0; x < 112; x++) {
+ for (color = 0; color < 2; color++) {
+ for (display = 0; display < 4; display++) {
+ for (entry = 0; entry < 2; entry++) {
+ unsigned long adr = gd->fb_base;
+ unsigned int bit_nr = 0;
+
+ pixel =
+ vfd_table[x][y][color]
+ [display][entry] +
+ frame_buf_offs;
+ /*
+ * wrap around if offset
+ * (see manual S3C2400)
+ */
+ if (pixel >=
+ FRAME_BUF_SIZE * 8)
+ pixel =
+ pixel -
+ (FRAME_BUF_SIZE * 8);
+ adr =
+ gd->fb_base +
+ (pixel / 32) * 4 +
+ (3 - (pixel % 32) / 8);
+ bit_nr = pixel % 8;
+ bit_nr =
+ (bit_nr >
+ 3) ? bit_nr - 4 : bit_nr +
+ 4;
+
+ adr_vfd_table[x][y][color]
+ [display][entry] = adr;
+ bit_vfd_table[x][y][color]
+ [display][entry] = bit_nr;
+ }
+ }
}
- }
}
- }
}
}
@@ -281,7 +346,7 @@ void set_vfd_pixel(unsigned char x, unsigned char y,
ulong adr;
unsigned char bit_nr, temp;
- if (! gd->vfd_type) {
+ if (!gd->vfd_type) {
/* Unknown type. */
return;
}
@@ -290,14 +355,14 @@ void set_vfd_pixel(unsigned char x, unsigned char y,
adr = adr_vfd_table[x][y][color][display][0];
/* Pixel-Eintrag Nr. 1 */
bit_nr = bit_vfd_table[x][y][color][display][0];
- temp=(*(volatile unsigned char*)(adr));
+ temp = (*(volatile unsigned char *)(adr));
if (value)
- temp |= (1<<bit_nr);
+ temp |= (1 << bit_nr);
else
- temp &= ~(1<<bit_nr);
+ temp &= ~(1 << bit_nr);
- (*(volatile unsigned char*)(adr))=temp;
+ (*(volatile unsigned char *)(adr)) = temp;
}
/*
@@ -308,38 +373,37 @@ void transfer_pic(int display, unsigned char *adr, int height, int width)
int x, y;
unsigned char temp;
- for (; height > 0; height -= 18)
- {
+ for (; height > 0; height -= 18) {
if (height > 18)
y = 18;
else
y = height;
- for (; y > 0; y--)
- {
- for (x = 0; x < width; x += 2)
- {
+ for (; y > 0; y--) {
+ for (x = 0; x < width; x += 2) {
temp = *adr++;
- set_vfd_pixel(x, y-1, 0, display, 0);
- set_vfd_pixel(x, y-1, 1, display, 0);
+ set_vfd_pixel(x, y - 1, 0, display, 0);
+ set_vfd_pixel(x, y - 1, 1, display, 0);
if ((temp >> 4) == BLAU)
- set_vfd_pixel(x, y-1, 0, display, 1);
+ set_vfd_pixel(x, y - 1, 0, display, 1);
else if ((temp >> 4) == ROT)
- set_vfd_pixel(x, y-1, 1, display, 1);
- else if ((temp >> 4) == VIOLETT)
- {
- set_vfd_pixel(x, y-1, 0, display, 1);
- set_vfd_pixel(x, y-1, 1, display, 1);
+ set_vfd_pixel(x, y - 1, 1, display, 1);
+ else if ((temp >> 4) == VIOLETT) {
+ set_vfd_pixel(x, y - 1, 0, display, 1);
+ set_vfd_pixel(x, y - 1, 1, display, 1);
}
- set_vfd_pixel(x+1, y-1, 0, display, 0);
- set_vfd_pixel(x+1, y-1, 1, display, 0);
+ set_vfd_pixel(x + 1, y - 1, 0, display, 0);
+ set_vfd_pixel(x + 1, y - 1, 1, display, 0);
if ((temp & 0x0F) == BLAU)
- set_vfd_pixel(x+1, y-1, 0, display, 1);
+ set_vfd_pixel(x + 1, y - 1, 0, display,
+ 1);
else if ((temp & 0x0F) == ROT)
- set_vfd_pixel(x+1, y-1, 1, display, 1);
- else if ((temp & 0x0F) == VIOLETT)
- {
- set_vfd_pixel(x+1, y-1, 0, display, 1);
- set_vfd_pixel(x+1, y-1, 1, display, 1);
+ set_vfd_pixel(x + 1, y - 1, 1, display,
+ 1);
+ else if ((temp & 0x0F) == VIOLETT) {
+ set_vfd_pixel(x + 1, y - 1, 0, display,
+ 1);
+ set_vfd_pixel(x + 1, y - 1, 1, display,
+ 1);
}
}
}
@@ -354,66 +418,73 @@ void transfer_pic(int display, unsigned char *adr, int height, int width)
* This function initializes VFD clock that is needed for the CPLD that
* manages the keyboard.
*/
-int vfd_init_clocks (void)
+int vfd_init_clocks(void)
{
int i;
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- struct s3c24x0_timers * const timers = s3c24x0_get_base_timers();
- struct s3c24x0_lcd * const lcd = s3c24x0_get_base_lcd();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_timers *const timers = s3c24x0_get_base_timers();
+ struct s3c24x0_lcd *const lcd = s3c24x0_get_base_lcd();
/* try to determine display type from the value
* defined by pull-ups
*/
- gpio->PCUP = (gpio->PCUP & 0xFFF0); /* activate GPC0...GPC3 pullups */
- gpio->PCCON = (gpio->PCCON & 0xFFFFFF00); /* configure GPC0...GPC3 as inputs */
+ /* activate GPC0...GPC3 pullups */
+ writel(readl(&gpio->pcup) & 0xFFF0, &gpio->pcup);
+ /* configure GPC0...GPC3 as inputs */
+ writel(readl(&gpio->pccon) & 0xFFFFFF00, &gpio->pccon);
/* allow signals to settle */
- for (i=0; i<10000; i++) /* udelay isn't working yet at this point! */
+ /* udelay isn't working yet@this point! */
+ for (i = 0; i < 10000; i++)
__asm__("NOP");
- vfd_board_id = (~gpio->PCDAT) & 0x000F; /* read GPC0...GPC3 port pins */
+ /* read GPC0...GPC3 port pins */
+ vfd_board_id = (~readl(&gpio->pcdat)) & 0x000F;
- VFD_DISABLE; /* activate blank for the vfd */
+ VFD_DISABLE; /* activate blank for the vfd */
#define NEW_CPLD_CLK
#ifdef NEW_CPLD_CLK
if (vfd_board_id) {
/* If new board revision, then use PWM 3 as cpld-clock */
- /* Enable 500 Hz timer for fill level sensor to operate properly */
+ /* Enable 500 Hz timer for fill level sensor
+ to operate properly */
/* Configure TOUT3 as functional pin, disable pull-up */
- gpio->PDCON &= ~0x30000;
- gpio->PDCON |= 0x20000;
- gpio->PDUP |= (1 << 8);
+ writel(readl(&gpio->pdcon) & ~0x30000, &gpio->pdcon);
+ writel(readl(&gpio->pdcon) | 0x20000, &gpio->pdcon);
+ writel(readl(&gpio->pdup) | (1 << 8), &gpio->pdup);
/* Configure the prescaler */
- timers->TCFG0 &= ~0xff00;
- timers->TCFG0 |= 0x0f00;
+ writel(readl(&timers->tcfg0) & ~0xff00, &timers->tcfg0);
+ writel(readl(&timers->tcfg0) | 0x0f00, &timers->tcfg0);
/* Select MUX input (divider) for timer3 (1/16) */
- timers->TCFG1 &= ~0xf000;
- timers->TCFG1 |= 0x3000;
+ writel(readl(&timers->tcfg1) & ~0xf000, &timers->tcfg1);
+ writel(readl(&timers->tcfg1) | 0x3000, &timers->tcfg1);
/* Enable autoreload and set the counter and compare
* registers to values for the 500 Hz clock
* (for a given prescaler (15) and divider (16)):
* counter = (66000000 / 500) >> 9;
*/
- timers->ch[3].TCNTB = 0x101;
- timers->ch[3].TCMPB = 0x101 / 2;
+ writel(0x101, &timers->ch[3].tcntb);
+ writel(0x101 / 2, &timers->ch[3].tcmpb);
/* Start timer */
- timers->TCON = (timers->TCON | UPDATE3 | RELOAD3) & ~INVERT3;
- timers->TCON = (timers->TCON | START3) & ~UPDATE3;
+ writel((readl(&timers->tcon) | UPDATE3 | RELOAD3) & ~INVERT3,
+ &timers->tcon);
+ writel((readl(&timers->tcon) | START3) & ~UPDATE3,
+ &timers->tcon);
}
#endif
/* If old board revision, then use vm-signal as cpld-clock */
- lcd->LCDCON2 = 0x00FFC000;
- lcd->LCDCON3 = 0x0007FF00;
- lcd->LCDCON4 = 0x00000000;
- lcd->LCDCON5 = 0x00000400;
- lcd->LCDCON1 = 0x00000B75;
+ writel(0x00FFC000, &lcd->lcdcon2);
+ writel(0x0007FF00, &lcd->lcdcon3);
+ writel(0x00000000, &lcd->lcdcon4);
+ writel(0x00000400, &lcd->lcdcon5);
+ writel(0x00000B75, &lcd->lcdcon1);
/* VM (GPD1) is used as clock for the CPLD */
- gpio->PDCON = (gpio->PDCON & 0xFFFFFFF3) | 0x00000008;
+ writel((readl(&gpio->pdcon) & 0xFFFFFFF3) | 0x00000008, &gpio->pdcon);
return 0;
}
@@ -429,8 +500,8 @@ int vfd_init_clocks (void)
*/
int drv_vfd_init(void)
{
- struct s3c24x0_lcd * const lcd = s3c24x0_get_base_lcd();
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_lcd *const lcd = s3c24x0_get_base_lcd();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
char *tmp;
ulong palette;
static int vfd_init_done = 0;
@@ -443,8 +514,8 @@ int drv_vfd_init(void)
debug("Detecting Revison of WA4-VFD: ID=0x%X\n", vfd_board_id);
switch (vfd_board_id) {
- case 0: /* board revision < Rev.200 */
- if ((tmp = getenv ("vfd_type")) == NULL) {
+ case 0: /* board revision < Rev.200 */
+ if ((tmp = getenv("vfd_type")) == NULL) {
break;
}
if (strcmp(tmp, "T119C") == 0) {
@@ -460,22 +531,21 @@ int drv_vfd_init(void)
default: /* default to MN11236, data inverted */
gd->vfd_type = VFD_TYPE_MN11236;
vfd_inv_data = 1;
- setenv ("vfd_type", "MN11236");
+ setenv("vfd_type", "MN11236");
}
- debug ("VFD type: %s%s\n",
- (gd->vfd_type == VFD_TYPE_T119C) ? "T119C" :
- (gd->vfd_type == VFD_TYPE_MN11236) ? "MN11236" :
- "unknown",
- vfd_inv_data ? ", inverted data" : "");
+ debug("VFD type: %s%s\n",
+ (gd->vfd_type == VFD_TYPE_T119C) ? "T119C" :
+ (gd->vfd_type == VFD_TYPE_MN11236) ? "MN11236" :
+ "unknown", vfd_inv_data ? ", inverted data" : "");
gd->fb_base = gd->fb_base;
create_vfd_table();
init_grid_ctrl();
- for (palette=0; palette < 16; palette++)
- (*(volatile unsigned int*)(PALETTE+(palette*4)))=palette;
- for (palette=16; palette < 256; palette++)
- (*(volatile unsigned int*)(PALETTE+(palette*4)))=0x00;
+ for (palette = 0; palette < 16; palette++)
+ (*(volatile unsigned int *)(PALETTE + (palette * 4))) = palette;
+ for (palette = 16; palette < 256; palette++)
+ (*(volatile unsigned int *)(PALETTE + (palette * 4))) = 0x00;
/*
* Hinweis: Der Framebuffer ist um genau ein Nibble verschoben
@@ -485,40 +555,43 @@ int drv_vfd_init(void)
* see manual S3C2400
*/
/* Stopp LCD-Controller */
- lcd->LCDCON1 = 0x00000000;
+ writel(0x00000000, &lcd->lcdcon1);
/* frame buffer startadr */
- lcd->LCDSADDR1 = gd->fb_base >> 1;
+ writel(gd->fb_base >> 1, &lcd->lcdsaddr1);
/* frame buffer endadr */
- lcd->LCDSADDR2 = (gd->fb_base + FRAME_BUF_SIZE) >> 1;
- lcd->LCDSADDR3 = ((256/4));
- lcd->LCDCON2 = 0x000DC000;
- if(gd->vfd_type == VFD_TYPE_MN11236)
- lcd->LCDCON2 = 37 << 14; /* MN11236: 38 lines */
+ writel((gd->fb_base + FRAME_BUF_SIZE) >> 1, &lcd->lcdsaddr2);
+ writel(256 / 4, &lcd->lcdsaddr3);
+ writel(0x000DC000, &lcd->lcdcon2);
+ if (gd->vfd_type == VFD_TYPE_MN11236)
+ writel(37 << 14, &lcd->lcdcon2); /* MN11236: 38 lines */
else
- lcd->LCDCON2 = 55 << 14; /* T119C: 56 lines */
- lcd->LCDCON3 = 0x0051000A;
- lcd->LCDCON4 = 0x00000001;
+ writel(55 << 14, &lcd->lcdcon2); /* T119C: 56 lines */
+ writel(0x0051000A, &lcd->lcdcon3);
+ writel(0x00000001, &lcd->lcdcon4);
if (gd->vfd_type && vfd_inv_data)
- lcd->LCDCON5 = 0x000004C0;
+ writel(0x000004C0, &lcd->lcdcon5);
else
- lcd->LCDCON5 = 0x00000440;
+ writel(0x00000440, &lcd->lcdcon5);
/* Port pins as LCD output */
- gpio->PCCON = (gpio->PCCON & 0xFFFFFF00)| 0x000000AA;
- gpio->PDCON = (gpio->PDCON & 0xFFFFFF03)| 0x000000A8;
-
- /* Synchronize VFD enable with LCD controller to avoid flicker */
- lcd->LCDCON1 = 0x00000B75; /* Start LCD-Controller */
- while((lcd->LCDCON5 & 0x180000)!=0x100000); /* Wait for end of VSYNC */
- while((lcd->LCDCON5 & 0x060000)!=0x040000); /* Wait for next HSYNC */
- while((lcd->LCDCON5 & 0x060000)==0x040000);
- while((lcd->LCDCON5 & 0x060000)!=0x000000);
- if(gd->vfd_type)
+ writel((readl(&gpio->pccon) & 0xFFFFFF00) | 0x000000AA, &gpio->pccon);
+ writel((readl(&gpio->pdcon) & 0xFFFFFF03) | 0x000000A8, &gpio->pdcon);
+
+ /* Synchronize VFD enable with LCD controller to avoid flicker */
+ /* Start LCD-Controller */
+ writel(0x00000B75, &lcd->lcdcon1);
+ /* Wait for end of VSYNC */
+ while ((readl(&lcd->lcdcon5) & 0x180000) != 0x100000) ;
+ /* Wait for next HSYNC */
+ while ((readl(&lcd->lcdcon5) & 0x060000) != 0x040000) ;
+ while ((readl(&lcd->lcdcon5) & 0x060000) == 0x040000) ;
+ while ((readl(&lcd->lcdcon5) & 0x060000) != 0x000000) ;
+ if (gd->vfd_type)
VFD_ENABLE;
- debug ("LCDSADDR1: %lX\n", lcd->LCDSADDR1);
- debug ("LCDSADDR2: %lX\n", lcd->LCDSADDR2);
- debug ("LCDSADDR3: %lX\n", lcd->LCDSADDR3);
+ debug("LCDSADDR1: %lX\n", readl(&lcd->lcdsaddr1));
+ debug("LCDSADDR2: %lX\n", readl(&lcd->lcdsaddr2));
+ debug("LCDSADDR3: %lX\n", readl(&lcd->lcdsaddr3));
return 0;
}
@@ -527,13 +600,13 @@ int drv_vfd_init(void)
* Disable VFD: should be run before resetting the system:
* disable VM, enable pull-up
*/
-void disable_vfd (void)
+void disable_vfd(void)
{
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
+ struct s3c24x0_gpio *const gpio = s3c24x0_get_base_gpio();
VFD_DISABLE;
- gpio->PDCON &= ~0xC;
- gpio->PDUP &= ~0x2;
+ writel(readl(&gpio->pdcon) & ~0xC, &gpio->pdcon);
+ writel(readl(&gpio->pdup) & ~0x2, &gpio->pdup);
}
/************************************************************************/
@@ -546,14 +619,15 @@ void disable_vfd (void)
*
* Note that this is running from ROM, so no write access to global data.
*/
-ulong vfd_setmem (ulong addr)
+ulong vfd_setmem(ulong addr)
{
ulong size;
/* Round up to nearest full page */
size = (FRAME_BUF_SIZE + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
- debug ("Reserving %ldk for VFD Framebuffer at: %08lx\n", size>>10, addr);
+ debug("Reserving %ldk for VFD Framebuffer at: %08lx\n", size >> 10,
+ addr);
return (size);
}
@@ -562,7 +636,7 @@ ulong vfd_setmem (ulong addr)
* Calculate fb size for VIDEOLFB_ATAG. Size returned contains fb,
* descriptors and palette areas.
*/
-ulong calc_fbsize (void)
+ulong calc_fbsize(void)
{
return FRAME_BUF_SIZE;
}
--
1.6.1.2
next reply other threads:[~2009-12-13 20:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-13 20:05 kevin.morfitt at fearnside-systems.co.uk [this message]
2009-12-15 12:24 ` [U-Boot] [PATCH ARM 3/3] s3c24x0 code style changes Wolfgang Denk
2009-12-15 14:01 ` kevin.morfitt at fearnside-systems.co.uk
2009-12-15 17:00 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B2548FF.6040103@fearnside-systems.co.uk \
--to=kevin.morfitt@fearnside-systems.co.uk \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox