summaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-octeon.c
AgeCommit message (Collapse)AuthorFilesLines
2016-08-26i2c: octeon: Rename driver to prepare for splitJan Glauber1-1253/+0
This is an intermediate commit in preparation of the driver split. The module rename in this commit will be reverted in the next patch, this is just done to make the series bisectible. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-08-22i2c: don't print error when adding adapter failsWolfram Sang1-3/+1
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>
2016-06-09i2c: octeon: Avoid printk after too long SMBUS messageJan Glauber1-5/+1
Remove the warning about a too long SMBUS message because the ipmi_ssif driver triggers this warning too frequently so it spams the message log. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-06-09i2c: octeon: Missing AAK flag in case of I2C_M_RECV_LENJan Glauber1-2/+9
During receive the controller requires the AAK flag for all bytes but the final one. This was wrong in case of I2C_M_RECV_LEN, where the decision if the final byte is to be transmitted happened before adding the additional received length byte. Set the AAK flag if additional bytes are to be received. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-27i2c: octeon: Add workaround for broken irqs on CN3860David Daney1-2/+51
CN3860 does not interrupt the CPU when the i2c status changes. If we get a timeout, and see the status has in fact changed, we know we have this problem, and drop back to polling. Signed-off-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-26i2c: octeon: Improve performance if interrupt is earlyPeter Swain1-9/+46
There is a race between the TWSI interrupt and the condition that is required before proceeding: Low-level: interrupt flag bit must be set High-level controller: valid bit must be clear If the interrupt comes too early and the condition is not met the wait will time out, and the transfer is aborted leading to very poor performance. To avoid this race retry for the condition ~80 µs later. The retry is avoided on the very first invocation of wait_event_timeout() (which tests the condition before entering the wait and is therefore always wrong in this case). EEPROM reads on 100kHz i2c now measure ~5.2kB/s, about 1/2 what's achievable, and much better than the worst-case 100 bytes/sec before. While at it remove the debug print from the low-level wait function. Signed-off-by: Peter Swain <pswain@cavium.com> Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-26i2c: octeon: Remove zero-length message supportJan Glauber1-4/+7
Zero-length message support (SMBUS QUICK or i2c) never worked with the Octeon hardware. Disable SMBUS QUICK support and bail out in case of a zero-length i2c request. After this change 'i2c-detect -q' will return an error on Octeon but the previously reported results were wrong anyway. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-25i2c: octeon: Add support for cn78xx chipsJan Glauber1-10/+119
cn78xx has a different interrupt architecture, so we have to manage the interrupts differently. Signed-off-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-25i2c: octeon: Enable High-Level ControllerDavid Daney1-10/+337
Use High-Level Controller (HLC) when possible. The HLC can read/write up to 8 bytes and is completely optional. The most important difference of the HLC is that it only requires one interrupt for a transfer (up to 8 bytes) where the low-level read/write requires 2 interrupts plus one interrupt per transferred byte. Since the interrupts are costly using the HLC improves the performance. Also, the HLC provides improved error handling. Signed-off-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Jan Glauber <jglauber@cavium.com> [wsa: fixed trivial checkpatch warnings] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-25i2c: octeon: Add flush writeq helper functionPeter Swain1-2/+7
Add helper function that reads back a value after writing to make sure the write is finished and use it in octeon_i2c_write_int(). Signed-off-by: Peter Swain <pswain@cavium.com> Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-25i2c: octeon: Use i2c recovery frameworkJan Glauber1-63/+96
Switch to the i2c bus recovery framework using generic SCL recovery. If this fails try to reset the hardware. The recovery is triggered during START on timeout of the interrupt or failure to reach the START / repeated-START condition. The START function is moved to xfer and while at it remove the xfer debug message (i2c core already provides a debug message for this). Signed-off-by: Jan Glauber <jglauber@cavium.com> [wsa: removed one empty line] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-25i2c: octeon: Improve error status checkingJan Glauber1-23/+106
Introduce a function that checks for valid status codes depending on the phase of a transmit or receive. Also add all existing status codes and improve error handling for various states. The Octeon TWSI has an "assert acknowledge" bit (TWSI_CTL_AAK) that is required to be set in master receive mode until the last byte is requested. The state check needs to consider if this bit was set. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-14i2c: octeon: Remove superfluous check in octeon_i2c_test_iflgJan Glauber1-2/+1
Remove superfluous check and stray newline. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-14i2c: octeon: Introduce helper functions for register accessJan Glauber1-25/+31
Add helper functions for control, data and status register access. This simplifies the code and makes the purpose of the register access clearer. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-14i2c: octeon: Rename [read|write]_sw to reg_[read|write]Jan Glauber1-26/+26
Rename the [read|write]_sw functions to make it clearer they access the TWSI registers. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-13i2c: octeon: Move set-clock and init-lowlevel upwardJan Glauber1-63/+63
No functional change, just moving the functions upward in preparation of improving the recovery. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-04-13i2c: octeon: Increase retry default and use fixed timeout valueJan Glauber1-1/+2
Convert the adapter timeout to 2 ms independently of depending on CONFIG_HZ. CONFIG_HZ is 100 for MIPS Cavium-Octeon so the timeout value is not changed. Also set retries to 5 to improve robustness. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-03-18i2c: octeon: Support I2C_M_RECV_LENDavid Daney1-5/+17
If I2C_M_RECV_LEN is set consider the length byte. Signed-off-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-03-18i2c: octeon: Cleanup resource allocation codeJan Glauber1-15/+3
Remove resource values from struct i2c_octeon and use devm_ioremap_resource helper. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-03-18i2c: octeon: Cleanup i2c-octeon driverJan Glauber1-106/+84
Cleanup only without functional change. - removed DRV_VERSION - defines: use defines instead of plain values, use BIT_ULL macro, add comments - rename waitqueue return value to time_left - sort local variables by length - fix indentation and whitespace errors - make function return void if the result is not used (octeon_i2c_stop, octeon_i2c_set_clock) - remove debug code from octeon_i2c_stop - renamed some functions for readability - update copyright Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-03-12i2c: octeon: Cleanup kerneldoc commentsJan Glauber1-50/+39
Remove point after parameter description and replace kerneldoc by a comment if it has no additional no value. Signed-off-by: Jan Glauber <jglauber@cavium.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2015-06-17i2c: octeon: remove unused signal handlingNicholas Mc Guire1-5/+2
'commit 2637e5fd232d ("i2c: octeon: Fix i2c fail problem when a process is terminated by a signal")' removed the wait_event_interruptible_timeout to prevent half/mixed i2c messages from being sent/recievd but forgot to drop the signal handling case in the return handling. This just removes this dead code. While at it the return variable is adjusted to the type expected. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-10-20i2c: busses: drop owner assignment from platform_driversWolfram Sang1-1/+0
A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-01-24i2c: delete non-required instances of include <linux/init.h>Paul Gortmaker1-1/+0
None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2013-08-23i2c: move OF helpers into the coreWolfram Sang1-3/+0
I2C of helpers used to live in of_i2c.c but experience (from SPI) shows that it is much cleaner to have this in the core. This also removes a circular dependency between the helpers and the core, and so we can finally register child nodes in the core instead of doing this manually in each driver. So, fix the drivers and documentation, too. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2013-04-23i2c: octeon: use HZ in timeout value송은봉1-1/+1
HZ based value is better than a magic number. Signed-off-by: Eunbong Song <eunb.song@samsung.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2013-04-19i2c: octeon: Fix i2c fail problem when a process is terminated by a signal송은봉1-4/+4
I've been debugging the abnormal operation of i2c on octeon. If a process is terminated by signal in the middle of i2c operation, next i2c read operation which is done by another process was failed. So i changed to ignore signal in the middle of i2c operation. After that the problem was not reproduced. Signed-off-by: Eunbong Song <eunb.song@samsung.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2013-02-22i2c: Remove unneeded xxx_set_drvdata(..., NULL) callsDoug Anderson1-4/+1
There is simply no reason to be manually setting the private driver data to NULL in the remove/fail to probe cases. This is just extra cruft code that can be removed. A few notes: * Nothing relies on drvdata being set to NULL. * The __device_release_driver() function eventually calls dev_set_drvdata(dev, NULL) anyway, so there's no need to do it twice. * I verified that there were no cases where xxx_get_drvdata() was being called in these drivers and checking for / relying on the NULL return value. This could be cleaned up kernel-wide but for now just take the baby step and remove from the i2c subsystem. Reported-by: Wolfram Sang <wsa@the-dreams.de> Reported-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Jean Delvare <khali@linux-fr.org> Acked-by: Peter Korsgaard <jacmet@sunsite.dk> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Wolfram Sang <wolfram@the-dreams.de>
2012-12-22i2c: remove __dev* attributes from subsystemBill Pemberton1-5/+5
CONFIG_HOTPLUG is going away as an option. As result the __dev* markings will be going away. Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Acked-by: Peter Korsgaard <peter.korsgaard@barco.com> (for ocores and mux-gpio) Acked-by: Havard Skinnemoen <hskinnemoen@gmail.com> (for i2c-gpio) Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn> (for puf3) Acked-by: Barry Song <baohua.song@csr.com> (for sirf) Reviewed-by: Jean Delvare <khali@linux-fr.org> [wsa: Fixed "foo* bar" flaws while we are here] Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
2012-07-23i2c: Convert i2c-octeon.c to use device tree.David Daney1-43/+49
There are three parts to this: 1) Remove the definitions of OCTEON_IRQ_TWSI and OCTEON_IRQ_TWSI2. The interrupts are specified by the device tree and these hard coded irq numbers block the used of the irq lines by the irq_domain code. 2) Remove platform device setup code from octeon-platform.c, it is now unused. 3) Convert i2c-octeon.c to use device tree. Part of this includes using the devm_* functions instead of the raw counterparts, thus simplifying error handling. No functionality is changed. Signed-off-by: David Daney <david.daney@cavium.com> Acked-by: Rob Herring <rob.herring@calxeda.com> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Cc: linux-mips@linux-mips.org Cc: devicetree-discuss@lists.ozlabs.org Cc: Grant Likely <grant.likely@secretlab.ca> Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/3939/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2012-01-12i2c/busses: Use module_platform_driver()Axel Lin1-15/+1
Convert the drivers in drivers/i2c/busses/* to use the module_platform_driver() macro which makes the code smaller and a bit simpler. Cc: Ben Dooks <ben-linux@fluff.org> Acked-by: Jochen Friedrich <jochen@scram.de> Acked-by: Peter Korsgaard <jacmet@sunsite.dk> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Cc: Manuel Lauss <manuel.lauss@googlemail.com> Cc: Barry Song <21cnbao@gmail.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Yong Zhang <yong.zhang0@gmail.com> Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2010-09-27i2c-octeon: Return -ETIMEDOUT in octeon_i2c_wait() on timeoutBernhard Walle1-1/+1
It doesn't make sense to set result to -ETIMEDOUT but return 0 (success) afterwards. Since there's code in octeon_i2c_start() to handle the error, it should be called. Signed-off-by: Bernhard Walle <walle@corscience.de> Acked-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
2010-04-30I2C: Fix section mismatch errors in i2c-octeon.cDavid Daney1-2/+2
Signed-off-by: David Daney <ddaney@caviumnetworks.com> To: linux-i2c@vger.kernel.org To: ben-linux@fluff.org To: khali@linux-fr.org Cc: linux-mips@linux-mips.org Cc: rade.bozic.ext@nsn.com Patchwork: http://patchwork.linux-mips.org/patch/1037/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2010-03-30include cleanup: Update gfp.h and slab.h includes to prepare for breaking ↵Tejun Heo1-0/+1
implicit slab.h inclusion from percpu.h percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-02-27MIPS: I2C: Add driver for Cavium OCTEON I2C ports.Rade Bozic1-0/+651
Signed-off-by: Rade Bozic <rade.bozic.ext@nsn.com> Signed-off-by: David Daney <ddaney@caviumnetworks.com> Cc: Michael Lawnick <michael.lawnick.ext@nsn.com> To: linux-mips@linux-mips.org To: linux-i2c@vger.kernel.org To: ben-linux@fluff.org To: khali@linux-fr.org Cc: rade.bozic.ext@nsn.com Cc: Michael Lawnick <michael.lawnick.ext@nsn.com> Patchwork: http://patchwork.linux-mips.org/patch/890/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>