diff options
Diffstat (limited to 'drivers/tty/serial/ifx6x60.c')
-rw-r--r-- | drivers/tty/serial/ifx6x60.c | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index ab93763862d5..8ee5a41d340d 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Jan Dumon <j.dumon@option.com> | 8 | * Jan Dumon <j.dumon@option.com> |
9 | * | 9 | * |
10 | * Copyright (C) 2009, 2010 Intel Corp | 10 | * Copyright (C) 2009, 2010 Intel Corp |
11 | * Russ Gorby <richardx.r.gorby@intel.com> | 11 | * Russ Gorby <russ.gorby@intel.com> |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
14 | * it under the terms of the GNU General Public License version 2 as | 14 | * it under the terms of the GNU General Public License version 2 as |
@@ -67,6 +67,7 @@ | |||
67 | #define IFX_SPI_MORE_MASK 0x10 | 67 | #define IFX_SPI_MORE_MASK 0x10 |
68 | #define IFX_SPI_MORE_BIT 12 /* bit position in u16 */ | 68 | #define IFX_SPI_MORE_BIT 12 /* bit position in u16 */ |
69 | #define IFX_SPI_CTS_BIT 13 /* bit position in u16 */ | 69 | #define IFX_SPI_CTS_BIT 13 /* bit position in u16 */ |
70 | #define IFX_SPI_MODE SPI_MODE_1 | ||
70 | #define IFX_SPI_TTY_ID 0 | 71 | #define IFX_SPI_TTY_ID 0 |
71 | #define IFX_SPI_TIMEOUT_SEC 2 | 72 | #define IFX_SPI_TIMEOUT_SEC 2 |
72 | #define IFX_SPI_HEADER_0 (-1) | 73 | #define IFX_SPI_HEADER_0 (-1) |
@@ -76,7 +77,7 @@ | |||
76 | static void ifx_spi_handle_srdy(struct ifx_spi_device *ifx_dev); | 77 | static void ifx_spi_handle_srdy(struct ifx_spi_device *ifx_dev); |
77 | 78 | ||
78 | /* local variables */ | 79 | /* local variables */ |
79 | static int spi_b16 = 1; /* 8 or 16 bit word length */ | 80 | static int spi_bpw = 16; /* 8, 16 or 32 bit word length */ |
80 | static struct tty_driver *tty_drv; | 81 | static struct tty_driver *tty_drv; |
81 | static struct ifx_spi_device *saved_ifx_dev; | 82 | static struct ifx_spi_device *saved_ifx_dev; |
82 | static struct lock_class_key ifx_spi_key; | 83 | static struct lock_class_key ifx_spi_key; |
@@ -244,7 +245,7 @@ static void ifx_spi_timeout(unsigned long arg) | |||
244 | * Map the signal state into Linux modem flags and report the value | 245 | * Map the signal state into Linux modem flags and report the value |
245 | * in Linux terms | 246 | * in Linux terms |
246 | */ | 247 | */ |
247 | static int ifx_spi_tiocmget(struct tty_struct *tty, struct file *filp) | 248 | static int ifx_spi_tiocmget(struct tty_struct *tty) |
248 | { | 249 | { |
249 | unsigned int value; | 250 | unsigned int value; |
250 | struct ifx_spi_device *ifx_dev = tty->driver_data; | 251 | struct ifx_spi_device *ifx_dev = tty->driver_data; |
@@ -262,7 +263,6 @@ static int ifx_spi_tiocmget(struct tty_struct *tty, struct file *filp) | |||
262 | /** | 263 | /** |
263 | * ifx_spi_tiocmset - set modem bits | 264 | * ifx_spi_tiocmset - set modem bits |
264 | * @tty: the tty structure | 265 | * @tty: the tty structure |
265 | * @filp: file handle issuing the request | ||
266 | * @set: bits to set | 266 | * @set: bits to set |
267 | * @clear: bits to clear | 267 | * @clear: bits to clear |
268 | * | 268 | * |
@@ -271,7 +271,7 @@ static int ifx_spi_tiocmget(struct tty_struct *tty, struct file *filp) | |||
271 | * | 271 | * |
272 | * FIXME: do we need to kick the tranfers when we do this ? | 272 | * FIXME: do we need to kick the tranfers when we do this ? |
273 | */ | 273 | */ |
274 | static int ifx_spi_tiocmset(struct tty_struct *tty, struct file *filp, | 274 | static int ifx_spi_tiocmset(struct tty_struct *tty, |
275 | unsigned int set, unsigned int clear) | 275 | unsigned int set, unsigned int clear) |
276 | { | 276 | { |
277 | struct ifx_spi_device *ifx_dev = tty->driver_data; | 277 | struct ifx_spi_device *ifx_dev = tty->driver_data; |
@@ -722,9 +722,9 @@ static void ifx_spi_io(unsigned long data) | |||
722 | /* note len is BYTES, not transfers */ | 722 | /* note len is BYTES, not transfers */ |
723 | ifx_dev->spi_xfer.len = IFX_SPI_TRANSFER_SIZE; | 723 | ifx_dev->spi_xfer.len = IFX_SPI_TRANSFER_SIZE; |
724 | ifx_dev->spi_xfer.cs_change = 0; | 724 | ifx_dev->spi_xfer.cs_change = 0; |
725 | ifx_dev->spi_xfer.speed_hz = 12500000; | 725 | ifx_dev->spi_xfer.speed_hz = ifx_dev->spi_dev->max_speed_hz; |
726 | /* ifx_dev->spi_xfer.speed_hz = 390625; */ | 726 | /* ifx_dev->spi_xfer.speed_hz = 390625; */ |
727 | ifx_dev->spi_xfer.bits_per_word = spi_b16 ? 16 : 8; | 727 | ifx_dev->spi_xfer.bits_per_word = spi_bpw; |
728 | 728 | ||
729 | ifx_dev->spi_xfer.tx_buf = ifx_dev->tx_buffer; | 729 | ifx_dev->spi_xfer.tx_buf = ifx_dev->tx_buffer; |
730 | ifx_dev->spi_xfer.rx_buf = ifx_dev->rx_buffer; | 730 | ifx_dev->spi_xfer.rx_buf = ifx_dev->rx_buffer; |
@@ -732,7 +732,7 @@ static void ifx_spi_io(unsigned long data) | |||
732 | /* | 732 | /* |
733 | * setup dma pointers | 733 | * setup dma pointers |
734 | */ | 734 | */ |
735 | if (ifx_dev->is_6160) { | 735 | if (ifx_dev->use_dma) { |
736 | ifx_dev->spi_msg.is_dma_mapped = 1; | 736 | ifx_dev->spi_msg.is_dma_mapped = 1; |
737 | ifx_dev->tx_dma = ifx_dev->tx_bus; | 737 | ifx_dev->tx_dma = ifx_dev->tx_bus; |
738 | ifx_dev->rx_dma = ifx_dev->rx_bus; | 738 | ifx_dev->rx_dma = ifx_dev->rx_bus; |
@@ -798,8 +798,8 @@ static int ifx_spi_create_port(struct ifx_spi_device *ifx_dev) | |||
798 | goto error_ret; | 798 | goto error_ret; |
799 | } | 799 | } |
800 | 800 | ||
801 | pport->ops = &ifx_tty_port_ops; | ||
802 | tty_port_init(pport); | 801 | tty_port_init(pport); |
802 | pport->ops = &ifx_tty_port_ops; | ||
803 | ifx_dev->minor = IFX_SPI_TTY_ID; | 803 | ifx_dev->minor = IFX_SPI_TTY_ID; |
804 | ifx_dev->tty_dev = tty_register_device(tty_drv, ifx_dev->minor, | 804 | ifx_dev->tty_dev = tty_register_device(tty_drv, ifx_dev->minor, |
805 | &ifx_dev->spi_dev->dev); | 805 | &ifx_dev->spi_dev->dev); |
@@ -960,7 +960,7 @@ static int ifx_spi_spi_probe(struct spi_device *spi) | |||
960 | { | 960 | { |
961 | int ret; | 961 | int ret; |
962 | int srdy; | 962 | int srdy; |
963 | struct ifx_modem_platform_data *pl_data = NULL; | 963 | struct ifx_modem_platform_data *pl_data; |
964 | struct ifx_spi_device *ifx_dev; | 964 | struct ifx_spi_device *ifx_dev; |
965 | 965 | ||
966 | if (saved_ifx_dev) { | 966 | if (saved_ifx_dev) { |
@@ -968,6 +968,12 @@ static int ifx_spi_spi_probe(struct spi_device *spi) | |||
968 | return -ENODEV; | 968 | return -ENODEV; |
969 | } | 969 | } |
970 | 970 | ||
971 | pl_data = (struct ifx_modem_platform_data *)spi->dev.platform_data; | ||
972 | if (!pl_data) { | ||
973 | dev_err(&spi->dev, "missing platform data!"); | ||
974 | return -ENODEV; | ||
975 | } | ||
976 | |||
971 | /* initialize structure to hold our device variables */ | 977 | /* initialize structure to hold our device variables */ |
972 | ifx_dev = kzalloc(sizeof(struct ifx_spi_device), GFP_KERNEL); | 978 | ifx_dev = kzalloc(sizeof(struct ifx_spi_device), GFP_KERNEL); |
973 | if (!ifx_dev) { | 979 | if (!ifx_dev) { |
@@ -983,14 +989,25 @@ static int ifx_spi_spi_probe(struct spi_device *spi) | |||
983 | init_timer(&ifx_dev->spi_timer); | 989 | init_timer(&ifx_dev->spi_timer); |
984 | ifx_dev->spi_timer.function = ifx_spi_timeout; | 990 | ifx_dev->spi_timer.function = ifx_spi_timeout; |
985 | ifx_dev->spi_timer.data = (unsigned long)ifx_dev; | 991 | ifx_dev->spi_timer.data = (unsigned long)ifx_dev; |
986 | ifx_dev->is_6160 = pl_data->is_6160; | 992 | ifx_dev->modem = pl_data->modem_type; |
993 | ifx_dev->use_dma = pl_data->use_dma; | ||
994 | ifx_dev->max_hz = pl_data->max_hz; | ||
995 | /* initialize spi mode, etc */ | ||
996 | spi->max_speed_hz = ifx_dev->max_hz; | ||
997 | spi->mode = IFX_SPI_MODE | (SPI_LOOP & spi->mode); | ||
998 | spi->bits_per_word = spi_bpw; | ||
999 | ret = spi_setup(spi); | ||
1000 | if (ret) { | ||
1001 | dev_err(&spi->dev, "SPI setup wasn't successful %d", ret); | ||
1002 | return -ENODEV; | ||
1003 | } | ||
987 | 1004 | ||
988 | /* ensure SPI protocol flags are initialized to enable transfer */ | 1005 | /* ensure SPI protocol flags are initialized to enable transfer */ |
989 | ifx_dev->spi_more = 0; | 1006 | ifx_dev->spi_more = 0; |
990 | ifx_dev->spi_slave_cts = 0; | 1007 | ifx_dev->spi_slave_cts = 0; |
991 | 1008 | ||
992 | /*initialize transfer and dma buffers */ | 1009 | /*initialize transfer and dma buffers */ |
993 | ifx_dev->tx_buffer = dma_alloc_coherent(&ifx_dev->spi_dev->dev, | 1010 | ifx_dev->tx_buffer = dma_alloc_coherent(ifx_dev->spi_dev->dev.parent, |
994 | IFX_SPI_TRANSFER_SIZE, | 1011 | IFX_SPI_TRANSFER_SIZE, |
995 | &ifx_dev->tx_bus, | 1012 | &ifx_dev->tx_bus, |
996 | GFP_KERNEL); | 1013 | GFP_KERNEL); |
@@ -999,7 +1016,7 @@ static int ifx_spi_spi_probe(struct spi_device *spi) | |||
999 | ret = -ENOMEM; | 1016 | ret = -ENOMEM; |
1000 | goto error_ret; | 1017 | goto error_ret; |
1001 | } | 1018 | } |
1002 | ifx_dev->rx_buffer = dma_alloc_coherent(&ifx_dev->spi_dev->dev, | 1019 | ifx_dev->rx_buffer = dma_alloc_coherent(ifx_dev->spi_dev->dev.parent, |
1003 | IFX_SPI_TRANSFER_SIZE, | 1020 | IFX_SPI_TRANSFER_SIZE, |
1004 | &ifx_dev->rx_bus, | 1021 | &ifx_dev->rx_bus, |
1005 | GFP_KERNEL); | 1022 | GFP_KERNEL); |
@@ -1025,18 +1042,11 @@ static int ifx_spi_spi_probe(struct spi_device *spi) | |||
1025 | goto error_ret; | 1042 | goto error_ret; |
1026 | } | 1043 | } |
1027 | 1044 | ||
1028 | pl_data = (struct ifx_modem_platform_data *)spi->dev.platform_data; | 1045 | ifx_dev->gpio.reset = pl_data->rst_pmu; |
1029 | if (pl_data) { | 1046 | ifx_dev->gpio.po = pl_data->pwr_on; |
1030 | ifx_dev->gpio.reset = pl_data->rst_pmu; | 1047 | ifx_dev->gpio.mrdy = pl_data->mrdy; |
1031 | ifx_dev->gpio.po = pl_data->pwr_on; | 1048 | ifx_dev->gpio.srdy = pl_data->srdy; |
1032 | ifx_dev->gpio.mrdy = pl_data->mrdy; | 1049 | ifx_dev->gpio.reset_out = pl_data->rst_out; |
1033 | ifx_dev->gpio.srdy = pl_data->srdy; | ||
1034 | ifx_dev->gpio.reset_out = pl_data->rst_out; | ||
1035 | } else { | ||
1036 | dev_err(&spi->dev, "missing platform data!"); | ||
1037 | ret = -ENODEV; | ||
1038 | goto error_ret; | ||
1039 | } | ||
1040 | 1050 | ||
1041 | dev_info(&spi->dev, "gpios %d, %d, %d, %d, %d", | 1051 | dev_info(&spi->dev, "gpios %d, %d, %d, %d, %d", |
1042 | ifx_dev->gpio.reset, ifx_dev->gpio.po, ifx_dev->gpio.mrdy, | 1052 | ifx_dev->gpio.reset, ifx_dev->gpio.po, ifx_dev->gpio.mrdy, |
@@ -1322,9 +1332,9 @@ static const struct spi_device_id ifx_id_table[] = { | |||
1322 | MODULE_DEVICE_TABLE(spi, ifx_id_table); | 1332 | MODULE_DEVICE_TABLE(spi, ifx_id_table); |
1323 | 1333 | ||
1324 | /* spi operations */ | 1334 | /* spi operations */ |
1325 | static const struct spi_driver ifx_spi_driver_6160 = { | 1335 | static const struct spi_driver ifx_spi_driver = { |
1326 | .driver = { | 1336 | .driver = { |
1327 | .name = "ifx6160", | 1337 | .name = DRVNAME, |
1328 | .bus = &spi_bus_type, | 1338 | .bus = &spi_bus_type, |
1329 | .pm = &ifx_spi_pm, | 1339 | .pm = &ifx_spi_pm, |
1330 | .owner = THIS_MODULE}, | 1340 | .owner = THIS_MODULE}, |
@@ -1346,7 +1356,7 @@ static void __exit ifx_spi_exit(void) | |||
1346 | { | 1356 | { |
1347 | /* unregister */ | 1357 | /* unregister */ |
1348 | tty_unregister_driver(tty_drv); | 1358 | tty_unregister_driver(tty_drv); |
1349 | spi_unregister_driver((void *)&ifx_spi_driver_6160); | 1359 | spi_unregister_driver((void *)&ifx_spi_driver); |
1350 | } | 1360 | } |
1351 | 1361 | ||
1352 | /** | 1362 | /** |
@@ -1388,7 +1398,7 @@ static int __init ifx_spi_init(void) | |||
1388 | return result; | 1398 | return result; |
1389 | } | 1399 | } |
1390 | 1400 | ||
1391 | result = spi_register_driver((void *)&ifx_spi_driver_6160); | 1401 | result = spi_register_driver((void *)&ifx_spi_driver); |
1392 | if (result) { | 1402 | if (result) { |
1393 | pr_err("%s: spi_register_driver failed(%d)", | 1403 | pr_err("%s: spi_register_driver failed(%d)", |
1394 | DRVNAME, result); | 1404 | DRVNAME, result); |