diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2013-06-29 02:44:18 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-26 18:53:27 -0400 |
commit | 21fc509f1194c2fa06eff4c72238210089c29453 (patch) | |
tree | cc458ad72251518283f0b2bd7d93671a338820bd /drivers/tty/serial/max310x.c | |
parent | 10d8b34a421716d55a4ff7c2d427c35e88b8fd60 (diff) |
serial: max310x: Add MAX3109 support
This patch adds support for MAX3109 (advanced dual universal asynchronous
receiver-transmitter) into max310x driver.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/max310x.c')
-rw-r--r-- | drivers/tty/serial/max310x.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 4620289e9e49..a6c46427363b 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Maxim (Dallas) MAX3107/8 serial driver | 2 | * Maxim (Dallas) MAX3107/8/9 serial driver |
3 | * | 3 | * |
4 | * Copyright (C) 2012-2013 Alexander Shiyan <shc_work@mail.ru> | 4 | * Copyright (C) 2012-2013 Alexander Shiyan <shc_work@mail.ru> |
5 | * | 5 | * |
@@ -13,9 +13,6 @@ | |||
13 | * (at your option) any later version. | 13 | * (at your option) any later version. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /* TODO: MAX3109 support (Dual) */ | ||
17 | /* TODO: MAX14830 support (Quad) */ | ||
18 | |||
19 | #include <linux/module.h> | 16 | #include <linux/module.h> |
20 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
21 | #include <linux/device.h> | 18 | #include <linux/device.h> |
@@ -269,6 +266,9 @@ | |||
269 | /* MAX3107 specific */ | 266 | /* MAX3107 specific */ |
270 | #define MAX3107_REV_ID (0xa0) | 267 | #define MAX3107_REV_ID (0xa0) |
271 | 268 | ||
269 | /* MAX3109 specific */ | ||
270 | #define MAX3109_REV_ID (0xc0) | ||
271 | |||
272 | struct max310x_devtype { | 272 | struct max310x_devtype { |
273 | char name[9]; | 273 | char name[9]; |
274 | int nr; | 274 | int nr; |
@@ -359,6 +359,25 @@ static int max3108_detect(struct device *dev) | |||
359 | return 0; | 359 | return 0; |
360 | } | 360 | } |
361 | 361 | ||
362 | static int max3109_detect(struct device *dev) | ||
363 | { | ||
364 | struct max310x_port *s = dev_get_drvdata(dev); | ||
365 | unsigned int val = 0; | ||
366 | int ret; | ||
367 | |||
368 | ret = regmap_read(s->regmap, MAX310X_REVID_REG, &val); | ||
369 | if (ret) | ||
370 | return ret; | ||
371 | |||
372 | if (((val & MAX310x_REV_MASK) != MAX3109_REV_ID)) { | ||
373 | dev_err(dev, | ||
374 | "%s ID 0x%02x does not match\n", s->devtype->name, val); | ||
375 | return -ENODEV; | ||
376 | } | ||
377 | |||
378 | return 0; | ||
379 | } | ||
380 | |||
362 | static void max310x_power(struct uart_port *port, int on) | 381 | static void max310x_power(struct uart_port *port, int on) |
363 | { | 382 | { |
364 | max310x_port_update(port, MAX310X_MODE1_REG, | 383 | max310x_port_update(port, MAX310X_MODE1_REG, |
@@ -382,6 +401,13 @@ static const struct max310x_devtype max3108_devtype = { | |||
382 | .power = max310x_power, | 401 | .power = max310x_power, |
383 | }; | 402 | }; |
384 | 403 | ||
404 | static const struct max310x_devtype max3109_devtype = { | ||
405 | .name = "MAX3109", | ||
406 | .nr = 2, | ||
407 | .detect = max3109_detect, | ||
408 | .power = max310x_power, | ||
409 | }; | ||
410 | |||
385 | static bool max310x_reg_writeable(struct device *dev, unsigned int reg) | 411 | static bool max310x_reg_writeable(struct device *dev, unsigned int reg) |
386 | { | 412 | { |
387 | switch (reg & 0x1f) { | 413 | switch (reg & 0x1f) { |
@@ -1226,6 +1252,7 @@ static SIMPLE_DEV_PM_OPS(max310x_pm_ops, max310x_suspend, max310x_resume); | |||
1226 | static const struct spi_device_id max310x_id_table[] = { | 1252 | static const struct spi_device_id max310x_id_table[] = { |
1227 | { "max3107", (kernel_ulong_t)&max3107_devtype, }, | 1253 | { "max3107", (kernel_ulong_t)&max3107_devtype, }, |
1228 | { "max3108", (kernel_ulong_t)&max3108_devtype, }, | 1254 | { "max3108", (kernel_ulong_t)&max3108_devtype, }, |
1255 | { "max3109", (kernel_ulong_t)&max3109_devtype, }, | ||
1229 | { } | 1256 | { } |
1230 | }; | 1257 | }; |
1231 | MODULE_DEVICE_TABLE(spi, max310x_id_table); | 1258 | MODULE_DEVICE_TABLE(spi, max310x_id_table); |