Skip to contentSkip to conversation

Add support for Embest SBC2440-II Board 3/7

U-Boot kevin.morfitt at fearnside-systems.co.uk 2 participants 2 messages Jun 25, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

This patch re-formats the s3c24x0 driver code, excluding the MTD NAND driver which is in patch 4, in preparation for changes to make the NAND driver support both s3c2410 and s3c2440 CPU's, ready for the addition of the Embest SBC2440-II Board.

The changes are as follows:

- re-indent the code using Lindent
- mak sure register layouts are defined using a C struct, from a comment by Wolfgang on 03/06/2009
- replace the upper-case typedef'ed C struct names with lower case non-typedef'ed ones, from a comment by Scott on 22/06/2009
- make sure registers are accessed using the proper accessor functions, from a comment by Wolfgang on 03/06/2009
- run checkpatch.pl and fix any error reports

---
 board/mpl/vcma9/vcma9.c           |    7 +-
 board/mpl/vcma9/vcma9.h           |   18 ++--
 board/samsung/smdk2400/smdk2400.c |    5 +-
 board/samsung/smdk2410/smdk2410.c |    5 +-
 board/sbc2410x/sbc2410x.c         |    7 +-
 board/trab/cmd_trab.c             |    8 +-
 board/trab/rs485.c                |   12 +-
 board/trab/trab.c                 |   17 ++-
 board/trab/trab_fkt.c             |   22 ++--
 board/trab/tsc2000.c              |   17 ++-
 board/trab/tsc2000.h              |    4 +-
 board/trab/vfd.c                  |   12 +-
 drivers/i2c/s3c24x0_i2c.c         |  273 +++++++++++++++++++------------------
 drivers/rtc/s3c24x0_rtc.c         |  134 +++++++++---------
 drivers/serial/serial_s3c24x0.c   |  160 ++++++++++++----------
 15 files changed, 368 insertions(+), 333 deletions(-)
board/mpl/vcma9/vcma9.c +4 -3
index a4c463a..3d0947d 100644
@@ -71,8 +71,9 @@ static inline void delay(unsigned long loops)
 
 int board_init(void)
 {
-	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_clock_power * const clk_power =
+					S3C24X0_GetBase_CLOCK_POWER();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* to reduce PLL lock time, adjust the LOCKTIME register */
 	clk_power->LOCKTIME = 0xFFFFFF;
@@ -172,7 +173,7 @@ static inline void NF_Init(void)
 void
 nand_init(void)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	NF_Init();
 #ifdef DEBUG
board/mpl/vcma9/vcma9.h +9 -9
index 220b705..8f98e9e 100644
@@ -39,14 +39,14 @@ typedef enum {
 
 static inline void NF_Conf(u16 conf)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	nand->NFCONF = conf;
 }
 
 static inline void NF_Cmd(u8 cmd)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	nand->NFCMD = cmd;
 }
@@ -59,14 +59,14 @@ static inline void NF_CmdW(u8 cmd)
 
 static inline void NF_Addr(u8 addr)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	nand->NFADDR = addr;
 }
 
 static inline void NF_SetCE(NFCE_STATE s)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	switch (s) {
 		case NFCE_LOW:
@@ -81,35 +81,35 @@ static inline void NF_SetCE(NFCE_STATE s)
 
 static inline void NF_WaitRB(void)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	while (!(nand->NFSTAT & (1<<0)));
 }
 
 static inline void NF_Write(u8 data)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	nand->NFDATA = data;
 }
 
 static inline u8 NF_Read(void)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	return(nand->NFDATA);
 }
 
 static inline void NF_Init_ECC(void)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	nand->NFCONF |= (1<<12);
 }
 
 static inline u32 NF_Read_ECC(void)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	return(nand->NFECC);
 }
