[PATCH 3/4] ark3116: Registers 0-7 are 8250 compatible

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

 



Replace numeric constants with macros from serial_reg.h.
Bart Hartgers pointed out that this devices appears to be a
 16450 hiding behind a USB interface.

Signed-off-by: Mike McCormack <mikem@xxxxxxxxxx>
---
 drivers/usb/serial/ark3116.c |  103 ++++++++++++++++++++---------------------
 1 files changed, 50 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 36f61d4..4255f59 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -24,6 +24,7 @@
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include <linux/serial.h>
+#include <linux/serial_reg.h>
 #include <linux/uaccess.h>
 
 
@@ -72,8 +73,8 @@ static int ark3116_attach(struct usb_serial *serial)
 		dbg("IrDA mode");
 
 	/* 3 */
-	ark3116_snd(serial, 0x0008, 0x0002);
-	ark3116_snd(serial, 0x0008, 0x0001);
+	ark3116_snd(serial, 0x0008, UART_FCR);
+	ark3116_snd(serial, 0x0008, UART_IER);
 	ark3116_snd(serial, 0x0000, 0x0008);
 	ark3116_snd(serial, is_irda(serial) ? 0x0001 : 0x0000,
 		    0x000B);
@@ -85,47 +86,47 @@ static int ark3116_attach(struct usb_serial *serial)
 	}
 
 	/* <-- seq7 */
-	ark3116_rcv(serial, 0x0000, 0x0003, buf);
-	ark3116_snd(serial, 0x0080, 0x0003);
-	ark3116_snd(serial, 0x001A, 0x0000);
-	ark3116_snd(serial, 0x0000, 0x0001);
-	ark3116_snd(serial, 0x0000, 0x0003);
+	ark3116_rcv(serial, 0x0000, UART_LCR, buf);
+	ark3116_snd(serial, 0x0080, UART_LCR);
+	ark3116_snd(serial, 0x001A, UART_DLL);
+	ark3116_snd(serial, 0x0000, UART_DLM);
+	ark3116_snd(serial, 0x0000, UART_LCR);
 
 	/* <-- seq12 */
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
-	ark3116_snd(serial, 0x0000, 0x0004);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
+	ark3116_snd(serial, 0x0000, UART_MCR);
 
 	/* 14 */
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
-	ark3116_snd(serial, 0x0000, 0x0004);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
+	ark3116_snd(serial, 0x0000, UART_MCR);
 
 	/* 16 */
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
 	/* --> seq17 */
-	ark3116_snd(serial, 0x0001, 0x0004);
+	ark3116_snd(serial, 0x0001, UART_MCR);
 
 	/* <-- seq18 */
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
 
 	/* --> seq19 */
-	ark3116_snd(serial, 0x0003, 0x0004);
+	ark3116_snd(serial, 0x0003, UART_MCR);
 
 	/* <-- seq20 */
 	/* seems like serial port status info (RTS, CTS, ...) */
 	/* returns modem control line status?! */
-	ark3116_rcv(serial, 0x0000, 0x0006, buf);
+	ark3116_rcv(serial, 0x0000, UART_MSR, buf);
 
 	/* set 9600 baud & do some init?! */
-	ark3116_snd(serial, 0x0083, 0x0003);
-	ark3116_snd(serial, 0x0038, 0x0000);
-	ark3116_snd(serial, 0x0001, 0x0001);
+	ark3116_snd(serial, 0x0083, UART_LCR);
+	ark3116_snd(serial, 0x0038, UART_DLL);
+	ark3116_snd(serial, 0x0001, UART_DLM);
 	if (is_irda(serial))
 		ark3116_snd(serial, 0x0000, 0x0009);
-	ark3116_snd(serial, 0x0003, 0x0003);
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
-	ark3116_snd(serial, 0x0000, 0x0003);
-	ark3116_rcv(serial, 0x0000, 0x0003, buf);
-	ark3116_snd(serial, 0x0003, 0x0003);
+	ark3116_snd(serial, 0x0003, UART_LCR);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
+	ark3116_snd(serial, 0x0000, UART_LCR);
+	ark3116_rcv(serial, 0x0000, UART_LCR, buf);
+	ark3116_snd(serial, 0x0003, UART_LCR);
 
 	return 0;
 }
