* Re: [PATCH v4] serial/arc-uart: Add New Driver
From: Vineet Gupta @ 2012-10-26 6:16 UTC (permalink / raw)
To: Greg KH; +Cc: alan, arc-linux-dev, linux-serial, linux-kernel
In-Reply-To: <20121025183643.GA22504@kroah.com>
On Friday 26 October 2012 12:06 AM, Greg KH wrote:
> On Thu, Oct 25, 2012 at 12:00:07PM +0530, Vineet.Gupta1@synopsys.com wrote:
>> From: Vineet Gupta <vgupta@synopsys.com>
>>
>> Hi Greg,
>>
>> Rebased off of tty-next and verfied that it builds fine.
> Did you run it?
Absolutely ! What I meant was, this specific version (rebased off of
tty-next) can't be run for ARC platform yet (for which this driver is
originally meant). The preceding version based off of 3.6 (including all
of Alan's review comments) already runs for our 3.6 kernel.
>
>> Please consider applying.
> I can't, see my review comments.
Updated revision to follow
Thx,
-Vineet
>
> thanks,
>
> greg k-h
^ permalink raw reply
* Re: [PATCH] serial/arc-uart: Add new driver
From: Vineet Gupta @ 2012-10-26 6:16 UTC (permalink / raw)
To: Greg KH; +Cc: alan, arc-linux-dev, linux-serial, linux-kernel
In-Reply-To: <20121025183619.GA22545@kroah.com>
On Friday 26 October 2012 12:06 AM, Greg KH wrote:
> On Thu, Oct 25, 2012 at 12:00:08PM +0530, Vineet.Gupta1@synopsys.com wrote:
>> From: Vineet Gupta <vgupta@synopsys.com>
>>
>> Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys)
>> FPGA Boards such as ARCAngel4/ML50x
>>
>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
>> ---
>> drivers/tty/serial/Kconfig | 25 ++
>> drivers/tty/serial/Makefile | 1 +
>> drivers/tty/serial/arc_uart.c | 747 ++++++++++++++++++++++++++++++++++++++
>> include/uapi/linux/serial_core.h | 2 +
>> 4 files changed, 775 insertions(+), 0 deletions(-)
>> create mode 100644 drivers/tty/serial/arc_uart.c
>>
>> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
>> index 2a53be5..efee7fe 100644
>> --- a/drivers/tty/serial/Kconfig
>> +++ b/drivers/tty/serial/Kconfig
>> @@ -1423,4 +1423,29 @@ config SERIAL_EFM32_UART_CONSOLE
>> depends on SERIAL_EFM32_UART=y
>> select SERIAL_CORE_CONSOLE
>>
>> +config SERIAL_ARC
>> + bool "ARC UART driver support"
>> + select SERIAL_CORE
>> + default y
>> + help
>> + Driver for on-chip UART for ARC(Synopsys) for the legacy
>> + FPGA Boards (ML50x/ARCAngel4)
> Unless you will break a user's box, NEVER define a default value for a
> new configuration option as y.
OK !
> And why can't I select this driver as a module?
Because it's missing the equivalent of following (plus some more changes)
- bool "ARC UART driver support"
+ tristate "ARC UART driver support"
ARC platform (where this driver originates from) always had system
console on UART - thus we never had the need for making it a loadable
module. But I guess as a matter of principle it nevertheless needs to
work - fixed in the next revision !
>> +
>> +config SERIAL_ARC_CONSOLE
>> + bool
>> + select SERIAL_CORE_CONSOLE
>> + depends on SERIAL_ARC=y
>> + default y
>> + help
>> + Enable system Console on ARC UART
>> +
>> +config SERIAL_ARC_NR_PORTS
>> + int 'Number of ports'
>> + range 1 3
>> + default 1
>> + depends on SERIAL_ARC
>> + help
>> + Set this to the number of serial ports you want the driver
>> + to support.
>> +
>> endmenu
>> diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
>> index 4f694da..df1b998 100644
>> --- a/drivers/tty/serial/Makefile
>> +++ b/drivers/tty/serial/Makefile
>> @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o
>> obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o
>> obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o
>> obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o
>> +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o
>> diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
>> new file mode 100644
>> index 0000000..9215bf4
>> --- /dev/null
>> +++ b/drivers/tty/serial/arc_uart.c
>> @@ -0,0 +1,747 @@
>> +/*
>> + * ARC On-Chip(fpga) UART Driver
>> + *
>> + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com)
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * vineetg: July 10th 2012
>> + * -Decoupled the driver from arch/arc
>> + * +Using platform_get_resource() for irq/membase (thx to bfin_uart.c)
>> + * +Using early_platform_xxx() for early console (thx to mach-shmobile/xxx)
>> + *
>> + * Vineetg: Aug 21st 2010
>> + * -Is uart_tx_stopped() not done in tty write path as it has already been
>> + * taken care of, in serial core
>> + *
>> + * Vineetg: Aug 18th 2010
>> + * -New Serial Core based ARC UART driver
>> + * -Derived largely from blackfin driver albiet with some major tweaks
>> + *
>> + * TODO:
>> + * -check if sysreq works
>> + */
>> +
>> +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
>> +#define SUPPORT_SYSRQ
>> +#endif
> Are you sure this works? Don't you usually need to include some .h
> files before you check these config values?
We've been using the exact same driver for years - literally.
AFAIK, all the CONFIG_xxx items come in from generated autoconf.h which
is included implicitly by build system via cmd line based -include
kconfig.h, thus any explicit header is not needed for them. Also
SUPPORT_SYSRQ needs to be defined BEFORE including any header because
that is the way serial_core.h build can be influenced in a non-ambiguous
way.
>> +
>> +#include <linux/module.h>
>> +#include <linux/serial.h>
>> +#include <linux/console.h>
>> +#include <linux/sysrq.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/tty.h>
>> +#include <linux/tty_flip.h>
>> +#include <linux/serial_core.h>
>> +#include <linux/io.h>
>> +
>> +/*************************************
>> + * ARC UART Hardware Specs
>> + ************************************/
>> +#define ARC_UART_TX_FIFO_SIZE 1
>> +
>> +/*
>> + * UART Register set (this is not a Standards Compliant IP)
>> + * Also each reg is Word aligned, but only 8 bits wide
>> + */
>> +#define R_ID0 0
>> +#define R_ID1 1
>> +#define R_ID2 2
>> +#define R_ID3 3
>> +#define R_DATA 4
>> +#define R_STS 5
>> +#define R_BAUDL 6
>> +#define R_BAUDH 7
>> +
>> +/* Bits for UART Status Reg (R/W) */
>> +#define RXIENB 0x04 /* Receive Interrupt Enable */
>> +#define TXIENB 0x40 /* Transmit Interrupt Enable */
>> +
>> +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */
>> +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */
>> +
>> +#define RXFULL 0x08 /* Receive FIFO full */
>> +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */
>> +
>> +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */
>> +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */
>> +
>> +/* Uart bit fiddling helpers: lowest level */
>> +#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg)
>> +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r))
>> +#define UART_REG_GET(u, r) readb(RBASE(u, r))
> What happens when you run sparse on this driver?
(1) The cast was indeed causing warning - that's now fixed, with an
equivalent of following:
-#define R_ID1 1
-#define R_ID2 2
-#define R_ID3 3
-#define R_DATA 4
-#define R_STS 5
-#define R_BAUDL 6
-#define R_BAUDH 7
+#define R_ID1 4
+#define R_ID2 8
+#define R_ID3 12
+#define R_DATA 16
+#define R_STS 20
+#define R_BAUDL 24
+#define R_BAUDH 28
-#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg)
+#define RBASE(uart, reg) (uart->port.membase + reg)
(2) Other two seem to be false warnings for imbalance of
spin_lock_irqsave/restore, which otherwise seem OK to me!
>
> thanks,
>
> greg k-h
^ permalink raw reply
* Re: [PATCH v2 2/3] serial: mxs-auart: add the DMA support for mx28
From: Vinod Koul @ 2012-10-25 11:08 UTC (permalink / raw)
To: Huang Shijie
Cc: vinod.koul, linux, gregkh, lauri.hintsala, linux-serial,
shawn.guo, linux-arm-kernel, alan
In-Reply-To: <5089033F.9040100@freescale.com>
On Thu, 2012-10-25 at 17:15 +0800, Huang Shijie wrote:
> yes. I have to setup the register. Could you told me which API is the
> right API?
dmaengine_slave_config() should be used to send the slave specfic
parameters
>
> It seems to the mxs-dma needs a patch again.
Yes definitely :)
--
Vinod Koul
Intel Corp.
^ permalink raw reply
* tty/serial patch queue caught up on
From: Greg KH @ 2012-10-25 20:37 UTC (permalink / raw)
To: linux-serial
Hi all,
I've caught up on my big pile of TTY and serial patches that were sent
to me during the merge window (and a bit before). So if I haven't
applied a patch that you sent me, consider it lost, so please resend.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH v4] serial/arc-uart: Add New Driver
From: Greg KH @ 2012-10-25 18:36 UTC (permalink / raw)
To: Vineet.Gupta1; +Cc: alan, arc-linux-dev, linux-serial, linux-kernel
In-Reply-To: <1351146608-21044-1-git-send-email-vgupta@synopsys.com>
On Thu, Oct 25, 2012 at 12:00:07PM +0530, Vineet.Gupta1@synopsys.com wrote:
> From: Vineet Gupta <vgupta@synopsys.com>
>
> Hi Greg,
>
> Rebased off of tty-next and verfied that it builds fine.
Did you run it?
> Please consider applying.
I can't, see my review comments.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH] serial/arc-uart: Add new driver
From: Greg KH @ 2012-10-25 18:36 UTC (permalink / raw)
To: Vineet.Gupta1; +Cc: alan, arc-linux-dev, linux-serial, linux-kernel
In-Reply-To: <1351146608-21044-2-git-send-email-vgupta@synopsys.com>
On Thu, Oct 25, 2012 at 12:00:08PM +0530, Vineet.Gupta1@synopsys.com wrote:
> From: Vineet Gupta <vgupta@synopsys.com>
>
> Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys)
> FPGA Boards such as ARCAngel4/ML50x
>
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> ---
> drivers/tty/serial/Kconfig | 25 ++
> drivers/tty/serial/Makefile | 1 +
> drivers/tty/serial/arc_uart.c | 747 ++++++++++++++++++++++++++++++++++++++
> include/uapi/linux/serial_core.h | 2 +
> 4 files changed, 775 insertions(+), 0 deletions(-)
> create mode 100644 drivers/tty/serial/arc_uart.c
>
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 2a53be5..efee7fe 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -1423,4 +1423,29 @@ config SERIAL_EFM32_UART_CONSOLE
> depends on SERIAL_EFM32_UART=y
> select SERIAL_CORE_CONSOLE
>
> +config SERIAL_ARC
> + bool "ARC UART driver support"
> + select SERIAL_CORE
> + default y
> + help
> + Driver for on-chip UART for ARC(Synopsys) for the legacy
> + FPGA Boards (ML50x/ARCAngel4)
Unless you will break a user's box, NEVER define a default value for a
new configuration option as y.
And why can't I select this driver as a module?
> +
> +config SERIAL_ARC_CONSOLE
> + bool
> + select SERIAL_CORE_CONSOLE
> + depends on SERIAL_ARC=y
> + default y
> + help
> + Enable system Console on ARC UART
> +
> +config SERIAL_ARC_NR_PORTS
> + int 'Number of ports'
> + range 1 3
> + default 1
> + depends on SERIAL_ARC
> + help
> + Set this to the number of serial ports you want the driver
> + to support.
> +
> endmenu
> diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
> index 4f694da..df1b998 100644
> --- a/drivers/tty/serial/Makefile
> +++ b/drivers/tty/serial/Makefile
> @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o
> obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o
> obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o
> obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o
> +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o
> diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
> new file mode 100644
> index 0000000..9215bf4
> --- /dev/null
> +++ b/drivers/tty/serial/arc_uart.c
> @@ -0,0 +1,747 @@
> +/*
> + * ARC On-Chip(fpga) UART Driver
> + *
> + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com)
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * vineetg: July 10th 2012
> + * -Decoupled the driver from arch/arc
> + * +Using platform_get_resource() for irq/membase (thx to bfin_uart.c)
> + * +Using early_platform_xxx() for early console (thx to mach-shmobile/xxx)
> + *
> + * Vineetg: Aug 21st 2010
> + * -Is uart_tx_stopped() not done in tty write path as it has already been
> + * taken care of, in serial core
> + *
> + * Vineetg: Aug 18th 2010
> + * -New Serial Core based ARC UART driver
> + * -Derived largely from blackfin driver albiet with some major tweaks
> + *
> + * TODO:
> + * -check if sysreq works
> + */
> +
> +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
> +#define SUPPORT_SYSRQ
> +#endif
Are you sure this works? Don't you usually need to include some .h
files before you check these config values?
> +
> +#include <linux/module.h>
> +#include <linux/serial.h>
> +#include <linux/console.h>
> +#include <linux/sysrq.h>
> +#include <linux/platform_device.h>
> +#include <linux/tty.h>
> +#include <linux/tty_flip.h>
> +#include <linux/serial_core.h>
> +#include <linux/io.h>
> +
> +/*************************************
> + * ARC UART Hardware Specs
> + ************************************/
> +#define ARC_UART_TX_FIFO_SIZE 1
> +
> +/*
> + * UART Register set (this is not a Standards Compliant IP)
> + * Also each reg is Word aligned, but only 8 bits wide
> + */
> +#define R_ID0 0
> +#define R_ID1 1
> +#define R_ID2 2
> +#define R_ID3 3
> +#define R_DATA 4
> +#define R_STS 5
> +#define R_BAUDL 6
> +#define R_BAUDH 7
> +
> +/* Bits for UART Status Reg (R/W) */
> +#define RXIENB 0x04 /* Receive Interrupt Enable */
> +#define TXIENB 0x40 /* Transmit Interrupt Enable */
> +
> +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */
> +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */
> +
> +#define RXFULL 0x08 /* Receive FIFO full */
> +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */
> +
> +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */
> +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */
> +
> +/* Uart bit fiddling helpers: lowest level */
> +#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg)
> +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r))
> +#define UART_REG_GET(u, r) readb(RBASE(u, r))
What happens when you run sparse on this driver?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 0/2] staging: dgrp: remove use of real_raw and read_cnt
From: Greg KH @ 2012-10-25 18:23 UTC (permalink / raw)
To: Bill Pemberton; +Cc: linux-serial
In-Reply-To: <1351183582-13573-1-git-send-email-wfp5p@virginia.edu>
On Thu, Oct 25, 2012 at 12:46:20PM -0400, Bill Pemberton wrote:
>
> Patches for tty-next to fix dgrp breakage when real_raw and and
> read_cnt where removed from tty_struct.
Now applied, thanks.
greg k-h
^ permalink raw reply
* [PATCH 1/2] staging: dgrp: remove use of real_raw and read_cnt in dgrp_input
From: Bill Pemberton @ 2012-10-25 16:46 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial
In-Reply-To: <1351183582-13573-1-git-send-email-wfp5p@virginia.edu>
dgrp_input used real_raw and read_cnt from struct tty_struct. Those
members have gone away. Rework the code to not use them.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
---
drivers/staging/dgrp/dgrp_net_ops.c | 67 +++++--------------------------------
1 file changed, 8 insertions(+), 59 deletions(-)
diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c
index ab839ea..0788357 100644
--- a/drivers/staging/dgrp/dgrp_net_ops.c
+++ b/drivers/staging/dgrp/dgrp_net_ops.c
@@ -151,20 +151,15 @@ static void dgrp_read_data_block(struct ch_struct *ch, u8 *flipbuf,
* Copys the rbuf to the flipbuf and sends to line discipline.
* Sends input buffer data to the line discipline.
*
- * There are several modes to consider here:
- * rawreadok, tty->real_raw, and IF_PARMRK
*/
static void dgrp_input(struct ch_struct *ch)
{
struct nd_struct *nd;
struct tty_struct *tty;
- int remain;
int data_len;
int len;
- int flip_len;
int tty_count;
ulong lock_flags;
- struct tty_ldisc *ld;
u8 *myflipbuf;
u8 *myflipflagbuf;
@@ -212,37 +207,11 @@ static void dgrp_input(struct ch_struct *ch)
spin_unlock_irqrestore(&nd->nd_lock, lock_flags);
- /* Decide how much data we can send into the tty layer */
- if (dgrp_rawreadok && tty->real_raw)
- flip_len = MYFLIPLEN;
- else
- flip_len = TTY_FLIPBUF_SIZE;
-
/* data_len should be the number of chars that we read in */
data_len = (ch->ch_rin - ch->ch_rout) & RBUF_MASK;
- remain = data_len;
/* len is the amount of data we are going to transfer here */
- len = min(data_len, flip_len);
-
- /* take into consideration length of ldisc */
- len = min(len, (N_TTY_BUF_SIZE - 1) - tty->read_cnt);
-
- ld = tty_ldisc_ref(tty);
-
- /*
- * If we were unable to get a reference to the ld,
- * don't flush our buffer, and act like the ld doesn't
- * have any space to put the data right now.
- */
- if (!ld) {
- len = 0;
- } else if (!ld->ops->receive_buf) {
- spin_lock_irqsave(&nd->nd_lock, lock_flags);
- ch->ch_rout = ch->ch_rin;
- spin_unlock_irqrestore(&nd->nd_lock, lock_flags);
- len = 0;
- }
+ len = tty_buffer_request_room(tty, data_len);
/* Check DPA flow control */
if ((nd->nd_dpa_debug) &&
@@ -254,42 +223,22 @@ static void dgrp_input(struct ch_struct *ch)
dgrp_read_data_block(ch, myflipbuf, len);
- /*
- * In high performance mode, we don't have to update
- * flag_buf or any of the counts or pointers into flip buf.
- */
- if (!dgrp_rawreadok || !tty->real_raw) {
- if (I_PARMRK(tty) || I_BRKINT(tty) || I_INPCK(tty))
- parity_scan(ch, myflipbuf, myflipflagbuf, &len);
- else
- memset(myflipflagbuf, TTY_NORMAL, len);
- }
+ if (I_PARMRK(tty) || I_BRKINT(tty) || I_INPCK(tty))
+ parity_scan(ch, myflipbuf, myflipflagbuf, &len);
+ else
+ memset(myflipflagbuf, TTY_NORMAL, len);
if ((nd->nd_dpa_debug) &&
(nd->nd_dpa_port == PORT_NUM(MINOR(tty_devnum(tty)))))
dgrp_dpa_data(nd, 1, myflipbuf, len);
- /*
- * If we're doing raw reads, jam it right into the
- * line disc bypassing the flip buffers.
- */
- if (dgrp_rawreadok && tty->real_raw)
- ld->ops->receive_buf(tty, myflipbuf, NULL, len);
- else {
- len = tty_buffer_request_room(tty, len);
- tty_insert_flip_string_flags(tty, myflipbuf,
- myflipflagbuf, len);
-
- /* Tell the tty layer its okay to "eat" the data now */
- tty_flip_buffer_push(tty);
- }
+ tty_insert_flip_string_flags(tty, myflipbuf,
+ myflipflagbuf, len);
+ tty_flip_buffer_push(tty);
ch->ch_rxcount += len;
}
- if (ld)
- tty_ldisc_deref(ld);
-
/*
* Wake up any sleepers (maybe dgrp close) that might be waiting
* for a channel flag state change.
--
1.7.12
^ permalink raw reply related
* [PATCH 2/2] staging: dgrp: remove rawreadok module option
From: Bill Pemberton @ 2012-10-25 16:46 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial
In-Reply-To: <1351183582-13573-1-git-send-email-wfp5p@virginia.edu>
The functionality behind this option has been removed in the driver so
remove the config option to set/unset it.
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
---
drivers/staging/dgrp/dgrp_common.h | 1 -
drivers/staging/dgrp/dgrp_driver.c | 4 ----
drivers/staging/dgrp/dgrp_specproc.c | 2 --
drivers/staging/dgrp/dgrp_sysfs.c | 18 ------------------
4 files changed, 25 deletions(-)
diff --git a/drivers/staging/dgrp/dgrp_common.h b/drivers/staging/dgrp/dgrp_common.h
index 05ff338..0583fe9 100644
--- a/drivers/staging/dgrp/dgrp_common.h
+++ b/drivers/staging/dgrp/dgrp_common.h
@@ -31,7 +31,6 @@
* All global storage allocation.
************************************************************************/
-extern int dgrp_rawreadok; /* Allow raw writing of input */
extern int dgrp_register_cudevices; /* enable legacy cu devices */
extern int dgrp_register_prdevices; /* enable transparent print devices */
extern int dgrp_poll_tick; /* Poll interval - in ms */
diff --git a/drivers/staging/dgrp/dgrp_driver.c b/drivers/staging/dgrp/dgrp_driver.c
index 6e4a0eb..aa26258 100644
--- a/drivers/staging/dgrp/dgrp_driver.c
+++ b/drivers/staging/dgrp/dgrp_driver.c
@@ -39,14 +39,10 @@ MODULE_VERSION(DIGI_VERSION);
struct list_head nd_struct_list;
struct dgrp_poll_data dgrp_poll_data;
-int dgrp_rawreadok = 1; /* Bypass flipbuf on input */
int dgrp_register_cudevices = 1;/* Turn on/off registering legacy cu devices */
int dgrp_register_prdevices = 1;/* Turn on/off registering transparent print */
int dgrp_poll_tick = 20; /* Poll interval - in ms */
-module_param_named(rawreadok, dgrp_rawreadok, int, 0644);
-MODULE_PARM_DESC(rawreadok, "Bypass flip buffers on input");
-
module_param_named(register_cudevices, dgrp_register_cudevices, int, 0644);
MODULE_PARM_DESC(register_cudevices, "Turn on/off registering legacy cu devices");
diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c
index 24327c3..db91f67 100644
--- a/drivers/staging/dgrp/dgrp_specproc.c
+++ b/drivers/staging/dgrp/dgrp_specproc.c
@@ -629,8 +629,6 @@ static int info_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "version: %s\n", DIGI_VERSION);
seq_puts(m, "register_with_sysfs: 1\n");
- seq_printf(m, "rawreadok: 0x%08x\t(%d)\n",
- dgrp_rawreadok, dgrp_rawreadok);
seq_printf(m, "pollrate: 0x%08x\t(%d)\n",
dgrp_poll_tick, dgrp_poll_tick);
diff --git a/drivers/staging/dgrp/dgrp_sysfs.c b/drivers/staging/dgrp/dgrp_sysfs.c
index e5a3c88..8b513e9 100644
--- a/drivers/staging/dgrp/dgrp_sysfs.c
+++ b/drivers/staging/dgrp/dgrp_sysfs.c
@@ -55,23 +55,6 @@ static DEVICE_ATTR(register_with_sysfs, 0400,
dgrp_class_register_with_sysfs_show, NULL);
-static ssize_t dgrp_class_rawreadok_show(struct device *c,
- struct device_attribute *attr,
- char *buf)
-{
- return snprintf(buf, PAGE_SIZE, "%d\n", dgrp_rawreadok);
-}
-static ssize_t dgrp_class_rawreadok_store(struct device *c,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- sscanf(buf, "0x%x\n", &dgrp_rawreadok);
- return count;
-}
-static DEVICE_ATTR(rawreadok, 0600, dgrp_class_rawreadok_show,
- dgrp_class_rawreadok_store);
-
-
static ssize_t dgrp_class_pollrate_show(struct device *c,
struct device_attribute *attr,
char *buf)
@@ -91,7 +74,6 @@ static DEVICE_ATTR(pollrate, 0600, dgrp_class_pollrate_show,
static struct attribute *dgrp_sysfs_global_settings_entries[] = {
&dev_attr_pollrate.attr,
- &dev_attr_rawreadok.attr,
&dev_attr_register_with_sysfs.attr,
NULL
};
--
1.7.12
^ permalink raw reply related
* [PATCH 0/2] staging: dgrp: remove use of real_raw and read_cnt
From: Bill Pemberton @ 2012-10-25 16:46 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial
Patches for tty-next to fix dgrp breakage when real_raw and and
read_cnt where removed from tty_struct.
--
Bill
^ permalink raw reply
* Re: 8250_early for big-endian
From: Alan Cox @ 2012-10-25 11:18 UTC (permalink / raw)
To: Noam Camus; +Cc: linux-serial@vger.kernel.org, Vineet Gupta, Gilad Ben Yossef
In-Reply-To: <264C179F799EF24AB26D5319053335E80CC300184F@ezexch.ezchip.com>
On Thu, 25 Oct 2012 09:08:53 +0200
Noam Camus <noamc@ezchip.com> wrote:
> ________________________________________
> From: Alan Cox [alan@lxorguk.ukuu.org.uk]
> Sent: Sunday, October 14, 2012 2:32 PM
>
> >For 8250_early it may well be the right thing is to support similar
> serial_in/serial_out methods.
>
> Hello Alan,
> Below is my proposed patch could you apply it?
>
> >From e819fbbf9690b72620c54a62fa34545c7b035f91 Mon Sep 17 00:00:00 2001
> From: Noam Camus <noamc@ezchip.com>
> Date: Wed, 3 Oct 2012 09:40:36 +0200
> Subject: [PATCH] tty/8250_early: Make serial_in/serial_out be over-ridden
>
> Now one can replace default methods with similar fit to its needs.
> e.g. choose other regshift, register offset...
>
> Signed-off-by: Noam Camus <noamc@ezchip.com>
> CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
> ---
> drivers/tty/serial/8250/8250_early.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
> index eaafb98..ac31b0c 100644
> --- a/drivers/tty/serial/8250/8250_early.c
> +++ b/drivers/tty/serial/8250/8250_early.c
> @@ -48,7 +48,7 @@ struct early_serial8250_device {
>
> static struct early_serial8250_device early_device;
>
> -static unsigned int __init serial_in(struct uart_port *port, int offset)
> +unsigned int __weak __init serial_in(struct uart_port *port, int offset)
If you make the symbols global then they need a prefix to avoid clashes -
just rename them something like serial8250_early_in/serial8250_early_out
and of course they ought to be in the header files somewhere...
Alan
^ permalink raw reply
* [REPOST-v2] sched: Prevent wakeup to enter critical section needlessly
From: Ivo Sieben @ 2012-10-25 10:12 UTC (permalink / raw)
To: linux-kernel, Andi Kleen, Oleg Nesterov, Peter Zijlstra,
Ingo Molnar
Cc: linux-serial, Alan Cox, Greg KH, Ivo Sieben
In-Reply-To: <1350549005-18309-1-git-send-email-meltedpianoman@gmail.com>
Check the waitqueue task list to be non empty before entering the critical
section. This prevents locking the spin lock needlessly in case the queue
was empty, and therefor also prevent scheduling overhead on a PREEMPT_RT
system.
Signed-off-by: Ivo Sieben <meltedpianoman@gmail.com>
---
repost:
Did I apply the memory barrier correct?
v2:
- We don't need the "careful" list empty, a normal list empty is sufficient:
if you miss an update it was just as it happened a little later.
- Because of memory ordering problems we can observe an unupdated list
administration. This can cause an wait_event-like code to miss an event.
Adding a memory barrier befor checking the list to be empty will guarantee we
evaluate a 100% updated list adminsitration.
kernel/sched/core.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2d8927f..168a9b2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3090,9 +3090,22 @@ void __wake_up(wait_queue_head_t *q, unsigned int mode,
{
unsigned long flags;
- spin_lock_irqsave(&q->lock, flags);
- __wake_up_common(q, mode, nr_exclusive, 0, key);
- spin_unlock_irqrestore(&q->lock, flags);
+ /*
+ * We check for list emptiness outside the lock. This prevents the wake
+ * up to enter the critical section needlessly when the task list is
+ * empty.
+ *
+ * Placed a full memory barrier before checking list emptiness to make
+ * 100% sure this function sees an up-to-date list administration.
+ * Note that other code that manipulates the list uses a spin_lock and
+ * therefore doesn't need additional memory barriers.
+ */
+ smp_mb();
+ if (!list_empty(&q->task_list)) {
+ spin_lock_irqsave(&q->lock, flags);
+ __wake_up_common(q, mode, nr_exclusive, 0, key);
+ spin_unlock_irqrestore(&q->lock, flags);
+ }
}
EXPORT_SYMBOL(__wake_up);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v2 2/3] serial: mxs-auart: add the DMA support for mx28
From: Huang Shijie @ 2012-10-25 9:15 UTC (permalink / raw)
To: Vinod Koul
Cc: vinod.koul, linux, gregkh, lauri.hintsala, linux-serial,
shawn.guo, linux-arm-kernel, alan
In-Reply-To: <1351145272.7077.8.camel@vkoul-udesk3>
于 2012年10月25日 14:07, Vinod Koul 写道:
> On Thu, 2012-10-25 at 13:50 +0800, Huang Shijie wrote:
>> 于 2012年10月25日 12:18, Vinod Koul 写道:
>>>> +
>>>> +static int mxs_auart_dma_tx(struct mxs_auart_port *s, int size)
>>>> +{
>>>> + struct dma_async_tx_descriptor *desc;
>>>> + struct scatterlist *sgl =&s->tx_sgl;
>>>> + struct dma_chan *channel = s->tx_dma_chan;
>>>> + u32 pio;
>>>> +
>>>> + /* [1] : send PIO. Note, the first pio word is CTRL1. */
>>>> + pio = AUART_CTRL1_XFER_COUNT(size);
>>>> + desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)&pio,
>>>> + 1, DMA_TRANS_NONE, 0);
>>> this seems like a hack. API expects a scatterlist as argument.
>>> Same thing about direction, NONE doesnt mean anything for dma transfer.
>> It's not a hack. this DMA descriptor is used to set the registers.
>> Please see the code in drivers/dma/mxs-dma.c:mxs_dam_prep_slave_sg().
> yes it is, and also an abuse of the api.
> prep_slave_sg() expects a scatter list and you are passing something
> else and using DMA_TRANS_NONE to do that, which makes no sense!!!
>
> If you have to setup your registers you need to setup based on what APIs
> passed you and not by abusing.
>
yes. I have to setup the register. Could you told me which API is the
right API?
It seems to the mxs-dma needs a patch again.
>>>> + if (!desc) {
>>>> + dev_err(s->dev, "step 1 error\n");
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> + /* [2] : set DMA buffer. */
>>>> + sg_init_one(sgl, s->tx_dma_buf, size);
>>>> + dma_map_sg(s->dev, sgl, 1, DMA_TO_DEVICE);
>>>> + desc = dmaengine_prep_slave_sg(channel, sgl,
>>>> + 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>>>> + if (!desc) {
>>>> + dev_err(s->dev, "step 2 error\n");
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> + /* [3] : submit the DMA */
>>>> + desc->callback = dma_tx_callback;
>>>> + desc->callback_param = s;
>>>> + dmaengine_submit(desc);
>>>> + dma_async_issue_pending(channel);
>>>> + return 0;
>>>> +}
>>>> +
>>>>
>>>> +static bool mxs_auart_dma_filter(struct dma_chan *chan, void *param)
>>>> +{
>>>> + struct mxs_auart_port *s = param;
>>>> +
>>>> + if (!mxs_dma_is_apbx(chan))
>>>> + return false;
>>>> +
>>>> + if (s->dma_channel == chan->chan_id) {
>>>> + chan->private =&s->dma_data;
>>> dont use chan->private. You need to dmaengine_slave_config API
>> please see the drivers/dma/mxs-dma.c:mxs_dam_alloc_chan_resoures().
>>
>> The mxs-dma driver uses ->private to store the channel interrupt number.
> And which it should not be doing. private is not supposed to be used for
> passing info. If it is generic add to slave config.
>
Could you give me an example which do not use the private?
The imx-sdma also uses the private to pass some info.
thanks
Huang Shijie
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* RE: 8250_early for big-endian
From: Noam Camus @ 2012-10-25 7:08 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-serial@vger.kernel.org, Vineet Gupta, Gilad Ben Yossef
In-Reply-To: <20121014133216.686277e1@pyramind.ukuu.org.uk>
________________________________________
From: Alan Cox [alan@lxorguk.ukuu.org.uk]
Sent: Sunday, October 14, 2012 2:32 PM
>For 8250_early it may well be the right thing is to support similar
serial_in/serial_out methods.
Hello Alan,
Below is my proposed patch could you apply it?
>From e819fbbf9690b72620c54a62fa34545c7b035f91 Mon Sep 17 00:00:00 2001
From: Noam Camus <noamc@ezchip.com>
Date: Wed, 3 Oct 2012 09:40:36 +0200
Subject: [PATCH] tty/8250_early: Make serial_in/serial_out be over-ridden
Now one can replace default methods with similar fit to its needs.
e.g. choose other regshift, register offset...
Signed-off-by: Noam Camus <noamc@ezchip.com>
CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
---
drivers/tty/serial/8250/8250_early.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index eaafb98..ac31b0c 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -48,7 +48,7 @@ struct early_serial8250_device {
static struct early_serial8250_device early_device;
-static unsigned int __init serial_in(struct uart_port *port, int offset)
+unsigned int __weak __init serial_in(struct uart_port *port, int offset)
{
switch (port->iotype) {
case UPIO_MEM:
@@ -62,7 +62,7 @@ static unsigned int __init serial_in(struct uart_port *port, int offset)
}
}
-static void __init serial_out(struct uart_port *port, int offset, int value)
+void __weak __init serial_out(struct uart_port *port, int offset, int value)
{
switch (port->iotype) {
case UPIO_MEM:
--
1.7.1
Noam
^ permalink raw reply related
* Re: [PATCH v2 2/3] serial: mxs-auart: add the DMA support for mx28
From: Vinod Koul @ 2012-10-25 6:07 UTC (permalink / raw)
To: Huang Shijie
Cc: vinod.koul, linux, gregkh, lauri.hintsala, linux-serial,
shawn.guo, linux-arm-kernel, alan
In-Reply-To: <5088D336.7040206@freescale.com>
On Thu, 2012-10-25 at 13:50 +0800, Huang Shijie wrote:
> 于 2012年10月25日 12:18, Vinod Koul 写道:
> >
> >> +
> >> +static int mxs_auart_dma_tx(struct mxs_auart_port *s, int size)
> >> +{
> >> + struct dma_async_tx_descriptor *desc;
> >> + struct scatterlist *sgl =&s->tx_sgl;
> >> + struct dma_chan *channel = s->tx_dma_chan;
> >> + u32 pio;
> >> +
> >> + /* [1] : send PIO. Note, the first pio word is CTRL1. */
> >> + pio = AUART_CTRL1_XFER_COUNT(size);
> >> + desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)&pio,
> >> + 1, DMA_TRANS_NONE, 0);
> > this seems like a hack. API expects a scatterlist as argument.
> > Same thing about direction, NONE doesnt mean anything for dma transfer.
> It's not a hack. this DMA descriptor is used to set the registers.
> Please see the code in drivers/dma/mxs-dma.c:mxs_dam_prep_slave_sg().
yes it is, and also an abuse of the api.
prep_slave_sg() expects a scatter list and you are passing something
else and using DMA_TRANS_NONE to do that, which makes no sense!!!
If you have to setup your registers you need to setup based on what APIs
passed you and not by abusing.
> >> + if (!desc) {
> >> + dev_err(s->dev, "step 1 error\n");
> >> + return -EINVAL;
> >> + }
> >> +
> >> + /* [2] : set DMA buffer. */
> >> + sg_init_one(sgl, s->tx_dma_buf, size);
> >> + dma_map_sg(s->dev, sgl, 1, DMA_TO_DEVICE);
> >> + desc = dmaengine_prep_slave_sg(channel, sgl,
> >> + 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> >> + if (!desc) {
> >> + dev_err(s->dev, "step 2 error\n");
> >> + return -EINVAL;
> >> + }
> >> +
> >> + /* [3] : submit the DMA */
> >> + desc->callback = dma_tx_callback;
> >> + desc->callback_param = s;
> >> + dmaengine_submit(desc);
> >> + dma_async_issue_pending(channel);
> >> + return 0;
> >> +}
> >> +
> >>
> >> +static bool mxs_auart_dma_filter(struct dma_chan *chan, void *param)
> >> +{
> >> + struct mxs_auart_port *s = param;
> >> +
> >> + if (!mxs_dma_is_apbx(chan))
> >> + return false;
> >> +
> >> + if (s->dma_channel == chan->chan_id) {
> >> + chan->private =&s->dma_data;
> > dont use chan->private. You need to dmaengine_slave_config API
> please see the drivers/dma/mxs-dma.c:mxs_dam_alloc_chan_resoures().
>
> The mxs-dma driver uses ->private to store the channel interrupt number.
And which it should not be doing. private is not supposed to be used for
passing info. If it is generic add to slave config.
--
Vinod Koul
Intel Corp.
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] serial/arc-uart: Add new driver
From: Vineet.Gupta1 @ 2012-10-25 6:30 UTC (permalink / raw)
To: alan, gregkh; +Cc: arc-linux-dev, linux-serial, linux-kernel, Vineet Gupta
In-Reply-To: <1351146608-21044-1-git-send-email-vgupta@synopsys.com>
From: Vineet Gupta <vgupta@synopsys.com>
Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys)
FPGA Boards such as ARCAngel4/ML50x
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
drivers/tty/serial/Kconfig | 25 ++
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/arc_uart.c | 747 ++++++++++++++++++++++++++++++++++++++
include/uapi/linux/serial_core.h | 2 +
4 files changed, 775 insertions(+), 0 deletions(-)
create mode 100644 drivers/tty/serial/arc_uart.c
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 2a53be5..efee7fe 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1423,4 +1423,29 @@ config SERIAL_EFM32_UART_CONSOLE
depends on SERIAL_EFM32_UART=y
select SERIAL_CORE_CONSOLE
+config SERIAL_ARC
+ bool "ARC UART driver support"
+ select SERIAL_CORE
+ default y
+ help
+ Driver for on-chip UART for ARC(Synopsys) for the legacy
+ FPGA Boards (ML50x/ARCAngel4)
+
+config SERIAL_ARC_CONSOLE
+ bool
+ select SERIAL_CORE_CONSOLE
+ depends on SERIAL_ARC=y
+ default y
+ help
+ Enable system Console on ARC UART
+
+config SERIAL_ARC_NR_PORTS
+ int 'Number of ports'
+ range 1 3
+ default 1
+ depends on SERIAL_ARC
+ help
+ Set this to the number of serial ports you want the driver
+ to support.
+
endmenu
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 4f694da..df1b998 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o
obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o
obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o
obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o
+obj-$(CONFIG_SERIAL_ARC) += arc_uart.o
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
new file mode 100644
index 0000000..9215bf4
--- /dev/null
+++ b/drivers/tty/serial/arc_uart.c
@@ -0,0 +1,747 @@
+/*
+ * ARC On-Chip(fpga) UART Driver
+ *
+ * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: July 10th 2012
+ * -Decoupled the driver from arch/arc
+ * +Using platform_get_resource() for irq/membase (thx to bfin_uart.c)
+ * +Using early_platform_xxx() for early console (thx to mach-shmobile/xxx)
+ *
+ * Vineetg: Aug 21st 2010
+ * -Is uart_tx_stopped() not done in tty write path as it has already been
+ * taken care of, in serial core
+ *
+ * Vineetg: Aug 18th 2010
+ * -New Serial Core based ARC UART driver
+ * -Derived largely from blackfin driver albiet with some major tweaks
+ *
+ * TODO:
+ * -check if sysreq works
+ */
+
+#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/module.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+#include <linux/platform_device.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial_core.h>
+#include <linux/io.h>
+
+/*************************************
+ * ARC UART Hardware Specs
+ ************************************/
+#define ARC_UART_TX_FIFO_SIZE 1
+
+/*
+ * UART Register set (this is not a Standards Compliant IP)
+ * Also each reg is Word aligned, but only 8 bits wide
+ */
+#define R_ID0 0
+#define R_ID1 1
+#define R_ID2 2
+#define R_ID3 3
+#define R_DATA 4
+#define R_STS 5
+#define R_BAUDL 6
+#define R_BAUDH 7
+
+/* Bits for UART Status Reg (R/W) */
+#define RXIENB 0x04 /* Receive Interrupt Enable */
+#define TXIENB 0x40 /* Transmit Interrupt Enable */
+
+#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */
+#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */
+
+#define RXFULL 0x08 /* Receive FIFO full */
+#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */
+
+#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */
+#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */
+
+/* Uart bit fiddling helpers: lowest level */
+#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg)
+#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r))
+#define UART_REG_GET(u, r) readb(RBASE(u, r))
+
+#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v))
+#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v))
+
+/* Uart bit fiddling helpers: API level */
+#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val)
+#define UART_GET_DATA(uart) UART_REG_GET(uart, R_DATA)
+
+#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val)
+#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val)
+
+#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val)
+#define UART_GET_STATUS(uart) UART_REG_GET(uart, R_STS)
+
+#define UART_ALL_IRQ_DISABLE(uart) UART_REG_CLR(uart, R_STS, RXIENB|TXIENB)
+#define UART_RX_IRQ_DISABLE(uart) UART_REG_CLR(uart, R_STS, RXIENB)
+#define UART_TX_IRQ_DISABLE(uart) UART_REG_CLR(uart, R_STS, TXIENB)
+
+#define UART_ALL_IRQ_ENABLE(uart) UART_REG_OR(uart, R_STS, RXIENB|TXIENB)
+#define UART_RX_IRQ_ENABLE(uart) UART_REG_OR(uart, R_STS, RXIENB)
+#define UART_TX_IRQ_ENABLE(uart) UART_REG_OR(uart, R_STS, TXIENB)
+
+#define ARC_SERIAL_DEV_NAME "ttyARC"
+
+struct arc_uart_port {
+ struct uart_port port;
+ unsigned long baud;
+ int is_emulated; /* H/w vs. Instruction Set Simulator */
+};
+
+static struct arc_uart_port arc_uart_ports[CONFIG_SERIAL_ARC_NR_PORTS];
+
+#ifdef CONFIG_SERIAL_ARC_CONSOLE
+static struct console arc_console;
+#endif
+
+#define DRIVER_NAME "arc-uart"
+
+static struct uart_driver arc_uart_driver = {
+ .owner = THIS_MODULE,
+ .driver_name = DRIVER_NAME,
+ .dev_name = ARC_SERIAL_DEV_NAME,
+ .major = 0,
+ .minor = 0,
+ .nr = CONFIG_SERIAL_ARC_NR_PORTS,
+#ifdef CONFIG_SERIAL_ARC_CONSOLE
+ .cons = &arc_console,
+#else
+ .cons = NULL,
+#endif
+};
+
+static void arc_serial_stop_rx(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+
+ UART_RX_IRQ_DISABLE(uart);
+}
+
+static void arc_serial_stop_tx(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+
+ while (!(UART_GET_STATUS(uart) & TXEMPTY))
+ cpu_relax();
+
+ UART_TX_IRQ_DISABLE(uart);
+}
+
+/*
+ * Return TIOCSER_TEMT when transmitter is not busy.
+ */
+static unsigned int arc_serial_tx_empty(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+ unsigned int stat;
+
+ stat = UART_GET_STATUS(uart);
+ if (stat & TXEMPTY)
+ return TIOCSER_TEMT;
+ else
+ return 0;
+}
+
+/*
+ * Driver internal routine, used by both tty(serial core) as well as tx-isr
+ * -Called under spinlock in either cases
+ * -also tty->stopped / tty->hw_stopped has already been checked
+ * = by uart_start( ) before calling us
+ * = tx_ist checks that too before calling
+ */
+static void arc_serial_tx_chars(struct arc_uart_port *uart)
+{
+ struct circ_buf *xmit = &uart->port.state->xmit;
+ int sent = 0;
+ unsigned char ch;
+
+ if (unlikely(uart->port.x_char)) {
+ UART_SET_DATA(uart, uart->port.x_char);
+ uart->port.icount.tx++;
+ uart->port.x_char = 0;
+ sent = 1;
+ } else if (xmit->tail != xmit->head) { /* TODO: uart_circ_empty */
+ ch = xmit->buf[xmit->tail];
+ xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+ uart->port.icount.tx++;
+ while (!(UART_GET_STATUS(uart) & TXEMPTY))
+ cpu_relax();
+ UART_SET_DATA(uart, ch);
+ sent = 1;
+ }
+
+ /*
+ * If num chars in xmit buffer are too few, ask tty layer for more.
+ * By Hard ISR to schedule processing in software interrupt part
+ */
+ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+ uart_write_wakeup(&uart->port);
+
+ if (sent)
+ UART_TX_IRQ_ENABLE(uart);
+}
+
+/*
+ * port is locked and interrupts are disabled
+ * uart_start( ) calls us under the port spinlock irqsave
+ */
+static void arc_serial_start_tx(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+
+ arc_serial_tx_chars(uart);
+}
+
+static void arc_serial_rx_chars(struct arc_uart_port *uart)
+{
+ struct tty_struct *tty = tty_port_tty_get(&uart->port.state->port);
+ unsigned int status, ch, flg = 0;
+
+ if (!tty)
+ return;
+
+ /*
+ * UART has 4 deep RX-FIFO. Driver's recongnition of this fact
+ * is very subtle. Here's how ...
+ * Upon getting a RX-Intr, such that RX-EMPTY=0, meaning data available,
+ * driver reads the DATA Reg and keeps doing that in a loop, until
+ * RX-EMPTY=1. Multiple chars being avail, with a single Interrupt,
+ * before RX-EMPTY=0, implies some sort of buffering going on in the
+ * controller, which is indeed the Rx-FIFO.
+ */
+ while (!((status = UART_GET_STATUS(uart)) & RXEMPTY)) {
+
+ ch = UART_GET_DATA(uart);
+ uart->port.icount.rx++;
+
+ if (unlikely(status & (RXOERR | RXFERR))) {
+ if (status & RXOERR) {
+ uart->port.icount.overrun++;
+ flg = TTY_OVERRUN;
+ UART_CLR_STATUS(uart, RXOERR);
+ }
+
+ if (status & RXFERR) {
+ uart->port.icount.frame++;
+ flg = TTY_FRAME;
+ UART_CLR_STATUS(uart, RXFERR);
+ }
+ } else
+ flg = TTY_NORMAL;
+
+ if (unlikely(uart_handle_sysrq_char(&uart->port, ch)))
+ goto done;
+
+ uart_insert_char(&uart->port, status, RXOERR, ch, flg);
+
+done:
+ tty_flip_buffer_push(tty);
+ }
+
+ tty_kref_put(tty);
+}
+
+/*
+ * A note on the Interrupt handling state machine of this driver
+ *
+ * kernel printk writes funnel thru the console driver framework and in order
+ * to keep things simple as well as efficient, it writes to UART in polled
+ * mode, in one shot, and exits.
+ *
+ * OTOH, Userland output (via tty layer), uses interrupt based writes as there
+ * can be undeterministic delay between char writes.
+ *
+ * Thus Rx-interrupts are always enabled, while tx-interrupts are by default
+ * disabled.
+ *
+ * When tty has some data to send out, serial core calls driver's start_tx
+ * which
+ * -checks-if-tty-buffer-has-char-to-send
+ * -writes-data-to-uart
+ * -enable-tx-intr
+ *
+ * Once data bits are pushed out, controller raises the Tx-room-avail-Interrupt.
+ * The first thing Tx ISR does is disable further Tx interrupts (as this could
+ * be the last char to send, before settling down into the quiet polled mode).
+ * It then calls the exact routine used by tty layer write to send out any
+ * more char in tty buffer. In case of sending, it re-enables Tx-intr. In case
+ * of no data, it remains disabled.
+ * This is how the transmit state machine is dynamically switched on/off
+ */
+
+static irqreturn_t arc_serial_isr(int irq, void *dev_id)
+{
+ struct arc_uart_port *uart = dev_id;
+ unsigned int status;
+
+ status = UART_GET_STATUS(uart);
+
+ /*
+ * Single IRQ for both Rx (data available) Tx (room available) Interrupt
+ * notifications from the UART Controller.
+ * To demultiplex between the two, we check the relevant bits
+ */
+ if ((status & RXIENB) && !(status & RXEMPTY)) {
+
+ /* already in ISR, no need of xx_irqsave */
+ spin_lock(&uart->port.lock);
+ arc_serial_rx_chars(uart);
+ spin_unlock(&uart->port.lock);
+ }
+
+ if ((status & TXIENB) && (status & TXEMPTY)) {
+
+ /* Unconditionally disable further Tx-Interrupts.
+ * will be enabled by tx_chars() if needed.
+ */
+ UART_TX_IRQ_DISABLE(uart);
+
+ spin_lock(&uart->port.lock);
+
+ if (!uart_tx_stopped(&uart->port))
+ arc_serial_tx_chars(uart);
+
+ spin_unlock(&uart->port.lock);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static unsigned int arc_serial_get_mctrl(struct uart_port *port)
+{
+ /*
+ * Pretend we have a Modem status reg and following bits are
+ * always set, to satify the serial core state machine
+ * (DSR) Data Set Ready
+ * (CTS) Clear To Send
+ * (CAR) Carrier Detect
+ */
+ return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+}
+
+static void arc_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+ /* MCR not present */
+}
+
+/* Enable Modem Status Interrupts */
+
+static void arc_serial_enable_ms(struct uart_port *port)
+{
+ /* MSR not present */
+}
+
+static void arc_serial_break_ctl(struct uart_port *port, int break_state)
+{
+ /* ARC UART doesn't support sending Break signal */
+}
+
+static int arc_serial_startup(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+
+ /* Before we hook up the ISR, Disable all UART Interrupts */
+ UART_ALL_IRQ_DISABLE(uart);
+
+ if (request_irq(uart->port.irq, arc_serial_isr, 0, "arc uart rx-tx",
+ uart)) {
+ pr_warn("Unable to attach ARC UART interrupt\n");
+ return -EBUSY;
+ }
+
+ UART_RX_IRQ_ENABLE(uart); /* Only Rx IRQ enabled to begin with */
+
+ return 0;
+}
+
+/* This is not really needed */
+static void arc_serial_shutdown(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+ free_irq(uart->port.irq, uart);
+}
+
+static void
+arc_serial_set_termios(struct uart_port *port, struct ktermios *new,
+ struct ktermios *old)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+ unsigned int baud, uartl, uarth, hw_val;
+ unsigned long flags;
+
+ /*
+ * Use the generic handler so that any specially encoded baud rates
+ * such as SPD_xx flags or "%B0" can be handled
+ * Max Baud I suppose will not be more than current 115K * 4
+ * Formula for ARC UART is: hw-val = ((CLK/(BAUD*4)) -1)
+ * spread over two 8-bit registers
+ */
+ baud = uart_get_baud_rate(port, new, old, 0, 460800);
+
+ hw_val = port->uartclk / (uart->baud * 4) - 1;
+ uartl = hw_val & 0xFF;
+ uarth = (hw_val >> 8) & 0xFF;
+
+ /*
+ * UART ISS(Instruction Set simulator) emulation has a subtle bug:
+ * A existing value of Baudh = 0 is used as a indication to startup
+ * it's internal state machine.
+ * Thus if baudh is set to 0, 2 times, it chokes.
+ * This happens with BAUD=115200 and the formaula above
+ * Until that is fixed, when running on ISS, we will set baudh to !0
+ */
+ if (uart->is_emulated)
+ uarth = 1;
+
+ spin_lock_irqsave(&port->lock, flags);
+
+ UART_ALL_IRQ_DISABLE(uart);
+
+ UART_SET_BAUDL(uart, uartl);
+ UART_SET_BAUDH(uart, uarth);
+
+ UART_RX_IRQ_ENABLE(uart);
+
+ /*
+ * UART doesn't support Parity/Hardware Flow Control;
+ * Only supports 8N1 character size
+ */
+ new->c_cflag &= ~(CMSPAR|CRTSCTS|CSIZE);
+ new->c_cflag |= CS8;
+
+ if (old)
+ tty_termios_copy_hw(new, old);
+
+ /* Don't rewrite B0 */
+ if (tty_termios_baud_rate(new))
+ tty_termios_encode_baud_rate(new, baud, baud);
+
+ uart_update_timeout(port, new->c_cflag, baud);
+
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static const char *arc_serial_type(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+
+ return uart->port.type == PORT_ARC ? DRIVER_NAME : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'.
+ */
+static void arc_serial_release_port(struct uart_port *port)
+{
+}
+
+/*
+ * Request the memory region(s) being used by 'port'.
+ */
+static int arc_serial_request_port(struct uart_port *port)
+{
+ return 0;
+}
+
+/*
+ * Verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int
+arc_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+ return 0;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void arc_serial_config_port(struct uart_port *port, int flags)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+
+ if (flags & UART_CONFIG_TYPE &&
+ arc_serial_request_port(&uart->port) == 0)
+ uart->port.type = PORT_ARC;
+}
+
+static void arc_serial_poll_putchar(struct uart_port *port, unsigned char chr)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+
+ while (!(UART_GET_STATUS(uart) & TXEMPTY))
+ cpu_relax();
+
+ UART_SET_DATA(uart, chr);
+}
+
+#ifdef CONFIG_CONSOLE_POLL
+static int arc_serial_poll_getchar(struct uart_port *port)
+{
+ struct arc_uart_port *uart = (struct arc_uart_port *)port;
+ unsigned char chr;
+
+ while (!(UART_GET_STATUS(uart) & RXEMPTY))
+ cpu_relax();
+
+ chr = UART_GET_DATA(uart);
+ return chr;
+}
+#endif
+
+static struct uart_ops arc_serial_pops = {
+ .tx_empty = arc_serial_tx_empty,
+ .set_mctrl = arc_serial_set_mctrl,
+ .get_mctrl = arc_serial_get_mctrl,
+ .stop_tx = arc_serial_stop_tx,
+ .start_tx = arc_serial_start_tx,
+ .stop_rx = arc_serial_stop_rx,
+ .enable_ms = arc_serial_enable_ms,
+ .break_ctl = arc_serial_break_ctl,
+ .startup = arc_serial_startup,
+ .shutdown = arc_serial_shutdown,
+ .set_termios = arc_serial_set_termios,
+ .type = arc_serial_type,
+ .release_port = arc_serial_release_port,
+ .request_port = arc_serial_request_port,
+ .config_port = arc_serial_config_port,
+ .verify_port = arc_serial_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+ .poll_put_char = arc_serial_poll_putchar,
+ .poll_get_char = arc_serial_poll_getchar,
+#endif
+};
+
+static int __devinit
+arc_uart_init_one(struct platform_device *pdev, struct arc_uart_port *uart)
+{
+ struct resource *res, *res2;
+ unsigned long *plat_data;
+
+ if (pdev->id < 0 || pdev->id >= CONFIG_SERIAL_ARC_NR_PORTS) {
+ dev_err(&pdev->dev, "Wrong uart platform device id.\n");
+ return -ENOENT;
+ }
+
+ plat_data = ((unsigned long *)(pdev->dev.platform_data));
+ uart->baud = plat_data[0];
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+
+ res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (!res2)
+ return -ENODEV;
+
+ uart->port.mapbase = res->start;
+ uart->port.membase = ioremap_nocache(res->start, resource_size(res));
+ if (!uart->port.membase)
+ /* No point of pr_err since UART itself is hosed here */
+ return -ENXIO;
+
+ uart->port.irq = res2->start;
+ uart->port.dev = &pdev->dev;
+ uart->port.iotype = UPIO_MEM;
+ uart->port.flags = UPF_BOOT_AUTOCONF;
+ uart->port.line = pdev->id;
+ uart->port.ops = &arc_serial_pops;
+
+ uart->port.uartclk = plat_data[1];
+ uart->port.fifosize = ARC_UART_TX_FIFO_SIZE;
+
+ /*
+ * uart_insert_char( ) uses it in decideding whether to ignore a
+ * char or not. Explicitly setting it here, removes the subtelty
+ */
+ uart->port.ignore_status_mask = 0;
+
+ /* Real Hardware vs. emulated to work around a bug */
+ uart->is_emulated = !!plat_data[2];
+
+ return 0;
+}
+
+#ifdef CONFIG_SERIAL_ARC_CONSOLE
+
+static int __devinit arc_serial_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = 115200;
+ int bits = 8;
+ int parity = 'n';
+ int flow = 'n';
+
+ if (co->index < 0 || co->index >= CONFIG_SERIAL_ARC_NR_PORTS)
+ return -ENODEV;
+
+ /*
+ * The uart port backing the console (e.g. ttyARC1) might not have been
+ * init yet. If so, defer the console setup to after the port.
+ */
+ port = &arc_uart_ports[co->index].port;
+ if (!port->membase)
+ return -ENODEV;
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+ /*
+ * Serial core will call port->ops->set_termios( )
+ * which will set the baud reg
+ */
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static void arc_serial_console_putchar(struct uart_port *port, int ch)
+{
+ arc_serial_poll_putchar(port, (unsigned char)ch);
+}
+
+/*
+ * Interrupts are disabled on entering
+ */
+static void arc_serial_console_write(struct console *co, const char *s,
+ unsigned int count)
+{
+ struct uart_port *port = &arc_uart_ports[co->index].port;
+ unsigned long flags;
+
+ spin_lock_irqsave(&port->lock, flags);
+ uart_console_write(port, s, count, arc_serial_console_putchar);
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static struct console arc_console = {
+ .name = ARC_SERIAL_DEV_NAME,
+ .write = arc_serial_console_write,
+ .device = uart_console_device,
+ .setup = arc_serial_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+ .data = &arc_uart_driver
+};
+
+static __init void early_serial_write(struct console *con, const char *s,
+ unsigned int n)
+{
+ struct uart_port *port = &arc_uart_ports[con->index].port;
+ unsigned int i;
+
+ for (i = 0; i < n; i++, s++) {
+ if (*s == '\n')
+ arc_serial_poll_putchar(port, '\r');
+ arc_serial_poll_putchar(port, *s);
+ }
+}
+
+static struct __initdata console arc_early_serial_console = {
+ .name = "early_ARCuart",
+ .write = early_serial_write,
+ .flags = CON_PRINTBUFFER | CON_BOOT,
+ .index = -1
+};
+
+static int __devinit arc_serial_probe_earlyprintk(struct platform_device *pdev)
+{
+ arc_early_serial_console.index = pdev->id;
+
+ arc_uart_init_one(pdev, &arc_uart_ports[pdev->id]);
+
+ arc_serial_console_setup(&arc_early_serial_console, NULL);
+
+ register_console(&arc_early_serial_console);
+ return 0;
+}
+#endif
+
+
+static int __devinit arc_serial_probe(struct platform_device *pdev)
+{
+ struct arc_uart_port *uart;
+ int rc;
+
+ if (is_early_platform_device(pdev))
+ return arc_serial_probe_earlyprintk(pdev);
+
+ uart = &arc_uart_ports[pdev->id];
+ rc = arc_uart_init_one(pdev, uart);
+ if (rc)
+ return rc;
+
+ return uart_add_one_port(&arc_uart_driver, &uart->port);
+}
+
+static int __devexit arc_serial_remove(struct platform_device *pdev)
+{
+ /* This will never be called */
+ return 0;
+}
+
+static struct platform_driver arc_platform_driver = {
+ .probe = arc_serial_probe,
+ .remove = __devexit_p(arc_serial_remove),
+ .driver = {
+ .name = DRIVER_NAME,
+ .owner = THIS_MODULE,
+ },
+};
+
+#ifdef CONFIG_SERIAL_ARC_CONSOLE
+/*
+ * Register an early platform driver of "earlyprintk" class.
+ * ARCH platform code installs the driver and probes the early devices
+ * The installation could rely on user specifying earlyprintk=xyx in cmd line
+ * or it could be done independently, for all "earlyprintk" class drivers.
+ * [see arch/arc/plat-arcfpga/platform.c]
+ */
+early_platform_init("earlyprintk", &arc_platform_driver);
+
+#endif /* CONFIG_SERIAL_ARC_CONSOLE */
+
+static int __init arc_serial_init(void)
+{
+ int ret;
+
+ pr_info("Serial: ARC serial driver: platform register\n");
+
+ ret = uart_register_driver(&arc_uart_driver);
+ if (ret)
+ return ret;
+
+ ret = platform_driver_register(&arc_platform_driver);
+ if (ret) {
+ pr_debug("uart register failed\n");
+ uart_unregister_driver(&arc_uart_driver);
+ }
+
+ return ret;
+}
+
+static void __exit arc_serial_exit(void)
+{
+ platform_driver_unregister(&arc_platform_driver);
+ uart_unregister_driver(&arc_uart_driver);
+}
+
+module_init(arc_serial_init);
+module_exit(arc_serial_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("plat-arcfpga/uart");
+MODULE_AUTHOR("Vineet Gupta");
+MODULE_DESCRIPTION("ARC(Synopsys) On-Chip(fpga) serial driver");
diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h
index 7e1ab20..ebcc73f 100644
--- a/include/uapi/linux/serial_core.h
+++ b/include/uapi/linux/serial_core.h
@@ -215,5 +215,7 @@
/* Energy Micro efm32 SoC */
#define PORT_EFMUART 100
+/* ARC (Synopsys) on-chip UART */
+#define PORT_ARC 101
#endif /* _UAPILINUX_SERIAL_CORE_H */
--
1.7.4.1
^ permalink raw reply related
* [PATCH v4] serial/arc-uart: Add New Driver
From: Vineet.Gupta1 @ 2012-10-25 6:30 UTC (permalink / raw)
To: alan, gregkh; +Cc: arc-linux-dev, linux-serial, linux-kernel, Vineet Gupta
From: Vineet Gupta <vgupta@synopsys.com>
Hi Greg,
Rebased off of tty-next and verfied that it builds fine.
Please consider applying.
Thanks,
Vineet
v4:
* UAPI disintegration fallout for serial_core.h
* rebased off of tty-next
v3:
* Removed empty arc_serial_set_ldisc()
* More set_termios fixes - CSIZE forced to CS8 (for 8N1)
* global @running_on_iss replaced with platform data, saved in device
specific port structure.
v2:
* ttyARC used as device name
* Dynamic assignment of major/minor numbers.
* Ref counting tty in rx routine to prevent it from disappearing in
case of a hangup
* set_termios fixes:
- hardware flow control/parity are marked as unsupported
- baud written back to termios
* cosmetics such as commenting the need for @running_on_iss, empty lines
etc
Vineet Gupta (1):
serial/arc-uart: Add new driver
drivers/tty/serial/Kconfig | 25 ++
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/arc_uart.c | 747 ++++++++++++++++++++++++++++++++++++++
include/uapi/linux/serial_core.h | 2 +
4 files changed, 775 insertions(+), 0 deletions(-)
create mode 100644 drivers/tty/serial/arc_uart.c
--
1.7.4.1
^ permalink raw reply
* Re: [PATCH v2 2/3] serial: mxs-auart: add the DMA support for mx28
From: Huang Shijie @ 2012-10-25 5:50 UTC (permalink / raw)
To: Vinod Koul
Cc: vinod.koul, gregkh, linux, lauri.hintsala, linux-serial,
shawn.guo, linux-arm-kernel, alan
In-Reply-To: <1351138689.5263.68.camel@vkoul-udesk3>
于 2012年10月25日 12:18, Vinod Koul 写道:
>
>> +
>> +static int mxs_auart_dma_tx(struct mxs_auart_port *s, int size)
>> +{
>> + struct dma_async_tx_descriptor *desc;
>> + struct scatterlist *sgl =&s->tx_sgl;
>> + struct dma_chan *channel = s->tx_dma_chan;
>> + u32 pio;
>> +
>> + /* [1] : send PIO. Note, the first pio word is CTRL1. */
>> + pio = AUART_CTRL1_XFER_COUNT(size);
>> + desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)&pio,
>> + 1, DMA_TRANS_NONE, 0);
> this seems like a hack. API expects a scatterlist as argument.
> Same thing about direction, NONE doesnt mean anything for dma transfer.
It's not a hack. this DMA descriptor is used to set the registers.
Please see the code in drivers/dma/mxs-dma.c:mxs_dam_prep_slave_sg().
>> + if (!desc) {
>> + dev_err(s->dev, "step 1 error\n");
>> + return -EINVAL;
>> + }
>> +
>> + /* [2] : set DMA buffer. */
>> + sg_init_one(sgl, s->tx_dma_buf, size);
>> + dma_map_sg(s->dev, sgl, 1, DMA_TO_DEVICE);
>> + desc = dmaengine_prep_slave_sg(channel, sgl,
>> + 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>> + if (!desc) {
>> + dev_err(s->dev, "step 2 error\n");
>> + return -EINVAL;
>> + }
>> +
>> + /* [3] : submit the DMA */
>> + desc->callback = dma_tx_callback;
>> + desc->callback_param = s;
>> + dmaengine_submit(desc);
>> + dma_async_issue_pending(channel);
>> + return 0;
>> +}
>> +
>>
>> +static bool mxs_auart_dma_filter(struct dma_chan *chan, void *param)
>> +{
>> + struct mxs_auart_port *s = param;
>> +
>> + if (!mxs_dma_is_apbx(chan))
>> + return false;
>> +
>> + if (s->dma_channel == chan->chan_id) {
>> + chan->private =&s->dma_data;
> dont use chan->private. You need to dmaengine_slave_config API
please see the drivers/dma/mxs-dma.c:mxs_dam_alloc_chan_resoures().
The mxs-dma driver uses ->private to store the channel interrupt number.
thanks
Huang Shijie
>> + return true;
>> + }
>> + return false;
>> +}
>> +
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* RE: [PATCH] serial:ifx6x60:different SPI word width configure requires different swap process
From: Bi, Chao @ 2012-10-25 0:40 UTC (permalink / raw)
To: Alan Cox
Cc: alan@linux.intel.com, linux-serial@vger.kernel.org, Gorby, Russ,
Liu, Chuansheng, Chen, Jun D
In-Reply-To: <20121024133129.1155cc2e@pyramind.ukuu.org.uk>
> Minor question - is that not just (len + 3) >> 2 ?
Yes, I'll update it in another mail. Thanks.
Chao
-----Original Message-----
From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
Sent: Wednesday, October 24, 2012 8:31 PM
To: Bi, Chao
Cc: alan@linux.intel.com; linux-serial@vger.kernel.org; Gorby, Russ; Liu, Chuansheng; Chen, Jun D
Subject: Re: [PATCH] serial:ifx6x60:different SPI word width configure requires different swap process
On Wed, 24 Oct 2012 14:48:48 +0800
chao bi <chao.bi@intel.com> wrote:
>
> SPI protocol driver only provide one function (swap_buf()) to swap SPI
> data into big endian format, which is only available when SPI
> controller's word width is 16 bits. But word width could be configured
> as 8/16/32 bits, different word width configure should be mapped to
> different swap methods.This patch is to make SPI protocol driver
> choose the right swap function corresponding to SPI word width configuration.
>
> cc: liu chuansheng <chuansheng.liu@intel.com>
> cc: Chen Jun <jun.d.chen@intel.com>
> Signed-off-by: channing <chao.bi@intel.com>
> + len = (0 == (len&0x03)) ? (len >> 2) : ((len >> 2) + 1);
Minor question - is that not just (len + 3) >> 2 ?
The SPI swapping stuff at runtime looks right so.
Acked-by: Alan Cox <alan@linux.intel.com>
^ permalink raw reply
* Re: [PATCH v2 2/3] serial: mxs-auart: add the DMA support for mx28
From: Vinod Koul @ 2012-10-25 4:18 UTC (permalink / raw)
To: Huang Shijie
Cc: vinod.koul, gregkh, linux, lauri.hintsala, linux-serial,
shawn.guo, linux-arm-kernel, alan
In-Reply-To: <1351074456-25863-3-git-send-email-b32955@freescale.com>
On Wed, 2012-10-24 at 18:27 +0800, Huang Shijie wrote:
> Only we meet the following conditions, we can enable the DMA support for
> auart:
>
> (1) We enable the DMA support in the dts file, such as
> arch/arm/boot/dts/imx28.dtsi.
>
> (2) We enable the hardware flow control.
>
> (3) We use the mx28, not the mx23. Due to hardware bug(see errata: 2836),
> we can not add the DMA support to mx23.
>
> Signed-off-by: Huang Shijie <b32955@freescale.com>
>
> #define to_auart_port(u) container_of(u, struct mxs_auart_port, port)
> +
> +static int mxs_auart_dma_tx(struct mxs_auart_port *s, int size)
> +{
> + struct dma_async_tx_descriptor *desc;
> + struct scatterlist *sgl = &s->tx_sgl;
> + struct dma_chan *channel = s->tx_dma_chan;
> + u32 pio;
> +
> + /* [1] : send PIO. Note, the first pio word is CTRL1. */
> + pio = AUART_CTRL1_XFER_COUNT(size);
> + desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)&pio,
> + 1, DMA_TRANS_NONE, 0);
this seems like a hack. API expects a scatterlist as argument.
Same thing about direction, NONE doesnt mean anything for dma transfer.
> + if (!desc) {
> + dev_err(s->dev, "step 1 error\n");
> + return -EINVAL;
> + }
> +
> + /* [2] : set DMA buffer. */
> + sg_init_one(sgl, s->tx_dma_buf, size);
> + dma_map_sg(s->dev, sgl, 1, DMA_TO_DEVICE);
> + desc = dmaengine_prep_slave_sg(channel, sgl,
> + 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> + if (!desc) {
> + dev_err(s->dev, "step 2 error\n");
> + return -EINVAL;
> + }
> +
> + /* [3] : submit the DMA */
> + desc->callback = dma_tx_callback;
> + desc->callback_param = s;
> + dmaengine_submit(desc);
> + dma_async_issue_pending(channel);
> + return 0;
> +}
> +
>
> +static bool mxs_auart_dma_filter(struct dma_chan *chan, void *param)
> +{
> + struct mxs_auart_port *s = param;
> +
> + if (!mxs_dma_is_apbx(chan))
> + return false;
> +
> + if (s->dma_channel == chan->chan_id) {
> + chan->private = &s->dma_data;
dont use chan->private. You need to dmaengine_slave_config API
> + return true;
> + }
> + return false;
> +}
> +
--
Vinod Koul
Intel Corp.
^ permalink raw reply
* [PATCH] serial:ifx6x60:different SPI word width configure requires different swap process
From: chao bi @ 2012-10-25 1:02 UTC (permalink / raw)
To: alan; +Cc: linux-serial, richardx.r.gorby, chuansheng.liu, jun.d.chen
SPI protocol driver only provide one function (swap_buf()) to swap SPI data
into big endian format, which is only available when SPI controller's word width
is 16 bits. But word width could be configured as 8/16/32 bits, different word
width configure should be mapped to different swap methods.This patch is to make
SPI protocol driver choose the right swap function corresponding to SPI word
width configuration.
cc: liu chuansheng <chuansheng.liu@intel.com>
cc: Chen Jun <jun.d.chen@intel.com>
Signed-off-by: channing <chao.bi@intel.com>
---
drivers/tty/serial/ifx6x60.c | 70 ++++++++++++++++++++++++++++++++++++------
drivers/tty/serial/ifx6x60.h | 1 +
2 files changed, 61 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index 5b9bc19..2d2bcbd 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -152,26 +152,67 @@ ifx_spi_power_state_clear(struct ifx_spi_device *ifx_dev, unsigned char val)
}
/**
- * swap_buf
+ * swap_buf_8
* @buf: our buffer
* @len : number of bytes (not words) in the buffer
* @end: end of buffer
*
* Swap the contents of a buffer into big endian format
*/
-static inline void swap_buf(u16 *buf, int len, void *end)
+static inline void swap_buf_8(unsigned char *buf, int len, void *end)
+{
+ /* don't swap buffer if SPI word width is 8 bits */
+ return;
+}
+
+/**
+ * swap_buf_16
+ * @buf: our buffer
+ * @len : number of bytes (not words) in the buffer
+ * @end: end of buffer
+ *
+ * Swap the contents of a buffer into big endian format
+ */
+static inline void swap_buf_16(unsigned char *buf, int len, void *end)
{
int n;
+ u16 *buf_16 = (u16 *)buf;
len = ((len + 1) >> 1);
- if ((void *)&buf[len] > end) {
- pr_err("swap_buf: swap exceeds boundary (%p > %p)!",
- &buf[len], end);
+ if ((void *)&buf_16[len] > end) {
+ pr_err("swap_buf_16: swap exceeds boundary (%p > %p)!",
+ &buf_16[len], end);
return;
}
for (n = 0; n < len; n++) {
- *buf = cpu_to_be16(*buf);
- buf++;
+ *buf_16 = cpu_to_be16(*buf_16);
+ buf_16++;
+ }
+}
+
+/**
+ * swap_buf_32
+ * @buf: our buffer
+ * @len : number of bytes (not words) in the buffer
+ * @end: end of buffer
+ *
+ * Swap the contents of a buffer into big endian format
+ */
+static inline void swap_buf_32(unsigned char *buf, int len, void *end)
+{
+ int n;
+
+ u32 *buf_32 = (u32 *)buf;
+ len = (len + 3) >> 2;
+
+ if ((void *)&buf_32[len] > end) {
+ pr_err("swap_buf_32: swap exceeds boundary (%p > %p)!\n",
+ &buf_32[len], end);
+ return;
+ }
+ for (n = 0; n < len; n++) {
+ *buf_32 = cpu_to_be32(*buf_32);
+ buf_32++;
}
}
@@ -449,7 +490,7 @@ static int ifx_spi_prepare_tx_buffer(struct ifx_spi_device *ifx_dev)
tx_count-IFX_SPI_HEADER_OVERHEAD,
ifx_dev->spi_more);
/* swap actual data in the buffer */
- swap_buf((u16 *)(ifx_dev->tx_buffer), tx_count,
+ ifx_dev->swap_buf((ifx_dev->tx_buffer), tx_count,
&ifx_dev->tx_buffer[IFX_SPI_TRANSFER_SIZE]);
return tx_count;
}
@@ -617,7 +658,7 @@ static void ifx_spi_complete(void *ctx)
if (!ifx_dev->spi_msg.status) {
/* check header validity, get comm flags */
- swap_buf((u16 *)ifx_dev->rx_buffer, IFX_SPI_HEADER_OVERHEAD,
+ ifx_dev->swap_buf(ifx_dev->rx_buffer, IFX_SPI_HEADER_OVERHEAD,
&ifx_dev->rx_buffer[IFX_SPI_HEADER_OVERHEAD]);
decode_result = ifx_spi_decode_spi_header(ifx_dev->rx_buffer,
&length, &more, &cts);
@@ -636,7 +677,8 @@ static void ifx_spi_complete(void *ctx)
actual_length = min((unsigned int)length,
ifx_dev->spi_msg.actual_length);
- swap_buf((u16 *)(ifx_dev->rx_buffer + IFX_SPI_HEADER_OVERHEAD),
+ ifx_dev->swap_buf(
+ (ifx_dev->rx_buffer + IFX_SPI_HEADER_OVERHEAD),
actual_length,
&ifx_dev->rx_buffer[IFX_SPI_TRANSFER_SIZE]);
ifx_spi_insert_flip_string(
@@ -1001,6 +1043,14 @@ static int ifx_spi_spi_probe(struct spi_device *spi)
return -ENODEV;
}
+ /* init swap_buf function according to word width configuration */
+ if (spi->bits_per_word == 32)
+ ifx_dev->swap_buf = swap_buf_32;
+ else if (spi->bits_per_word == 16)
+ ifx_dev->swap_buf = swap_buf_16;
+ else
+ ifx_dev->swap_buf = swap_buf_8;
+
/* ensure SPI protocol flags are initialized to enable transfer */
ifx_dev->spi_more = 0;
ifx_dev->spi_slave_cts = 0;
diff --git a/drivers/tty/serial/ifx6x60.h b/drivers/tty/serial/ifx6x60.h
index e8464ba..d8869f5 100644
--- a/drivers/tty/serial/ifx6x60.h
+++ b/drivers/tty/serial/ifx6x60.h
@@ -124,6 +124,7 @@ struct ifx_spi_device {
#define MR_INPROGRESS 1
#define MR_COMPLETE 2
wait_queue_head_t mdm_reset_wait;
+ void (*swap_buf)(unsigned char *buf, int len, void *end);
};
#endif /* _IFX6X60_H */
--
1.7.1
^ permalink raw reply related
* Re: [PATCH v3] serial/arc-uart: Add new driver
From: Greg KH @ 2012-10-24 18:32 UTC (permalink / raw)
To: Vineet.Gupta1; +Cc: alan, linux-serial, linux-kernel
In-Reply-To: <1349336152-30443-1-git-send-email-vgupta@synopsys.com>
On Thu, Oct 04, 2012 at 01:05:52PM +0530, Vineet.Gupta1@synopsys.com wrote:
> From: Vineet Gupta <vgupta@synopsys.com>
>
> Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys)
> FPGA Boards such as ARCAngel4/ML50x
This patch does not apply against my tty-next tree, care to rebase it
and resend it so that I can apply it?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH] tty/serial/8250: Make omap hardware workarounds local to 8250.h
From: Greg Kroah-Hartman @ 2012-10-24 18:31 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux-serial, Alan Cox
In-Reply-To: <20121003223158.GL4840@atomide.com>
On Wed, Oct 03, 2012 at 03:31:58PM -0700, Tony Lindgren wrote:
> This allows us to get rid of the ifdefs in 8250.c.
>
> Cc: Alan Cox <alan@linux.intel.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
>
> ---
>
> Would appreciate some minimal immutable branch
> with this commit that I can also pull in to my
> upcoming omap cleanup branch for v3.8 merge window
> as I'll be moving plat/serial.h for the ARM common
> zImage changes.
This is now in my tty-next branch of the tty.git tree, if you want to
pull from that.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH-v3] tty: prevent unnecessary work queue lock checking on flip buffer copy
From: Greg KH @ 2012-10-24 18:22 UTC (permalink / raw)
To: Alan Cox; +Cc: Ivo Sieben, linux-serial, RT
In-Reply-To: <20121023111659.6f4427c7@bob.linux.org.uk>
On Tue, Oct 23, 2012 at 11:16:59AM +0100, Alan Cox wrote:
> > Note, I took out the WARN_ON() in this patch, as what is that really
> > going to help here? It also will conflict with a patch from Jiri I'll
> > ba applying after this one, so if you think it's needed, care to send
> > a follow-on patch based on linux-next in a few days?
>
> It catches anyone flipping low_latency wrongly or in other places. It's
> fairly important as WARN_ON() goes !
Ok, I've applied the patch that Ivo sent doing this.
greg k-h
^ permalink raw reply
* Re: [PATCH 0/1] staging: Add firewire-serial driver
From: Peter Hurley @ 2012-10-24 15:56 UTC (permalink / raw)
To: Stefan Richter
Cc: Greg Kroah-Hartman, devel, linux1394-devel, linux-kernel,
linux-serial
In-Reply-To: <20121024154141.3029ad92@stein>
> > > drivers/staging/fwserial/dma_fifo.c | 310 ++++
> > > drivers/staging/fwserial/dma_fifo.h | 130 ++
> > > drivers/staging/fwserial/fwserial.c | 2885 +++++++++++++++++++++++++++++++++++
> > > drivers/staging/fwserial/fwserial.h | 355 +++++
>
> drivers/firewire/net.c is 1721 lines, sbp_target is 2868 lines.
> Why is fwserial bigger?
1) Exclude the dma_fifo* files in the comparison, because block & net
devices get dma-able memory management from their subsystems.
2) Certain tty concepts don't map well to an automated bus, so these are
simulated (eg, break handling)
3) fwserial has to implement a protocol to virtually cable peers
4) sbp_target only supports 1 target.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox