aboutsummaryrefslogtreecommitdiff
path: root/hw/p8-i2c.c
AgeCommit message (Collapse)AuthorFilesLines
2015-09-11timer: Pass current timer to timer callbacksBenjamin Herrenschmidt1-7/+10
The caller usually has it and it avoids additional mftb() which can be expensive. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [stewart@linux.vnet.ibm.com: fix run-timer unit test] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-26Fix spelling mistakesStewart Smith1-2/+2
See https://github.com/lucasdemarchi/codespel Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-31errorlog: Deprecate elog callback parameterSamuel Mendoza-Jonas1-5/+5
There are now no users of the call_out parameter and future users should use the log_append_msg() and log_append_data() functions, so remove all references to call_out. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-06p8-i2c: Keep centaur OCC cache disabled during initsBenjamin Herrenschmidt1-2/+26
To avoid possible XSCOM collisions Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-06p8-i2c: Ensure request "result" field is updated on completionBenjamin Herrenschmidt1-0/+1
It may or may not already contain the right error code (it can be used internally by the state machine to carry the error accross the recovery state), but in case where it's not, update it. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-06p8-i2c: Add support for Centaur i2cBenjamin Herrenschmidt1-14/+90
The Centaur i2c differs from the main P8 one two ways: - It doesn't have interrupts, we need to always use polling - There is a sensor cache for use by the OCC that regularly generates i2c transactions in HW on that bus. It needs to be disabled before we can perform i2c accesses and re-enabled later. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-05-13Add a couple more missing Naples referencesBenjamin Herrenschmidt1-0/+2
The i2c and SLW code are testing for P8 chips by chip type and missing Naples. Fix this. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-04i2c: Workaround bad clock-frequency property from HostBootBenjamin Herrenschmidt1-0/+6
The cell clock is 50Mhz on P8, not 600Mhz ! Remove this when HB has been fixed. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-04p8/i2c: Add OPAL properties in the i2c bus nodesNeelesh Gupta1-97/+162
We are getting the i2c device tree data from the hostboot and it has i2cm nodes compatible to multiple chips like p8 and centaur. The patch further adds the OPAL properties to the i2c bus nodes required by the kernel. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-19update users of GET/SETFIELD()Dan Streetman1-1/+1
The last two patches updated GETFIELD() and SETFIELD() to no longer require the user to specify the mask and shift of a field, and to remove all _LSH defines and rename any _MASK defines. There are some places where the masks were used directly, where the caller needs to have the _MASK suffix removed. There are also two users of SETFIELD() where the field name still has the _MASK suffix because there is an existing macro with the base name. Change users of SETFIELD() to include the _MASK suffix where needed. Change direct users of any mask to remove the _MASK suffix. Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-19Change user-defined _MASK/_LSH to just maskDan Streetman1-30/+15
The last patch changed the SETFIELD() and GETFIELD() macros to automatically calculate the shift of a given mask, so manually specifying the shift is no longer needed. Additionally, any masks should have the _MASK suffix removed since the GETFIELD() and SETFIELD() operations expected to be passed the mask name without the _MASK suffix (and so either the mask name or the get/setfield call needs to have its mask name changed). Change all _MASK masks to remove the _MASK suffix, except for any places that leaving _MASK makes sense (e.g. already an existing define without _MASK suffix). Remove all _LSH defines, as they are no longer needed. Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-18i2c: Turn large time_wait_ms() into statesBenjamin Herrenschmidt1-21/+29
In the recovery case Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-06Move skiboot internal things from opal.h to opal-api.hStewart Smith1-0/+2
This is probably not the best collection of things in the world, but it means that opal.h is much closer to being directly usable by an OS. This triggers a bunch of #include fixes throughout the tree. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-01-21i2c: Unify the frequencies to calculate bit rate divisorNeelesh Gupta1-6/+3
Provide the frequencies in same unit (HZ) for calculating the bit rate divisor value. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-11-14i2c: Update DT bindings and minor changesBenjamin Herrenschmidt1-53/+86
The i2c bus frequency is now per port and we use more standard properties this and the clock frequency of the master cell itself. Also use "ibm,opal-i2c" as a compatible match to indicate that the DT node is compatible with the OPAL APIs, whether it's a P8 i2c bus or something else (we will eventually expose the centaur i2c's too for example). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-14i2c: Provide FFDC data in the driverNeelesh Gupta1-72/+195
Define SRCs of I2C component and interface with the existing skiboot 'errorlog' infrasturcute for commiting the logs. Add the i2c specific OPAL error codes to differentiate various types of errors during i2c operations. To ease debugging, dump the i2c register contents, 'master' and 'request' structure bits in case any error occured during transfer on the bus. Minor clean-ups as well. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-12i2c: Use new timer facility and improve interrupts handlingBenjamin Herrenschmidt1-67/+47
We only poll the masters for the chip that got the interrupt and we improve the running of the timers as well. We user the new TIMER_POLL facility to replace the use of the OPAL poller, which simplifies the code further. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-11i2c: Move bus management and OPAL API to core i2c codeBenjamin Herrenschmidt1-116/+10
And start adding interfaces to lookup i2c busses. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-10i2c: Improve operations without interruptsBenjamin Herrenschmidt1-18/+91
We use a timer for running the state machine without interrupts. When we get proper timers using the SLW engine, we'll be able to also reduce the timeouts but for now, use a large (4s) per-char timeout for polled mode as it depends on the opal poll frequency which can be very slow. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-07i2c: Rework P8 i2c driverBenjamin Herrenschmidt1-479/+543
This updates the i2c driver significantly, using a simpler state machine, using the new timer for timeouts, and fixing a number of issues. I also changed the Linux interface so I've changed the token number since some builds have been done with the old code already. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-05i2c: Bug fixes, clean up of the codeNeelesh Gupta1-157/+107
Fixed few bugs and clean up a lot. Renamed the state machine variables to make more sense. A new helper 'p8_i2c_check_work' to avoid hitting deep call stack after request complete. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-10-27hw/i2c: i2c driver infrastructure providing device I/ONeelesh Gupta1-0/+1111
This patch adds the generic i2c driver infrastructure to handle multiple i2c master cores present in the system and exposes structures and interfaces for the client to perform I/O on the i2c slave devices. The driver adds the capability to queue multiple requests from client and let clients notified asynchronously after completion. It does that by handling the i2c interrupt or through OPAL poller in the absence of interrupt. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>