[PATCH RESEND] max3100 driver

2007-12-29 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071229  against v2.6.23

Signed-off-by: Christian Pellegrin <[EMAIL PROTECTED]>
---
 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(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..9b6a08c
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,1003 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin <[EMAIL PROTECTED]>
+ *
+ * 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.
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
+ * to use polling for flow control. TX empty IRQ is unusable, since
+ * writing conf clears FIFO buffer and we cannot have this interrupt
+ * always asking us for attention.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = "max3100",
+   .platform_data  = _plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },
+};
+
+ * The initial minor number is 128 to prevent clashes with ttyS:
+ * mknod /dev/ttyMAX0 c 4 128
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define MAX3100_C(1<<14)
+#define MAX3100_D(0<<14)
+#define MAX3100_W(1<<15)
+#define MAX3100_RX   (0<<15)
+
+#define MAX3100_WC   (MAX3100_W  | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX | MAX3100_C)
+#define MAX3100_WD   (MAX3100_W  | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX | MAX3100_D)
+#define MAX3100_CMD  (3 << 14)
+
+#define MAX3100_T(1<<14)
+#define MAX3100_R(1<<15)
+
+#define MAX3100_FEN  (1<<13)
+#define MAX3100_SHDN (1<<12)
+#define MAX3100_TM   (1<<11)
+#define MAX3100_RM   (1<<10)
+#define MAX3100_PM   (1<<9)
+#define MAX3100_RAM  (1<<8)
+#define MAX3100_IR   (1<<7)
+#define MAX3100_ST   (1<<6)
+#define MAX3100_PE   (1<<5)
+#define MAX3100_L(1<<4)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (1<<10)
+#define MAX3100_RAFE (1<<10)
+#define MAX3100_RTS  (1<<9)
+#define MAX3100_CTS  (1<<9)
+#define MAX3100_PT   (1<<8)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+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:1;  /* rts status */
+   int conf;   /* configuration for the MAX31000
+* (bits 0-7, bits 8-11 are irqs) */
+   int last_cts_rx;/* last CTS received for flow ctrl */
+
+   unsigned int tx_buf_cur;/* current char to tx */
+   /* current number of chars in tx buf */
+   unsigned int tx_buf_tot;
+   unsigned char *tx_buf;
+   /* shared tx buffer spinlock (no sem since write may sleep) */
+   spinlock_t tx_buf_lock;
+
+   int tx_stopped:1;   /* when we should not send chars */
+   int parity:3;   /* keeps track if we 

[PATCH RESEND] max3100 driver

2007-12-29 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071229  against v2.6.23

Signed-off-by: Christian Pellegrin [EMAIL PROTECTED]
---
 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(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..9b6a08c
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,1003 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin [EMAIL PROTECTED]
+ *
+ * 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.
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
+ * to use polling for flow control. TX empty IRQ is unusable, since
+ * writing conf clears FIFO buffer and we cannot have this interrupt
+ * always asking us for attention.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = max3100,
+   .platform_data  = max3100_plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },
+};
+
+ * The initial minor number is 128 to prevent clashes with ttyS:
+ * mknod /dev/ttyMAX0 c 4 128
+ */
+
+#include linux/bitops.h
+#include linux/console.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/fcntl.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/keyboard.h
+#include linux/major.h
+#include linux/mm.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/pm.h
+#include linux/reboot.h
+#include linux/sched.h
+#include linux/serial_core.h
+#include linux/signal.h
+#include linux/spi/spi.h
+#include linux/string.h
+#include linux/timer.h
+#include linux/tty.h
+#include linux/tty_flip.h
+#include linux/uaccess.h
+#include linux/workqueue.h
+
+#include asm/system.h
+
+#include linux/serial_max3100.h
+
+#define MAX3100_C(114)
+#define MAX3100_D(014)
+#define MAX3100_W(115)
+#define MAX3100_RX   (015)
+
+#define MAX3100_WC   (MAX3100_W  | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX | MAX3100_C)
+#define MAX3100_WD   (MAX3100_W  | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX | MAX3100_D)
+#define MAX3100_CMD  (3  14)
+
+#define MAX3100_T(114)
+#define MAX3100_R(115)
+
+#define MAX3100_FEN  (113)
+#define MAX3100_SHDN (112)
+#define MAX3100_TM   (111)
+#define MAX3100_RM   (110)
+#define MAX3100_PM   (19)
+#define MAX3100_RAM  (18)
+#define MAX3100_IR   (17)
+#define MAX3100_ST   (16)
+#define MAX3100_PE   (15)
+#define MAX3100_L(14)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (110)
+#define MAX3100_RAFE (110)
+#define MAX3100_RTS  (19)
+#define MAX3100_CTS  (19)
+#define MAX3100_PT   (18)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+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:1;  /* rts status */
+   int conf;   /* configuration for the MAX31000
+* (bits 0-7, bits 8-11 are irqs) */
+   int last_cts_rx;/* last CTS received for flow ctrl */
+
+   unsigned int tx_buf_cur;  

