[PATCH] tty/serial : Add I2C support to Max310x driver (linux-3.8.13)

2016-09-07 Thread MeghanSaitwal

MAX3107/8 chip supports both SPI and I2C protocol. Currently, max310x
driver support only SPI protocol. This patch adds I2C support to the
driver. With I2C support, we have added bulk read/write functionality
which can be enabled using BULK_RW_ENABLE variable.

Signed-off-by: Meghan Saitwal 
meghansait...@eaton.com
Tested-by: Devidas Kalane 
devidaskal...@eaton.com
Suggested-by: Ashwin Patwekar 
ashwinpatwe...@eaton.com
drivers/tty/serial/Kconfig   |   38 +++-
drivers/tty/serial/Makefile  |2
drivers/tty/serial/max310x.c |  268 +++--
3 files changed, 254 insertions(+), 54 deletions(-)

diff -purN a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
--- a/drivers/tty/serial/Kconfig  2016-09-01 12:05:32.092474214 +0530
+++ b/drivers/tty/serial/Kconfig   2016-09-01 12:11:12.938507208 
+0530
@@ -276,19 +276,45 @@ config SERIAL_MAX3100
   help
 MAX3100 chip support

+config SERIAL_MAX310X_CORE
+ tristate
+
config SERIAL_MAX310X
-  bool "MAX310X support"
-  depends on SPI
+ tristate "MAX310X support"
+ depends on (SPI && !I2C) || I2C
   select SERIAL_CORE
-  select REGMAP_SPI if SPI
-  default n
   help
 This selects support for an advanced UART from Maxim (Dallas).
 Supported ICs are MAX3107, MAX3108.
 Each IC contains 128 words each of receive and transmit FIFO
-that can be controlled through I2C or high-speed SPI.
+   that can be controlled through I2C or high-speed SPI.
+   Select SPI or I2C bus using options below.
+
+config SERIAL_MAX310X_SPI
+ bool "MAX310x for spi interface"
+ depends on SERIAL_MAX310X
+ depends on SPI
+ select SERIAL_MAX310X_CORE if SERIAL_MAX310X
+ select REGMAP_SPI if SPI
+ default y
+ help
+Enable MAX310x driver on SPI bus,
+If required say y, and say n to spi if not required,
+Enabled by default to support oldconfig.
+You must select at least one bus for the driver to be built.
+
+config SERIAL_MAX310X_I2C
+ bool "MAX310x for I2C interface"
+ depends on SERIAL_MAX310X
+ depends on I2C
+ select SERIAL_MAX310XX_CORE if SERIAL_MAX310X
+ select REGMAP_I2C if I2C
+ help
+Enable MAX310x driver on I2C bus,
+If required say y, and say n to i2c if not required,
+This is additional support to existing driver.
+You must select at least one bus for the driver to be built.

-Say Y here if you want to support this ICs.

 config SERIAL_DZ
   bool "DECstation DZ serial driver"
diff -purN a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
--- a/drivers/tty/serial/Makefile   2016-09-01 12:07:31.815485804 
+0530
+++ b/drivers/tty/serial/Makefile2016-09-01 12:11:40.576509884 +0530
@@ -28,7 +28,7 @@ obj-$(CONFIG_SERIAL_BFIN) += bfin_uart.o
obj-$(CONFIG_SERIAL_BFIN_SPORT) += bfin_sport_uart.o
obj-$(CONFIG_SERIAL_SAMSUNG) += samsung.o
obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
-obj-$(CONFIG_SERIAL_MAX310X) += max310x.o
+obj-$(CONFIG_SERIAL_MAX310X_CORE) += max310x.o
obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
obj-$(CONFIG_SERIAL_MUX) += mux.o
obj-$(CONFIG_SERIAL_68328) += 68328serial.o
diff -purN a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
--- a/drivers/tty/serial/max310x.c2013-05-12 02:27:46.0 
+0530
+++ b/drivers/tty/serial/max310x.c 2016-08-12 10:22:40.0 +0530
@@ -25,8 +25,11 @@
#include 
#include 
#include 
+#include 
#include 

+#define BULK_RW_ENABLE  0
+
#define MAX310X_MAJOR 204
#define MAX310X_MINOR 209

@@ -272,6 +275,8 @@ struct max310x_port {
   const char   *name;
   int   uartclk;

+ unsigned charbuf[MAX310X_FIFO_SIZE];
+
   unsigned int   nr_gpio;
#ifdef CONFIG_GPIOLIB
   struct gpio_chipgpio;
@@ -459,7 +464,7 @@ static int max310x_set_ref_clk(struct ma

 static void max310x_handle_rx(struct max310x_port *s, unsigned int rxlen)
{
-  unsigned int sts = 0, ch = 0, flag;
+ unsigned int sts = 0, ch = 0, flag, bytes_read, i;
   struct tty_struct *tty = tty_port_tty_get(>port.state->port);

if (!tty)
@@ -473,7 +478,64 @@ static void max310x_handle_rx(struct max

dev_dbg(s->port.dev, "RX Len = %u\n", rxlen);

- 

How to submit patche to this list?

2016-09-06 Thread MeghanSaitwal
Hi,

I want to know about the procedure to submit the patch to this list.


Thanks,
Meghan Saitwal