Commit graph

28 commits

Author SHA1 Message Date
Jakub Kicinski 68be64ca7e sc16is7xx: constify devtype
devtype structures are all declared as const.
Compiler does not complain because we cast
their pointers to save them in .driver_data.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-04 22:07:27 -07:00
Jakub Kicinski c64349722d sc16is7xx: support multiple devices
We currently register the uart driver during device probe
which makes it hard to support more than one chip.
Move the driver registration to module init/exit time and
preallocate space for up to 8 lines (4-8 chips).

Reported-by: Michael Allwright <michael.allwright@upb.de>
Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-04 22:07:27 -07:00
Jakub Kicinski e92a886bf7 sc16is7xx: save and use per-chip line number
In preparation of supporting multiple devices we should save
the per-chip line number (0 or 1), because the uart_port line
will reflect system-wide uart number and will be offseted for
chips other than the first to register.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-04 22:07:27 -07:00
Greg Kroah-Hartman 92311e46ec Merge 4.2-rc4 into tty-next
Other serial driver work wants to build on patches now in 4.2-rc4 so
merge the branch so this can properly happen.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-27 11:12:39 -07:00
Krzysztof Kozlowski 7e8af24fbe tty: serial: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-23 18:04:59 -07:00
Bo Svangård dec273ecc1 sc16is7xx: fix FIFO address of secondary UART
Calls to regmap_raw_read/write needed register rewrite in a
similar way as function calls to regmap_read/write already had.
This enables reading/writing the serial datastream to the device.

Signed-off-by: Bo Svangård <bo.svangard@embeddedart.se>
Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-23 15:32:32 -07:00
Jakub Kicinski 478d1051a0 sc16is7xx: use kworker for RS-485 configuration
RS-485 configuration is also done under the spinlock
so no blocking I/O allowed.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:47:27 +09:00
Jakub Kicinski 059d581530 sc16is7xx: use kworker to update ier bits
.stop_rx/tx() are called in atomic context, we cannot use
blocking I/O. While at it correct the name of RX bit and
'*' placement in pointer declarations.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:47:27 +09:00
Jakub Kicinski a010408536 sc16is7xx: use kworker for md_proc
Convert md_proc into general async reconfiguration procedure.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:47:27 +09:00
Jakub Kicinski dbe5a40cba sc16is7xx: move RTS delay to workqueue
Instead of spinning under port->lock let's just sleep
inside the kthread.  It should be equivalent as TX cannot
proceed when thread is blocked.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:47:27 +09:00
Jakub Kicinski 9e6f4ca3e5 sc16is7xx: use kthread_worker for tx_work and irq
Convert workqueue usage to a real-time kworker.  The problem
with workqueues is that we cannot set real-time priorities on
our work and asynchronous reconfiguration can be blocked by
less important tasks.

We need kthread for the interrupt anyway and because we will
now be using single kthread for all TX-related operations we
can get rid of the port mutex.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:47:27 +09:00
Jakub Kicinski 4ae82e5d23 sc16is7xx: use LSR_TEMT_BIT in .tx_empty()
LSR_TEMT_BIT (LSR bit 6) provides us exactly the information
we need to determine if transmission is finished - FIFO level
and shift register empty.  We can save ourselves reading FIFO
level explicitly if we use this bit.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:47:27 +09:00
Jakub Kicinski 4117a60c8e sc16is7xx: add missing compatible strings
Without matching bus-specific strings driver will not be loaded
automatically.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:47:27 +09:00
Jakub Kicinski 5451bb29f7 sc16is7xx: remove RS-485 delay RTS handling
Users of RS-485 can request via ioctl that RTS signals should
be activated selected number of milliseconds before the actual
data transmission or delay reception certain number of milli-
seconds after the transmission is finished.  In sc16is7xx,
however, RTS signalling is handled by the hardware and driver
has no way of providing this feature.

We still try to provide .delay_rts_before_send by delaying
transmission but without actual effect on the RTS line.

Note: this change will make the driver return -EINVAL when the
      feature is requested (.delay_rts_after_send is set).

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:45:28 +09:00
Rama Kiran Kumar Indrakanti 2c837a8a8f sc16is7xx: spi interface is added
spi interface for sc16is7xx is added along with Kconfig flag
to enable spi or i2c, thus in a instance we can have either
spi or i2c or both, in sync to the hw.

Signed-off-by: Rama Kiran Kumar Indrakanti <indrakanti_ram@hotmail.com>
Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-01 06:45:27 +09:00
Jakub Kicinski f0e381158a sc16is7xx: expose RTS inversion in RS-485 mode
Hardware is capable of inverting RTS signal when working
in RS-485 mode.  Expose this functionality to user space.
Relay on a matching combination of standard flags
(SER_RS485_RTS_ON_SEND and SER_RS485_RTS_AFTER_SEND) to
detect when user space is requesting inverted RTS mode.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-10 14:43:48 +02:00
Jakub Kicinski 0814e8d5da sc16is7xx: enable the clock
Although clk_disable_unprepare() is called both on .remove()
and in .probe() error path, the clock is never actually enabled.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-26 22:38:36 +01:00
Jakub Kicinski 9764e7a0f6 sc16is7xx: don't wipe out port configuration on shutdown
EFCR register contains RS-485 configuration which should not
be changed by shutdown.  Instead of doing a write only update
the appropriate bits.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-26 22:38:36 +01:00
Jakub Kicinski 11b03ea0c1 sc16is7xx: remove ports on probe error path
If ports are not explicitly removed on the error path
the device will not get properly unregistered leaving
/dev/ttySC* nodes in the filesystem.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-26 22:38:36 +01:00
Ricardo Ribalda Delgado b57d15fe8b serial/sc16is7xx: Use the rs485 functions on serial_core
In order to unify all the rs485 ioctl handling.
Use the implementation of TIOC[GS]RS485 ioctl handling on serial_core.

Reviewed-by: Alan Cox <alan@linux.intel.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-06 14:59:21 -08:00
Ricardo Ribalda Delgado c015b4ad2a serial/sc16is7xx: Remove obsolete #ifset TIOC[SG]RS485
Commit e676253b19 ("serial/8250: Add support for RS485 IOCTLs") added
references to TIOC[SG]RS48 on 8250_core.c. This change triggered the
need to define them in all the arches that uses tty/serial.

This made #ifdef TIOC[SG]RS48 obsolete.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 19:29:05 -08:00
Linus Walleij e27e278608 tty: sc16is7xx: remove retval from gpiochip_remove()
We are trying to smoke out the use of the return value from
gpiochip_remove() from the kernel, this has been missed.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-09-23 17:51:36 +02:00
Jon Ringle dc824ebed0 serial: sc16is7xx: Correct initialization of s->clk
The s->clk never gets setup in sc16is7xx_probe() and instead was using a
local clk variable, but then testing the uninitialized s->clk during
teardown

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-27 11:50:38 -07:00
Alexander Shiyan 8b152f1096 serial: treewide: Remove empty implementations of enable_ms()
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-09 17:29:38 -07:00
Jon Ringle beb04a9f04 serial: sc16is7xx: dynamically allocate tx/rx buffer
This fixes the warnings:

   drivers/tty/serial/sc16is7xx.c: In function 'sc16is7xx_handle_rx':
>> drivers/tty/serial/sc16is7xx.c:548:1: warning: 'sc16is7xx_handle_rx' uses dynamic stack allocation [enabled by default]
   drivers/tty/serial/sc16is7xx.c: In function 'sc16is7xx_handle_tx':
>> drivers/tty/serial/sc16is7xx.c:589:1: warning: 'sc16is7xx_handle_tx' uses dynamic stack allocation [enabled by default]

Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-28 12:22:42 -07:00
Jan Moskyto Matejka 3df5adb23f serial: sc16is7xx: compile I2C when REGMAP_I2C is module
drivers/tty/serial/sc16is7xx.c:1060:12: warning: 'sc16is7xx_probe' defined but not used [-Wunused-function]
 static int sc16is7xx_probe(struct device *dev,
            ^
drivers/tty/serial/sc16is7xx.c:1176:12: warning: 'sc16is7xx_remove' defined but not used [-Wunused-function]
 static int sc16is7xx_remove(struct device *dev)
            ^
drivers/tty/serial/sc16is7xx.c:1215:29: warning: 'regcfg' defined but not used [-Wunused-variable]
 static struct regmap_config regcfg = {
                             ^

Fixed these warnings by removing the `#ifdef CONFIG_REGMAP_I2C' around their
calls as this driver selects REGMAP_I2C in Kconfig. This part of driver just
didn't compile at all when REGMAP_I2C configured as module (CONFIG_REGMAP_I2C
is not defined, just CONFIG_REGMAP_I2C_MODULE).

Signed-off-by: Jan Moskyto Matejka <mq@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-28 12:22:42 -07:00
Jon Ringle d952795d81 serial: sc16is7xx: fix implicit decl of func copy_{to,from}_user
Fix by including linux/uaccess.h:

   drivers/tty/serial/sc16is7xx.c: In function 'sc16is7xx_ioctl':
>> drivers/tty/serial/sc16is7xx.c:861:3: error: implicit declaration of function 'copy_from_user' [-Werror=implicit-function-declaration]
>> drivers/tty/serial/sc16is7xx.c:867:3: error: implicit declaration of function 'copy_to_user' [-Werror=implicit-function-declaration]

Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-04-25 13:22:41 -07:00
Jon Ringle dfeae619d7 serial: sc16is7xx
The SC16IS7xx is a slave I2C-bus/SPI interface to a single-channel
high performance UART. The SC16IS7xx's internal register set is
backward-compatible with the widely used and widely popular 16C450.

The SC16IS7xx also provides additional advanced features such as
auto hardware and software flow control, automatic RS-485 support, and
software reset.

Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-04-25 10:08:48 -07:00