[PATCH RESEND] max3100 driver

2007-12-28 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071228  against v2.6.23

Signed-off-by: Christian Pellegrin <[EMAIL PROTECTED]>
---
 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(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..7f2c371
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,987 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin <[EMAIL PROTECTED]>
+ *
+ * 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.
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
+ * to use polling for flow control. TX empty IRQ is unusable, since
+ * writing conf clears FIFO buffer and we cannot have this interrupt
+ * always asking us for attention.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = "max3100",
+   .platform_data  = _plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },
+};
+
+ * The initial minor number is 128 to prevent clashes with ttyS:
+ * mknod /dev/ttyMAX0 c 4 128
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define MAX3100_C(1<<14)
+#define MAX3100_D(0<<14)
+#define MAX3100_W(1<<15)
+#define MAX3100_RX   (0<<15)
+
+#define MAX3100_WC   (MAX3100_W  | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX | MAX3100_C)
+#define MAX3100_WD   (MAX3100_W  | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX | MAX3100_D)
+#define MAX3100_CMD  (3 << 14)
+
+#define MAX3100_T(1<<14)
+#define MAX3100_R(1<<15)
+
+#define MAX3100_FEN  (1<<13)
+#define MAX3100_SHDN (1<<12)
+#define MAX3100_TM   (1<<11)
+#define MAX3100_RM   (1<<10)
+#define MAX3100_PM   (1<<9)
+#define MAX3100_RAM  (1<<8)
+#define MAX3100_IR   (1<<7)
+#define MAX3100_ST   (1<<6)
+#define MAX3100_PE   (1<<5)
+#define MAX3100_L(1<<4)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (1<<10)
+#define MAX3100_RAFE (1<<10)
+#define MAX3100_RTS  (1<<9)
+#define MAX3100_CTS  (1<<9)
+#define MAX3100_PT   (1<<8)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+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 */
+   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 */
+   unsigned char *tx_buf;
+   /* shared tx buffer spinlock (no sem
+* since write may sleep) */
+   spinlock_t tx_buf_lock;
+
+   int tx_stopped:1;   /* when we should not send chars */
+   int parity:3;   /* keeps 

[PATCH RESEND] max3100 driver

2007-12-28 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071228  against v2.6.23

Signed-off-by: Christian Pellegrin [EMAIL PROTECTED]
---
 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(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..7f2c371
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,987 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin [EMAIL PROTECTED]
+ *
+ * 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.
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
+ * to use polling for flow control. TX empty IRQ is unusable, since
+ * writing conf clears FIFO buffer and we cannot have this interrupt
+ * always asking us for attention.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = max3100,
+   .platform_data  = max3100_plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },
+};
+
+ * The initial minor number is 128 to prevent clashes with ttyS:
+ * mknod /dev/ttyMAX0 c 4 128
+ */
+
+#include linux/bitops.h
+#include linux/console.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/fcntl.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/keyboard.h
+#include linux/major.h
+#include linux/mm.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/pm.h
+#include linux/reboot.h
+#include linux/sched.h
+#include linux/serial_core.h
+#include linux/signal.h
+#include linux/spi/spi.h
+#include linux/string.h
+#include linux/timer.h
+#include linux/tty.h
+#include linux/tty_flip.h
+#include linux/uaccess.h
+#include linux/workqueue.h
+
+#include asm/system.h
+
+#include linux/serial_max3100.h
+
+#define MAX3100_C(114)
+#define MAX3100_D(014)
+#define MAX3100_W(115)
+#define MAX3100_RX   (015)
+
+#define MAX3100_WC   (MAX3100_W  | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX | MAX3100_C)
+#define MAX3100_WD   (MAX3100_W  | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX | MAX3100_D)
+#define MAX3100_CMD  (3  14)
+
+#define MAX3100_T(114)
+#define MAX3100_R(115)
+
+#define MAX3100_FEN  (113)
+#define MAX3100_SHDN (112)
+#define MAX3100_TM   (111)
+#define MAX3100_RM   (110)
+#define MAX3100_PM   (19)
+#define MAX3100_RAM  (18)
+#define MAX3100_IR   (17)
+#define MAX3100_ST   (16)
+#define MAX3100_PE   (15)
+#define MAX3100_L(14)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (110)
+#define MAX3100_RAFE (110)
+#define MAX3100_RTS  (19)
+#define MAX3100_CTS  (19)
+#define MAX3100_PT   (18)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+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 */
+   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 