board/samsung/smdk2400/smdk2400.c +3 -2
index 0b82070..9f75d01 100644
@@ -45,8 +45,9 @@ extern int do_mdm_init; /* defined in common/main.c */
 
 int board_init (void)
 {
-	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_clock_power * const clk_power =
+					S3C24X0_GetBase_CLOCK_POWER();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* memory and cpu-speed are setup before relocation */
 	/* change the clock to be 50 MHz 1:1:1 */
board/samsung/smdk2410/smdk2410.c +3 -2
index 802348d..e54ea16 100644
@@ -67,8 +67,9 @@ static inline void delay (unsigned long loops)
 
 int board_init (void)
 {
-	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_clock_power * const clk_power =
+					S3C24X0_GetBase_CLOCK_POWER();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* to reduce PLL lock time, adjust the LOCKTIME register */
 	clk_power->LOCKTIME = 0xFFFFFF;
board/sbc2410x/sbc2410x.c +4 -3
index 6c894a3..ed7fe18 100644
@@ -74,8 +74,9 @@ static inline void delay (unsigned long loops)
 
 int board_init (void)
 {
-	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_clock_power * const clk_power =
+					S3C24X0_GetBase_CLOCK_POWER();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* to reduce PLL lock time, adjust the LOCKTIME register */
 	clk_power->LOCKTIME = 0xFFFFFF;
@@ -169,7 +170,7 @@ static inline void NF_Init(void)
 
 void nand_init(void)
 {
-	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
+	struct s3c2410_nand * const nand = S3C2410_GetBase_NAND();
 
 	NF_Init();
 #ifdef DEBUG
board/trab/cmd_trab.c +4 -4
index d0465fb..2df6767 100644
@@ -644,7 +644,7 @@ static int adc_read (unsigned int channel)
 {
 	int j = 1000; /* timeout value for wait loop in us */
 	int result;
-	S3C2400_ADC *padc;
+	struct s3c2400_adc *padc;
 
 	padc = S3C2400_GetBase_ADC();
 	channel &= 0x7;
@@ -686,7 +686,7 @@ static int adc_read (unsigned int channel)
 
 static void adc_init (void)
 {
-	S3C2400_ADC *padc;
+	struct s3c2400_adc *padc;
 
 	padc = S3C2400_GetBase_ADC();
 
@@ -707,7 +707,7 @@ static void adc_init (void)
 
 static void led_set (unsigned int state)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	led_init ();
 
@@ -740,7 +740,7 @@ static void led_blink (void)
 
 static void led_init (void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* configure GPA12 as output and set to High -> LED off */
 	gpio->PACON &= ~(1 << 12);
board/trab/rs485.c +6 -6
index 97aea91..3d2471f 100644
@@ -42,7 +42,7 @@ static void trab_rs485_disable_rx(void);
 
 static void rs485_setbrg (void)
 {
-	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+	struct s3c24x0_uart * const uart = S3C24X0_GetBase_UART(UART_NR);
 	int i;
 	unsigned int reg = 0;
 
@@ -67,7 +67,7 @@ static void rs485_setbrg (void)
 
 static void rs485_cfgio (void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	gpio->PFCON &= ~(0x3 << 2);
 	gpio->PFCON |=  (0x2 << 2); /* configure GPF1 as RXD1 */
@@ -101,7 +101,7 @@ int rs485_init (void)
  */
 int rs485_getc (void)
 {
-	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+	struct s3c24x0_uart * const uart = S3C24X0_GetBase_UART(UART_NR);
 
 	/* wait for character to arrive */
 	while (!(uart->UTRSTAT & 0x1));
@@ -114,7 +114,7 @@ int rs485_getc (void)
  */
 void rs485_putc (const char c)
 {
-	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+	struct s3c24x0_uart * const uart = S3C24X0_GetBase_UART(UART_NR);
 
 	/* wait for room in the tx FIFO */
 	while (!(uart->UTRSTAT & 0x2));
@@ -131,7 +131,7 @@ void rs485_putc (const char c)
  */
 int rs485_tstc (void)
 {
-	S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
+	struct s3c24x0_uart * const uart = S3C24X0_GetBase_UART(UART_NR);
 
 	return uart->UTRSTAT & 0x1;
 }
@@ -168,7 +168,7 @@ static void set_rs485re(unsigned char rs485re_state)
 
 static void set_rs485de(unsigned char rs485de_state)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* This is on PORT A bit 11 */
 	if(rs485de_state)
board/trab/trab.c +9 -8
index ddf6abf..78edffb 100644
@@ -68,8 +68,9 @@ int board_init ()
 #if defined(CONFIG_VFD)
 	extern int vfd_init_clocks(void);
 #endif
-	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_clock_power * const clk_power =
+					S3C24X0_GetBase_CLOCK_POWER();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* memory and cpu-speed are setup before relocation */
 #ifdef CONFIG_TRAB_50MHZ
@@ -337,22 +338,22 @@ static int key_pressed(void)
 
 static inline void SET_CS_TOUCH(void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	gpio->PDDAT &= 0x5FF;
 }
 
 static inline void CLR_CS_TOUCH(void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	gpio->PDDAT |= 0x200;
 }
 
 static void spi_init(void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-	S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_spi * const spi = S3C24X0_GetBase_SPI();
 	int i;
 
 	/* Configure I/O ports. */
@@ -376,7 +377,7 @@ static void spi_init(void)
 
 static void wait_transmit_done(void)
 {
-	S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
+	struct s3c24x0_spi * const spi = S3C24X0_GetBase_SPI();
 
 	while (!(spi->ch[0].SPSTA & 0x01)); /* wait until transfer is done */
 }
@@ -384,7 +385,7 @@ static void wait_transmit_done(void)
 static void tsc2000_write(unsigned int page, unsigned int reg,
 						  unsigned int data)
 {
-	S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
+	struct s3c24x0_spi * const spi = S3C24X0_GetBase_SPI();
 	unsigned int command;
 
 	SET_CS_TOUCH();
board/trab/trab_fkt.c +11 -11
index 53cdb5a..7626133 100644
@@ -406,7 +406,7 @@ static int adc_read (unsigned int channel)
 {
 	int j = 1000; /* timeout value for wait loop in us */
 	int result;
-	S3C2400_ADC *padc;
+	struct s3c2400_adc *padc;
 
 	padc = S3C2400_GetBase_ADC();
 	channel &= 0x7;
@@ -446,7 +446,7 @@ static int adc_read (unsigned int channel)
 
 static void adc_init (void)
 {
-	S3C2400_ADC *padc;
+	struct s3c2400_adc *padc;
 
 	padc = S3C2400_GetBase_ADC();
 
@@ -490,7 +490,7 @@ int do_power_switch (void)
 {
 	int result;
 
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* configure GPE7 as input */
 	gpio->PECON &= ~(0x3 << (2 * 7));
@@ -557,7 +557,7 @@ int do_vfd_id (void)
 	int i;
 	long int pcup_old, pccon_old;
 	int vfd_board_id;
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* try to red vfd board id from the value defined by pull-ups */
 
@@ -589,8 +589,8 @@ int do_buzzer (char **argv)
 {
 	int counter;
 
-	S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_timers * const timers = S3C24X0_GetBase_TIMERS();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* set prescaler for timer 2, 3 and 4 */
 	timers->TCFG0 &= ~0xFF00;
@@ -637,7 +637,7 @@ int do_buzzer (char **argv)
 
 int do_led (char **argv)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* configure PC14 and PC15 as output */
 	gpio->PCCON &= ~(0xF << 28);
@@ -692,7 +692,7 @@ int do_led (char **argv)
 
 int do_full_bridge (char **argv)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* configure PD5 and PD6 as output */
 	gpio->PDCON &= ~((0x3 << 5*2) | (0x3 << 6*2));
@@ -801,7 +801,7 @@ int do_motor_contact (void)
 
 int do_motor (char **argv)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	/* Configure I/O port */
 	gpio->PGCON &= ~(0x3 << 0);
@@ -827,8 +827,8 @@ static void print_identifier (void)
 int do_pwm (char **argv)
 {
 	int counter;
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-	S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_timers * const timers = S3C24X0_GetBase_TIMERS();
 
 	if (strcmp (argv[2], "on") == 0) {
 		/* configure pin GPD8 as TOUT3 */
board/trab/tsc2000.c +9 -8
index f13a5a9..9a13632 100644
@@ -27,6 +27,7 @@
 
 #include <common.h>
 #include <s3c2400.h>
+#include <asm/io.h>
 #include <div64.h>
 #include "tsc2000.h"
 
@@ -44,8 +45,8 @@
 
 void spi_init(void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-	S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_spi * const spi = S3C24X0_GetBase_SPI();
 	int i;
 
 	/* Configure I/O ports. */
@@ -71,7 +72,7 @@ void spi_init(void)
 
 void spi_wait_transmit_done(void)
 {
-	S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
+	struct s3c24x0_spi * const spi = S3C24X0_GetBase_SPI();
 
 	while (!(spi->ch[0].SPSTA & 0x01)); /* wait until transfer is done */
 }
@@ -79,7 +80,7 @@ void spi_wait_transmit_done(void)
 
 void tsc2000_write(unsigned short reg, unsigned short data)
 {
-	S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
+	struct s3c24x0_spi * const spi = S3C24X0_GetBase_SPI();
 	unsigned int command;
 
 	SET_CS_TOUCH();
@@ -100,7 +101,7 @@ void tsc2000_write(unsigned short reg, unsigned short data)
 unsigned short tsc2000_read (unsigned short reg)
 {
 	unsigned short command, data;
-	S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
+	struct s3c24x0_spi * const spi = S3C24X0_GetBase_SPI();
 
 	SET_CS_TOUCH();
 	command = 0x8000 | reg;
@@ -123,7 +124,7 @@ unsigned short tsc2000_read (unsigned short reg)
 
 void tsc2000_set_mux (unsigned int channel)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	CLR_MUX1_ENABLE; CLR_MUX2_ENABLE;
 	CLR_MUX3_ENABLE; CLR_MUX4_ENABLE;
@@ -200,7 +201,7 @@ void tsc2000_set_mux (unsigned int channel)
 
 void tsc2000_set_range (unsigned int range)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	switch (range) {
 	case 1:
@@ -306,7 +307,7 @@ s32 tsc2000_contact_temp (void)
 
 void tsc2000_reg_init (void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	tsc2000_write(TSC2000_REG_ADC, 0x2036);
 	tsc2000_write(TSC2000_REG_REF, 0x0011);
board/trab/tsc2000.h +2 -2
index af1b644..a5b81ca 100644
@@ -128,7 +128,7 @@ void adc_wait_conversion_done(void);
 
 static inline void SET_CS_TOUCH(void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	gpio->PDDAT &= 0x5FF;
 }
@@ -136,7 +136,7 @@ static inline void SET_CS_TOUCH(void)
 
 static inline void CLR_CS_TOUCH(void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	gpio->PDDAT |= 0x200;
 }
board/trab/vfd.c +6 -6
index 37d3aa4..df25ba9 100644
@@ -358,9 +358,9 @@ int vfd_init_clocks (void)
 {
 	int i;
 
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-	S3C24X0_TIMERS * const timers = S3C24X0_GetBase_TIMERS();
-	S3C24X0_LCD * const lcd = S3C24X0_GetBase_LCD();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_timers * const timers = S3C24X0_GetBase_TIMERS();
+	struct s3c24x0_lcd * const lcd = S3C24X0_GetBase_LCD();
 
 	/* try to determine display type from the value
 	 * defined by pull-ups
@@ -429,8 +429,8 @@ int vfd_init_clocks (void)
  */
 int drv_vfd_init(void)
 {
-	S3C24X0_LCD * const lcd = S3C24X0_GetBase_LCD();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_lcd * const lcd = S3C24X0_GetBase_LCD();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 	char *tmp;
 	ulong palette;
 	static int vfd_init_done = 0;
@@ -529,7 +529,7 @@ int drv_vfd_init(void)
  */
 void disable_vfd (void)
 {
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	struct s3c24x0_gpio * const gpio = S3C24X0_GetBase_GPIO();
 
 	VFD_DISABLE;
 	gpio->PDCON &= ~0xC;
drivers/i2c/s3c24x0_i2c.c +139 -134

496 lines not on this page · raw message

drivers/rtc/s3c24x0_rtc.c +68 -66

208 lines not on this page · raw message

drivers/serial/serial_s3c24x0.c +91 -69

297 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#1 lore raw

Hi Kevin,

Quoted 8 lines

This patch re-formats the s3c24x0 driver code, excluding the MTD NAND driver which is in patch 4, in preparation for changes to make the NAND driver support both s3c2410 and s3c2440 CPU's, ready for the addition of the Embest SBC2440-II Board.

The changes are as follows:

- re-indent the code using Lindent

If it is at all possible, then please split indentation changes into a seprate commit. Not doing this makes such a big patch especially hard to review as "real" changes can hide behind indentation changes.

Also we do not believe that using Lindent fully automatic is a good idea. If you look at the review below, sometimes nice indentation is lost this way.

Quoted 4 lines

- mak sure register layouts are defined using a C struct, from a comment by Wolfgang on 03/06/2009
- replace the upper-case typedef'ed C struct names with lower case non-typedef'ed ones, from a comment by Scott on 22/06/2009

I don't see that we get rid of the typedefs though - are they still used elsewhere?

Quoted 5 lines

- make sure registers are accessed using the proper accessor functions, from a comment by Wolfgang on 03/06/2009
- run checkpatch.pl and fix any error reports

Apart from that changes look good. I especially looked at the trab/smdk2400 changes.

Quoted 18 lines
---
 board/mpl/vcma9/vcma9.c           |    7 +-
 board/mpl/vcma9/vcma9.h           |   18 ++--
 board/samsung/smdk2400/smdk2400.c |    5 +-
 board/samsung/smdk2410/smdk2410.c |    5 +-
 board/sbc2410x/sbc2410x.c         |    7 +-
 board/trab/cmd_trab.c             |    8 +-
 board/trab/rs485.c                |   12 +-
 board/trab/trab.c                 |   17 ++-
 board/trab/trab_fkt.c             |   22 ++--
 board/trab/tsc2000.c              |   17 ++-
 board/trab/tsc2000.h              |    4 +-
 board/trab/vfd.c                  |   12 +-
 drivers/i2c/s3c24x0_i2c.c         |  273 +++++++++++++++++++------------------
 drivers/rtc/s3c24x0_rtc.c         |  134 +++++++++---------
 drivers/serial/serial_s3c24x0.c   |  160 ++++++++++++----------
 15 files changed, 368 insertions(+), 333 deletions(-)

[...]

Quoted 36 lines
drivers/rtc/s3c24x0_rtc.c +11 -15
-int rtc_get (struct rtc_time *tmp)
+int rtc_get(struct rtc_time *tmp)
 {
-	S3C24X0_RTC * const rtc = S3C24X0_GetBase_RTC();
+	struct s3c24x0_rtc *rtc = S3C24X0_GetBase_RTC();
 	uchar sec, min, hour, mday, wday, mon, year;
-	uchar a_sec,a_min, a_hour, a_date, a_mon, a_year, a_armed;
+	uchar a_sec, a_min, a_hour, a_date, a_mon, a_year, a_armed;
 
 	/* enable access to RTC registers */
 	SetRTC_Access(RTC_ENABLE);
 
 	/* read RTC registers */
 	do {
-		sec	= rtc->BCDSEC;
-		min	= rtc->BCDMIN;
-		hour	= rtc->BCDHOUR;
-		mday	= rtc->BCDDATE;
-		wday	= rtc->BCDDAY;
-		mon	= rtc->BCDMON;
-		year	= rtc->BCDYEAR;
-	} while (sec != rtc->BCDSEC);
+		sec = readb(&rtc->BCDSEC);
+		min = readb(&rtc->BCDMIN);
+		hour = readb(&rtc->BCDHOUR);
+		mday = readb(&rtc->BCDDATE);
+		wday = readb(&rtc->BCDDAY);
+		mon = readb(&rtc->BCDMON);
+		year = readb(&rtc->BCDYEAR);
+	} while (sec != readb(&rtc->BCDSEC));
 
 	/* read ALARM registers */
-	a_sec	= rtc->ALMSEC;
-	a_min	= rtc->ALMMIN;
-	a_hour	= rtc->ALMHOUR;
-	a_date	= rtc->ALMDATE;

drivers/rtc/s3c24x0_rtc.c typedef enum { · line 104

Quoted 10 lines
drivers/rtc/s3c24x0_rtc.c +7 -3
-	a_mon	= rtc->ALMMON;
-	a_year	= rtc->ALMYEAR;
-	a_armed	= rtc->RTCALM;
+	a_sec = readb(&rtc->ALMSEC);
+	a_min = readb(&rtc->ALMMIN);
+	a_hour = readb(&rtc->ALMHOUR);
+	a_date = readb(&rtc->ALMDATE);
+	a_mon = readb(&rtc->ALMMON);
+	a_year = readb(&rtc->ALMYEAR);
+	a_armed = readb(&rtc->RTCALM);

Nice indentations which make the code actually easier to read are lost.

[...]

drivers/rtc/s3c24x0_rtc.c typedef enum { · line 124

Quoted 10 lines
drivers/rtc/s3c24x0_rtc.c +3 -3
-	tmp->tm_sec  = bcd2bin(sec  & 0x7F);
-	tmp->tm_min  = bcd2bin(min  & 0x7F);
+	tmp->tm_sec = bcd2bin(sec & 0x7F);
+	tmp->tm_min = bcd2bin(min & 0x7F);
 	tmp->tm_hour = bcd2bin(hour & 0x3F);
 	tmp->tm_mday = bcd2bin(mday & 0x3F);
-	tmp->tm_mon  = bcd2bin(mon & 0x1F);
+	tmp->tm_mon = bcd2bin(mon & 0x1F);
 	tmp->tm_year = bcd2bin(year);
 	tmp->tm_wday = bcd2bin(wday & 0x07);

Ditto.

[...]

Quoted 19 lines
drivers/rtc/s3c24x0_rtc.c +5 -9
-int rtc_set (struct rtc_time *tmp)
+int rtc_set(struct rtc_time *tmp)
 {
-	S3C24X0_RTC * const rtc = S3C24X0_GetBase_RTC();
+	struct s3c24x0_rtc *rtc = S3C24X0_GetBase_RTC();
 	uchar sec, min, hour, mday, wday, mon, year;
 
 #ifdef RTC_DEBUG
-	printf ( "Set DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
-		tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
-		tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+	printf("Set DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
+	       tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
+	       tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
 #endif
-	year	= bin2bcd(tmp->tm_year % 100);
-	mon	= bin2bcd(tmp->tm_mon);
-	wday	= bin2bcd(tmp->tm_wday);
-	mday	= bin2bcd(tmp->tm_mday);

drivers/rtc/s3c24x0_rtc.c typedef enum { · line 156

Quoted 10 lines
drivers/rtc/s3c24x0_rtc.c +7 -3
-	hour	= bin2bcd(tmp->tm_hour);
-	min	= bin2bcd(tmp->tm_min);
-	sec	= bin2bcd(tmp->tm_sec);
+	year = bin2bcd(tmp->tm_year % 100);
+	mon = bin2bcd(tmp->tm_mon);
+	wday = bin2bcd(tmp->tm_wday);
+	mday = bin2bcd(tmp->tm_mday);
+	hour = bin2bcd(tmp->tm_hour);
+	min = bin2bcd(tmp->tm_min);
+	sec = bin2bcd(tmp->tm_sec);

Ditto.

Quoted 9 lines
drivers/rtc/s3c24x0_rtc.c +0 -4
 	/* enable access to RTC registers */
 	SetRTC_Access(RTC_ENABLE);
 
 	/* write RTC registers */
-	rtc->BCDSEC	= sec;
-	rtc->BCDMIN	= min;
-	rtc->BCDHOUR	= hour;
-	rtc->BCDDATE	= mday;

drivers/rtc/s3c24x0_rtc.c typedef enum { · line 168

Quoted 10 lines
drivers/rtc/s3c24x0_rtc.c +7 -3
-	rtc->BCDDAY	= wday;
-	rtc->BCDMON	= mon;
-	rtc->BCDYEAR	= year;
+	writeb(sec, &rtc->BCDSEC);
+	writeb(min, &rtc->BCDMIN);
+	writeb(hour, &rtc->BCDHOUR);
+	writeb(mday, &rtc->BCDDATE);
+	writeb(wday, &rtc->BCDDAY);
+	writeb(mon, &rtc->BCDMON);
+	writeb(year, &rtc->BCDYEAR);

And again.

[...]

Quoted 6 lines
drivers/serial/serial_s3c24x0.c +1 -1
@@ -289,12 +312,11 @@ serial_puts (const char *s)
 #if defined(CONFIG_SERIAL_MULTI)
 DECLARE_S3C_SERIAL_FUNCTIONS(0);
 struct serial_device s3c24xx_serial0_device =
-	INIT_S3C_SERIAL_STRUCTURE(0, "s3ser0", "S3UART1");
+INIT_S3C_SERIAL_STRUCTURE(0, "s3ser0", "S3UART1");

drivers/serial/serial_s3c24x0.c serial_puts (const char *s) · line 322

Quoted 10 lines
drivers/serial/serial_s3c24x0.c +2 -3
 DECLARE_S3C_SERIAL_FUNCTIONS(1);
 struct serial_device s3c24xx_serial1_device =
-	INIT_S3C_SERIAL_STRUCTURE(1, "s3ser1", "S3UART2");
+INIT_S3C_SERIAL_STRUCTURE(1, "s3ser1", "S3UART2");
 DECLARE_S3C_SERIAL_FUNCTIONS(2);
 struct serial_device s3c24xx_serial2_device =
-	INIT_S3C_SERIAL_STRUCTURE(2, "s3ser2", "S3UART3");
-
+INIT_S3C_SERIAL_STRUCTURE(2, "s3ser2", "S3UART3");
 #endif /* CONFIG_SERIAL_MULTI */

Why is there no indentation here? The previous version looked better.

Cheers
Detlev

Signature · 6 lines
When critics disagree the artist is in accord with himself.
                                    --- Oscar Wilde
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de