summaryrefslogtreecommitdiffstats
path: root/include/i2c.h
Commit message (Collapse)AuthorAgeFilesLines
* core/i2c: split i2c_request_send()Oliver O'Halloran2019-03-281-1/+2
| | | | | | | | | | | | | | | Split the i2c_request_send() method into two methods: i2c_request_send() which allocates and populates and i2c_request structure, and i2c_request_sync() which take a request structure and blocks until it completes. This allows code that allocates a i2c_request structure elsewhere to make use of the existing busy-wait and request retry logic. Fix the return types to use int64_t while we're here since these are returning OPAL_API error codes. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* core/i2c: Add request state trackingOliver O'Halloran2019-03-281-2/+12
| | | | | | | | | Allow the submitter to track the state of an I2C request by adding a state field to the request. This avoids the need to use a stub completion callback in some cases. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* hw/p8-i2c: Fix i2c request timeoutFrederic Barrat2018-09-271-1/+1
| | | | | | | | | | | | | | | | Commit eb146fac9685 ("core/i2c: Move the timeout field into i2c_request") simplified a bit how a request timeout is handled. However there's now some confusion between milliseconds and timebase increments when defining or using the timeout values, which breaks i2c requests made for opencapi, and probably others too. This patch declares all the timeout in milliseconds and just converts to timebase at the end of the chain, as needed. Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com> Tested-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Reviewed-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* core/i2c: Remove bus specific alloc and free callbacksOliver O'Halloran2018-09-171-12/+0
| | | | | | | These are now pointless and they can be replaced with zalloc() and free(). Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* core/i2c: Move the timeout field into i2c_requestOliver O'Halloran2018-09-171-9/+1
| | | | | | | | | | | Currently to set a per-request timeout you need to use i2c_req_set_timeout() which is a wrapper for a per-bus method that sets the actual timeout. This design doesn't make a whole lot of sense, so move the timeout field into the generic i2c_request structure and set the timeout to be set using that. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* p8-i2c: Limit number of retry attemptsOliver O'Halloran2017-11-201-0/+1
| | | | | | | | | | | | Current we will attempt to start an I2C transaction until it succeeds. In the event that the OCC does not release the lock on an I2C bus this results in an async token being held forever and the kernel thread that started the transaction will block forever while waiting for an async completion message. Fix this by limiting the number of attempts to start the transaction. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* i2c: Move tpm i2c wrapper code into coreAndrew Donnellan2017-10-021-0/+5
| | | | | | | | | | | | | The TPM code has a wrapper around the main i2c API to allow synchronous use. Move it into core/i2c.c so it can be used by other possible users. In particular, a future patch will use this to drive OpenCAPI device resets during boot time. Cc: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Cc: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* p8-i2c: occ: Add support for OCC to use I2C enginesShilpasri G Bhat2017-06-061-0/+3
| | | | | | | | | | | | | | This patch adds support to share the I2C engines with host and OCC. OCC uses I2C engines to read DIMM temperatures and to communicate with GPU. OCC Flag register is used for locking between host and OCC. Host requests for the bus by setting a bit in OCC Flag register. OCC sends an interrupt to indicate the change in ownership. Originally-from: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: Pretty heavily rework logic, including fixing bus owner change and separating out occ lock from sensor cache] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* i2c: Add nuvoton quirk, disallowing i2cdetect as it locks TPMStewart Smith2016-12-021-0/+9
| | | | | | | | | | | | | | In TPM 2.0 Firmware 1.3.0.1 and 1.3.1.0 (at least) there exists a bug where if you send the wrong thing to the TPM it may lock the bus, with no way of recovery except powering the TPM off/on. On our current systems, the only way to power the TPM off/on is to pull the power on the system (*NOT* just power off/on to host from BMC). So, this patch adds the ability to do things to the i2c request really early on, well before it hits any hardware, such as quickly drop it. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* i2c: Add i2c_run_req() to crank the state machine for a requestStewart Smith2016-11-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Doing everything asynchronously is brilliant, it's exactly what we want to do. Except... the tpm driver wants to do things synchronously, which isn't so cool. For reasons that are not yet completely known, we spend an awful lot of time in the main thread *not* running pollers (potentially seconds), which doesn't bode well for I2C timeouts. Since the TPM measure is done in a secondary thread, we do *not* run pollers there either (as of 323c8aeb54bd4e0b9004091fcbb4a9daeda2f576 - which is roughly as of skiboot 2.1.1). But we still need to crank the i2c state machine, so we introduce a call to do just that. It will return how long the poll interval should be, so that we can time_wait() for a more appropriate time for whatever i2c implementation is sitting behind things. Without this, it was "easy" to get to a situation where the i2c state machine wasn't cranked at all, and you'd hit the i2c timeout (for the issued operation) before the poller to crank i2c was ever called. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Tested-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* hw/p8-i2c: Allow to set I2C request timeoutGavin Shan2016-06-141-0/+9
| | | | | | | | | | | | | | | | | | Prior to PCI enumeration, the PHB slot's power state might be changed during fundamental reset. The fundamental reset is implemented by state machine and it's driven by a polling mechanism in predetermined interval (A). On the other hand, PCI slot's power supply is controlled by I2C chip on Firenze platform. It means the PCI slot's power supply state is changed through I2C request which has a timeout timer running in variable interval (B). Comparing to (A), (B) is small and short. That means I2C timeout is reached before first poll running in interval of (A). It's unexpected behaviour. This allows to set I2C request timeout ((B)) to avoid the issue. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Reviewed-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* i2c: Provide FFDC data in the driverNeelesh Gupta2014-11-141-0/+14
| | | | | | | | | | | | | | 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>
* i2c: Use new timer facility and improve interrupts handlingBenjamin Herrenschmidt2014-11-121-3/+1
| | | | | | | | | | 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>
* i2c: Move bus management and OPAL API to core i2c codeBenjamin Herrenschmidt2014-11-111-3/+25
| | | | | | And start adding interfaces to lookup i2c busses. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* i2c: Rework P8 i2c driverBenjamin Herrenschmidt2014-11-071-1/+2
| | | | | | | | | 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>
* i2c: Bug fixes, clean up of the codeNeelesh Gupta2014-11-051-1/+0
| | | | | | | | | 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>
* hw/i2c: i2c driver infrastructure providing device I/ONeelesh Gupta2014-10-271-0/+53
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>
OpenPOWER on IntegriCloud