[PATCH] max3100 driver

2007-12-17 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071217  against v2.6.23

Signed-off-by: Christian Pellegrin <[EMAIL PROTECTED]>
---
 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(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..d07936d
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,956 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin <[EMAIL PROTECTED]>
+ *
+ * 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.
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
+ * to use polling for flow control. TX empty IRQ is unusable, since
+ * writing conf clears FIFO buffer and we cannot have this interrupt
+ * always asking us for attention.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = "max3100",
+   .platform_data  = _plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },
+};
+
+ * The initial minor number is 128 to prevent clashes with ttyS:
+ * mknod /dev/ttyMAX0 c 4 128
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define MAX3100_C(1<<14)
+#define MAX3100_D(0<<14)
+#define MAX3100_W(1<<15)
+#define MAX3100_RX   (0<<15)
+
+#define MAX3100_WC   (MAX3100_W  | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX | MAX3100_C)
+#define MAX3100_WD   (MAX3100_W  | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX | MAX3100_D)
+#define MAX3100_CMD  (3 << 14)
+
+#define MAX3100_T(1<<14)
+#define MAX3100_R(1<<15)
+
+#define MAX3100_FEN  (1<<13)
+#define MAX3100_SHDN (1<<12)
+#define MAX3100_TM   (1<<11)
+#define MAX3100_RM   (1<<10)
+#define MAX3100_PM   (1<<9)
+#define MAX3100_RAM  (1<<8)
+#define MAX3100_IR   (1<<7)
+#define MAX3100_ST   (1<<6)
+#define MAX3100_PE   (1<<5)
+#define MAX3100_L(1<<4)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (1<<10)
+#define MAX3100_RAFE (1<<10)
+#define MAX3100_RTS  (1<<9)
+#define MAX3100_CTS  (1<<9)
+#define MAX3100_PT   (1<<8)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+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 */
+   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 */
+   unsigned char *tx_buf;
+   /* shared tx buffer spinlock (no sem
+* since write may sleep) */
+   spinlock_t tx_buf_lock;
+
+   int tx_stopped; /* when we should not send chars */
+   int parity; /* keeps track 

[PATCH] max3100 driver

2007-12-17 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071217  against v2.6.23

Signed-off-by: Christian Pellegrin [EMAIL PROTECTED]
---
 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(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..d07936d
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,956 @@
+
+/*
+ *
+ *  Copyright (C) 2007 Christian Pellegrin [EMAIL PROTECTED]
+ *
+ * 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.
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
+ * to use polling for flow control. TX empty IRQ is unusable, since
+ * writing conf clears FIFO buffer and we cannot have this interrupt
+ * always asking us for attention.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = max3100,
+   .platform_data  = max3100_plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },
+};
+
+ * The initial minor number is 128 to prevent clashes with ttyS:
+ * mknod /dev/ttyMAX0 c 4 128
+ */
+
+#include linux/bitops.h
+#include linux/console.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/fcntl.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/keyboard.h
+#include linux/major.h
+#include linux/mm.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/pm.h
+#include linux/reboot.h
+#include linux/sched.h
+#include linux/serial_core.h
+#include linux/signal.h
+#include linux/spi/spi.h
+#include linux/string.h
+#include linux/timer.h
+#include linux/tty.h
+#include linux/tty_flip.h
+#include linux/uaccess.h
+#include linux/workqueue.h
+
+#include asm/system.h
+
+#include linux/serial_max3100.h
+
+#define MAX3100_C(114)
+#define MAX3100_D(014)
+#define MAX3100_W(115)
+#define MAX3100_RX   (015)
+
+#define MAX3100_WC   (MAX3100_W  | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX | MAX3100_C)
+#define MAX3100_WD   (MAX3100_W  | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX | MAX3100_D)
+#define MAX3100_CMD  (3  14)
+
+#define MAX3100_T(114)
+#define MAX3100_R(115)
+
+#define MAX3100_FEN  (113)
+#define MAX3100_SHDN (112)
+#define MAX3100_TM   (111)
+#define MAX3100_RM   (110)
+#define MAX3100_PM   (19)
+#define MAX3100_RAM  (18)
+#define MAX3100_IR   (17)
+#define MAX3100_ST   (16)
+#define MAX3100_PE   (15)
+#define MAX3100_L(14)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (110)
+#define MAX3100_RAFE (110)
+#define MAX3100_RTS  (19)
+#define MAX3100_CTS  (19)
+#define MAX3100_PT   (18)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+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 */
+   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; 

[PATCH] netmos 9855 fix

2007-12-05 Thread chripell
Fixes wrong netmos 9855 serial port configuration.

Generated on  20071205  against v2.6.21

Signed-off-by: Christian Pellegrin <[EMAIL PROTECTED]>
---
 drivers/parport/parport_serial.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 78c0a26..5b04e78 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -77,7 +77,7 @@ static struct parport_pc_pci cards[] __devinitdata = {
/* titan_110l */{ 1, { { 3, -1 }, } },
/* titan_210l */{ 1, { { 3, -1 }, } },
/* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, 
netmos_parallel_init },
-   /* netmos_9855 */   { 1, { { 0, -1 }, }, 
netmos_parallel_init },
+   /* netmos_9855 */   { 1, { { 2, -1 }, }, 
netmos_parallel_init },
/* avlab_1s1p */{ 1, { { 1, 2}, } },
/* avlab_1s2p */{ 2, { { 1, 2}, { 3, 4 },} },
/* avlab_2s1p */{ 1, { { 2, 3}, } },
@@ -185,7 +185,7 @@ static struct pciserial_board pci_parport_serial_boards[] 
__devinitdata = {
.uart_offset= 8,
},
[netmos_9855] = {
-   .flags  = FL_BASE2 | FL_BASE_BARS,
+   .flags  = FL_BASE4 | FL_BASE_BARS,
.num_ports  = 1,
.base_baud  = 115200,
.uart_offset= 8,
--
1.4.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] max3100 driver

2007-12-05 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071205  against v2.6.23

Signed-off-by: Christian Pellegrin <[EMAIL PROTECTED]>
---
 drivers/serial/Kconfig |7 +
 drivers/serial/Makefile|1 +
 drivers/serial/max3100.c   |  960 
 include/linux/serial_max3100.h |   25 +
 4 files changed, 993 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..dd48258
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,960 @@
+
+/* 
+ *
+ *  Copyright (C) 2007 Christian Pellegrin <[EMAIL PROTECTED]>
+ *
+ * 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.
+ *
+ * version 0.1  31/5/2006   first public release
+ * version 0.2  11/11/2007  ported to kernel 2.6.23
+ *
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS
+ * so we have to use polling for flow control. TX empty
+ * IRQ is unusable, since writing conf clears FIFO buffer.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = "max3100",
+   .platform_data  = _plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },  
+};
+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define MAX3100_C(1<<14)
+#define MAX3100_D(0<<14)
+#define MAX3100_W(1<<15)
+#define MAX3100_RX   (0<<15)
+
+#define MAX3100_WC   (MAX3100_W | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX| MAX3100_C)
+#define MAX3100_WD   (MAX3100_W | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX| MAX3100_D)
+#define MAX3100_CMD  (3 << 14)
+
+#define MAX3100_T(1<<14)
+#define MAX3100_R(1<<15)
+
+#define MAX3100_FEN  (1<<13)
+#define MAX3100_SHDN (1<<12)
+#define MAX3100_TM   (1<<11)
+#define MAX3100_RM   (1<<10)
+#define MAX3100_PM   (1<<9)
+#define MAX3100_RAM  (1<<8)
+#define MAX3100_IR   (1<<7)
+#define MAX3100_ST   (1<<6)
+#define MAX3100_PE   (1<<5)
+#define MAX3100_L(1<<4)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (1<<10)
+#define MAX3100_RAFE (1<<10)
+#define MAX3100_RTS  (1<<9)
+#define MAX3100_CTS  (1<<9)
+#define MAX3100_PT   (1<<8)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+struct max3100_port_s {
+   struct uart_port port;
+   struct spi_device *spi;
+   struct tty_struct   *tty;
+  
+   struct semaphore   spi_txrx; /* protects access to the hw */
+
+   int rts;/* rts status, can be MAX3100_RTS or 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 */
+   unsigned char *tx_buf;
+   spinlock_t tx_buf_lock; /* shared tx buffer spinlock (no sem
+* since write may sleep) */
+
+   int tx_stopped; /* when we should not send chars */
+   int parity; /* keeps track if we 

[PATCH] netmos 9855 fix

2007-12-05 Thread chripell
Fixes wrong netmos 9855 serial port configuration.

Generated on  20071205  against v2.6.21

Signed-off-by: Christian Pellegrin [EMAIL PROTECTED]
---
 drivers/parport/parport_serial.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 78c0a26..5b04e78 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -77,7 +77,7 @@ static struct parport_pc_pci cards[] __devinitdata = {
/* titan_110l */{ 1, { { 3, -1 }, } },
/* titan_210l */{ 1, { { 3, -1 }, } },
/* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, 
netmos_parallel_init },
-   /* netmos_9855 */   { 1, { { 0, -1 }, }, 
netmos_parallel_init },
+   /* netmos_9855 */   { 1, { { 2, -1 }, }, 
netmos_parallel_init },
/* avlab_1s1p */{ 1, { { 1, 2}, } },
/* avlab_1s2p */{ 2, { { 1, 2}, { 3, 4 },} },
/* avlab_2s1p */{ 1, { { 2, 3}, } },
@@ -185,7 +185,7 @@ static struct pciserial_board pci_parport_serial_boards[] 
__devinitdata = {
.uart_offset= 8,
},
[netmos_9855] = {
-   .flags  = FL_BASE2 | FL_BASE_BARS,
+   .flags  = FL_BASE4 | FL_BASE_BARS,
.num_ports  = 1,
.base_baud  = 115200,
.uart_offset= 8,
--
1.4.4.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] max3100 driver

2007-12-05 Thread chripell
This patch adds support for the MAX3100 SPI UART.

Generated on  20071205  against v2.6.23

Signed-off-by: Christian Pellegrin [EMAIL PROTECTED]
---
 drivers/serial/Kconfig |7 +
 drivers/serial/Makefile|1 +
 drivers/serial/max3100.c   |  960 
 include/linux/serial_max3100.h |   25 +
 4 files changed, 993 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 81b52b7..4e7111b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index af6377d..9f67e52 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
new file mode 100644
index 000..dd48258
--- /dev/null
+++ b/drivers/serial/max3100.c
@@ -0,0 +1,960 @@
+
+/* 
+ *
+ *  Copyright (C) 2007 Christian Pellegrin [EMAIL PROTECTED]
+ *
+ * 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.
+ *
+ * version 0.1  31/5/2006   first public release
+ * version 0.2  11/11/2007  ported to kernel 2.6.23
+ *
+ *
+ *
+ * Notes: the MAX3100 doesn't provide an interrupt on CTS
+ * so we have to use polling for flow control. TX empty
+ * IRQ is unusable, since writing conf clears FIFO buffer.
+ *
+ * Example platform data:
+
+static struct plat_max3100 max3100_plat_data = {
+   .loopback = 0,
+   .crystal = 0,
+   .only_edge_irq = 0,
+};
+
+static struct spi_board_info spi_board_info[] = {
+   {
+   .modalias   = max3100,
+   .platform_data  = max3100_plat_data,
+   .irq= IRQ_EINT12,
+   .max_speed_hz   = 5*1000*1000,
+   .chip_select= 0,
+   },  
+};
+
+ */
+
+#include linux/bitops.h
+#include linux/console.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/errno.h
+#include linux/fcntl.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/keyboard.h
+#include linux/major.h
+#include linux/mm.h
+#include linux/module.h
+#include linux/pm.h
+#include linux/reboot.h
+#include linux/sched.h
+#include linux/serial_core.h
+#include linux/signal.h
+#include linux/spi/spi.h
+#include linux/string.h
+#include linux/timer.h
+#include linux/tty.h
+#include linux/tty_flip.h
+#include linux/workqueue.h
+
+#include asm/delay.h
+#include asm/io.h
+#include asm/irq.h
+#include asm/semaphore.h
+#include asm/system.h
+#include asm/uaccess.h
+
+#include linux/serial_max3100.h
+
+#define MAX3100_C(114)
+#define MAX3100_D(014)
+#define MAX3100_W(115)
+#define MAX3100_RX   (015)
+
+#define MAX3100_WC   (MAX3100_W | MAX3100_C)
+#define MAX3100_RC   (MAX3100_RX| MAX3100_C)
+#define MAX3100_WD   (MAX3100_W | MAX3100_D)
+#define MAX3100_RD   (MAX3100_RX| MAX3100_D)
+#define MAX3100_CMD  (3  14)
+
+#define MAX3100_T(114)
+#define MAX3100_R(115)
+
+#define MAX3100_FEN  (113)
+#define MAX3100_SHDN (112)
+#define MAX3100_TM   (111)
+#define MAX3100_RM   (110)
+#define MAX3100_PM   (19)
+#define MAX3100_RAM  (18)
+#define MAX3100_IR   (17)
+#define MAX3100_ST   (16)
+#define MAX3100_PE   (15)
+#define MAX3100_L(14)
+#define MAX3100_BAUD (0xf)
+
+#define MAX3100_TE   (110)
+#define MAX3100_RAFE (110)
+#define MAX3100_RTS  (19)
+#define MAX3100_CTS  (19)
+#define MAX3100_PT   (18)
+#define MAX3100_DATA (0xff)
+
+#define MAX3100_RT   (MAX3100_R | MAX3100_T)
+#define MAX3100_RTC  (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
+
+struct max3100_port_s {
+   struct uart_port port;
+   struct spi_device *spi;
+   struct tty_struct   *tty;
+  
+   struct semaphore   spi_txrx; /* protects access to the hw */
+
+   int rts;/* rts status, can be MAX3100_RTS or 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;