serial: samsung: merge all SoC specific port reset functions
authorThomas Abraham <thomas.abraham@linaro.org>
Mon, 24 Oct 2011 09:48:21 +0000 (11:48 +0200)
committerKukjin Kim <kgene.kim@samsung.com>
Fri, 23 Dec 2011 01:06:59 +0000 (10:06 +0900)
The port reset function in each of the platform specific extension performs
the same operations and hence all the reset port functions can be merged into
one and moved into the common samsung uart driver. The SoC specific port reset
functions are removed from SoC extensions.

Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
drivers/tty/serial/s3c2410.c
drivers/tty/serial/s3c2412.c
drivers/tty/serial/s3c2440.c
drivers/tty/serial/s3c6400.c
drivers/tty/serial/s5pv210.c
drivers/tty/serial/samsung.c

index e668a9d2bbc9661c313f0fcba264a520e4d89229..1491c32d1436fd595c48588bb6bb226e7ab3574b 100644 (file)
 
 #include "samsung.h"
 
-static int s3c2410_serial_resetport(struct uart_port *port,
-                                   struct s3c2410_uartcfg *cfg)
-{
-       dbg("s3c2410_serial_resetport: port=%p (%08lx), cfg=%p\n",
-           port, port->mapbase, cfg);
-
-       wr_regl(port, S3C2410_UCON,  cfg->ucon);
-       wr_regl(port, S3C2410_ULCON, cfg->ulcon);
-
-       /* reset both fifos */
-
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon);
-
-       return 0;
-}
-
 static struct s3c24xx_uart_info s3c2410_uart_inf = {
        .name           = "Samsung S3C2410 UART",
        .type           = PORT_S3C2410,
@@ -56,7 +39,6 @@ static struct s3c24xx_uart_info s3c2410_uart_inf = {
        .num_clks       = 2,
        .clksel_mask    = S3C2410_UCON_CLKMASK,
        .clksel_shift   = S3C2410_UCON_CLKSHIFT,
-       .reset_port     = s3c2410_serial_resetport,
 };
 
 static int s3c2410_serial_probe(struct platform_device *dev)
index 5b85c1953c51bd607857ad2707bccb14e73b1c12..38ae730307dfe174d20ee493915265b68107082d 100644 (file)
 
 #include "samsung.h"
 
-static int s3c2412_serial_resetport(struct uart_port *port,
-                                   struct s3c2410_uartcfg *cfg)
-{
-       unsigned long ucon = rd_regl(port, S3C2410_UCON);
-
-       dbg("%s: port=%p (%08lx), cfg=%p\n",
-           __func__, port, port->mapbase, cfg);
-
-       /* ensure we don't change the clock settings... */
-
-       ucon &= S3C2412_UCON_CLKMASK;
-
-       wr_regl(port, S3C2410_UCON,  ucon | cfg->ucon);
-       wr_regl(port, S3C2410_ULCON, cfg->ulcon);
-
-       /* reset both fifos */
-
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon);
-
-       return 0;
-}
-
 static struct s3c24xx_uart_info s3c2412_uart_inf = {
        .name           = "Samsung S3C2412 UART",
        .type           = PORT_S3C2412,
@@ -63,7 +40,6 @@ static struct s3c24xx_uart_info s3c2412_uart_inf = {
        .num_clks       = 4,
        .clksel_mask    = S3C2412_UCON_CLKMASK,
        .clksel_shift   = S3C2412_UCON_CLKSHIFT,
-       .reset_port     = s3c2412_serial_resetport,
 };
 
 /* device management */
index 39930f819fa27e0df2d65f3f90692fc2577faf52..70652f56ab605a1fbb774e31256c2888ec1366b0 100644 (file)
 
 #include "samsung.h"
 
-static int s3c2440_serial_resetport(struct uart_port *port,
-                                   struct s3c2410_uartcfg *cfg)
-{
-       unsigned long ucon = rd_regl(port, S3C2410_UCON);
-
-       dbg("s3c2440_serial_resetport: port=%p (%08lx), cfg=%p\n",
-           port, port->mapbase, cfg);
-
-       /* ensure we don't change the clock settings... */
-
-       ucon &= (S3C2440_UCON0_DIVMASK | (3<<10));
-
-       wr_regl(port, S3C2410_UCON,  ucon | cfg->ucon);
-       wr_regl(port, S3C2410_ULCON, cfg->ulcon);
-
-       /* reset both fifos */
-
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon);
-
-       return 0;
-}
-
 static struct s3c24xx_uart_info s3c2440_uart_inf = {
        .name           = "Samsung S3C2440 UART",
        .type           = PORT_S3C2440,
@@ -62,7 +39,6 @@ static struct s3c24xx_uart_info s3c2440_uart_inf = {
        .num_clks       = 4,
        .clksel_mask    = S3C2440_UCON_CLKMASK,
        .clksel_shift   = S3C2440_UCON_CLKSHIFT,
-       .reset_port     = s3c2440_serial_resetport,
 };
 
 /* device management */
index c5a6d46450894c8ccee0c8ee9df8c0140fc39a37..30a69f1cd3e69dd5fd149d42ff1e6cb7d57a1bf3 100644 (file)
 
 #include "samsung.h"
 
-static int s3c6400_serial_resetport(struct uart_port *port,
-                                   struct s3c2410_uartcfg *cfg)
-{
-       unsigned long ucon = rd_regl(port, S3C2410_UCON);
-
-       dbg("s3c6400_serial_resetport: port=%p (%08lx), cfg=%p\n",
-           port, port->mapbase, cfg);
-
-       /* ensure we don't change the clock settings... */
-
-       ucon &= S3C6400_UCON_CLKMASK;
-
-       wr_regl(port, S3C2410_UCON,  ucon | cfg->ucon);
-       wr_regl(port, S3C2410_ULCON, cfg->ulcon);
-
-       /* reset both fifos */
-
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon);
-
-       return 0;
-}
-
 static struct s3c24xx_uart_info s3c6400_uart_inf = {
        .name           = "Samsung S3C6400 UART",
        .type           = PORT_S3C6400,
@@ -64,7 +41,6 @@ static struct s3c24xx_uart_info s3c6400_uart_inf = {
        .num_clks       = 4,
        .clksel_mask    = S3C6400_UCON_CLKMASK,
        .clksel_shift   = S3C6400_UCON_CLKSHIFT,
-       .reset_port     = s3c6400_serial_resetport,
 };
 
 /* device management */
index 173df5afb0fa3933e3571d08f4f00ae82f0aadbf..d23209460dd3c1d03f88e557897239be5b616193 100644 (file)
 #include <plat/regs-serial.h>
 #include "samsung.h"
 
-static int s5pv210_serial_resetport(struct uart_port *port,
-                                       struct s3c2410_uartcfg *cfg)
-{
-       unsigned long ucon = rd_regl(port, S3C2410_UCON);
-
-       ucon &= S5PV210_UCON_CLKMASK;
-       wr_regl(port, S3C2410_UCON,  ucon | cfg->ucon);
-       wr_regl(port, S3C2410_ULCON, cfg->ulcon);
-
-       /* reset both fifos */
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
-       wr_regl(port, S3C2410_UFCON, cfg->ufcon);
-
-       /* It is need to delay When reset FIFO register */
-       udelay(1);
-
-       return 0;
-}
-
 #define S5PV210_UART_DEFAULT_INFO(fifo_size)                   \
                .name           = "Samsung S5PV210 UART0",      \
                .type           = PORT_S3C6400,                 \
@@ -58,8 +39,7 @@ static int s5pv210_serial_resetport(struct uart_port *port,
                .def_clk_sel    = S3C2410_UCON_CLKSEL0,         \
                .num_clks       = 2,                            \
                .clksel_mask    = S5PV210_UCON_CLKMASK,         \
-               .clksel_shift   = S5PV210_UCON_CLKSHIFT,        \
-               .reset_port     = s5pv210_serial_resetport
+               .clksel_shift   = S5PV210_UCON_CLKSHIFT
 
 static struct s3c24xx_uart_info s5p_port_fifo256 = {
        S5PV210_UART_DEFAULT_INFO(256),
index dc5a4edbc4500812200d71d0006b1b2fd5d41434..78aea1a49ad81af2e7f0a3890ee97b2d50a6dfb0 100644 (file)
@@ -965,16 +965,29 @@ static struct s3c24xx_uart_port s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS
 
 /* s3c24xx_serial_resetport
  *
- * wrapper to call the specific reset for this port (reset the fifos
- * and the settings)
+ * reset the fifos and other the settings.
 */
 
-static inline int s3c24xx_serial_resetport(struct uart_port *port,
-                                          struct s3c2410_uartcfg *cfg)
+static void s3c24xx_serial_resetport(struct uart_port *port,
+                                  struct s3c2410_uartcfg *cfg)
 {
        struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+       unsigned long ucon = rd_regl(port, S3C2410_UCON);
+       unsigned int ucon_mask;
 
-       return (info->reset_port)(port, cfg);
+       ucon_mask = info->clksel_mask;
+       if (info->type == PORT_S3C2440)
+               ucon_mask |= S3C2440_UCON0_DIVMASK;
+
+       ucon &= ucon_mask;
+       wr_regl(port, S3C2410_UCON,  ucon | cfg->ucon);
+
+       /* reset both fifos */
+       wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
+       wr_regl(port, S3C2410_UFCON, cfg->ufcon);
+
+       /* some delay is required after fifo reset */
+       udelay(1);
 }