Skip to contentSkip to conversation

max3100 driver

PATCH RESEND Superseded [email protected] 2 participants 4 messages Dec 28, 2007 – Dec 29, 2007

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 max3100 driver

This patch adds support for the MAX3100 SPI UART.

Generated on 20071228 against v2.6.23

---
 drivers/serial/Kconfig         |    7 +
 drivers/serial/Makefile        |    1 +
 drivers/serial/max3100.c       |  987 ++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_max3100.h |   28 ++
 4 files changed, 1023 insertions(+), 0 deletions(-)
drivers/serial/Kconfig +7 -0
index 81b52b7..4e7111b 100644
@@ -461,6 +461,13 @@ config SERIAL_S3C2410_CONSOLE
 	  your boot loader about how to pass options to the kernel at
 	  boot time.)
 
+config SERIAL_MAX3100
+        tristate "MAX3100 support"
+        depends on SPI
+        help
+          MAX3100 chip support
+
+
 config SERIAL_DZ
 	bool "DECstation DZ serial driver"
 	depends on MACH_DECSTATION && 32BIT
drivers/serial/Makefile +1 -0
index af6377d..9f67e52 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
 obj-$(CONFIG_SERIAL_BFIN) += bfin_5xx.o
 obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o
+obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
 obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o
 obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o
 obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o
drivers/serial/max3100.c new file +987 -0

987 lines not on this page · raw message

include/linux/serial_max3100.h new file +28 -0
new file mode 100644
index 0000000..5c0489e
@@ -0,0 +1,28 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#ifndef _LINUX_SERIAL_MAX3100_H
+#define _LINUX_SERIAL_MAX3100_H 1
+
+struct plat_max3100 {
+/* force MAX3100 in loopback */
+	int loopback;
+/* 0 for 3.6864 Mhz, 1 for 1.8432  */
+	int crystal;
+/* for archs like PXA with only edge irqs */
+	int only_edge_irq;
+/* MAX3100 has a shutdown pin. This is a hook
+   called on suspend and resume to activate it.*/
+	void (*max3100_hw_suspend) (int suspend);
+};
+
+#endif

--
1.4.4.4

#1 lore raw
Quoted 4 lines · On Dec 28 2007 14:01, [email protected] wrote:

+
+ * The initial minor number is 128 to prevent clashes with ttyS:
+ * mknod /dev/ttyMAX0 c 4 128
+ */

[4:128] is taken by ttyS64. Please look into Documentation/devices.txt.

drivers/serial/max3100.c line 115

Quoted 8 lines
drivers/serial/max3100.c new file +8 -0
+struct max3100_port_s {
+	struct uart_port port;
+	struct spi_device *spi;
+	struct tty_struct 	*tty;
+
+	struct mutex   spi_txrx;/* protects access to the hw */
+
+	int rts;		/* rts status, can be MAX3100_RTS or 0 */

possibly be bool then, if it only takes on two values?

drivers/serial/max3100.c line 121

Quoted 6 lines
drivers/serial/max3100.c new file +6 -0
+	int conf;		/* configuration for the MAX31000
+				 * (bits 0-7, bits 8-11 are irqs) */
+	int last_cts_rx;	/* last CTS received for flow ctrl */
+
+	int tx_buf_cur;	        /* current char to tx */
+	int tx_buf_tot;		/* current number of chars in tx buf */

Probably unsigned?

drivers/serial/max3100.c line 200

Quoted 9 lines
drivers/serial/max3100.c new file +9 -0
+static int max3100_do_parity(struct max3100_port_s *s, u16 c)
+{
+	int parity;
+	int i, n;
+
+	if (s->parity & MAX3100_PARITY_ODD)
+		parity = 0;
+	else
+		parity = 1;

Or

	parity = !!(s->parity & MAX3100_PARITY_ODD);
	n = (s->parity & MAX3100_7BIT) ? 7 : 8;

(up to you)

drivers/serial/max3100.c line 208

Quoted 2 lines
drivers/serial/max3100.c new file +2 -0
+	for (i = 0; i < n; i++)
+		parity = parity ^ ((c>>i) & 1);
		parity ^= (c >> i) & 1;

drivers/serial/max3100.c line 250

Quoted 7 lines
drivers/serial/max3100.c new file +7 -0
+	return parity;
+}
+
+	if (s->loopback) {
+		if ((tx & MAX3100_CMD) == MAX3100_RC)
+			tx |= 1;
+	}
	if (s->loopback && (tx & MAX3100_CMD) == MAX3100_RC)
		tx |= 1;

drivers/serial/max3100.c line 987

Quoted 2 lines
drivers/serial/max3100.c new file +2 -0
+MODULE_DESCRIPTION("MAX3100 driver");
+MODULE_LICENSE("GPL");

I notice a steep increase in serial drivers. Everyone got their new chips for xmas, eh? :)

author
#2 lore raw

Hi,

Quoted 3 lines · Jan Engelhardt

[4:128] is taken by ttyS64. Please look into Documentation/devices.txt.

I did it but I think it's better to reuse a minor from ttyS than allocating a new major (64 serial ports is a lot). I saw that other drivers take a similar approach, just tend to stay away from low numbers that are used by 8250 and its child (that can be connected more or less everywhere). Perhaps in these udev times the serial minor number should be allocated dinamicaly. Do you think this makes sense?

Quoted 5 lines

I notice a steep increase in serial drivers. Everyone got their new chips for xmas, eh? :)

This year I was a bad boy so Santa brought me just a cheap uart. For next Xmas I hope in a WLAN chip or something like that. ;-)

Signature · 5 lines
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
#3 lore raw

PATCH RESEND 1/1 max3100 driver

This patch adds support for the MAX3100 SPI UART.

Generated on 20071229 against v2.6.23

---
 drivers/serial/Kconfig         |    7 +
 drivers/serial/Makefile        |    1 +
 drivers/serial/max3100.c       | 1003 ++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_max3100.h |   28 ++
 4 files changed, 1039 insertions(+), 0 deletions(-)
drivers/serial/Kconfig +7 -0
index 81b52b7..4e7111b 100644
@@ -461,6 +461,13 @@ config SERIAL_S3C2410_CONSOLE
 	  your boot loader about how to pass options to the kernel at
 	  boot time.)
 
+config SERIAL_MAX3100
+        tristate "MAX3100 support"
+        depends on SPI
+        help
+          MAX3100 chip support
+
+
 config SERIAL_DZ
 	bool "DECstation DZ serial driver"
 	depends on MACH_DECSTATION && 32BIT
drivers/serial/Makefile +1 -0
index af6377d..9f67e52 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
 obj-$(CONFIG_SERIAL_BFIN) += bfin_5xx.o
 obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o
+obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
 obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o
 obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o
 obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o
drivers/serial/max3100.c new file +1003 -0

1,003 lines not on this page · raw message

include/linux/serial_max3100.h new file +28 -0
new file mode 100644
index 0000000..5c0489e
@@ -0,0 +1,28 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#ifndef _LINUX_SERIAL_MAX3100_H
+#define _LINUX_SERIAL_MAX3100_H 1
+
+struct plat_max3100 {
+/* force MAX3100 in loopback */
+	int loopback;
+/* 0 for 3.6864 Mhz, 1 for 1.8432  */
+	int crystal;
+/* for archs like PXA with only edge irqs */
+	int only_edge_irq;
+/* MAX3100 has a shutdown pin. This is a hook
+   called on suspend and resume to activate it.*/
+	void (*max3100_hw_suspend) (int suspend);
+};
+
+#endif

--
1.4.4.4