@@ -247,32 +248,28 @@ static void ark3116_set_termios(struct tty_struct *tty,
 		ark3116_baud = 3000000 / baud;
 
 	/* ? */
-	ark3116_rcv(serial, 0x0000, 0x0003, buf);
-
-	/* offset = buf[0]; */
-	/* offset = 0x03; */
-	/* dbg("using 0x%04X as target for 0x0003:", 0x0080 + offset); */
+	ark3116_rcv(serial, 0x0000, UART_LCR, buf);
 
 	/* set baudrate */
 	dbg("setting baudrate to %d (->reg=%d)", baud, ark3116_baud);
-	ark3116_snd(serial, 0x0083, 0x0003);
-	ark3116_snd(serial, (ark3116_baud & 0x00FF), 0x0000);
-	ark3116_snd(serial, (ark3116_baud & 0xFF00) >> 8, 0x0001);
-	ark3116_snd(serial, 0x0003, 0x0003);
+	ark3116_snd(serial, 0x0083, UART_LCR);
+	ark3116_snd(serial, (ark3116_baud & 0x00FF), UART_DLL);
+	ark3116_snd(serial, (ark3116_baud & 0xFF00) >> 8, UART_DLM);
+	ark3116_snd(serial, 0x0003, UART_LCR);
 
 	/* ? */
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
-	ark3116_snd(serial, 0x0000, 0x0003);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
+	ark3116_snd(serial, 0x0000, UART_LCR);
 
 	/* set data bit count, stop bit count & parity: */
 	dbg("updating bit count, stop bit or parity (cfg=0x%02X)", config);
-	ark3116_rcv(serial, 0x0000, 0x0003, buf);
-	ark3116_snd(serial, config, 0x0003);
+	ark3116_rcv(serial, 0x0000, UART_LCR, buf);
+	ark3116_snd(serial, config, UART_LCR);
 
 	if (cflag & CRTSCTS)
 		dbg("CRTSCTS not supported by chipset?!");
 
-	/* TEST ark3116_snd(154, 0xFFFF, 0x0006); */
+	/* TEST ark3116_snd(154, 0xFFFF, UART_MSR); */
 }
 
 static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
@@ -289,29 +286,29 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
 		goto err_out;
 
 	/* open */
-	ark3116_rcv(serial, 0x0000, 0x0003, buf);
+	ark3116_rcv(serial, 0x0000, UART_LCR, buf);
 
-	ark3116_snd(serial, 0x0082, 0x0003);
-	ark3116_snd(serial, 0x001A, 0x0000);
-	ark3116_snd(serial, 0x0000, 0x0001);
-	ark3116_snd(serial, 0x0002, 0x0003);
+	ark3116_snd(serial, 0x0082, UART_LCR);
+	ark3116_snd(serial, 0x001A, UART_DLL);
+	ark3116_snd(serial, 0x0000, UART_DLM);
+	ark3116_snd(serial, 0x0002, UART_LCR);
 
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
-	ark3116_snd(serial, 0x0002, 0x0004);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
+	ark3116_snd(serial, 0x0002, UART_MCR);
 
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
-	ark3116_snd(serial, 0x0000, 0x0004);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
+	ark3116_snd(serial, 0x0000, UART_MCR);
 
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
 
-	ark3116_snd(serial, 0x0001, 0x0004);
+	ark3116_snd(serial, 0x0001, UART_MCR);
 
-	ark3116_rcv(serial, 0x0000, 0x0004, buf);
+	ark3116_rcv(serial, 0x0000, UART_MCR, buf);
 
-	ark3116_snd(serial, 0x0003, 0x0004);
+	ark3116_snd(serial, 0x0003, UART_MCR);
 
 	/* returns different values (control lines?!) */
-	ark3116_rcv(serial, 0x0000, 0x0006, buf);
+	ark3116_rcv(serial, 0x0000, UART_MSR, buf);
 
 	/* initialise termios */
 	if (tty)
@@ -368,7 +365,7 @@ static int ark3116_tiocmget(struct tty_struct *tty, struct file *file)
 	 */
 
 	/* read register */
-	ark3116_rcv(serial, 0x0000, 0x0006, &temp);
+	ark3116_rcv(serial, 0x0000, UART_MSR, &temp);
 
 	/* i do not really know if bit4=CTS and bit6=DSR... just a
 	 * quick guess!
-- 
1.5.6.5


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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux