Skip to contentSkip to conversation

max3100 driver

PATCH Superseded [email protected] 2 participants 4 messages Dec 17, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 max3100 driver

This patch adds support for the MAX3100 SPI UART.

Generated on 20071217 against v2.6.23

---
 drivers/serial/Kconfig         |    7 +
 drivers/serial/Makefile        |    1 +
 drivers/serial/max3100.c       |  956 ++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_max3100.h |   25 +
 4 files changed, 989 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 +956 -0

956 lines not on this page · raw message

include/linux/serial_max3100.h new file +25 -0
new file mode 100644
index 0000000..c6b5c45
@@ -0,0 +1,25 @@
+
+/*
+ *
+ *  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 {
+	int loopback;
+/* force MAX3100 in loopback */
+	int crystal;
+/* 0 for 3.6864 Mhz, 1 for 1.8432  */
+	int only_edge_irq;
+/* for archs like PXA with only edge irqs */
+};
+
+#endif

--
1.4.4.4

#1 lore raw
Quoted 12 lines · On 12/17/2007 09:17 AM, [email protected] wrote:

This patch adds support for the MAX3100 SPI UART.

Generated on 20071217 against v2.6.23

---
 drivers/serial/Kconfig         |    7 +
 drivers/serial/Makefile        |    1 +
 drivers/serial/max3100.c       |  956 ++++++++++++++++++++++++++++++++++++++++
 include/linux/serial_max3100.h |   25 +
 4 files changed, 989 insertions(+), 0 deletions(-)

[...]

Quoted 5 lines
drivers/serial/max3100.c new file +0 -0
new file mode 100644
index 0000000..d07936d

[...]

Quoted 9 lines
drivers/serial/max3100.c new file +9 -0
+static int __devexit max3100_remove(struct spi_device *spi)
+{
+	int i;
+
+	i = 0;
+
+	for (i = 0; i < MAX_MAX3100; i++)
+		if (max3100s[i] && max3100s[i]->ref_count > 0)
+			return -EBUSY;

drivers/serial/max3100.c line 900

Quoted 10 lines
drivers/serial/max3100.c new file +10 -0
+
+	for (i = 0; i < MAX_MAX3100; i++)
+		if (max3100s[i]) {
+			tty_unregister_device(serial_driver, i);
+			kfree(max3100s[i]);
+			max3100s[i] = NULL;
+		}
+
+	if (serial_driver)
+		tty_unregister_driver(serial_driver);

You probably wanted to unregister it after _all_ cards are removed, not after each...

drivers/serial/max3100.c line 911

Quoted 11 lines
drivers/serial/max3100.c new file +11 -0
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int max3100_suspend(struct spi_device *spi, pm_message_t state)
+{
+	struct max3100_port_s *s = dev_get_drvdata(&spi->dev);
+	u16 tx, rx;
+
+	tx = MAX3100_WC | MAX3100_SHDN;
+	max3100_sr(s, tx, &rx, 0);

Also you should synchronize_irq() after stopping them here.

drivers/serial/max3100.c

Quoted 2 lines
drivers/serial/max3100.c new file +2 -0
+	return 0;
+}

regards,

Signature · 2 lines
Jiri Slaby ([email protected])
Faculty of Informatics, Masaryk University
author
#2 lore raw
Quoted 4 lines · Jiri Slaby

You probably wanted to unregister it after _all_ cards are removed, not after each...

Hi,

thanks you are right. I haven't noticed this since spi devices are not hot-pluggable so I could remove them only with rmmod (and so all of them toghether). Anyway the code I sent is ugly, I will correct and resend.

Quoted 3 lines

Also you should synchronize_irq() after stopping them here.

I see. I guess I will have problems on suspending with serial activity otherwise.

Thanks,

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
Quoted 11 lines · chri
Quoted 3 lines · Jiri Slaby

You probably wanted to unregister it after _all_ cards are removed, not after each...

Hi,

thanks you are right. I haven't noticed this since spi devices are not hot-pluggable so I could remove them only with rmmod (and so all of them toghether). Anyway the code I sent is ugly, I will correct and resend.

Won't bind/unbind in sysfs help you?