summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/sh-sci.c
Commit message (Collapse)AuthorAgeFilesLines
* serial: sh-sci: Stop transfers in sci_shutdown()Geert Uytterhoeven2016-06-261-0/+4
| | | | | | | | | | | | | | | | | | Make sure the transmitter and receiver are stopped when shutting down the port, and related interrupts are disabled. Without this: - New input data may be received into the RX FIFO, possibly triggering a new RX DMA completion, - Transfers will still be enabled on a subsequent startup of the UART, before the UART's FIFOs have been reset, causing reading of stale data. Inspired by a patch in the BSP by Koji Matsuoka <koji.matsuoka.xm@renesas.com>. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Clear (H)SCIF timeout and overrun during resetGeert Uytterhoeven2016-06-251-0/+5
| | | | | | | | | Add the missing timeout bit definition for (H)SCIF. Clear the timeout and overrun flag bits during UART reset, cfr. the initialization flowchart in the datasheet. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Clear RX, error, and break flags during resetGeert Uytterhoeven2016-06-251-0/+4
| | | | | | | | | | | | Setting the FIFO reset bits is not sufficient to reset the RX FIFO. After this the status register's RDF flag bit may still be set, causing the reception of one stale byte of data. To fix this, clear all status flag bits related to reception, error, and break handling, cfr. the initialization flowchart in the datasheet. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Do not start transfers from sci_startup()Geert Uytterhoeven2016-06-251-6/+0
| | | | | | | | | | | | | | | | | | | FIFO reset is done in sci_reset(), called from sci_set_termios(), while sci_start_tx() and sci_start_rx() are called before, from sci_startup(). However, starting transfers before the UART's FIFOs have been reset may cause reading of stale data. Remove the calls to sci_start_tx() and sci_start_rx() from sci_startup() to fix this. Transfers are still started when needed: - sci_start_rx() is called from sci_set_termios() after FIFO reset, if the CREAD flag is set, - sci_start_tx() is called from uart_change_speed() immediately thereafter, if transmission is enabled. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Add DT support for dedicated RTS/CTSGeert Uytterhoeven2016-06-251-0/+3
| | | | | | | | | Add support for indicating the availability of dedicated lines for RTS/CTS hardware flow control, using the standard "uart-has-rtscts" DT property. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Fix support for hardware-assisted RTS/CTSGeert Uytterhoeven2016-06-251-7/+83
| | | | | | | | | | | The existing support for hardware-assisted RTS/CTS is rudimentary and doesn't work. Add support for hardware-assisted RTS/CTS hardware flow control for the (H)SCIF, SCIFA, and SCIFB variants. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Add pin initialization for SCIFA/SCIFBGeert Uytterhoeven2016-06-251-1/+15
| | | | | | | | | | | Before, the driver relied on initialization by the boot loader, or by implicit reset state. Note that unlike on (H)SCIF, the RTS/CTS bits exist only if dedicated RTS/CTS pins are available, which depends on the SoC and UART instance. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Correct pin initialization on (H)SCIFGeert Uytterhoeven2016-06-251-15/+8
| | | | | | | | | | | | | | | | Correct pin initialization on (H)SCIF: - RTS must be deasserted (it's active low), - SCK must be an input, as it may be used as the optional external clock input. Initial pin configuration must always be done: - Regardless of the presence of dedicated RTS and CTS pins: if the register exists, the RTS/CTS bits exist, too, - Regardless of hardware flow control being enabled or not: RTS must be deasserted. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Do not open-code sci_getreg()Geert Uytterhoeven2016-06-251-5/+2
| | | | | | | | | Replace open-coded variants of sci_getreg() by function calls, and drop intermediate variables where appropriate. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Add support for GPIO-controlled modem linesGeert Uytterhoeven2016-06-251-1/+45
| | | | | | | | | | | | | | Enhance the Renesas SCI UART driver to add support for GPIO-controlled modem lines (CTS, DSR, DCD, RNG, RTS, DTR), using the serial_mctrl_gpio helpers. GPIO-controlled modem lines can be used when dedicated modem lines are not available. Invalid configurations specifying both GPIO RTS/CTS and dedicated RTS/CTS are rejected. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Always set TIOCM_CTS in .get_mctrl() callbackGeert Uytterhoeven2016-06-251-2/+2
| | | | | | | | | | | | | | | | | | Documentation/serial/driver clearly states: If the port does not support CTS, DCD or DSR, the driver should indicate that the signal is permanently active. Hence always set TIOCM_CTS, as we currently don't look at the CTS hardware line state at all. FWIW, this fixes the transmit path when hardware-assisted flow control is enabled, and userspace enables CRTSCTS. The receive path is still broken, as RTS is never asserted. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Remove redundant instances of EARLYCON_DECLARE()Geert Uytterhoeven2016-03-071-5/+0
| | | | | | | | | | As of commit 2eaa790989e03900 ("earlycon: Use common framework for earlycon declarations") it is no longer needer to specify both EARLYCON_DECLARE() and OF_EARLYCON_DECLARE(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Add support for SCIFA/SCIFB variable sampling ratesGeert Uytterhoeven2016-02-061-2/+27
| | | | | | | | | | | | | | | | Add support for sparse variable sampling rates on SCIFA and SCIFB. According to the datasheet, sampling rate 1/5 needs a small quirk to avoid corrupting the first byte received. This increases the range and accuracy of supported baud rates. E.g. on r8a7791/koelsch: - Supports now 134, 150, and standard 500000-4000000 bps, - Perfect match for 134, 150, 500000, 1000000, 2000000, and 4000000 bps, - Accuracy has increased for most standard bps values. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Use a bitmask to indicate supported sampling ratesGeert Uytterhoeven2016-02-061-39/+27
| | | | | | | | | | Replace the single sampling rate and special handling for HSCIF's variable sampling rates by a bitmask and a custom iterator. This prepares for the advent of SCIFA/SCIFB's sparse variable sampling rates. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Use premultiplier to handle half sampling rateGeert Uytterhoeven2016-02-061-6/+10
| | | | | | | | | | | | | | | | On SCIx variants different from HSCIF, the bit rate is equal to the sampling clock rate divided by half the sampling rate. Currently this is handled by dividing the sampling rate by two, which was OK as it was always even. Replace halving the sampling rate by premultiplying the base clock frequency by 2, to accommodate odd sampling rates on SCIFA/SCIFB later. Replace the shift value in the BRG divider calculation by a premultiplication of the base clock frequency too, for consistency. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Preserve SCIFA/SCIFB bit rate config for serial consoleGeert Uytterhoeven2016-02-061-1/+2
| | | | | | | | | SCIFA and SCIFB have additional bit rate config bits in the Serial Mode Register. Don't touch them when using the port as a serial console, as we rely on the boot loader to have configured the serial port config. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Add more Serial Mode Register documentationGeert Uytterhoeven2016-02-061-1/+1
| | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Add CONFIG_SERIAL_EARLYCON supportYoshinori Sato2016-02-061-5/+72
| | | | | | | | | | | | "earlyprintk" is architecture specific option. General "earlycon" option support is much better. Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp> [uli: preserve other SCSCR bits when asserting RE and TE] Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com> [geert: rewording, #ifdef rework] Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Remove cpufreq notifier to fix crash/deadlockGeert Uytterhoeven2016-01-071-42/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BSP team noticed that there is spin/mutex lock issue on sh-sci when CPUFREQ is used. The issue is that the notifier function may call mutex_lock() while the spinlock is held, which can lead to a BUG(). This may happen if CPUFREQ is changed while another CPU calls clk_get_rate(). Taking the spinlock was added to the notifier function in commit e552de2413edad1a ("sh-sci: add platform device private data"), to protect the list of serial ports against modification during traversal. At that time the Common Clock Framework didn't exist yet, and clk_get_rate() just returned clk->rate without taking a mutex. Note that since commit d535a2305facf9b4 ("serial: sh-sci: Require a device per port mapping."), there's no longer a list of serial ports to traverse, and taking the spinlock became superfluous. To fix the issue, just remove the cpufreq notifier: 1. The notifier doesn't work correctly: all it does is update stored clock rates; it does not update the divider in the hardware. The divider will only be updated when calling sci_set_termios(). I believe this was broken back in 2004, when the old drivers/char/sh-sci.c driver (where the notifier did update the divider) was replaced by drivers/serial/sh-sci.c (where the notifier just updated port->uartclk). Cfr. full-history-linux commits 6f8deaef2e9675d9 ("[PATCH] sh: port sh-sci driver to the new API") and 3f73fe878dc9210a ("[PATCH] Remove old sh-sci driver"). 2. On modern SoCs, the sh-sci parent clock rate is no longer related to the CPU clock rate anyway, so using a cpufreq notifier is futile. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge branch 'scif-clk-sck-brg-for-v4.5' of ↵Greg Kroah-Hartman2016-01-071-152/+403
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into tty-next Geert writes: Summary: - Clean up the naming of clocks in the sh-sci driver and its DT bindings, - Add support for the optional external clock on (H)SCI(F), where this pin can serve as a clock input, - Add support for the optional clock sources for the Baud Rate Generator for External Clock (BRG), as found on some SCIF variants and on HSCIF.
| * serial: sh-sci: Drop the sci_fck clock fallbackLaurent Pinchart2015-12-171-5/+0
| | | | | | | | | | | | | | | | | | | | All platforms that used to define an sci_fck clock have now switched to the fck name. Remove the fallback code. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Add support for optional BRG on (H)SCIFGeert Uytterhoeven2015-12-171-5/+80
| | | | | | | | | | | | | | | | | | Add support for using the Baud Rate Generator for External Clock (BRG), as found on some SCIF and HSCIF variants, to provide the sampling clock. This can improve baud rate range and accuracy. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Add support for optional external (H)SCK inputGeert Uytterhoeven2015-12-171-3/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for using the SCIx clock pin "(H)SCK" as an external clock input on (H)SCI(F), providing the sampling clock. Note that this feature is not yet supported on the select SCIFA variants that also have it (e.g. sh7723, sh7724, and r8a7740). On (H)SCIF variants with an External Baud Rate Generator (BRG), the BRG Clock Select Register must be configured for the external clock. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Prepare for multiple sampling clock sourcesGeert Uytterhoeven2015-12-171-60/+134
| | | | | | | | | | | | | | | | | | | | Refactor the clock and baud rate parameter code to ease adding support for multiple sampling clock sources. sci_scbrr_calc() now returns the bit rate error, so it can be compared to the bit rate error using other sampling clock sources. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Correct SCIF type on R-Car for BRGGeert Uytterhoeven2015-12-171-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "renesas,scif" compatible value is currently used for the SCIF variant in all Renesas SoCs of the R-Car family. However, the variant used in the R-Car family is not the common "SH-4(A)" variant, but a derivative with added "Baud Rate Generator for External Clock" (BRG), which is also present in sh7734. Use the family-specific SCIF compatible values for R-Car Gen1, Gen2, and Gen3 SoCs to differentiate. The "renesas,scif" compatible value can still be used as a common denominator for SCIF variants with the "SH-4(A)" register layout (i.e. ignoring the "Serial Extension Mode Register" (SCEMR) and the new BRG-specific registers). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Correct SCIF type on RZ/A1HGeert Uytterhoeven2015-12-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "renesas,scif" compatible value is currently used for the SCIF variant in all Renesas SoCs of the R-Car and RZ families. However, the variant used in the RZ family is not the common "SH-4(A)" variant, but the "SH-2(A) with FIFO data count register" variant, as it has the "Serial Extension Mode Register" (SCEMR), just like on sh7203, sh7263, sh7264, and sh7269. Use the (already documented) SoC-specific "renesas,scif-r7s72100" compatible value to differentiate. The "renesas,scif" compatible value can still be used as a common denominator for SCIF variants with the "SH-4(A)" register layout (i.e. ignoring the SCEMR register). Note that currently both variants are treated the same, but this may change if support for the SCEMR register is ever added. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Replace struct sci_port_info by type/regtype encodingGeert Uytterhoeven2015-12-171-29/+11
| | | | | | | | | | | | | | | | | | | | | | Store the encoded port and register types directly in of_device_id.data, instead of using a pointer to a structure. This saves memory and simplifies the source code, especially when adding more compatible entries later. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Add BRG register definitionsGeert Uytterhoeven2015-12-171-0/+46
| | | | | | | | | | | | | | | | | | Add register definitions for the Baud Rate Generator for External Clock (BRG), as found in some SCIF and in HSCIF, including a new regtype for the "SH-4(A)"-derived SCIF variant with BRG. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Take into account sampling rate for max baud rateGeert Uytterhoeven2015-12-171-1/+4
| | | | | | | | | | | | | | | | | | | | The maximum baud rate depends on the sampling rate. HSCIF has a variable sampling rate and sets s->sampling_rate to zero, hence use the minimum sampling rate of 8. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Merge sci_scbrr_calc() and sci_baud_calc_hscif()Geert Uytterhoeven2015-12-171-23/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For low bit rates, the for-loop that reduces the divider returned by sci_scbrr_calc() and picks the clock select value may terminate without finding suitable values, leading to out-of-range divider and clock select values. sci_baud_calc_hscif() doesn't suffer from this problem, as it correctly uses clamp(). Since there are only two relevant differences between HSCIF and other variants w.r.t. bit rate configuration (fixed vs. variable sample rate, and an additional factor of two), sci_scbrr_calc() and sci_baud_calc_hscif() can be merged, fixing the issue with out-of-range values. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Avoid calculating the receive margin for HSCIFGeert Uytterhoeven2015-12-171-27/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | When assuming D = 0.5 and F = 0, maximizing the receive margin M is equivalent to maximizing the sample rate N. Hence there's no need to calculate the receive margin, as we can obtain the same result by iterating over all possible sample rates in reverse order, and skipping parameter sets that don't provide a lower bit rate error. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Improve bit rate error calculation for HSCIFGeert Uytterhoeven2015-12-171-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The algorithm to find the best parameters for the requested bit rate calculates the relative bit rate error, using "(br * scrate) / 1000". For small "br * scrate", this has two problems: - The quotient may be zero, leading to a division by zero error, - This may introduce a large rounding error. Switch from relative to absolute bit rate error calculation to fix this. The default baud rate generator values can be removed, as there will always be one set of values that gives the smallest absolute error. Print the best set of values when debugging. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Avoid overflow in sci_baud_calc_hscif()Geert Uytterhoeven2015-12-171-6/+19
| | | | | | | | | | | | | | | | | | | | | | If bps >= 1048576, the multiplication of the predivider and "bps" will overflow, and both br and err will contain bogus values. Skip the current and all higher clock select predividers when overflow is detected. Simplify the calculations using intermediates while we're at it. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Make unsigned values in sci_baud_calc_hscif() unsignedGeert Uytterhoeven2015-12-171-5/+6
| | | | | | | | | | | | | | | | | | Move the -1 offset of br to the assignment to *brr, so br cannot become negative anymore, and update the clamp() call. Now all unsigned values in sci_baud_calc_hscif() can become unsigned. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Convert from clk_get() to devm_clk_get()Geert Uytterhoeven2015-12-171-6/+4
| | | | | | | | | | | | | | Transfer clock cleanup handling to the core device management code. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Don't overwrite clock selection in serial_console_write()Geert Uytterhoeven2015-12-171-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Blindly writing the default configuration value into the SCSCR register may change the clock selection bits, breaking the serial console if the current driver settings differ from the default settings. Keep the current clock selection bits to prevent this from happening on e.g. r8a7791/koelsch when support for the BRG will be added. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Drop unused frame_len parameter for sci_baud_calc_hscif()Geert Uytterhoeven2015-12-171-21/+3
| | | | | | | | | | | | | | | | | | | | As F is assumed to be zero in the receive margin formula, frame_len is not used. Remove it, together with the sci_baud_calc_frame_len() helper function. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Use existing local variable in sci_parse_dt()Geert Uytterhoeven2015-12-171-1/+1
| | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
| * serial: sh-sci: Grammar s/Get ... for/Get ... from/Geert Uytterhoeven2015-12-171-1/+1
| | | | | | | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Drop useless check for zero sampling_rateGeert Uytterhoeven2015-12-171-7/+1
| | | | | | | | | | | | | | | | | | sci_port.sampling_rate is always non-zero, except for HSCIF, which uses sci_baud_calc_hscif() instead of sci_scbrr_calc(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * serial: sh-sci: Drop the interface clockLaurent Pinchart2015-12-171-23/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As no platform defines an interface clock the SCI driver always falls back to a clock named "peripheral_clk". - On SH platforms that clock is the base clock for the SCI functional clock and has the same frequency, - On ARM platforms that clock doesn't exist, and clk_get() will return the default clock for the device. We can thus make the functional clock mandatory and drop the interface clock. EPROBE_DEFER is handled for clocks that may be referenced from DT (i.e. "fck", and the deprecated "sci_ick"). Cc: devicetree@vger.kernel.org Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Simon Horman <horms+renesas@verge.net.au> [geert: Handle EPROBE_DEFER, reformat description, break long comment line] Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Rob Herring <robh@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | serial: sh-sci: Fix length of scatterlistYoshihiro Shimoda2015-12-121-1/+1
|/ | | | | | | | | | | | This patch fixes an issue that the "length" of scatterlist should be set using sg_dma_len(). Otherwise, a dmaengine driver cannot work correctly if CONFIG_NEED_SG_DMA_LENGTH=y. Fixes: 7b39d90184 (serial: sh-sci: Fix NULL pointer dereference if HIGHMEM is enabled) Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Add DT support to DMA setupGeert Uytterhoeven2015-10-041-31/+47
| | | | | | | | | | | | | | | | | | | Add support for obtaining DMA channel information from the device tree. This requires switching from the legacy sh_dmae_slave structures with hardcoded channel numbers and the corresponding filter function to: 1. dma_request_slave_channel_compat(), - On legacy platforms, dma_request_slave_channel_compat() uses the passed DMA channel numbers that originate from platform device data, - On DT-based platforms, dma_request_slave_channel_compat() will retrieve the information from DT. 2. and the generic dmaengine_slave_config() configuration method, which requires filling in DMA register ports and slave bus widths. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Pause DMA engine and get DMA status againMuhammad Hamza Farooq2015-10-041-0/+16
| | | | | | | | | | Occasionally, DMA transaction completes _after_ DMA engine is stopped. Verify if the transaction has not finished before forcing the engine to stop and push the data Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Do not terminate DMA engine when race condition occursMuhammad Hamza Farooq2015-10-041-1/+6
| | | | | | | | | | When DMA packet completion and timer expiry take place at the same time, do not terminate the DMA engine, leading by submission of new descriptors, as the DMA communication hasn't necessarily stopped here. Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Call dma_async_issue_pending when transaction completesMuhammad Hamza Farooq2015-10-041-0/+3
| | | | | | | | | | | dmaengine_submit() will not start the DMA operation, it merely adds it to the pending queue. If the queue is no longer running, it won't be restarted until dma_async_issue_pending() is called. Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com> [geert: Add more description] Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Redirect port interrupts to CPU _only_ when DMA stopsMuhammad Hamza Farooq2015-10-041-8/+10
| | | | | | | | | | Since the DMA engine is not stopped everytime rx_timer_fn is called, the interrupts have to be redirected back to CPU only when incomplete DMA transaction is handled Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Remove timer on shutdown of portAleksandar Mitev2015-10-041-0/+8
| | | | | | | | | | | This prevents DMA timer timeout that can trigger after the port has been closed. Signed-off-by: Aleksandar Mitev <amitev@visteon.com> [geert: Move del_timer_sync() outside spinlock to avoid circular locking dependency between rx_timer_fn() and del_timer_sync()] Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Stop calling sci_start_rx() from sci_request_dma()Geert Uytterhoeven2015-10-041-1/+0
| | | | | | | | There's no need to call sci_start_rx() from sci_request_dma() when DMA setup fails, as sci_startup() will call sci_start_rx() anyway. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sh-sci: Submit RX DMA from RX interrupt on (H)SCIFGeert Uytterhoeven2015-10-041-2/+5
| | | | | | | | | | | | | | | | | | | | | For DMA receive requests, the driver is only notified by DMA completion after the whole DMA request has been transferred. If less data is received, it will stay stuck until more data arrives. The driver handles this by setting up a timer handler from the receive interrupt, after reception of the first character. Unlike SCIFA and SCIFB, SCIF and HSCIF don't issue receive interrupts on reception of individual characters if a receive DMA request is in progress, so the timer is never set up. To fix receive DMA on SCIF and HSCIF, submit the receive DMA request from the receive interrupt handler instead. In some sense this is similar to the SCIFA/SCIFB behavior, where the RDRQE (Rx Data Transfer Request Enable) bit is also set from the receive interrupt handler. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
OpenPOWER on IntegriCloud