summaryrefslogtreecommitdiff
path: root/drivers/i2c/busses/i2c-designware-slave.c
AgeCommit message (Collapse)AuthorFilesLines
2019-08-29i2c: designware: Synchronize IRQs when unregistering slave clientJarkko Nikula1-0/+1
Make sure interrupt handler i2c_dw_irq_handler_slave() has finished before clearing the the dev->slave pointer in i2c_dw_unreg_slave(). There is possibility for a race if i2c_dw_irq_handler_slave() is running on another CPU while clearing the dev->slave pointer. Reported-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Reported-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-08-20i2c: designware: Add SPDX license tagAndy Shevchenko1-14/+1
Replace short statement in comment with proper SPDX license tag. Note, for i2c-desingware-slave.c the identifier is chosen in accordance with MODULE_LICENSE() macro since it is visible to user. Another point to this choice is that the header seems to be copy'n'paste from the other file of this very driver. Acked-by: Luis Oliveira <Luis.Oliveira@synopsys.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-07-04i2c: designware: Move SDA hold time configuration to common codeJarkko Nikula1-21/+6
SDA hold time configuration is common to both master and slave code. It is also something that can be done once during probe and do only register write when HW needs to be reinitialized. Remove duplication and move SDA hold time configuration to common code. It will be called from slave probe and for master code from a new i2c_dw_set_timings_master() to where we will populate more probe time timing parameter setting. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-07-04i2c: designware: Move register access detection to common codeJarkko Nikula1-14/+4
Move register access detection out from master and slave HW initialization code to common code. Motivation for this is to have register access configured before HW initialization and remove duplicated code. This allows to do further separation between probe time initialization and runtime reinitialization code. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-07-04i2c: designware: Remove needless variable from i2c_dw_init_slave()Jarkko Nikula1-3/+1
Commit 43df43e6ba13 ("i2c: designware: Don't set SCL timings and speed mode when in slave mode") made variable comp_param1 needless in i2c_dw_init_slave(). Remove it now. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-05-15i2c: designware: refactor low-level enable/disableAlexander Monakov1-3/+3
Low-level controller enable function __i2c_dw_enable is overloaded to also handle disabling. What's worse, even though the documentation requires polling the IC_ENABLE_STATUS register when disabling, this is not done: polling needs to be requested specifically by calling __i2c_dw_enable_and_wait, which can also poll on enabling, but that doesn't work if the IC_ENABLE_STATUS register is not implemented. This is quite confusing if not in fact backwards. Especially since the documentation says that disabling should be followed by polling, the driver should be using a separate function where it does one-shot disables to make the optimization stand out. This refactors the two functions so that requested status is given in the name rather than in a boolean argument. Specifically: - __i2c_dw_enable: enable without polling (in accordance with docs) - __i2c_dw_disable: disable and do poll (also as suggested by docs) - __i2c_dw_disable_nowait: disable without polling (Linux-specific) No functional change. Signed-off-by: Alexander Monakov <amonakov@ispras.ru> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> [wsa: fixed blank lines in header file] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-11-27i2c: designware: Don't set SCL timings and speed mode when in slave modeJarkko Nikula1-64/+0
According to data sheet SCL timing parameters and DW_IC_CON SPEED mode bits are not used when operating in slave mode. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Tested-by: Luis Oliveira <lolivei@synopsys.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-09-10Merge branch 'i2c/for-4.14' of ↵Linus Torvalds1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: - new drivers for Spreadtrum I2C, Intel Cherry Trail Whiskey Cove SMBUS - quite some driver updates - cleanups for the i2c-mux subsystem - some subsystem-wide constification - further cleanup of include/linux/i2c * 'i2c/for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (50 commits) i2c: sprd: Fix undefined reference errors i2c: nomadik: constify amba_id i2c: versatile: Make i2c_algo_bit_data const i2c: busses: make i2c_adapter_quirks const i2c: busses: make i2c_adapter const i2c: busses: make i2c_algorithm const i2c: Add Spreadtrum I2C controller driver dt-bindings: i2c: Add Spreadtrum I2C controller documentation i2c-cht-wc: make cht_wc_i2c_adap_driver static MAINTAINERS: Add entry for drivers/i2c/busses/i2c-cht-wc.c i2c: aspeed: Retain delay/setup/hold values when configuring bus frequency dt-bindings: i2c: eeprom: Document vendor to be used and deprecated ones i2c: i801: Restore the presence state of P2SB PCI device after reading BAR MAINTAINERS: drop entry for Blackfin I2C and Sonic's email blackfin: merge the two TWI header files i2c: davinci: Preserve return value of devm_clk_get i2c: mediatek: Add i2c compatible for MediaTek MT7622 dt-bindings: i2c: Add MediaTek MT7622 i2c binding dt-bindings: i2c: modify information formats i2c: mux: i2c-arb-gpio-challenge: allow compiling w/o OF support ...
2017-08-17i2c: designware: Fix runtime PM for I2C slave modeJarkko Nikula1-0/+3
I2C slave controller must be powered and active all the time when I2C slave backend is registered in order to let master address and communicate with us. Now if the controller is runtime PM capable it will be suspended after probe and cannot ever respond to the master or generate interrupts. Fix this by resuming the controller when I2C slave backend is registered and let it suspend after unregistering. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-08-17i2c: designware: Remove needless pm_runtime_put_noidle() callJarkko Nikula1-1/+0
I guess pm_runtime_put_noidle() call in i2c_dw_probe_slave() was copied by accident from similar master mode adapter registration code. It is unbalanced due missing pm_runtime_get_noresume() but harmless since it doesn't decrease dev->power.usage_count below zero. In theory we can hit similar needless runtime suspend/resume cycle during slave mode adapter registration that was happening when registering the master mode adapter. See commit cd998ded5c12 ("i2c: designware: Prevent runtime suspend during adapter registration"). However, since we are slave, we can consider it as a wrong configuration if we have other slaves attached under this adapter and can omit the pm_runtime_get_noresume()/pm_runtime_put_noidle() calls for simplicity. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-08-14i2c: designware: Fix oops from i2c_dw_irq_handler_slaveJarkko Nikula1-1/+1
When i2c-designware is initialized in slave mode the i2c-designware-slave.c: i2c_dw_irq_handler_slave() can hit a NULL pointer dereference when I2C slave backend is not registered but code is accessing the struct dw_i2c_dev.slave without testing is it NULL. We might get spurious interrupts from other devices or from IRQ core during unloading the driver when CONFIG_DEBUG_SHIRQ is set. Existing check for enable and IRQ status is not enough since device can be power gated and those bits may read 1. Fix this by handling the interrupt only when also struct dw_i2c_dev.slave is set. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-08-12i2c: constify internal structuresGustavo A. R. Silva1-1/+1
Check for i2c_algorithm and i2c_adapter_quirks structures that are only stored in the algo and quirks fields of an i2c_adapter structure correspondingly. These fields are declared const, so i2c_algorithm and i2c_adapter_quirks structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> (for designware) Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-07-04i2c: designware: Make HW init functions staticJarkko Nikula1-2/+1
Recent i2c-designware slave support patches use master or slave HW init functions through the function pointer so we can declare them static. While at it, rename i2c_dw_init() as i2c_dw_init_master(). Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Luis Oliveira <lolivei@synopsys.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-07-04i2c: designware: fix spelling mistakesColin Ian King1-1/+1
Trivial fixes to spelling mistakes in dev_dbg message "STAUTS" -> "STATUS" "SLAVE_ACTTVITY" -> "SLAVE_ACTIVITY" Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-06-28i2c: designware: add SLAVE mode functionsLuis Oliveira1-0/+394
- Changes in Kconfig to enable I2C_DESIGNWARE_SLAVE support - Slave functions added to core library file - Slave abort sources added to common source file - New driver: i2c-designware-slave added - Changes in the Makefile to compile the I2C_DESIGNWARE_SLAVE module when supported by the architecture. All the SLAVE flow is added but it is not enabled via platform driver. Signed-off-by: Luis Oliveira <lolivei@synopsys.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> [wsa: made a function static and one-lined a message] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>