s5j/serial: fix initialization order
authorHeesub Shin <heesub.shin@samsung.com>
Tue, 12 Sep 2017 05:07:36 +0000 (14:07 +0900)
committersunghan <sh924.chang@samsung.com>
Wed, 20 Sep 2017 08:45:57 +0000 (17:45 +0900)
GPIO pinmux configuration should be done before starting to supply PCLK
and EXTCLK to UART when opening it. Otherwise, a noise signal may be
introduced into the receiving FIFO, causing an odd RX interrupt. For the
same reason, this also applies when closing it.

This commit fixes the issue that select() and poll() fails on serial
devices.

Change-Id: I05309a1637574936f53a529d018dd28600b14295
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
os/arch/arm/src/s5j/s5j_serial.c

index fcb784b..77594b3 100644 (file)
@@ -320,19 +320,6 @@ static void up_configure(struct up_dev_s *priv)
 
        /* Ensure that UART clock is supplied... */
 
-       /* Configure pinmux to set function for RXD/TXD/RTS/CTS pins */
-       s5j_configgpio(priv->rxd);
-       s5j_configgpio(priv->txd);
-#if defined(CONFIG_S5J_UART_FLOWCONTROL)
-       if (priv->rts) {
-               s5j_configgpio(priv->rts);
-       }
-
-       if (priv->cts) {
-               s5j_configgpio(priv->cts);
-       }
-#endif
-
        /* UMCON */
        if (priv->rts || priv->cts) {
                /* nRTS and nCTS are controlled by hardware */
@@ -400,6 +387,19 @@ static int up_setup(struct uart_dev_s *dev)
 {
        struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
 
+       /* Configure pinmux to set function for RXD/TXD/RTS/CTS pins */
+       s5j_configgpio(priv->rxd);
+       s5j_configgpio(priv->txd);
+#if defined(CONFIG_S5J_UART_FLOWCONTROL)
+       if (priv->rts) {
+               s5j_configgpio(priv->rts);
+       }
+
+       if (priv->cts) {
+               s5j_configgpio(priv->cts);
+       }
+#endif
+
        s5j_clk_enable(priv->pclk);
        s5j_clk_enable(priv->extclk);
 
@@ -438,6 +438,9 @@ static void up_shutdown(struct uart_dev_s *dev)
        uart_modifyreg32(priv, S5J_UART_UINTM_OFFSET, 0,
                                        UART_UINTM_TXD_MASK | UART_UINTM_RXD_MASK);
 
+       s5j_clk_disable(priv->pclk);
+       s5j_clk_disable(priv->extclk);
+
        s5j_unconfiggpio(priv->rxd);
        s5j_unconfiggpio(priv->txd);
 
@@ -450,9 +453,6 @@ static void up_shutdown(struct uart_dev_s *dev)
                s5j_unconfiggpio(priv->cts);
        }
 #endif
-
-       s5j_clk_disable(priv->pclk);
-       s5j_clk_disable(priv->extclk);
 }
 
 /****************************************************************************