Re: [spi-devel-general] [RFC][PATCH v2] serial: spi: add spi-uart driver for Maxim 3110
On Tue, Feb 09, 2010 at 09:36:44AM +0800, Feng Tang wrote: On Tue, 9 Feb 2010 08:26:35 +0800 Grant Likely grant.lik...@secretlab.ca wrote: On Mon, Feb 8, 2010 at 5:20 PM, Andrew Morton a...@linux-foundation.org wrote: On Mon, 8 Feb 2010 16:59:46 +0800 Feng Tang feng.t...@intel.com wrote: Hi All, Here is a driver for Maxim 3110 SPI-UART device, please help to review. It has been validated with Designware SPI controller (drivers/spi: dw_spi.c dw_spi_pci.c). It supports polling and IRQ mode, supports batch read, and provides a console. I wonder if this is an spi subsystem thing or a serial subsystem thing. It looks more like a serial driver to me. I'm assuming serial; and hence I haven't picked it up into my tree. g. Yes, it's more related to serial stuff, and thus I put them into drivers/serial That's fine. Care to address Andrew's issues and resend the patch? thanks, greg k-h -- Download Intelreg; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
Re: [spi-devel-general] [RFC][PATCH v2] serial: spi: add spi-uart driver for Maxim 3110
+ for (i = 0; i len; i++) { + obuf[i] = (u8)xmit-buf[xmit-tail] | WD_TAG; + xmit-tail = (xmit-tail + 1) + (UART_XMIT_SIZE - 1); Could this driver use include/linux/kfifo.h, rather than open-coding it? The circ buffer stuff comes from the serial layer. The whole serial layer wants switching to kfifo (as and when we know why the kfifo changes seem to have broken USB serial) but the driver can't do that itself and use the serial core code until then. (Actually most of the serial_core code wants a rewrite but having had a couple of goes at doing it I've not figured out any way to do it without simply breaking all sorts of embedded platform serial drivers that need specific hardware to fix). + } + max3110_write_then_read(max, (u8 *)obuf, + (u8 *)ibuf, len * 2, 0); Error codes are ignored. The drivers/serial midlayer has no provision for reporting them. Alan -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
[spi-devel-general] [RFC][PATCH v2] serial: spi: add spi-uart driver for Maxim 3110
Hi All, Here is a driver for Maxim 3110 SPI-UART device, please help to review. It has been validated with Designware SPI controller (drivers/spi: dw_spi.c dw_spi_pci.c). It supports polling and IRQ mode, supports batch read, and provides a console. change since v1: * Address comments from Alan Cox * Use a use_irq module parameter to runtime check whether to use IRQ mode * Add the suspend/resume implementation Thanks! Feng From 6d14c5d68cdae8d48b6d8a00b6653022f2b100d0 Mon Sep 17 00:00:00 2001 From: Feng Tang feng.t...@intel.com Date: Mon, 8 Feb 2010 16:02:59 +0800 Subject: [PATCH] serial: spi: add spi-uart driver for Maxim 3110 This is the driver for Max3110 SPI-UART device, which connect to host with SPI interface. It supports baud rates from 300 to 230400, and supports both polling and IRQ mode, as well as providing a console for system use Its datasheet could be found here: http://datasheets.maxim-ic.com/en/ds/MAX3110E-MAX3111E.pdf Signed-off-by: Feng Tang feng.t...@intel.com --- drivers/serial/Kconfig | 12 + drivers/serial/max3110.c| 848 +++ drivers/serial/max3110.h| 59 +++ include/linux/serial_core.h |3 + 4 files changed, 922 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/max3110.c create mode 100644 drivers/serial/max3110.h diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 9ff47db..f7daf2f 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -688,6 +688,18 @@ config SERIAL_SA1100_CONSOLE your boot loader (lilo or loadlin) about how to pass options to the kernel at boot time.) +config SERIAL_MAX3110 + tristate SPI UART driver for Max3110 + select SERIAL_CORE + select SERIAL_CORE_CONSOLE + help + This is the UART protocol driver for MAX3110 device + +config MAX3110_DESIGNWARE + boolean Enable Max3110 to work with Designware controller + default y + depends on SERIAL_MAX3110 + config SERIAL_BFIN tristate Blackfin serial port support depends on BLACKFIN diff --git a/drivers/serial/max3110.c b/drivers/serial/max3110.c new file mode 100644 index 000..c7c012b --- /dev/null +++ b/drivers/serial/max3110.c @@ -0,0 +1,848 @@ +/* + * max3110.c - spi uart protocol driver for Maxim 3110 + * + * Copyright (c) 2009, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * Note: + * * From Max3110 spec, the Rx FIFO has 8 words, while the Tx FIFO only has + * 1 word. If SPI master controller doesn't support sclk frequency change, + * then the char need be sent out one by one with some delay + * + * * Currently only RX availabe interrrupt is used + */ + +#include linux/module.h +#include linux/ioport.h +#include linux/init.h +#include linux/console.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/serial_reg.h + +#include linux/kthread.h +#include linux/delay.h +#include asm/atomic.h +#include linux/spi/spi.h +#include linux/spi/dw_spi.h + +#include max3110.h + +#define PR_FMT max3110: + +struct uart_max3110 { + struct uart_port port; + struct spi_device *spi; + char *name; + + wait_queue_head_t wq; + struct task_struct *main_thread; + struct task_struct *read_thread; + int mthread_up; + spinlock_t lock; + + u32 baud; + u16 cur_conf; + u8 clock; + u8 parity, word_7bits; + + atomic_t uart_tx_need; + + /* console related */ + struct circ_buf con_xmit; + atomic_t con_tx_need; + + /* irq related */ + u16 irq; + atomic_t irq_pending; +}; + +static struct uart_max3110 *pmax; + +static int use_irq = 1; +module_param(use_irq, int, 0444); +MODULE_PARM_DESC(use_irq, Whether using Max3110's IRQ capability); + +static void receive_chars(struct uart_max3110 *max, + unsigned char *str, int len); +static int max3110_read_multi(struct uart_max3110 *max, int len, u8 *buf); +static void max3110_con_receive(struct uart_max3110 *max); + +int max3110_write_then_read(struct uart_max3110 *max, + const u8 *txbuf, u8 *rxbuf, unsigned len, int always_fast) +{ + struct spi_device *spi = max-spi; +
Re: [spi-devel-general] [RFC][PATCH v2] serial: spi: add spi-uart driver for Maxim 3110
On Mon, Feb 8, 2010 at 5:20 PM, Andrew Morton a...@linux-foundation.org wrote: On Mon, 8 Feb 2010 16:59:46 +0800 Feng Tang feng.t...@intel.com wrote: Hi All, Here is a driver for Maxim 3110 SPI-UART device, please help to review. It has been validated with Designware SPI controller (drivers/spi: dw_spi.c dw_spi_pci.c). It supports polling and IRQ mode, supports batch read, and provides a console. change since v1: * Address comments from Alan Cox * Use a use_irq module parameter to runtime check whether to use IRQ mode * Add the suspend/resume implementation Thanks! Feng From 6d14c5d68cdae8d48b6d8a00b6653022f2b100d0 Mon Sep 17 00:00:00 2001 From: Feng Tang feng.t...@intel.com Date: Mon, 8 Feb 2010 16:02:59 +0800 Subject: [PATCH] serial: spi: add spi-uart driver for Maxim 3110 This is the driver for Max3110 SPI-UART device, which connect to host with SPI interface. It supports baud rates from 300 to 230400, and supports both polling and IRQ mode, as well as providing a console for system use Its datasheet could be found here: http://datasheets.maxim-ic.com/en/ds/MAX3110E-MAX3111E.pdf I wonder if this is an spi subsystem thing or a serial subsystem thing. It looks more like a serial driver to me. I'm assuming serial; and hence I haven't picked it up into my tree. g. -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general