summaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-rcar.c
Commit message (Collapse)AuthorAgeFilesLines
* i2c: rcar: avoid race when unregistering slave clientWolfram Sang2019-08-141-4/+7
| | | | | | | | | | | After we disabled interrupts, there might still be an active one running. Sync before clearing the pointer to the slave device. Fixes: de20d1857dd6 ("i2c: rcar: add slave support") Reported-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: wait for data empty before starting DMAWolfram Sang2019-03-201-7/+4Star
| | | | | | | | | | | When sending with DMA, the driver transfers the first byte with PIO (as documented). However, it started DMA right after the first byte was written. This worked, but was not according to the datasheet which suggests to wait until data register was empty again. Implement this. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: let DMA enable routine return success statusWolfram Sang2019-03-201-5/+6
| | | | | | | | | We will need to know if enabling DMA was successful in a later patch. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: sanity check for minimal DMA lengthWolfram Sang2019-03-201-2/+6
| | | | | | | | | | Use a macro for the hardcoded value and apply a build check. If it is not met, the driver logic will not work anymore. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: explain the lockless designWolfram Sang2019-03-121-0/+9
| | | | | | | | | | To make sure people can understand the lockless design of this driver without the need to dive into git history, add a comment giving an overview of the situation. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: fix concurrency issue related to ICDMAERHiromitsu Yamasaki2019-03-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the problem that an interrupt may set up a new I2C message and the DMA callback overwrites this setup. By disabling the DMA Enable Register(ICDMAER), rcar_i2c_dma_unmap() enables interrupts for register settings (such as Master Control Register(ICMCR)) and advances the I2C transfer sequence. If an interrupt occurs immediately after ICDMAER is disabled, the callback handler later continues and overwrites the previous settings from the interrupt. So, disable ICDMAER at the end of the callback to ensure other interrupts are masked until then. Note that this driver needs to work lock-free because there are IP cores with a HW race condition which prevent us from using a spinlock in the interrupt handler. Reproduction test: 1. Add a delay after disabling ICDMAER. (It is expected to generate an interrupt of rcar_i2c_irq()) void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv) { ... rcar_i2c_write(priv, ICDMAER, 0); usleep_range(500, 800) ... priv->dma_direction = DMA_NONE; } 2. Execute DMA transfers $ i2ctransfer -y 4 w9@0x6a 1 1+ r16 3. A log message of BUG_ON() will be displayed. Fixes: 73e8b0528346 ("i2c: rcar: add DMA support") Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> [wsa: updated test case to be more reliable, added note to comment] Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: refactor TCYC handlingWolfram Sang2019-02-081-9/+6Star
| | | | | | | | | | The latest documentation made it clear that we need to initialize the TCYC value independently of DMA. The old code used TCYC06 (wrongly) for non-DMA transfers. The new code sets TCYC up independently from DMA. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: comment maintenanceWolfram Sang2019-02-051-5/+2Star
| | | | | | | | | Update copyright years and remove a comment which grew incorrect and useless over time. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: Fix clients using i2c from suspend callbackGeert Uytterhoeven2019-01-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When doing s2idle/s2ram on Salvator-X(S): WARNING: CPU: 2 PID: 971 at drivers/i2c/i2c-core-base.c:1869 __i2c_transfer+0x608/0x910 [...] Call trace: __i2c_transfer+0x608/0x910 i2c_smbus_xfer_emulated+0x158/0x5b0 __i2c_smbus_xfer+0x17c/0x818 i2c_smbus_xfer+0x64/0x98 i2c_smbus_read_byte_data+0x40/0x70 cs2000_bset.isra.1+0x2c/0x68 __cs2000_set_rate.constprop.7+0x80/0x148 cs2000_resume+0x18/0x20 dpm_run_callback+0x74/0x330 device_resume_early+0xd4/0x120 dpm_resume_early+0x158/0x4f8 suspend_devices_and_enter+0x36c/0xd98 [...] On second resume, the sound driver fails with: cs2000-cp 2-004f: pll lock failed rcar_sound ec500000.sound: can't use clk 1 As the CS2000 clock driver needs to send I2C messages during suspend, the I2C controller driver should be suspended later, and resumed earlier. Fix this by using the noirq sleep ops instead of the normal sleep ops, which are called after the late sleep ops, as used by the CS2000 clock driver. Fixes: 18569fa89a4db9ed ("i2c: rcar: add suspend/resume support") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: add suspend/resume supportWolfram Sang2019-01-081-0/+25
| | | | | | | | | Because the adapter will be set up before every transaction anyhow, we just need to mark it as suspended to the I2C core. Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: check bus state before reinitializingWolfram Sang2018-11-271-4/+5
| | | | | | | | | | | | | We should check the bus state before reinitializing the IP core. Otherwise, the internal bus busy state which also tracks multi-master activity is lost. Credits go to the Renesas BSP team for suggesting this change. Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Fixes: ae481cc13965 ("i2c: rcar: fix resume by always initializing registers before transfer") Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: cleanup DMA for all kinds of failureWolfram Sang2018-10-201-1/+5
| | | | | | | | | DMA needs to be cleaned up not only on timeout, but on all errors where it has been setup before. Fixes: 73e8b0528346 ("i2c: rcar: add DMA support") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: use SPDX identifier for Renesas driversWolfram Sang2018-08-241-9/+1Star
| | | | | | Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: implement STOP and REP_START according to docsWolfram Sang2018-08-201-14/+20
| | | | | | | | | | | | | | | | | | When doing a REP_START after a read message, the driver used to trigger a STOP first which would then be overwritten by REP_START. This was the only stable method found when doing the last refactoring. However, this was not in accordance with the documentation. After research from our BSP team and myself, we now can implement a version which works and is according to the documentation. The new approach ensures the ICMCR register is only changed when really needed. Tested on a R-Car Gen2 (H2) and Gen3 with DMA (M3N). Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: refactor private flagsWolfram Sang2018-08-201-3/+4
| | | | | | | | | Use BIT macro to avoid shift-31-problem, indent a little more and use GENMASK to make it easier to add new flags. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: use core to detect 'no zero length' quirkWolfram Sang2018-08-041-7/+6Star
| | | | | | | | And don't reimplement in the driver. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: handle RXDMA HW behaviour on Gen3Wolfram Sang2018-07-231-3/+51
| | | | | | | | | | | | | | On Gen3, we can only do RXDMA once per transfer reliably. For that, we must reset the device, then we can have RXDMA once. This patch implements this. When there is no reset controller or the reset fails, RXDMA will be blocked completely. Otherwise, it will be disabled after the first RXDMA transfer. Based on a commit from the BSP by Hiromitsu Yamasaki, yet completely refactored to handle multiple read messages within one transfer. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: use the new get_bus_free callbackWolfram Sang2018-07-171-10/+11
| | | | | | | | To break out of recovery as early as possible, feed back the bus_free logic state. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: busses: make use of i2c_8bit_addr_from_msgPeter Rosin2018-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Because it looks neater. For diolan, this allows factoring out some code that is now common between if and else. For eg20t, pch_i2c_writebytes is always called with a write in msgs->flags, and pch_i2c_readbytes with a read. For imx, i2c_imx_dma_write and i2c_imx_write are always called with a write in msgs->flags, and i2c_imx_read with a read. For qup, qup_i2c_write_tx_fifo_v1 is always called with a write in qup->msg->flags. For stu300, also restructure debug output for resends, since that code as a result is only handling debug output. Reviewed-by: Guenter Roeck <linux@roeck-us.net> [diolan] Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [efm32 and imx] Acked-by: Linus Walleij <linus.walleij@linaro.org> [stu300] Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: enhance comment to avoid regressionsWolfram Sang2018-04-301-0/+2
| | | | | | | | Give a clear testcase for people wishing to change this code. It is also a reminder for me if people ask about it. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: fix mask value of prohibited bitHiromitsu Yamasaki2018-03-241-2/+2
| | | | | | | | | | According to documentation, Bit 7 of ICMSR is unused and 0 should be written to it. Fix the mask accordingly. Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com> [wsa: edited commit message] Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: fix some trivial typos in commentsWolfram Sang2018-01-241-3/+3
| | | | | | | Nothing big, but they get annoying after a while ;) Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: implement bus recoveryWolfram Sang2018-01-161-2/+52
| | | | | | | | | We can force levels of SCL and SDA, so we can use that for bus recovery. Note that we cannot read SDA back, because we will only get the internal state of the bus free detection. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: skip DMA if buffer is not safeWolfram Sang2017-12-031-1/+1
| | | | | | | | | | This HW is prone to races, so it needs to setup new messages in irq context. That means we can't alloc bounce buffers if a message buffer is not DMA safe. So, in that case, simply fall back to PIO. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: avoid unused ret variableEugeniu Rosca2017-08-171-3/+2Star
| | | | | | | | | Fix smatch warning: drivers/i2c/busses/i2c-rcar.c:628 \ rcar_i2c_request_dma_chan() warn: unused return: ret = PTR_ERR() Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* Merge branch 'i2c/for-4.13' of ↵Linus Torvalds2017-07-121-2/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "This pull request contains: - i2c core reorganization. One source file became too monolithic. It is now split up, yet we still have the same named object as the final output. This should ease maintenance. - new drivers: ZTE ZX2967 family, ASPEED 24XX/25XX - designware driver gained slave mode support - xgene-slimpro driver gained ACPI support - bigger overhaul for pca-platform driver - the algo-bit module now supports messages with enforced STOP - slightly bigger than usual set of driver updates and improvements and with much appreciated quality assurance from Andy Shevchenko" * 'i2c/for-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (51 commits) i2c: Provide a stub for i2c_detect_slave_mode() i2c: designware: Let slave adapter support be optional i2c: designware: Make HW init functions static i2c: designware: fix spelling mistakes i2c: pca-platform: propagate error from i2c_pca_add_numbered_bus i2c: pca-platform: correctly set algo_data.reset_chip i2c: acpi: Do not create i2c-clients for LNXVIDEO ACPI devices i2c: designware: enable SLAVE in platform module i2c: designware: add SLAVE mode functions i2c: zx2967: drop COMPILE_TEST dependency i2c: zx2967: always use the same device when printing errors i2c: pca-platform: use dev_warn/dev_info instead of printk i2c: pca-platform: use device managed allocations i2c: pca-platform: add devicetree awareness i2c: pca-platform: switch to struct gpio_desc dt-bindings: add bindings for i2c-pca-platform i2c: cadance: fix ctrl/addr reg write order i2c: zx2967: add i2c controller driver for ZTE's zx2967 family dt: bindings: add documentation for zx2967 family i2c controller i2c: algo-bit: add support for I2C_M_STOP ...
| * i2c: rcar: document HW incapabilitiesWolfram Sang2017-06-231-1/+6
| | | | | | | | | | | | | | | | Add recent findings (IGNORE_NAK) and document in a bit more detail why the feature is not possible. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: use proper name for the R-Car SoCWolfram Sang2017-06-191-1/+1
| | | | | | | | | | | | | | | | It is 'R-Car', not 'RCar'. No code or binding changes, only descriptive text. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* | i2c: rcar: use correct length when unmapping DMAWolfram Sang2017-06-151-1/+1
|/ | | | | | | | | | | | Because we need to transfer some bytes with PIO, the msg length is not the length of the DMA buffer. Use the correct value which we used when doing the mapping. Fixes: 73e8b0528346e8 ("i2c: rcar: add DMA support") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: clarify PM handling with more commentsWolfram Sang2017-04-211-1/+3
| | | | | | | | | PM handling is correct but might be a bit subtle. Add some comments for clarification. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: fix resume by always initializing registers before transferWolfram Sang2017-04-211-2/+2
| | | | | | | | | | | Resume failed because of uninitialized registers. Instead of adding a resume callback, we simply initialize registers before every transfer. This lightweight change is more robust and will keep us safe if we ever need support for power domains or dynamic frequency changes. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: Add per-Generation fallback bindingsSimon Horman2016-12-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | In the case of Renesas R-Car hardware we know that there are generations of SoCs, e.g. Gen 2 and Gen 3. But beyond that it's not clear what the relationship between IP blocks might be. For example, I believe that r8a7790 is older than r8a7791 but that doesn't imply that the latter is a descendant of the former or vice versa. We can, however, by examining the documentation and behaviour of the hardware at run-time observe that the current driver implementation appears to be compatible with the IP blocks on SoCs within a given generation. For the above reasons and convenience when enabling new SoCs a per-generation fallback compatibility string scheme is being adopted for drivers for Renesas SoCs. Also: * Deprecate renesas,i2c-rcar. It seems poorly named as it is only compatible with R-Car Gen 1. It also appears unused in mainline. * Add some text to describe per-SoC bindings Signed-off-by: Simon Horman <horms+renesas@verge.net.au> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* Merge branch 'i2c/for-4.9' of ↵Linus Torvalds2016-10-071-3/+2Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "Here is the 4.9 pull request from I2C including: - centralized error messages when registering to the core - improved lockdep annotations to prevent false positives - DT support for muxes, gates, and arbitrators - bus speeds can now be obtained from ACPI - i2c-octeon got refactored and now supports ThunderX SoCs, too - i2c-tegra and i2c-designware got a bigger bunch of updates - a couple of standard driver fixes and improvements" * 'i2c/for-4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (71 commits) i2c: axxia: disable clks in case of failure in probe i2c: octeon: thunderx: Limit register access retries i2c: uniphier-f: fix misdetection of incomplete STOP condition gpio: pca953x: variable 'id' was used twice i2c: i801: Add support for Kaby Lake PCH-H gpio: pca953x: fix an incorrect lockdep warning i2c: add a warning to i2c_adapter_depth() lockdep: make MAX_LOCKDEP_SUBCLASSES unconditionally visible i2c: export i2c_adapter_depth() i2c: rk3x: Fix variable 'min_total_ns' unused warning i2c: rk3x: Fix sparse warning i2c / ACPI: Do not touch an I2C device if it belongs to another adapter i2c: octeon: Fix high-level controller status check i2c: octeon: Avoid sending STOP during recovery i2c: octeon: Fix set SCL recovery function i2c: rcar: add support for r8a7796 (R-Car M3-W) i2c: imx: make bus recovery through pinctrl optional i2c: meson: add gxbb compatible string i2c: uniphier-f: set the adapter to master mode when probing i2c: uniphier-f: avoid WARN_ON() of clk_disable() in failure path ...
| * i2c: rcar: add support for r8a7796 (R-Car M3-W)Ulrich Hecht2016-09-161-0/+1
| | | | | | | | | | | | | | Same as r8a7795. Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: don't print error when adding adapter failsWolfram Sang2016-08-221-3/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The core will do this for us now. Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Acked-by: Peter Korsgaard <peter@korsgaard.com> Acked-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Thierry Reding <treding@nvidia.com> Acked-by: Ray Jui <ray.jui@broadcom.com> Acked-by: Vladimir Zapolskiy <vz@mleia.com> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* | i2c: rcar: use proper device with dma_mapping_errorWolfram Sang2016-08-251-1/+1
|/ | | | | | | | We must use the same device we used for mapping. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: use dma_request_chan()Niklas Söderlund2016-05-261-1/+1
| | | | | | | | | | New drivers should not use dma_request_slave_channel_reason() but dma_request_chan(). The former is a macro to the later so this change do not effect the driver in any way. Reported-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: add DMA supportNiklas Söderlund2016-05-151-4/+229
| | | | | | | | | | | | | | | | | | Make it possible to transfer i2c message buffers via DMA. Start/Stop/Sending_Slave_Address and some data is still handled using the old state machine, it is sending the bulk of the data that is done via DMA. The first byte of a transmission and the last two bytes of reception are sent/received using PIO. This is needed for the HW to have access to the first byte before DMA transmit and to be able to set the STOP condition for DMA reception. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Acked-by: Rob Herring <robh@kernel.org> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> [wsa: fixed a checkpatch warning] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* i2c: rcar: don't open code of_device_get_match_data()Wolfram Sang2016-03-031-1/+1
| | | | | | | | | | This change will also make Coverity happy by avoiding a theoretical NULL pointer dereference; yet another reason is to use the above helper function to tighten the code and make it more readable. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* Merge branch 'i2c/for-4.5' of ↵Linus Torvalds2016-01-141-175/+144Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "Quite some driver updates: - piix4 can now handle multiplexed adapters - brcmstb, xlr, eg20t, designware drivers support more SoCs - emev2 gained i2c slave support - img-scb and rcar got bigger refactoring to remove issues - lots of common driver updates i2c core changes: - new quirk flag when an adapter does not support clock stretching, so clients can be configured to avoid that if possible - added a helper function to retrieve timing parameters from firmware (with rcar being the first user) - "multi-master" DT binding added so drivers can adapt to this setting (like disabling PM to keep arbitration working) - RuntimePM for the logical adapter device is now always enabled by the core to ensure propagation from childs to the parent (the HW device) - new macro builtin_i2c_driver to reduce boilerplate" * 'i2c/for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (70 commits) i2c: create builtin_i2c_driver to avoid registration boilerplate i2c: imx: fix i2c resource leak with dma transfer dt-bindings: i2c: eeprom: add another EEPROM device dt-bindings: move I2C eeprom descriptions to the proper file i2c: designware: Do not require clock when SSCN and FFCN are provided DT: i2c: trivial-devices: Add Epson RX8010 and MPL3115 i2c: s3c2410: remove superfluous runtime PM calls i2c: always enable RuntimePM for the adapter device i2c: designware: retry transfer on transient failure i2c: ibm_iic: rename i2c_timings struct due to clash with generic version i2c: designware: Add support for AMD Seattle I2C i2c: imx: Remove unneeded comments i2c: st: use to_platform_device() i2c: designware: use to_pci_dev() i2c: brcmstb: Adding support for CM and DSL SoCs i2c: mediatek: fix i2c multi transfer issue in high speed mode i2c: imx: improve code readability i2c: imx: Improve message log when DMA is not used i2c: imx: add runtime pm support to improve the performance i2c: imx: init bus recovery info before adding i2c adapter ...
| * i2c: rcar: disable PM in multi-master modeWolfram Sang2016-01-021-3/+14
| | | | | | | | | | | | | | | | | | | | In multi master mode, the IP core needs to be always active for arbitration reasons. Get the config from DT and set up PM depending on the config. Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: remove macros dealing with flagsWolfram Sang2016-01-021-13/+9Star
| | | | | | | | | | | | | | | | | | These macros don't really hide complexity, but C idioms. Removing them makes the code easier to read IMO and make a planned extension easier. Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: honor additional i2c timings from DTWolfram Sang2015-12-141-9/+12
| | | | | | | | | | Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: switch to i2c generic dt parsingWolfram Sang2015-12-141-7/+9
| | | | | | | | | | | | | | | | Switch to the new generic functions. Plain convert, no functionality added yet. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: refactor probe function a littleWolfram Sang2015-12-141-23/+17Star
| | | | | | | | | | | | | | | | | | | | | | | | The probe function is a little bit messy, something here, something there. Rework it so that there is some order: first init the private structure, then the adapter, then do HW init. This also allows us to remove the device argument of the clock calculation function, because it now can be deduced from the private structure. Also, shorten some lines where possible. This is a preparation for further refactoring. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: handle difference in setting up non-first messageWolfram Sang2015-11-301-5/+16
| | | | | | | | | | | | | | Signed-off-by: Ryo Kataoka <ryo.kataoka.wt@renesas.com> Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: clean up after refactoringWolfram Sang2015-11-301-23/+9Star
| | | | | | | | | | | | | | | | Update the comments to match current behaviour. Shorten some comments. Update copyrights. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: revoke START request earlyWolfram Sang2015-11-301-16/+7Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we don't clear START generation as soon as possible, it may cause another message to be generated, e.g. when receiving NACK in address phase. To keep the race window as small as possible, we clear it right at the beginning of the interrupt. We don't need any checks since we always want to stop START and STOP generation on the next occasion after we started it. This patch improves the situation but sadly does not completely fix it. It is still to be researched if we can do better given this HW design. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: check master irqs before slave irqsWolfram Sang2015-11-301-8/+5Star
| | | | | | | | | | | | | | | | Due to the HW design, master IRQs are timing critical, so give them precedence over slave IRQ. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
| * i2c: rcar: don't issue stop when HW does it automaticallyWolfram Sang2015-11-301-2/+2
| | | | | | | | | | | | | | | | The manual says (55.4.8.6) that HW does automatically send STOP after NACK was received. My measuerments confirm that. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>