summaryrefslogtreecommitdiff
path: root/drivers/i2c
AgeCommit message (Collapse)Author
2019-07-12Merge tag 'v4.14.126' into 4.14-2.0.x-imxMax Krummenacher
This is the 4.14.126 stable release Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> Conflicts: drivers/gpio/gpio-vf610.c: Follow commit 338aa10750ba gpio: vf610: Do not share irq_chip drivers/gpu/drm/bridge/adv7511/adv7511_drv.c: Follow commit 67793bd3b394 drm/bridge: adv7511: Fix low refresh rate selection Use drm_mode_vrefresh(mode) helper drivers/net/ethernet/freescale/fec_main.c: Keep downstream file. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c Follow commit 46953f97224d brcmfmac: fix missing checks for kmemdup sound/soc/fsl/Kconfig: Follow commit ea751227c813 ASoC: imx: fix fiq dependencies Logical Conflicts: sound/soc/fsl/fsl_sai.c: Revert upstream d7325abe29b as downstream fixed it differently drivers/clk/imx/clk-imx6sl.c Revert upstream bda9f846ae0 as downstream implemented it differently 68c736e9378
2019-06-11i2c: xiic: Add max_read_len quirkRobert Hancock
commit 49b809586730a77b57ce620b2f9689de765d790b upstream. This driver does not support reading more than 255 bytes at once because the register for storing the number of bytes to read is only 8 bits. Add a max_read_len quirk to enforce this. This was found when using this driver with the SFP driver, which was previously reading all 256 bytes in the SFP EEPROM in one transaction. This caused a bunch of hard-to-debug errors in the xiic driver since the driver/logic was treating the number of bytes to read as zero. Rejecting transactions that aren't supported at least allows the problem to be diagnosed more easily. Signed-off-by: Robert Hancock <hancock@sedsystems.ca> Reviewed-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-08Merge branch 'linux-4.14.y_for_4.14-2.0.x-imx' into 4.14-2.0.x-imxPhilippe Schenker
2019-05-08i2c: i2c-stm32f7: Fix SDADEL minimum formulaNicolas Le Bayon
commit c86da50cfd840edf223a242580913692acddbcf6 upstream. It conforms with Reference Manual I2C timing section. Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver") Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com> Signed-off-by: Bich Hemon <bich.hemon@st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-23i2c: tegra: fix maximum transfer sizeSowjanya Komatineni
commit f4e3f4ae1d9c9330de355f432b69952e8cef650c upstream. Tegra186 and prior supports maximum 4K bytes per packet transfer including 12 bytes of packet header. This patch fixes max write length limit to account packet header size for transfers. Cc: stable@vger.kernel.org # 4.4+ Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-23i2c: bcm2835: Clear current buffer pointers and counts after a transferPaul Kocialkowski
[ Upstream commit f275a4659484716259cc46268d9043424e51cf0f ] The driver's interrupt handler checks whether a message is currently being handled with the curr_msg pointer. When it is NULL, the interrupt is considered to be unexpected. Similarly, the i2c_start_transfer routine checks for the remaining number of messages to handle in num_msgs. However, these values are never cleared and always keep the message and number relevant to the latest transfer (which might be done already and the underlying message memory might have been freed). When an unexpected interrupt hits with the DONE bit set, the isr will then try to access the flags field of the curr_msg structure, leading to a fatal page fault. The msg_buf and msg_buf_remaining fields are also never cleared at the end of the transfer, which can lead to similar pitfalls. Fix these issues by introducing a cleanup function and always calling it after a transfer is finished. Fixes: e2474541032d ("i2c: bcm2835: Fix hang for writing messages larger than 16 bytes") Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-03-23i2c: cadence: Fix the hold bit settingShubhrajyoti Datta
[ Upstream commit d358def706880defa4c9e87381c5bf086a97d5f9 ] In case the hold bit is not needed we are carrying the old values. Fix the same by resetting the bit when not needed. Fixes the sporadic i2c bus lockups on National Instruments Zynq-based devices. Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller") Reported-by: Kyle Roeschley <kyle.roeschley@ni.com> Acked-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> Tested-by: Kyle Roeschley <kyle.roeschley@ni.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-03-20MLK-20993 i2c: rpmsg: add a BUG_ON to catch alias id issuePeng Fan
The alias ID must be defined in device tree, because that will be used as BUS ID to Cortex M4. If the alias ID not defined, linux kernel will automatically allocate one ID which might not be the same number used in Cortex M4 and Cortex M4 will not send msg to I2C controller. So let's add BUG_ON to catch issue as earlier as possible to avoid wasting efforts. Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Clark Wang <xiaoning.wang@nxp.com>
2019-03-14MLK-21140 i2c: rpmsg: ensure received bus_id and addr is same as sentClark Wang
For some chips may need long time to get the response from M4 sometimes, enlarge timeout to 500ms. Add a judgement to check if the received data is the current transfer wanted. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
2019-03-13i2c: omap: Use noirq system sleep pm ops to idle device for suspendTony Lindgren
[ Upstream commit c6e2bd956936d925748581e4d0294f10f1d92f2c ] We currently get the following error with pixcir_ts driver during a suspend resume cycle: omap_i2c 4802a000.i2c: controller timed out pixcir_ts 1-005c: pixcir_int_enable: can't read reg 0x34 : -110 pixcir_ts 1-005c: Failed to disable interrupt generation: -110 pixcir_ts 1-005c: Failed to stop dpm_run_callback(): pixcir_i2c_ts_resume+0x0/0x98 [pixcir_i2c_ts] returns -110 PM: Device 1-005c failed to resume: error -110 And at least am437x based devices with pixcir_ts will fail to resume to a touchscreen that is configured as the wakeup-source in device tree for these devices. This is because pixcir_ts tries to reconfigure it's registers for noirq suspend which fails. This also leaves i2c-omap in enabled state for suspend. Let's fix the pixcir_ts issue and make sure i2c-omap is suspended by adding SET_NOIRQ_SYSTEM_SLEEP_PM_OPS. Let's also get rid of some ifdefs while at it and replace them with __maybe_unused as SET_RUNTIME_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS already deal with the various PM Kconfig options. Reported-by: Keerthy <j-keerthy@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Acked-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-03-05MLK-21023 i2c: rpmsg-imx: add mutex lock when transfer i2c messagesClark Wang
I2c_lock_bus function in i2c-core-base will not stop the transfer to different devices on different buses at the same time. Since the multiple rpmsg i2c buses share one rpmsg channel, so it has to add mutex to protect rpmsg resource accessing. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
2019-02-22MLK-20940-1 i2c: busses: Add virtual i2c driver based on rpmsgClark Wang
Add virtual i2c driver to send SRTM i2c messages to M4. Each virtual I2C bus has a specal bus id, which is abstracted by M4. Each SRTM message include a bus id for the bus which the device is on. Virtual i2c rpmsg bus will bind rpbus nodes with compatible string "fsl,i2c-rpbus". And "rpmsg-i2c-channel" will probe only one rpmsg channel for all rpbuses. This virtual i2c driver depends on CONFIG_I2C and CONFIG_RPMSG. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
2019-02-12i2c-axxia: check for error conditions firstAdamski, Krzysztof (Nokia - PL/Wroclaw)
[ Upstream commit 4f5c85fe3a60ace555d09898166af372547f97fc ] It was observed that when using seqentional mode contrary to the documentation, the SS bit (which is supposed to only be set if automatic/sequence command completed normally), is sometimes set together with NA (NAK in address phase) causing transfer to falsely be considered successful. My assumption is that this does not happen during manual mode since the controller is stopping its work the moment it sets NA/ND bit in status register. This is not the case in Automatic/Sequentional mode where it is still working to send STOP condition and the actual status we get depends on the time when the ISR is run. This patch changes the order of checking status bits in ISR - error conditions are checked first and only if none of them occurred, the transfer may be considered successful. This is required to introduce using of sequentional mode in next patch. Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-02-12i2c: sh_mobile: add support for r8a77990 (R-Car E3)Simon Horman
[ Upstream commit 5eb316e636eb298c204f5b368526d4480b63c0ba ] Add support for the IIC code for the r8a77990 (R-Car E3). It is not considered compatible with existing fallback bindings due to the documented absence of automatic transmission registers. These registers are currently not used by the driver and thus the provides the same behaviour for "renesas,iic-r8a77990" and "renesas,rcar-gen3-iic". The point of declaring incompatibility is to allow for automatic transmission register support to be added to "renesas,iic-r8a77990" and "renesas,rcar-gen3-iic" in future. 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-02-12MLK-20773 i2c-imx: add a limit of maximum transfer speed for imx7dClark Wang
According the e7805 in Errata, the SCK low level period should be less than 1.3us. The other series platform use this same IP can match the errata, and ensure the low level period longer than 1.3us when the speed set to 400KHz. However, only at imx7d platform, the low level period is less than 1.3us in the same situation. Therefore, limit the maximum transfer speed to 384KHz when probe at imx7d platform. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
2019-02-12MLK-20368 i2c-imx: Coverity: fix divide by zero warningClark Wang
"i2c_clk_rate / 2" might be zero when the i2c_clk_rate gets the clock is 0 or 1, so add a judgment to avoid the denominator is equal to 0. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
2019-02-12MLK-20380: i2c: xenfront: fix i2cdetect bugFlynn xu
The bug is when using i2cdetect in DomU, some i2c device will be skiped, fixed this through add I2C_FUNC_SMBUS_QUICK functionality. Signed-off-by: Flynn xu <flynn.xu@nxp.com>
2019-02-12MLK-20349 i2c: xen front: fix build warningPeng Fan
Fixes build warning introduced by 90e818a0abcc("MLK-20342 i2c: xen-i2cback/front: Add i2c_smbus interface") Signed-off-by: Peng Fan <peng.fan@nxp.com>
2019-02-12MLK-20342 i2c: xen-i2cback/front: Add i2c_smbus interfaceFlynn xu
Add smbus_xfer interface in xen-i2cback/front driver. Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Flynn xu <flynn.xu@nxp.com>
2019-02-12MLK-20319 i2c:xen-i2cfront: fix uninitalized variableFlynn xu
Fix uninitalized variable Signed-off-by: Flynn xu <flynn.xu@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com>
2019-02-12MLK-20196-2 i2c: xen-i2cback: fix uninitalized variablesPeng Fan
Fix Coverity id 5186949 5187047, uninitialized variables. Signed-off-by: Peng Fan <peng.fan@nxp.com>
2019-02-12MLK-20196-1 i2c: xen-i2cback: fix num_msg usagePeng Fan
When req.num_msg is less than 2, also need initialze num_msg. Also modify the if/else if to use num_msg Signed-off-by: Peng Fan <peng.fan@nxp.com>
2019-02-12MLK-19728-2 i2c: introduce xen i2c paravirtualization driverPeng Fan
Add i2c backend frontend support. The transaction only support one msg each time. The frontend sends a request to backend, backend use i2c_transfer to do real transaction to hardware and return the results to frontend. Now i2cdump/get/set works. In domu cfg file, use "vi2c = ['backend=0,be-adapter=5a800000.i2c,addr=0x51;0x44']" to create a dummy controller in frontend and allowed slaves in backend. Currently the slave address check not added, it will be supported in furture patch. Signed-off-by: Peng Fan <peng.fan@nxp.com>
2019-02-12MLK-17426 imx: lpi2c: add debug message when i2c peripheral clk doesn't workGao Pan
add debug message when i2c peripheral clk rate is 0, then directly return -EINVAL. Signed-off-by: Gao Pan <pandy.gao@nxp.com> Reviewed-by: Andy Duan <fugang.duan@nxp.com>
2019-02-12MLK-17290-02 i2c: imx-lpi2c: manage irq resource request/release in runtime pmFugang Duan
Manage irq resource request/release in runtime pm to save irq domain's power. Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Tested-by: Guoniu.Zhou <guoniu.zhou@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com>
2019-02-12MLK-16713 i2c: imx-lpi2c: add runtime pm supportFugang Duan
- Add runtime pm support to dynamicly manage the ipg and per clocks. - Put the suspend to suspend_noirq. - Call .pm_runtime_force_suspend() to force runtime pm suspended in .suspend_noirq(). BuildInfo: - SCFW 88456c73, IMX-MKIMAGE 06bc2767, ATF a438801 - U-Boot 2017.03-imx_v2017.03_4.9.51_imx8_beta1+g7953d47 Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Signed-off-by: Gao Pan <pandy.gao@nxp.com> Reviewed-by: Anson Huang <Anson.Huang@nxp.com> During 4.14 rebase added pm_runtime_get_sync/pm_runtime_put around the reading of LPI2C_PARAM. Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2019-02-12MA-10480 Make CONFIG_I2C_IMX to depend on CONFIG_ARCH_MXC_ARM64guoyin.chen
imx8mscale evk uses the i2c imx driver to control the pfuze driver otherwise pfuze driver wont be probed with I2C_IMX Change-Id: Iaeacde58a4cbe34a3d18cb16814d2334c74c2b79 (cherry-picked from commit ad7200824fa740a1fe9d418d3f949ff97b083bdf) Signed-off-by: guoyin.chen <guoyin.chen@nxp.com>
2019-02-12MLK-16203 enable runtime pm of i2c temporary when do system suspendGao Pan
When we do system suspend, the runtime pm will be disabled, but we need to control the PMIC to power on/off the regulator, if the runtime pm is disabled, if will failed to request runtime wakeup. So data transfer will failed. Signed-off-by: Bai Ping <ping.bai@nxp.com> Signed-off-by: Gao Pan <pandy.gao@nxp.com>
2019-02-12MLK-16220 lpi2c: imx8: improve i2c driver probe priorityGao Pan
use subsys_initcall for i2c driver to improve i2c driver probe priority Signed-off-by: Gao Pan <pandy.gao@nxp.com>
2019-02-12MLK-16095-01 i2c: mux: pca954x: add i2c bus switch PCA9646 chip supportFugang Duan
Add i2c bus switch PCA9646 chip support, which 2-wire bus switch and buffered 4-channel. Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-14982-1 imx8: lpi2c: add ipg clk for lpi2c driverGao Pan
The lpi2c IP needs two clks: ipg clk and per clk. The old lpi2c driver missed ipg clk. This patch adds ipg clk for lpi2c driver. Signed-off-by: Gao Pan <pandy.gao@nxp.com>
2019-02-12MLK-14981-2 Kconfig: add lpi2c driver dependency for ARM64Gao Pan
add lpi2c driver dependency for ARM64 Signed-off-by: Gao Pan <pandy.gao@nxp.com>
2019-02-12MLK-11403: I2C: imx: restore pin setting for i2cGao Pan
restore pin setting for i2c in suspend/resume Signed-off-by: Gao Pan <gaopan@freescale.com> (cherry picked from commit 8aed73af218f25e0677b8980b3706246dd68790d) Signed-off-by: Robin Gong <yibin.gong@nxp.com> Conflicts: drivers/i2c/busses/i2c-imx.c
2019-02-12MLK-14394 i2c: imx-lpi2c: change default bitrateGao Pan
Due to the eviation i2c clk settings, the result may less than 100KBps. As a result, some i2c slave works in wrong condition. This patch changes i2c bitrate to 200KBps Signed-off-by: Gao Pan <pandy.gao@nxp.com>
2019-02-12MLK-14393 i2c: imx-lpi2c: directly retrun ISR when detect a NACKGao Pan
A NACK flag in ISR means i2c bus error. In such codition, there is no need to do read/write operation. It's better to return ISR directly and then stop i2c transfer. Signed-off-by: Gao Pan <pandy.gao@nxp.com> (cherry-pick from 839d59e48b6fdbd882776a48a88ce26ff14d8b86)
2019-02-12MLK-13572 i2c: imx-lpi2c: add imx8qm bindingGao Pan
During the 4.14 rebase the only relevant change was moving from imx8dv to an imx8qm binding. Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2019-02-12MLK-11403: I2C: imx: restore pin setting for i2cGao Pan
restore pin setting for i2c in suspend/resume Signed-off-by: Gao Pan <gaopan@freescale.com>
2019-02-12MLK-10893: i2c: imx: add irqf_no_suspendgaopan
The i2c irq is masked when pcie starts a i2c transfer process during noirq suspend stage. As a result, i2c transfer fails. To solve the problem, IRQF_NO_SUSPEND is added to i2c bus. Signed-off-by: Gao Pan <b54642@freescale.com> Signed-off-by: Fugang Duan <B38611@freescale.com>
2019-01-16i2c: dev: prevent adapter retries and timeout being set as minus valueYi Zeng
commit 6ebec961d59bccf65d08b13fc1ad4e6272a89338 upstream. If adapter->retries is set to a minus value from user space via ioctl, it will make __i2c_transfer and __i2c_smbus_xfer skip the calling to adapter->algo->master_xfer and adapter->algo->smbus_xfer that is registered by the underlying bus drivers, and return value 0 to all the callers. The bus driver will never be accessed anymore by all users, besides, the users may still get successful return value without any error or information log print out. If adapter->timeout is set to minus value from user space via ioctl, it will make the retrying loop in __i2c_transfer and __i2c_smbus_xfer always break after the the first try, due to the time_after always returns true. Signed-off-by: Yi Zeng <yizeng@asrmicro.com> [wsa: minor grammar updates to commit message] Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-21i2c: uniphier-f: fix violation of tLOW requirement for Fast-modeMasahiro Yamada
[ Upstream commit ece27a337d42a3197935711997f2880f0957ed7e ] Currently, the clock duty is set as tLOW/tHIGH = 1/1. For Fast-mode, tLOW is set to 1.25 us while the I2C spec requires tLOW >= 1.3 us. tLOW/tHIGH = 5/4 would meet both Standard-mode and Fast-mode: Standard-mode: tLOW = 5.56 us, tHIGH = 4.44 us Fast-mode: tLOW = 1.39 us, tHIGH = 1.11 us Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-21i2c: uniphier: fix violation of tLOW requirement for Fast-modeMasahiro Yamada
[ Upstream commit 8469636ab5d8c77645b953746c10fda6983a8830 ] Currently, the clock duty is set as tLOW/tHIGH = 1/1. For Fast-mode, tLOW is set to 1.25 us while the I2C spec requires tLOW >= 1.3 us. tLOW/tHIGH = 5/4 would meet both Standard-mode and Fast-mode: Standard-mode: tLOW = 5.56 us, tHIGH = 4.44 us Fast-mode: tLOW = 1.39 us, tHIGH = 1.11 us Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-21i2c: scmi: Fix probe error on devices with an empty SMB0001 ACPI device nodeHans de Goede
[ Upstream commit 0544ee4b1ad574aec3b6379af5f5cdee42840971 ] Some AMD based HP laptops have a SMB0001 ACPI device node which does not define any methods. This leads to the following error in dmesg: [ 5.222731] cmi: probe of SMB0001:00 failed with error -5 This commit makes acpi_smbus_cmi_add() return -ENODEV instead in this case silencing the error. In case of a failure of the i2c_add_adapter() call this commit now propagates the error from that call instead of -EIO. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-12-21i2c: axxia: properly handle master timeoutAdamski, Krzysztof (Nokia - PL/Wroclaw)
[ Upstream commit 6c7f25cae54b840302e4f1b371dbf318fbf09ab2 ] According to Intel (R) Axxia TM Lionfish Communication Processor Peripheral Subsystem Hardware Reference Manual, the AXXIA I2C module have a programmable Master Wait Timer, which among others, checks the time between commands send in manual mode. When a timeout (25ms) passes, TSS bit is set in Master Interrupt Status register and a Stop command is issued by the hardware. The axxia_i2c_xfer(), does not properly handle this situation, however. For each message a separate axxia_i2c_xfer_msg() is called and this function incorrectly assumes that any interrupt might happen only when waiting for completion. This is mostly correct but there is one exception - a master timeout can trigger if enough time has passed between individual transfers. It will, by definition, happen between transfers when the interrupts are disabled by the code. If that happens, the hardware issues Stop command. The interrupt indicating timeout will not be triggered as soon as we enable them since the Master Interrupt Status is cleared when master mode is entered again (which happens before enabling irqs) meaning this error is lost and the transfer is continued even though the Stop was issued on the bus. The subsequent operations completes without error but a bogus value (0xFF in case of read) is read as the client device is confused because aborted transfer. No error is returned from master_xfer() making caller believe that a valid value was read. To fix the problem, the TSS bit (indicating timeout) in Master Interrupt Status register is checked before each transfer. If it is set, there was a timeout before this transfer and (as described above) the hardware already issued Stop command so the transaction should be aborted thus -ETIMEOUT is returned from the master_xfer() callback. In order to be sure no timeout was issued we can't just read the status just before starting new transaction as there will always be a small window of time (few CPU cycles at best) where this might still happen. For this reason we have to temporally disable the timer before checking for TSS bit. Disabling it will, however, clear the TSS bit so in order to preserve that information, we have to read it in ISR so we have to ensure that the TSS interrupt is not masked between transfers of one transaction. There is no need to call bus recovery or controller reinitialization if that happens so it's skipped. Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-13i2c: rcar: cleanup DMA for all kinds of failureWolfram Sang
[ Upstream commit 31d86033a0749a0463ea654130b2de5c163154f1 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-20i2c: rcar: handle RXDMA HW behaviour on Gen3Wolfram Sang
commit 2b16fd63059ab9a46d473620749672dc342e1d21 upstream. 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> Cc: stable@kernel.org Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-18i2c: i2c-scmi: fix for i2c_smbus_write_block_dataEdgar Cherkasov
commit 08d9db00fe0e300d6df976e6c294f974988226dd upstream. The i2c-scmi driver crashes when the SMBus Write Block transaction is executed: WARNING: CPU: 9 PID: 2194 at mm/page_alloc.c:3931 __alloc_pages_slowpath+0x9db/0xec0 Call Trace: ? get_page_from_freelist+0x49d/0x11f0 ? alloc_pages_current+0x6a/0xe0 ? new_slab+0x499/0x690 __alloc_pages_nodemask+0x265/0x280 alloc_pages_current+0x6a/0xe0 kmalloc_order+0x18/0x40 kmalloc_order_trace+0x24/0xb0 ? acpi_ut_allocate_object_desc_dbg+0x62/0x10c __kmalloc+0x203/0x220 acpi_os_allocate_zeroed+0x34/0x36 acpi_ut_copy_eobject_to_iobject+0x266/0x31e acpi_evaluate_object+0x166/0x3b2 acpi_smbus_cmi_access+0x144/0x530 [i2c_scmi] i2c_smbus_xfer+0xda/0x370 i2cdev_ioctl_smbus+0x1bd/0x270 i2cdev_ioctl+0xaa/0x250 do_vfs_ioctl+0xa4/0x600 SyS_ioctl+0x79/0x90 do_syscall_64+0x73/0x130 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 ACPI Error: Evaluating _SBW: 4 (20170831/smbus_cmi-185) This problem occurs because the length of ACPI Buffer object is not defined/initialized in the code before a corresponding ACPI method is called. The obvious patch below fixes this issue. Signed-off-by: Edgar Cherkasov <echerkasov@dev.rtsoft.ru> Acked-by: Viktor Krasnov <vkrasnov@dev.rtsoft.ru> Acked-by: Michael Brunner <Michael.Brunner@kontron.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-10i2c: uniphier-f: issue STOP only for last message or I2C_M_STOPMasahiro Yamada
[ Upstream commit 4c85609b08c4761eca0a40fd7beb06bc650f252d ] This driver currently emits a STOP if the next message is not I2C_MD_RD. It should not do it because it disturbs the I2C_RDWR ioctl, where read/write transactions are combined without STOP between. Issue STOP only when the message is the last one _or_ flagged with I2C_M_STOP. Fixes: 6a62974b667f ("i2c: uniphier_f: add UniPhier FIFO-builtin I2C driver") Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-10i2c: uniphier: issue STOP only for last message or I2C_M_STOPMasahiro Yamada
[ Upstream commit 38f5d8d8cbb2ffa2b54315118185332329ec891c ] This driver currently emits a STOP if the next message is not I2C_MD_RD. It should not do it because it disturbs the I2C_RDWR ioctl, where read/write transactions are combined without STOP between. Issue STOP only when the message is the last one _or_ flagged with I2C_M_STOP. Fixes: dd6fd4a32793 ("i2c: uniphier: add UniPhier FIFO-less I2C driver") Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-03i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBusMika Westerberg
[ Upstream commit 7fd6d98b89f382d414e1db528e29a67bbd749457 ] Commit 7ae81952cda ("i2c: i801: Allow ACPI SystemIO OpRegion to conflict with PCI BAR") made it possible for AML code to access SMBus I/O ports by installing custom SystemIO OpRegion handler and blocking i80i driver access upon first AML read/write to this OpRegion. However, while ThinkPad T560 does have SystemIO OpRegion declared under the SMBus device, it does not access any of the SMBus registers: Device (SMBU) { ... OperationRegion (SMBP, PCI_Config, 0x50, 0x04) Field (SMBP, DWordAcc, NoLock, Preserve) { , 5, TCOB, 11, Offset (0x04) } Name (TCBV, 0x00) Method (TCBS, 0, NotSerialized) { If ((TCBV == 0x00)) { TCBV = (\_SB.PCI0.SMBU.TCOB << 0x05) } Return (TCBV) /* \_SB_.PCI0.SMBU.TCBV */ } OperationRegion (TCBA, SystemIO, TCBS (), 0x10) Field (TCBA, ByteAcc, NoLock, Preserve) { Offset (0x04), , 9, CPSC, 1 } } Problem with the current approach is that it blocks all I/O port access and because this system has touchpad connected to the SMBus controller after first AML access (happens during suspend/resume cycle) the touchpad fails to work anymore. Fix this so that we allow ACPI AML I/O port access if it does not touch the region reserved for the SMBus. Fixes: 7ae81952cda ("i2c: i801: Allow ACPI SystemIO OpRegion to conflict with PCI BAR") Link: https://bugzilla.kernel.org/show_bug.cgi?id=200737 Reported-by: Yussuf Khalil <dev@pp3345.net> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-26i2c: aspeed: Fix initial values of master and slave stateJae Hyun Yoo
[ Upstream commit 517fde0eb5a8f46c54ba6e2c36e32563b23cb14f ] This patch changes the order of enum aspeed_i2c_master_state and enum aspeed_i2c_slave_state defines to make their initial value to ASPEED_I2C_MASTER_INACTIVE and ASPEED_I2C_SLAVE_STOP respectively. In case of multi-master use, if a slave data comes ahead of the first master xfer, master_state starts from an invalid state so this change fixes the issue. Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>