serial: max310x: Driver rework
PATCH RESEND 2/3 serial: max310x: Add MAX3109 support
In reply to Alexander ShiyanThis patch adds support for MAX3109 (advanced dual universal asynchronous receiver-transmitter) into max310x driver.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/max310x.c | 35 +++++++++++++++++++++++++++++++---- include/linux/platform_data/max310x.h | 4 ++-- 3 files changed, 34 insertions(+), 7 deletions(-)
drivers/tty/serial/Kconfig +1 -1
@@ -297,7 +297,7 @@ config SERIAL_MAX310X default n help This selects support for an advanced UART from Maxim (Dallas). - Supported ICs are MAX3107, MAX3108. + Supported ICs are MAX3107, MAX3108, MAX3109. Each IC contains 128 words each of receive and transmit FIFO that can be controlled through I2C or high-speed SPI.
drivers/tty/serial/max310x.c +31 -4
@@ -1,5 +1,5 @@/* -* Maxim (Dallas) MAX3107/8 serial driver +* Maxim (Dallas) MAX3107/8/9 serial driver * * Copyright (C) 2012-2013 Alexander Shiyan <[email protected]> *
@@ -13,9 +13,6 @@* (at your option) any later version. */ -/* TODO: MAX3109 support (Dual) */ -/* TODO: MAX14830 support (Quad) */ -#include <linux/module.h> #include <linux/delay.h> #include <linux/device.h>
@@ -269,6 +266,9 @@/* MAX3107 specific */ #define MAX3107_REV_ID (0xa0) +/* MAX3109 specific */ +#define MAX3109_REV_ID (0xc0) +struct max310x_devtype {char name[9 ];int nr;
@@ -359,6 +359,25 @@ static int max3108_detect(struct device *dev)return 0 ; } +static int max3109_detect (struct device *dev) +{ +struct max310x_port *s =dev_get_drvdata (dev); +unsigned int val =0 ; +int ret; + + ret =regmap_read (s->regmap,MAX310X_REVID_REG , &val); +if (ret) +return ret; + +if (((val & MAX310x_REV_MASK) !=MAX3109_REV_ID )) { +dev_err (dev, +"%s ID 0x%02x does not match\n" , s->devtype->name, val); +return -ENODEV ; + } + +return 0 ; +} +static void max310x_power (struct uart_port *port,int on) { max310x_port_update(port, MAX310X_MODE1_REG,
@@ -382,6 +401,13 @@ static const struct max310x_devtype max3108_devtype = { .power = max310x_power, }; +static const struct max310x_devtype max3109_devtype = { + .name ="MAX3109" , + .nr =2 , + .detect = max3109_detect, + .power = max310x_power, +}; +static bool max310x_reg_writeable (struct device *dev,unsigned int reg) {switch (reg &0x1f ) {
@@ -1226,6 +1252,7 @@ static SIMPLE_DEV_PM_OPS(max310x_pm_ops, max310x_suspend, max310x_resume);static const struct spi_device_id max310x_id_table[] = { {"max3107" , (kernel_ulong_t)&max3107_devtype, }, {"max3108" , (kernel_ulong_t)&max3108_devtype, }, + {"max3109" , (kernel_ulong_t)&max3109_devtype, }, { } };MODULE_DEVICE_TABLE (spi, max310x_id_table);
include/linux/platform_data/max310x.h +2 -2
@@ -1,5 +1,5 @@/* -* Maxim (Dallas) MAX3107/8 serial driver +* Maxim (Dallas) MAX3107/8/9 serial driver * * Copyright (C) 2012 Alexander Shiyan <[email protected]> *
@@ -37,7 +37,7 @@* }; */ -#define MAX310X_MAX_UARTS 1 +#define MAX310X_MAX_UARTS 2/* MAX310X platform data structure */ struct max310x_pdata {
Signature · 1 line
1.8.1.5
PATCH RESEND 3/3 serial: max310x: Add MAX14830 support
In reply to Alexander ShiyanThis patch adds support for MAX14830 (advanced quad universal asynchronous receiver-transmitter) into max310x driver.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/max310x.c | 45 ++++++++++++++++++++++++++++++++++- include/linux/platform_data/max310x.h | 4 ++-- 3 files changed, 47 insertions(+), 4 deletions(-)
drivers/tty/serial/Kconfig +1 -1
@@ -297,7 +297,7 @@ config SERIAL_MAX310X default n help This selects support for an advanced UART from Maxim (Dallas). - Supported ICs are MAX3107, MAX3108, MAX3109. + Supported ICs are MAX3107, MAX3108, MAX3109, MAX14830. Each IC contains 128 words each of receive and transmit FIFO that can be controlled through I2C or high-speed SPI.
drivers/tty/serial/max310x.c +44 -1
73 lines not on this page · raw message
include/linux/platform_data/max310x.h +2 -2
@@ -1,5 +1,5 @@/* -* Maxim (Dallas) MAX3107/8/9 serial driver +* Maxim (Dallas) MAX3107/8/9, MAX14830 serial driver * * Copyright (C) 2012 Alexander Shiyan <[email protected]> *
@@ -37,7 +37,7 @@* }; */ -#define MAX310X_MAX_UARTS 2 +#define MAX310X_MAX_UARTS 4/* MAX310X platform data structure */ struct max310x_pdata {
Signature · 1 line
1.8.1.5
PATCH RESEND 1/3 serial: max310x: Driver rework
This patch rework max310x driver.
Major changes have been made:
- Prepare driver to support ICs with more than one UART.
- Prepare driver to support work with I2C-bus.
The patch changes almost every function and can not be divided into parts.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/tty/serial/Kconfig | 4 +- drivers/tty/serial/max310x.c | 918 +++++++++++++++++----------------- include/linux/platform_data/max310x.h | 5 +- 3 files changed, 454 insertions(+), 473 deletions(-)
drivers/tty/serial/Kconfig +2 -2
@@ -291,9 +291,9 @@ config SERIAL_MAX3100 config SERIAL_MAX310X bool "MAX310X support" - depends on SPI + depends on SPI_MASTER select SERIAL_CORE - select REGMAP_SPI if SPI + select REGMAP_SPI if SPI_MASTER default n help This selects support for an advanced UART from Maxim (Dallas).
drivers/tty/serial/max310x.c +451 -467
1,351 lines not on this page · raw message
include/linux/platform_data/max310x.h +1 -4
@@ -42,9 +42,8 @@/* MAX310X platform data structure */ struct max310x_pdata {/* Flags global to driver */ -const u8 driver_flags:2 ; +const u8 driver_flags;#define MAX310X_EXT_CLK (0x00000001)/* External clock enable */ -#define MAX310X_AUTOSLEEP (0x00000002)/* Enable AutoSleep mode */ /* Flags global to UART port */ const u8 uart_flags[MAX310X_MAX_UARTS ];#define MAX310X_LOOPBACK (0x00000001)/* Loopback mode enable */
@@ -60,8 +59,6 @@ struct max310x_pdata {void (*init)(void );/* Called before finish */ void (*exit)(void); -/* Suspend callback */ - void (*suspend)(int do_suspend); };#endif
Signature · 1 line
1.8.1.5