[PATCH V2 11/14] Serial: sc26xx - initialise hardware if not done by bootloader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If hardware is not initialised by bootloader after a hard reset
the MR1,MR2 registers may be 0xFF.
This causes the transmitter to never initialise and an infinite
loop to occur later.

Acked-By: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>

Signed-off-by: Martin Fuzzey <mfuzzey@xxxxxxxxx>

---

 drivers/serial/sc26xx.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/sc26xx.c b/drivers/serial/sc26xx.c
index 09e73a3..2e17bbc 100644
--- a/drivers/serial/sc26xx.c
+++ b/drivers/serial/sc26xx.c
@@ -832,6 +832,27 @@ static const struct chip_def * __devinit detect_chip_type(
 	return chip;
 }
 
+static void __devinit hw_init(struct uart_port *port)
+{
+	u8 mr;
+
+	/* Sometimes on cold boot MR1,MR2 are 0xFF (reset problem?)
+	 * Initialise if channel mode in MR2 is not normal otherwise
+	 * assume bootloader has done the init.
+	 */
+	write_cmd_port(port, CR_RES_MR); /* MR1 */
+	READ_SC_PORT(port, MRx); /* skip MR1 */
+	mr = READ_SC_PORT(port, MRx);
+	if (mr & 0xC0) {
+		write_cmd_port(port, CR_RES_MR);
+
+		/* Values below are arbitary (will be changed by set_termios)
+		 * but must be different so that chip detection works */
+		WRITE_SC_PORT(port, MRx, 0x10);
+		WRITE_SC_PORT(port, MRx, 0x00);
+	}
+}
+
 static int __devinit sc26xx_probe(struct platform_device *dev)
 {
 	struct resource *res, *irq_res;
@@ -869,6 +890,7 @@ static int __devinit sc26xx_probe(struct platform_device *dev)
 	up->port[0].dev = &dev->dev;
 
 	sc26xx_init_masks(up, 0, pdata->signal_map[0]);
+	hw_init(&up->port[0]);
 
 	sc26xx_port = &up->port[0];
 
@@ -876,6 +898,7 @@ static int __devinit sc26xx_probe(struct platform_device *dev)
 	up->port[1].line = 1;
 
 	sc26xx_init_masks(up, 1, pdata->signal_map[1]);
+	hw_init(&up->port[1]);
 
 	if (pdata->chip_name)
 		up->chip = chip_by_name(pdata->chip_name);

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux