Commit Graph

608 Commits

Author SHA1 Message Date
Andy Shevchenko d1834babe4 serial: 8250_dma: adjust DMA address of the UART
Some UARTs, e.g. one is used in Intel Quark, have a different address base for
DMA operations. Introduce an additional field (per RX and TX DMA channels) in
struct uart_8250_dma to cover those cases.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 16:13:29 +02:00
Andy Shevchenko 8d17047207 serial: 8250_dma: switch to new dmaengine_terminate_* API
Convert dmaengine_terminate_all() calls to synchronous and asynchronous
versions where appropriate.

Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 16:13:29 +02:00
Eddie Huang 81bb549fdf serial: 8250_mtk: support big baud rate.
mediatek can support baud rate up to 4M.
the 'uart_get_baud_rate' function will limit the max baud rate.
Modify max baud to remove the limit.

Signed-off-by: Long Cheng <long.cheng@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 16:01:26 +02:00
Andy Shevchenko 47b34d2ef2 serial: 8250_mid: fix divide error bug if baud rate is 0
Since the commit c1a67b48f6 ("serial: 8250_pci: replace switch-case by
formula for Intel MID"), the 8250 driver crashes in the byt_set_termios()
function with a divide error. This is caused by the fact that a baud rate of 0
(B0) is not handled properly. Fix it by falling back to B9600 in this case.

Reported-by: "Mendez Salinas, Fernando" <fernando.mendez.salinas@intel.com>
Fixes: c1a67b48f6 ("serial: 8250_pci: replace switch-case by formula for Intel MID")
Cc: stable@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 15:49:26 +02:00
Kefeng Wang e16b46f190 serial: 8250_dw: Check the data->pclk when get apb_pclk
It should check the data->pclk, not data->clk when get apb_pclk.

Fixes: c8ed99d4f6a8("serial: 8250_dw: Add support for deferred probing")
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 15:43:52 +02:00
Andy Shevchenko 5db4f7f80d Revert "tty/serial/8250: use mctrl_gpio helpers"
Serial console is broken in v4.8-rcX. Mika and I independently bisected down to
commit 4ef03d3287 ("tty/serial/8250: use mctrl_gpio helpers").

Since neither author nor anyone else didn't propose a solution we better revert
it for now.

This reverts commit 4ef03d3287.

Link: https://lkml.kernel.org/r/20160809130229.GN1729@lahna.fi.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-31 15:36:01 +02:00
Arnd Bergmann 87a713c8ff 8250/fintek: rename IRQ_MODE macro
A bugfix for the fintek driver required defining some macros, but
one of them clashes with a system header on ARM:

drivers/tty/serial/8250/8250_fintek.c:34:0: error: "IRQ_MODE" redefined [-Werror]
 #define IRQ_MODE 0x70

In file included from /git/arm-soc/arch/arm/include/asm/ptrace.h:13:0,
                 from /git/arm-soc/arch/arm/include/asm/irqflags.h:6,
                 from /git/arm-soc/include/linux/irqflags.h:15,
                 from /git/arm-soc/arch/arm/include/asm/bitops.h:27,
                 from /git/arm-soc/include/linux/bitops.h:36,
                 from /git/arm-soc/include/linux/kernel.h:10,
                 from /git/arm-soc/include/linux/list.h:8,
                 from /git/arm-soc/include/linux/module.h:9,
                 from /git/arm-soc/drivers/tty/serial/8250/8250_fintek.c:11:
arch/arm/include/uapi/asm/ptrace.h:55:0: note: this is the location of the previous definition

This renames the newly introduced 'IRQ_MODE' macro to FINTEK_IRQ_MODE.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 4da22f1418 ("serial: 8250_fintek: fix the mismatched IRQ mode")
Link: https://patchwork.kernel.org/patch/9200119/
Acked-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Acked-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-18 18:16:13 +02:00
Masahiro Yamada 755dd8aa12 serial: 8250_ingenic: drop #if conditional surrounding earlycon code
The #if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
conditional has been added to the OF_EARLYCON_DECLARE() define.

The same conditional can be dropped from 8250_ingenic.c because
the unused symbols will be marked as __maybe_unsed.
Also, the Kconfig dependency can become much simpler.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:31:04 -07:00
Masahiro Yamada ae73975f19 serial: 8250_mtk: drop !defined(MODULE) conditional
The !defined(MODULE) conditional has been added to the
OF_EARLYCON_DECLARE() define.

This commit partially reverts commit 3f5921a60f ("serial:
8250/mediatek: fix building with SERIAL_8250=m").

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:31:04 -07:00
Masahiro Yamada 68b780598d serial: 8250_uniphier: drop !defined(MODULE) conditional
The !defined(MODULE) conditional has been added to the
OF_EARLYCON_DECLARE() define.

Now we can revert commit a2d3ea2f23 ("serial: 8250/uniphier:
fix modular build").

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:31:04 -07:00
Yegor Yefremov 4ef03d3287 tty/serial/8250: use mctrl_gpio helpers
This patch permits the usage for GPIOs to control
the CTS/RTS/DTR/DSR/DCD/RI signals.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:30:42 -07:00
Yegor Yefremov 36fd95b17e tty/serial/8250: make UART_MCR register access consistent
Introduce serial8250_out_MCR() and serial8250_in_MCR() routines, that
replace following calls:

serial_out(port, UART_MCR, val)
serial_port_out(up, UART_MCR, val)
serial_in(port, UART_MCR)

This patch is needed in order to integrate reading/writing of MCR
signals via SERIAL_MCTRL_GPIO infrastructure later.

Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:30:42 -07:00
Chuah, Kim Tatt 692aa19056 serial: 8250_mid: Read RX buffer on RX DMA timeout for DNV
In DNV, when RX DMA is used and number of bytes received is less than
transfer size, only RX DMA timeout interrupt is sent. When this happens,
read the RX buffer.

Signed-off-by: Chuah, Kim Tatt <kim.tatt.chuah@intel.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:30:42 -07:00
Chuah, Kim Tatt fd9e516d83 serial: 8250_dma: Export serial8250_rx_dma_flush()
Export serial8250_rx_dma_flush() for use by SOC UART drivers.

Signed-off-by: Chuah, Kim Tatt <kim.tatt.chuah@intel.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:30:42 -07:00
Chuah, Kim Tatt c6f82787a5 dmaengine: hsu: Export hsu_dma_get_status()
To allow other code to safely read DMA Channel Status Register (where
the register attribute for Channel Error, Descriptor Time Out &
Descriptor Done fields are read-clear), export hsu_dma_get_status().
hsu_dma_irq() is renamed to hsu_dma_do_irq() and requires Status
Register value to be passed in.

Signed-off-by: Chuah, Kim Tatt <kim.tatt.chuah@intel.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:30:42 -07:00
Matthew Leach d03516df83 tty: serial: 8250: add CON_CONSDEV to flags
When using the 8250 as a boot console and the main console results in
messages being printed twice.  The console framework will only
unregister boot consoles if a new console is registered with the
CON_CONSDEV flag set.

Set this flag for the univ8250 console to prevent double-registration.

Signed-off-by: Matthew Leach <matthew.leach@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:05:13 -07:00
Masahiro Yamada 8d6d544cfb serial: 8250_uniphier: add COMPILE_TEST option
Add COMPILE_TEST for the compilation test coverage.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 13:55:35 -07:00
Alexandr Petrenko 55c368cb76 8250_pci: Adds support for the WCH CH355 4S card
Adds support for the WCH CH355 4S card in the 8250 serial driver.

Signed-off-by: Alexandr Petrenko <petrenkoas83@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 13:50:53 -07:00
Ji-Ze Hong (Peter Hong) 4da22f1418 serial: 8250_fintek: fix the mismatched IRQ mode
Some BIOS only use _OSI("Linux") to distinguish between Linux & Windows.
Apply Level/Low to UART trigger mode if Windows, Edge/High mode otherwise.
But since 2.6.23 the mainline kernel no longer returns true for
_OSI(“Linux”).

The default IRQ0~15 trigger mode in Linux is Edge/High mode without
ACPI MADT override. It mismatches IRQ mode and makes UART malfunctional on
such motherboard.

This patch will check the current IRQ mode and apply correct mode to UART.

The following link is F81216AD spec PDF:
http://html.alldatasheet.com/html-pdf/257956/FINTEK/F81216AD/5569/
25/F81216AD.html

LDN0~3
	70h: IRQ channel & Mode register
		Bit 6~5	:
			00	: Active low level mode
			01	: Active high edge mode
		Bit 4	: Sharing Flag (0: not share/1: share)
		Bit 3~0 : IRQ channel

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 13:50:53 -07:00
Kefeng Wang 01e4d27355 serial: 8250_early: Add earlycon support for Synopsys DesignWare ABP UART
Some board like Hisilicon D02 uses Synopsys DesignWare ABP UART, declare an
OF early console for it, so early console device can be enabled with comand
line "earlycon"(without option) via the "stdout-path" property in device-tree.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Tested-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 09:12:55 -07:00
Jiri Slaby 17b2720b11 tty: 8250, remove shadow and unused variables
The compiler complains about variables that are set, but never used:
* intX variables in exar_handle_irq
  drivers/tty/serial/8250/8250_port.c:1864:34: warning: variable ‘int3’ set but not used [-Wunused-but-set-variable]
* val variable in pci_quatech_wqopr
  drivers/tty/serial/8250/8250_pci.c:1139:10: warning: variable ‘val’ set but not used [-Wunused-but-set-variable]

And about a shadow variable:
* tmout in wait_for_xmitr is defined twice with the same type. Both of
  them are also initialized before use.

Remove all of them.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Matt Schulte <matts@commtech-fastcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 09:04:48 -07:00
Jiri Slaby 934014d522 tty: 8250, kill DEBUG_INTR
Convert DEBUG_INTR to pr_debug:
* defined semantics (DEBUG, DYNAMIC_DEBUG)
* KERN_DEBUG level instead of KERN_DEFAULT
* emit __func__ and \n
* verified 'fmt' even when !DEBUG

I wonder if anybody ever used that or whether we should just drop the
lines.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 08:56:30 -07:00
Jiri Slaby b0f8aed2cd tty: 8250, drop unused members from struct old_serial_port
hub6 and irqflags from struct old_serial_port are nowhere set. Drop
them from the structure and replace the reads by zeros.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 08:56:30 -07:00
Linus Torvalds e10abc629f TTY and Serial driver update for 4.7-rc1
Here's the large TTY and Serial driver update for 4.7-rc1.
 
 A few new serial drivers are added here, and Peter has fixed a bunch of
 long-standing bugs in the tty layer and serial drivers as normal.  Full
 details in the shortlog.
 
 All of these have been in linux-next for a while with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iEYEABECAAYFAlc/0/oACgkQMUfUDdst+ynzyQCgsa54VNijdAzU6AA5HEfqmf2M
 cGMAn1boH7hUWlAbJmzzihx4JASoGjYW
 =V5VH
 -----END PGP SIGNATURE-----

Merge tag 'tty-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty and serial driver updates from Greg KH:
 "Here's the large TTY and Serial driver update for 4.7-rc1.

  A few new serial drivers are added here, and Peter has fixed a bunch
  of long-standing bugs in the tty layer and serial drivers as normal.
  Full details in the shortlog.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'tty-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (88 commits)
  MAINTAINERS: 8250: remove website reference
  serial: core: Fix port mutex assert if lockdep disabled
  serial: 8250_dw: fix wrong logic in dw8250_check_lcr()
  tty: vt, finish looping on duplicate
  tty: vt, return error when con_startup fails
  QE-UART: add "fsl,t1040-ucc-uart" to of_device_id
  serial: mctrl_gpio: Drop support for out1-gpios and out2-gpios
  serial: 8250dw: Add device HID for future AMD UART controller
  Fix OpenSSH pty regression on close
  serial: mctrl_gpio: add IRQ locking
  serial: 8250: Integrate Fintek into 8250_base
  serial: mps2-uart: add support for early console
  serial: mps2-uart: add MPS2 UART driver
  dt-bindings: document the MPS2 UART bindings
  serial: sirf: Use generic uart-has-rtscts DT property
  serial: sirf: Introduce helper variable struct device_node *np
  serial: mxs-auart: Use generic uart-has-rtscts DT property
  serial: imx: Use generic uart-has-rtscts DT property
  doc: DT: Add Generic Serial Device Tree Bindings
  serial: 8250: of: Make tegra_serial_handle_break() static
  ...
2016-05-20 20:57:27 -07:00
Linus Torvalds a0d3c7c5c0 dmaengine updates for 4.7
This time round the update brings in following changes:
 
  - New tegra driver for ADMA device
  - Support for Xilinx AXI Direct Memory Access Engine and Xilinx AXI Central
    Direct Memory Access Engine and few updates to this driver.
  - New cyclic capability to sun6i and few updates.
  - Slave-sg support in bcm2835.
  - Updates to many drivers like designware, hsu, mv_xor, pxa, edma,
    qcom_hidma & bam.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJXPVb9AAoJEHwUBw8lI4NHnDQP/AtUYBTI8XD68iGh5eCTEtwO
 3dNgUmOvIAIl0ZtVKex3b7j2S52IN7EDv44QmsmvMHgjvaupUsZ/HeIHgoI37y39
 /qoRkyiG75ht68BrNjKcpJLsOyxaAUT1tMyf/bYXlDW8O7qEPtRDhuvUB+i+s3RX
 ljNOQXH2WaQTJrNeZxkvbp92iGiu3j7AKyCh9MJ4gnF4y2oA1bFp++QpH5qcBOTp
 0nccs7pgDQhw2nzHmhYbEmvgcKPrPQi+67U7eIed7n7wiThAIXIEbZl6AYk9kFaK
 gSa4/N3fwnZc9TFR5O6qdanvsYdW4JC1P5Ydm0opExo3lgtMckQ3sGKFIwTG8eU4
 YiyQE1uVHRqT82zxPCecTF+I0Y4g68oCJURrHED6kxKGA5a8ojU04aGebXDiNKlp
 FEDceEC5ch7ZPw8CCTola+TYpf9Vni3g7OkrdkPY9cX/aDXDROghTCg9jgPJ2aL/
 oai5axc5gQMEFzHPaEwFp45tgXw7IvIzaqYHmiWE11fsRbGUSB2HAwBXytI9ReC0
 XTMBvc08YvisbIpIR29T0R5cerzdDuK9bXxYHHHOeUFg0t8R8UGaP1UxEQCVmLsT
 AIrHupoccPJ7IAn0h6mShtZ2yzBfj3rU4tEMJR/Oj/VvjW3gKbbZ5XVi92fOurBs
 xjn9uBBZ/Pt9hgprwlmY
 =0Sy7
 -----END PGP SIGNATURE-----

Merge tag 'dmaengine-4.7-rc1' of git://git.infradead.org/users/vkoul/slave-dma

Pull dmaengine updates from Vinod Koul:
 "This time round the update brings in following changes:

   - new tegra driver for ADMA device

   - support for Xilinx AXI Direct Memory Access Engine and Xilinx AXI
     Central Direct Memory Access Engine and few updates to this driver

   - new cyclic capability to sun6i and few updates

   - slave-sg support in bcm2835

   - updates to many drivers like designware, hsu, mv_xor, pxa, edma,
     qcom_hidma & bam"

* tag 'dmaengine-4.7-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (84 commits)
  dmaengine: ioatdma: disable relaxed ordering for ioatdma
  dmaengine: of_dma: approximate an average distribution
  dmaengine: core: Use IS_ENABLED() instead of checking for built-in or module
  dmaengine: edma: Re-evaluate errors when ccerr is triggered w/o error event
  dmaengine: qcom_hidma: add support for object hierarchy
  dmaengine: qcom_hidma: add debugfs hooks
  dmaengine: qcom_hidma: implement lower level hardware interface
  dmaengine: vdma: Add clock support
  Documentation: DT: vdma: Add clock support for dmas
  dmaengine: vdma: Add config structure to differentiate dmas
  MAINTAINERS: Update Tegra DMA maintainers
  dmaengine: tegra-adma: Add support for Tegra210 ADMA
  Documentation: DT: Add binding documentation for NVIDIA ADMA
  dmaengine: vdma: Add Support for Xilinx AXI Central Direct Memory Access Engine
  Documentation: DT: vdma: update binding doc for AXI CDMA
  dmaengine: vdma: Add Support for Xilinx AXI Direct Memory Access Engine
  Documentation: DT: vdma: update binding doc for AXI DMA
  dmaengine: vdma: Rename xilinx_vdma_ prefix to xilinx_dma
  dmaengine: slave means at least one of DMA_SLAVE, DMA_CYCLIC
  dmaengine: mv_xor: Allow selecting mv_xor for mvebu only compatible SoC
  ...
2016-05-19 11:47:18 -07:00
Kefeng Wang 6550be9f62 serial: 8250_dw: fix wrong logic in dw8250_check_lcr()
Commit cdcea058e5 ("serial: 8250_dw: Avoid serial_outx code duplicate
with new dw8250_check_lcr()") introduce a wrong logic when write val to
LCR reg. When CONFIG_64BIT enabled, __raw_writeq is used unconditionally.

The __raw_readq/__raw_writeq is introduced by commit bca2092d78 ("serial:
8250_dw: Use 64-bit access for OCTEON.") for OCTEON.

So for 64BIT && !PORT_OCTEON, we better to use coincident write function.

Fixes: cdcea058e510("serial: 8250_dw: Avoid serial_outx code duplicate with new dw8250_check_lcr()")
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-05-03 16:10:38 -07:00
Wang Hongcheng 204e986d91 serial: 8250dw: Add device HID for future AMD UART controller
Add device HID AMDI0020 to match the AMD ACPI Vendor ID (AMDI) as
registered in http://www.uefi.org/acpi_id_list, and the UART
controller on future AMD paltform will use the HID instead of AMD0020.

Signed-off-by: Wang Hongcheng <annie.wang@amd.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-05-01 13:22:54 -07:00
Ricardo Ribalda Delgado fa01e2ca9f serial: 8250: Integrate Fintek into 8250_base
The 8250_fintek driver advertises as the PNP0501 driver; however this
conflicts with the standard 16550A uart PNP0501. The conflict causes
the 8250_fintek driver to load with _every_ PNP0501, but never probe,
and causing the entire 8250 driver stack to unload if the 8250_fintek
driver is unloaded (modprobe doesn't know that 8250_pnp rather than
8250_fintek claimed the resource).

This patch merges the Fintek driver into 8250_base. On autoconfig_16550
the device is probed to verify if it is a FINTEK device or not.

This custom probing can be disabled completely via configuration. When a
Fintek device is not probed it will behave as a standard 16550A device,
with no RS485 capabilities.

Reported-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Thierry Reding 28264eb6c3 serial: 8250: of: Make tegra_serial_handle_break() static
This function is not used outside the file, so it can be static.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley d1f981506b serial: omap8250: Terminate rx dma only for flushes
DMA completed normally does not require termination; only terminate
paused rx dma stemming from rx dma flush.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley 33d9b8b23a serial: 8250: Extract IIR logic steering from rx dma
Using fake IIR values to perform rx dma operations unnecessarily
conflates separate operations, stopping in-progress dma with starting
new dma.

Introduce serial8250_rx_dma_flush() to handle stopping in-progress dma
[omap8250 already has equivalent omap_8250_rx_dma_flush()].
Replace rx_dma(UART_IIR_RX_TIMEOUT) with the equivalent *_rx_dma_flush(),
and rx_dma(0) with the equivalent *_rx_dma(). Handle IIR steering
in the irq handler with handle_rx_dma() helper.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley b74fdd23d8 serial: omap8250: Simplify rx dma completion interface
Extract the operation (restarting new rx dma) performed when error
argument is true.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley ed183ee689 serial: omap8250: Drop rx buffer sync
commit 27c310c5c3 ("serial: 8250_dma: no need to sync RX buffer")
notes the RX DMA buffer is allocated from DMA coherent memory, and
thus does not need sync'd for each transaction. The same is true
for OMAP RX DMA.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley ddedfd82bc serial: 8250: Validate dmaengine tx chan meets requirements
8250 dma support requires the dmaegine driver support terminate.
Query slave caps to determine if necessary commands/properties are
supported; disable dma if not.

Note this means dmaengine driver must support slave caps reporting
as well.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley ec5a11a91e serial: 8250: Validate dmaengine rx chan meets requirements
8250 dma support requires the dmaengine driver support error-free
pause/terminate and better-than-descriptor residue granularity. Query
slave caps to determine if necessary commands/properties are supported;
disable dma if not.

Note this means dmaengine driver must support slave caps reporting
as well.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Masahiro Yamada 1681d2116c serial: 8250_uniphier: add "\n" at the end of error log
Just in case.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley 9c5895057b serial: 8250: Remove unused define
HIGH_BITS_OFFSET is only used in the serial core; remove from 8250-
specific header.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley f56f0a54b0 serial: omap8250: Eliminate local in omap8250_runtime_resume()
Eliminate 'loss_cntx' local variable.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley d601744dc1 serial: 8250: Reduce expr in 8250 irq handler
If !up->dma == F, then up->dma == T and can be elided from the
(up->dma && up->dma->tx_err) sub-expression.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Peter Hurley a86f50ed35 serial: 8250: Eliminate needless local in irq handlers
dma_err is not used other than for boolean evaluation;
substitute the actual operation directly.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Andy Shevchenko ceeafb8e22 serial: 8250_mid: correct comment regarding Tangier HSU
On Intel Penwell and Tangier the HSU block (3 HSU ports) has a global register
set which is currently not used by the driver. On Tangier it has it's own PCI
device and thus available for enumeration. Since it's not a real HSU port we
just skip it and therefore put a comment in the code why we do so.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Andy Shevchenko 1fc969c759 serial: 8250_mid: make module available only on X86
There is no reason to compile module on non-X86 platforms, though COMPILE_TEST
is provided for sake of what it does.

While here, set default to SERIAL_8250 that user doesn't need an explicit
option to be set and hide it from non-expert.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Andy Shevchenko dea5ac3ae4 serial: 8250_mid: include missed linux/bitops.h
The BIT() macro, that is definded in bitops.h, is used in the driver. Include
necessary header for that.

While here, reorder included headers alphabetically.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Andy Shevchenko c42850f1ae serial: 8250_mid: recognize interrupt source in handler
There is a special register that shows interrupt status by source. In
particular case the source can be a combination of DMA Tx, DMA Rx, and UART.

Read the register and call the handlers only for sources that request an
interrupt.

Fixes: 6ede6dcd87 ("serial: 8250_mid: add support for DMA engine handling from UART MMIO")
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Andy Shevchenko 107e15fc1f serial: 8250_mid: use proper bar for DNV platform
Unlike Intel Medfield and Tangier platforms DNV uses PCI BAR0 for IO compatible
resources and BAR1 for MMIO. We need latter in a way to support DMA. Introduce
an additional field in the internal structure and pass PCI BAR based on device
ID.

Reported-by: "Lai, Poey Seng" <poey.seng.lai@intel.com>
Fixes: 6ede6dcd87 ("serial: 8250_mid: add support for DMA engine handling from UART MMIO")
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Wan Ahmad Zainie c2684ed7d0 serial: 8250_pci: report DCD and DSR signals as active for Bay Trail
Bay Trail UART port does not support DCD and DSR lines. The driver
shall report that these signals are permanently active. This patch
is for HSUART enumerated via PCI.

For ACPI, see commit dfd37668ea ("serial: 8250_dw: Fix get_mctrl
behaviour"). The commit also describes the possible issue if these
signals are enabled on a port without these pins.

Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
Wan Ahmad Zainie 144ef5c2df serial: 8250: export get_mctrl function
Exposes get_mctrl() function so that it can be overriden with platform
specific implementation.

Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30 09:26:55 -07:00
David Müller 6f210c18c1 serial: 8250_pci: fix divide error bug if baud rate is 0
Since commit 21947ba654 ("serial: 8250_pci: replace switch-case by
formula"), the 8250 driver crashes in the byt_set_termios() function
with a divide error. This is caused by the fact that a baud rate of 0 (B0)
is not handled properly. Fix it by falling back to B9600 in this case.

Signed-off-by: David Müller <d.mueller@elsoft.ch>
Fixes: 21947ba654 ("serial: 8250_pci: replace switch-case by formula")
Cc: stable@vger.kernel.org
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-28 20:07:10 -07:00
Greg Kroah-Hartman f077b73682 Revert "serial: 8250: Add hardware dependency to RT288X option"
This reverts commit 8d2acdb9fc.

It's causing problems, and somehow I missed that Peter didn't like it at
all :(
So revert it for now until it gets sorted out.

Reported-by: Mason <slash.tmp@free.fr>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: Mans Rullgard <mans@mansr.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: John Crispin <blogic@openwrt.org>
Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
2016-04-19 15:17:37 +09:00
Yegor Yefremov 0c66940d58 tty/serial/8250: fix RS485 half-duplex RX
When in half-duplex mode RX will be disabled before TX, but not
enabled after deactivating transmitter. This patch enables
UART_IER_RLSI and UART_IER_RDI interrupts after TX is over.

Cc: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Fixes: e490c9144c ("tty: Add software emulated RS485 support for 8250")
Acked-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-19 15:15:38 +09:00
Andy Shevchenko c422025c18 dmaengine: dw: rename masters to reflect actual topology
The source and destination masters are reflecting buses or their layers to
where the different devices can be connected. The patch changes the master
names to reflect which one is related to which independently on the transfer
direction.

The outcome of the change is that the memory data width is now always limited
by a data width of the master which is dedicated to communicate to memory.

The patch will not break anything since all current users have the same data
width for all masters. Though it would be nice to revisit avr32 platforms to
check what is the actual hardware topology in use there. It seems that it has
one bus and two masters on it as stated by Table 8-2, that's why everything
works independently on the master in use. The purpose of the sequential patch
is to fix the driver for configuration of more than one bus.

The change is done in the assumption that src_master and dst_master are
reflecting a connection to the memory and peripheral correspondently on avr32
and otherwise on the rest.

Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
2016-04-13 21:36:09 +05:30
Maciej S. Szmigiero a95fc9c8e5 serial: 8250: describe CONFIG_SERIAL_8250_RSA
CONFIG_SERIAL_8250_RSA has waited for a long
time to have meaningful help text so let's
finally describe what this option actually does.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Mathieu OTHACEHE c216c4ad59 tty: serial: 8250: add MOXA Smartio MUE boards support
Add support for :

- CP-102E: 2 ports RS232 PCIE card
- CP-102EL: 2 ports RS232 PCIE card
- CP-132EL: 2 ports RS422/485 PCIE card
- CP-114EL: 4 ports RS232/422/485 PCIE card
- CP-104EL-A: 4 ports RS232 PCIE card
- CP-168EL-A: 8 ports RS232 PCIE card
- CP-118EL-A: 8 ports RS232/422/485 PCIE card
- CP-118E-A: 8 ports RS422/485 PCIE card
- CP-138E-A: 8 ports RS422/485 PCIE card
- CP-134EL-A: 4 ports RS422/485 PCIE card
- CP-116E-A (A): 8 ports RS232/422/485 PCIE card
- CP-116E-A (B): 8 ports RS232/422/485 PCIE card

This patch is based on information extracted from
vendor mxupcie driver available on MOXA website.

I was able to test it on a CP-168EL-A on PC.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Andy Shevchenko 013e3586d8 serial: 8250: convert drivers to use up_to_u8250p()
up_to_u8250p() casts struct uart_port * to struct uart_8250_port *. Update code
to use it instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Arnd Bergmann 3f5921a60f serial: 8250/mediatek: fix building with SERIAL_8250=m
The Mediatek 8250 driver has a 'bool' Kconfig symbol, but that
breaks when SERIAL_8250 is a loadable module:

drivers/tty/built-in.o: In function `mtk8250_set_termios':
:(.text+0x1bee8): undefined reference to `serial8250_do_set_termios'
:(.text+0x1bf10): undefined reference to `uart_get_baud_rate'
:(.text+0x1c09c): undefined reference to `uart_get_divisor'
drivers/tty/built-in.o: In function `mtk8250_do_pm':
:(.text+0x1c0d0): undefined reference to `serial8250_do_pm'
drivers/tty/built-in.o: In function `mtk8250_probe':
:(.text+0x1c2e4): undefined reference to `serial8250_register_8250_port'
serial/8250/8250_mtk.c:287:242: error: data definition has no type or storage class [-Werror]
serial/8250/8250_mtk.c:287:122: error: 'mtk8250_platform_driver_init' defined but not used [-Werror=unused-function]

This changes the symbol to a 'tristate', so the dependency on
SERIAL_8250 also works when that is set to 'm'.
To actually build the driver, we also need to include <linux/module.h>.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Arnd Bergmann 7d774fb8ca serial: 8250/ingenic: fix building with SERIAL_8250=m
The Ingenic 8250 driver has a 'bool' Kconfig symbol, but that
breaks when SERIAL_8250 is a loadable module:

drivers/tty/built-in.o: In function `ingenic_uart_probe':
8250_ingenic.c:(.text+0x1c1a0): undefined reference to `serial8250_register_8250_port'

This changes the symbol to a 'tristate', plus a dependency on
SERIAL_8250, which makes it work again. Unlike the other
soc-specific backends, this one has no dependency on an
architecture or a platform. I'm adding a dependency on
MIPS || COMPILE_TEST as well here, to avoid showing the driver
on architectures that are not interested in it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Arnd Bergmann a2d3ea2f23 serial: 8250/uniphier: fix modular build
The newly added uniphier serial port driver fails to build as
a loadable module when the base 8250 driver is built-in and
its console support enabled:

ERROR: "early_serial8250_setup" [drivers/tty/serial/8250/8250_uniphier.ko] undefined!

This changes the driver to only provide the early console support
if it is built-in itself as well.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Arnd Bergmann 49c56bfcb7 Revert "drivers/tty/serial: make 8250/8250_ingenic.c explicitly non-modular"
This reverts commit cafe1ac640  ("drivers/tty: make serial
8250_ingenic.c explicitly non-modular"), which attempted to remove dead
code but did not have the desired effect when the main 8250 driver was
a loadable module itself.

This would normally result in a link error, but as the entire
drivers/tty/serial/8250/ directory is only entered when CONFIG_SERIAL_8250
is set, we never notice that the driver does not get built in this
configuration.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Arnd Bergmann 88725e917d Revert "drivers/tty/serial: make 8250/8250_mtk.c explicitly non-modular"
This reverts commit d72d391c12 ("drivers/tty/serial: make
8250/8250_mtk.c explicitly non-modular"), which intended to remove dead
code but did not have the desired effect when the main 8250 driver was
a module itself.

This would normally result in a link error, but as the entire
drivers/tty/serial/8250/ directory is only entered when CONFIG_SERIAL_8250
is set, we never notice that the driver does not get built in this
configuration.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Jean Delvare 8d2acdb9fc serial: 8250: Add hardware dependency to RT288X option
Kconfig option SERIAL_8250_RT288X seems to be only relevant on MIPS
platforms, so do not present it on other architectures, unless
build-testing.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Mans Rullgard <mans@mansr.com>
Cc: Jiri Slaby <jslaby@suse.com>
Acked-by: John Crispin <blogic@openwrt.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Andy Shevchenko e78240152b serial: 8250_pci: all known Braswell ports are 1 channel
There is no need to have channel offset defined since all BayTrail and Braswell
ports are 1 channel. Remove unneeded definition.

While here, remove comment which has no value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Andy Shevchenko 3f64b1d327 serial: 8250_pci: convert to pcim_*() API
The managed API provides a better approach to help with acquiring and releasing
resources. Besides that error handling becomes simpler.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Andy Shevchenko 31f28cc2a2 serial: 8250_dw: remove leftover definitions
The clocks are managed through clk-fractional-divider.c module, and thus CLK
framework takes care about it. Remove letfovers from this driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Andy Shevchenko 34eefb595c serial: 8250_dw: remove redundant 'else' keyword
When the main branch contains return statement the 'else' keyword is not
needed. Remove it here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Matwey V. Kornilov b18a183eaa tty: serial: Use GFP_ATOMIC instead of GFP_KERNEL in serial8250_em485_init()
serial8250_em485_init() is supposed to be protected with
p->port.lock spinlock.
This may lead to issues when kmalloc sleeps, so it is better to use
GFP_ATOMIC in this spinlocked context.

Fixes: e490c9144c ("tty: Add software emulated RS485 support for 8250")
Reported-by: Ильяс Гасанов <torso.nafi@gmail.com>
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Matwey V. Kornilov bf2a0be45f tty: serial: 8250: Cleanup p->em485 in serial8250_unregister_port
Formally, currently there is no memory leak, but if
serial8250_ports[line] is reused with other 8250 driver, then em485
will be already activated and it will cause issues.

Fixes: e490c9144c ("tty: Add software emulated RS485 support for 8250")
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-07 16:11:14 -08:00
Martin Sperl e1a7d24827 serial: bcm2835: fix unsigned int issue with irq
Fixes error condition check when requesting the irq,
that would not trigger because of uart_port.irq being
defined as unsigned int.

Reported by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-14 17:39:36 -08:00
Jon Hunter 0ab556c266 serial: 8250_early: Add earlycon support for Tegra
Declare an OF early console for Tegra so that the early console device
can be specified via the "stdout-path" property in device-tree.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-14 17:39:36 -08:00
Arnd Bergmann 9db669f14f 8250: mediatek: mark PM functions as __maybe_unused
The mtk8250_runtime_suspend function is not used when runtime PM is
disabled, so we get a warning about an unused function:

drivers/tty/serial/8250/8250_mtk.c:119:12: error: 'mtk8250_runtime_suspend' defined but not used [-Werror=unused-function]
 static int mtk8250_runtime_suspend(struct device *dev)

This marks all the PM functions as __maybe_unused to avoid the warning,
and removes the #ifdef around the PM_SLEEP functions for consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-14 17:39:36 -08:00
Greg Kroah-Hartman 249f3c4fe4 Merge 4.5-rc4 into tty-next
We want the fixes in here, and this resolves a merge error in tty_io.c

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-14 14:36:04 -08:00
Greg Kroah-Hartman c8053b5876 Revert "8250: uniphier: allow modular build with 8250 console"
This reverts commit d56edd7ed0, it
shouldn't have been applied, it was fixed properly with commit
71f50c6d9a ("of: drop symbols declared by
_OF_DECLARE() from modules")

Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07 18:22:54 -08:00
Anton Wuerfel b3bd666807 tty: serial: 8250: Add generic port init macro
This patch removes redundant 8250 port initialization macros and
replaces them by a single generic base-macro, which is specialized
as needed.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel b3d67936bf tty: serial: 8250: Fix indentation warnings
Checkpatch complains about incorrect indentation of switch/case statements.
This patch fixes the corresponding warnings. Additionally some indentation
is changed to match the correct format specified in the Linux Kernel
Coding Style.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 829b000024 tty: serial: 8250: Merge duplicate conditions
This patch refactors a switch case statement by merging an if condition
in the default case into an identical condition right after the switch
statement.
This comes with a slight change in behaviour: If pci_netmos_9900_numports
returns 0, an additional warning is printed.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 9faef1cb33 tty: serial: 8250: Correct conversion specifiers
This patch fixes compiler warnings about wrong conversion specifiers used
in a debug output in 8250_pnp.c. The precise warning is:

drivers/tty/serial/8250/8250_pnp.c: In function ‘serial_pnp_probe’:
include/linux/dynamic_debug.h:64:16: warning: format ‘%x’ expects argument
of [...]

drivers/tty/serial/8250/8250_pnp.c:467:2: note: in expansion of macro
‘dev_dbg’
  dev_dbg(&dev->dev,
  ^
include/linux/dynamic_debug.h:64:16: warning: format ‘%lx’ expects argument
of [...]

drivers/tty/serial/8250/8250_pnp.c:467:2: note: in expansion of macro
‘dev_dbg’
  dev_dbg(&dev->dev,
  ^

Those warnings never got triggered, because the command was nested
in an #ifdef, which is removed by a patch of this series.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Phillip Raffeck 952773b52b tty: serial: 8250: Remove SERIAL_DEBUG_PNP macro
This patch removes the macro SERIAL_DEBUG_PNP, which is used to enable
debugging at compile time.
As SERIAL_DEBUG_PNP is an orphan, the corresponding #ifdef is removed.
To keep the ability to enable debugging at compile time,
the call to printk(KERN_DEBUG ...) is replaced by a corresponding
call to dev_dbg(), which is configurable via CONFIG_DYNAMIC_DEBUG.

Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Phillip Raffeck 9f59fbf0f2 tty: serial: 8250: Suitably replace printk
This patch replaces printk by the corresponding variant of dev_* in order
to fix checkpatch warnings. If no suitable device pointer is present, the
corresponding pr_* variant is used.

Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 90ad7c442f tty: serial: 8250: Fix multi-line strings
Merged user-visible multi-line strings into a single line according to the
Linux Kernel Coding Style, which allows user-visible strings to exceed the
maximum line length of 80 characters. The main reason for this is to
facilitate grepping for these strings.
However, some strings were ignored in this patch, because the use of
format specifiers breaks the ability to grep anyway.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 149a44cc98 tty: serial: 8250: Add parentheses to macro
This patch fixes a checkpatch warning caused by missing parentheses
in the definition of a macro.
Furthermore redundant parentheses are removed in an assignment.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 207c28b1c6 tty: serial: 8250: Fix line continuation warning
Fixed checkpatch warning about an unnecessary line continuation in a
multi-line variable assignment.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel b34f9fafea tty: serial: 8250: Move EXPORT_SYMBOL to function
This patch moves EXPORT_SYMBOL macros directly after the definition of
the corresponding symbol to remove checkpatch warnings.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel c2f5fde143 tty: serial: 8250: Remove else after return
This patch fixes checkpatch warnings about unnecessary else blocks after
return statements.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 740dc2defc tty: serial: 8250: Fix multiline comment style
Checkpatch outputs some warnings about incorrect comment style,
which is fixed by this patch.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel f7941f508d tty: serial: 8250: Fix braces after struct
This patch fixes a checkpatch warning by moving an opening curly brace
to its correct position.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 6d7c157fc7 tty: serial: 8250: Replace spaces with tabs
Indentation is changed to match the correct format of using tabs instead
of spaces wherever possible.

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Anton Wuerfel 1a33e342cf tty: serial: 8250: Fix whitespace errors
This patch fixes whitespace errors reported by checkpatch to increase
readability. Main focus is on missing spaces after commas in
function headers and macros (like foo,bar edited to foo, bar).

Signed-off-by: Anton Würfel <anton.wuerfel@fau.de>
Signed-off-by: Phillip Raffeck <phillip.raffeck@fau.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@i4.cs.fau.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:15:53 -08:00
Martin Sperl bdc5f30095 serial: bcm2835: add driver for bcm2835-aux-uart
The bcm2835 SOC contains an auxiliary uart, which is very close
to the ns16550 with some differences.

The big difference is that the uart HW is not using an internal divider
of 16 but 8, which results in an effictive baud-rate being twice
the requested baud-rate.

This driver handles this device correctly and handles the difference in
the HW divider by scaling up the clock by a factor of 2.

The approach to write a separate (wrapper) driver instead of using a
multiplying clock and "ns16550" as compatibility in the device-tree
has been recommended by Stephen Warren.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:13:30 -08:00
Wang Dongsheng 434ba16e86 serial: 8250: of: Enable suspend/resume for 8250_of driver
Suspend/resume functions should work for 8250_of driver.

Signed-off-by: Wang Dongsheng <dongsheng.wang@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:13:30 -08:00
Jeremy McNicoll 7dde55787b tty: Add support for PCIe WCH382 2S multi-IO card
WCH382 2S board is a PCIe card with 2 DB9 COM ports detected as
Serial controller: Device 1c00:3253 (rev 10) (prog-if 05 [16850])

Signed-off-by: Jeremy McNicoll <jmcnicol@redhat.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:08:00 -08:00
Arnd Bergmann d56edd7ed0 8250: uniphier: allow modular build with 8250 console
The recently added uniphier 8250 port driver supports early console
probing, and it supports being built as a module, but the combination
of the two fails to link:

ERROR: "early_serial8250_setup" [drivers/tty/serial/8250/8250_uniphier.ko] undefined!

Given that earlycon support in a loadable module makes no sense,
making that code conditional on 'MODULE' is a correct solution.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: b8d20e06ea ("serial: 8250_uniphier: add earlycon support")
Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 23:04:51 -08:00
Paul Gortmaker cafe1ac640 drivers/tty: make serial 8250_ingenic.c explicitly non-modular
The Kconfig currently controlling compilation of this code is:

drivers/tty/serial/8250/Kconfig:config SERIAL_8250_INGENIC
drivers/tty/serial/8250/Kconfig:        bool "Support for Ingenic SoC serial ports"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

We explicitly disallow a driver unbind, since that doesn't have a
sensible use case anyway, and it allows us to drop the ".remove"
code for non-modular drivers.

Since module_platform_driver() uses the same init level priority as
builtin_platform_driver() the init ordering remains unchanged with
this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information
was (or is now) contained at the top of the file in the comments.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:56:43 -08:00
Jan Beulich 8178a89eb8 serial/8250_pci: simplify Pericom handling
Considering that pci_pericom_setup(()'s only difference to
pci_default_setup() is the setting of the uartclk field, and taking
into account that this field already gets taken care of by having the
base_baud field filled in the pci_boards[] entries, there's no need
for both the function and the quirks table entry.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:51:04 -08:00
Geliang Tang 30c6c352ce serial: 8250_pci: use to_pci_dev()
Use to_pci_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:51:04 -08:00
Sebastian Frias 0b41ce9910 8250: use callbacks to access UART_DLL/UART_DLM
Some UART HW has a single register combining UART_DLL/UART_DLM
(this was probably forgotten in the change that introduced the
callbacks, commit b32b19b8ff)

Fixes: b32b19b8ff ("[SERIAL] 8250: set divisor register correctly ...")

Signed-off-by: Sebastian Frias <sf84@laposte.net>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:38:42 -08:00
Noam Camus 5a43140cc4 serial: 8250_dw: Do not use readl/writel before checking port iotype
Direct call to readl()/writel() is checked against iotype
and in case of UPIO_MEM32BE we use ioread32be()/iowrite32be()
instead of them.

Signed-off-by: Noam Camus <noamc@ezchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:28:23 -08:00
Noam Camus 4625090187 serial: 8250_dw: Add support for big-endian MMIO accesses
Add support for UPIO_MEM32BE in addition to UPIO_MEM32.

For big endian we use 2 new accessors similar to little endian,
called dw8250_serial_out32be() and dw8250_serial_in32be().

Signed-off-by: Noam Camus <noamc@ezchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:28:23 -08:00
Noam Camus cdcea058e5 serial: 8250_dw: Avoid serial_outx code duplicate with new dw8250_check_lcr()
With the help of Heikki we take common code that
makes sure LCR write wasn't ignored and put it in new function called
dw8250_check_lcr(). This function serves 3 serial_out routines:
dw8250_serial_out(), dw8250_serial_out32(), and dw8250_serial_outq().

This patch only brings better code reuse.

Signed-off-by: Noam Camus <noamc@ezchip.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:28:23 -08:00
Matwey V. Kornilov 344cee2470 tty: 8250_omap: Use software emulated RS485 direction control
Use software emulated RS485 direction control to provide RS485 API
existed in omap_serial driver. Note that 8250_omap issues interrupt
on shift register empty which is single prerequesite for using software
emulated RS485.

Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:23:26 -08:00
Matwey V. Kornilov e490c9144c tty: Add software emulated RS485 support for 8250
Implementation of software emulation of RS485 direction handling is based
on omap_serial driver.
Before and after transmission RTS is set to the appropriate value.

Note that before calling serial8250_em485_init() the caller has to
ensure that UART will interrupt when shift register empty. Otherwise,
emultaion cannot be used.

Both serial8250_em485_init() and serial8250_em485_destroy() are
idempotent functions.

Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:23:26 -08:00
Matwey V. Kornilov a07a70bcb7 tty: Move serial8250_stop_rx() in front of serial8250_start_tx()
Software RS485 emultaion is to be added in the following commit.
serial8250_start_tx() will need to refer serial8250_stop_rx().
Move serial8250_stop_rx() in front of serial8250_start_tx() in order
to avoid function forward declaration.

Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06 22:23:26 -08:00