Skip to contentSkip to conversation

Support for Meilhaus serial boards - patch (kernel 2.6.28)

PATCH Krzysztof Gantzke 2 participants 2 messages Jan 19, 2009 – Jan 20, 2009

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

Dear Linux-serial team
Meilhaus (PCI ID: 0x1402) ME90xx, ME91xx and ME93xx support added. The are RS232 and RS422/485 PCI serial boards.
This patch was tested on x86 and x86_64 machines.

Could you added this to main tree, please.

Best regards,
Krzysztof Gantzke

Signature · 5 lines
Krzysztof Gantzke

Meilhaus Electronic GmbH
Fischerstr. 2
D-82178 Puchheim
drivers/serial//8250.c +49 -0
diff -U 10 -b -w -B -E -p -r -x '.*' -- linux-2.6.28-me9x00/drivers/serial//8250.c linux-2.6.28/drivers/serial//8250.c
@@ -2494,20 +2494,68 @@ static int
 serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
 	if (ser->irq >= nr_irqs || ser->irq < 0 ||
 	    ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
 	    ser->type >= ARRAY_SIZE(uart_config) || ser->type == PORT_CIRRUS ||
 	    ser->type == PORT_STARTECH)
 		return -EINVAL;
 	return 0;
 }
 
+static int
+serial8250_set_rs232(struct uart_port *port)
+{
+	struct uart_8250_port *up = (struct uart_8250_port *) port;
+
+	if(up->port.type == PORT_16C950){
+		up->acr &= ~0x18;
+		serial_icr_write(up, UART_ACR, up->acr);
+	}
+	else if(up->port.type == PORT_16550A){
+		serial_outp(up, 0x8, serial_inp(up, 0x8) & ~0x20);
+	}
+
+	return 0;
+}
+
+static int
+serial8250_set_rs485(struct uart_port *port)
+{
+	struct uart_8250_port *up = (struct uart_8250_port *) port;
+
+	if(up->port.type == PORT_16C950){
+		up->acr |= 0x18;
+		serial_icr_write(up, UART_ACR, up->acr);
+	}
+	else if(up->port.type == PORT_16550A){
+		serial_outp(up, 0x8, serial_inp(up, 0x8) | 0x20);
+	}
+	else{
+		return -ENOIOCTLCMD;
+	}
+
+	return 0;
+}
+
+static int
+serial8250_ioctl(struct uart_port *port, unsigned int cmd, unsigned long uarg){
+	switch(cmd){
+		case TIOCSRS232:
+			return serial8250_set_rs232(port);
+		case TIOCSRS485:
+			return serial8250_set_rs485(port);
+		default:
+			return -ENOIOCTLCMD;
+	}
+	return 0;
+}
+
 static const char *
 serial8250_type(struct uart_port *port)
 {
 	int type = port->type;
 
 	if (type >= ARRAY_SIZE(uart_config))
 		type = 0;
 	return uart_config[type].name;
 }
 
@@ -2522,20 +2570,21 @@ static struct uart_ops serial8250_pops =
 	.break_ctl	= serial8250_break_ctl,
 	.startup	= serial8250_startup,
 	.shutdown	= serial8250_shutdown,
 	.set_termios	= serial8250_set_termios,
 	.pm		= serial8250_pm,
 	.type		= serial8250_type,
 	.release_port	= serial8250_release_port,
 	.request_port	= serial8250_request_port,
 	.config_port	= serial8250_config_port,
 	.verify_port	= serial8250_verify_port,
+	.ioctl		= serial8250_ioctl,
 #ifdef CONFIG_CONSOLE_POLL
 	.poll_get_char = serial8250_get_poll_char,
 	.poll_put_char = serial8250_put_poll_char,
 #endif
 };
 
 static struct uart_8250_port serial8250_ports[UART_NR];
 
 static void __init serial8250_isa_init_ports(void)
 {
src/linux-2.6.28/drivers/serial//8250_pci.c renamed from work/linux-sources/linux-2.6.28-me9x00/drivers/serial//8250_pci.c +240 -0

380 lines not on this page · raw message

arch/x86/include/asm//ioctls.h +5 -0
diff -U 10 -b -w -B -E -p -r -x '.*' -- linux-2.6.28-me9x00/arch/x86/include/asm//ioctls.h linux-2.6.28/arch/x86/include/asm//ioctls.h
@@ -49,20 +49,25 @@
 #define TIOCGSID	0x5429  /* Return the session ID of FD */
 #define TCGETS2		_IOR('T', 0x2A, struct termios2)
 #define TCSETS2		_IOW('T', 0x2B, struct termios2)
 #define TCSETSW2	_IOW('T', 0x2C, struct termios2)
 #define TCSETSF2	_IOW('T', 0x2D, struct termios2)
 #define TIOCGRS485	0x542E
 #define TIOCSRS485	0x542F
 #define TIOCGPTN	_IOR('T', 0x30, unsigned int)
 				/* Get Pty Number (of pty-mux device) */
 #define TIOCSPTLCK	_IOW('T', 0x31, int)  /* Lock/unlock Pty */
+
+/* Meilhaus */
+#define TIOCGRS232	_IOR('T', 0x48, unsigned int)
+#define TIOCSRS232	_IOW('T', 0x48, unsigned int)
+
 #define TCGETX		0x5432 /* SYS5 TCGETX compatibility */
 #define TCSETX		0x5433
 #define TCSETXF		0x5434
 #define TCSETXW		0x5435
 
 #define FIONCLEX	0x5450
 #define FIOCLEX		0x5451
 #define FIOASYNC	0x5452
 #define TIOCSERCONFIG	0x5453
 #define TIOCSERGWILD	0x5454
#1 lore raw
Quoted 6 lines · On Monday 19 January 2009 16:10:32 Krzysztof Gantzke wrote:

Dear Linux-serial team
Meilhaus (PCI ID: 0x1402) ME90xx, ME91xx and ME93xx support added. The are RS232 and RS422/485 PCI serial boards.
This patch was tested on x86 and x86_64 machines.

Could you added this to main tree, please.

NAK. You should not add an ioctl to revert to RS232 mode but check serial_rs485.flags in TIOCSRS485. Enable RS485 when SER_RS485_ENABLED is set, disable it otherwise.

You should also probably base your patch to 8250.c on top of Matthias Fuchs' patch ('[PATCH V3] serial: Add ioctl to enable auto rs485 mode with some Exar UARTs').

Best regards,

Signature · 9 lines
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75