summaryrefslogtreecommitdiff
path: root/chip/it83xx/i2c.c
Commit message (Collapse)AuthorAgeFilesLines
* ish: Trim down the release branchstabilize-wristpin-14469.59.B-ishstabilize-voshyr-14637.B-ishstabilize-quickfix-14695.187.B-ishstabilize-quickfix-14695.124.B-ishstabilize-quickfix-14526.91.B-ishstabilize-14695.85.B-ishstabilize-14695.107.B-ishstabilize-14682.B-ishstabilize-14633.B-ishstabilize-14616.B-ishstabilize-14589.B-ishstabilize-14588.98.B-ishstabilize-14588.14.B-ishstabilize-14588.123.B-ishstabilize-14536.B-ishstabilize-14532.B-ishstabilize-14528.B-ishstabilize-14526.89.B-ishstabilize-14526.84.B-ishstabilize-14526.73.B-ishstabilize-14526.67.B-ishstabilize-14526.57.B-ishstabilize-14498.B-ishstabilize-14496.B-ishstabilize-14477.B-ishstabilize-14469.9.B-ishstabilize-14469.8.B-ishstabilize-14469.58.B-ishstabilize-14469.41.B-ishstabilize-14442.B-ishstabilize-14438.B-ishstabilize-14411.B-ishstabilize-14396.B-ishstabilize-14395.B-ishstabilize-14388.62.B-ishstabilize-14388.61.B-ishstabilize-14388.52.B-ishstabilize-14385.B-ishstabilize-14345.B-ishstabilize-14336.B-ishstabilize-14333.B-ishrelease-R99-14469.B-ishrelease-R98-14388.B-ishrelease-R102-14695.B-ishrelease-R101-14588.B-ishrelease-R100-14526.B-ishfirmware-cherry-14454.B-ishfirmware-brya-14505.B-ishfirmware-brya-14505.71.B-ishfactory-kukui-14374.B-ishfactory-guybrush-14600.B-ishfactory-cherry-14455.B-ishfactory-brya-14517.B-ishJack Rosenthal2021-11-051-946/+0
| | | | | | | | | | | | | | | | | | | | | | In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* it83xx: i2c: don't check bus busy if transaction is ongoing.Dino Li2021-07-301-4/+9
| | | | | | | | | | | | | | | | | | | | | This CL fixes that i2c driver will prompt "I2C chx reset cause 1" issue when one i2c transaction is separated into at least three i2c_xfer and I2C_XFER_START flag is set at least two times. eg. - i2c_xfer with I2C_XFER_START flag - i2c_xfer with I2C_XFER_START flag <= this will cause reset - xxx - i2c_xfer with I2C_XFER_STOP flag BRANCH=none BUG=none TEST=no i2c reset on Asurada, Drawcia, and ADL-RVP. Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: I97161db0bb0c54de3ad55d82512a6a188036270f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3058724 Tested-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Eric Yilun Lin <yllin@google.com>
* task_set_event: remove the wait argumentDawid Niedzwiecki2020-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | There is an option in the task_set_event function which force the calling task to wait for an event. However, the option is never used thus remove it. This also will help in the Zephyr migration process. BUG=b:172360521 BRANCH=none TEST=make buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ic152fd3d6862d487bcc0024c48d136556c0b81bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521599 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* COIL: Standardize i2c peripheral languageDossym Nurmukhanov2020-12-121-6/+6
| | | | | | | | | | | BUG=none TEST=validate volteer build (i2c_peripheral.c is not used by any boards) BRANCH=none Signed-off-by: dossym@chromium.org Change-Id: Ib2d78dc3fc9f4f189f84409cf43ab96788c429be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2587227 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* it83xx/i2c: adjust Tlow and Thigh of 400kHz clockDino Li2020-11-251-2/+2
| | | | | | | | | | | | | | | | This CL increased clock's Tlow to 1.51 us (1.3 us minimum) and reduced Thigh to 1.087 us (0.6 us minimum). BUG=b:163384683 BRANCH=none TEST=i2c clock meet timing at 400kHz. Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: Id62b2370018ba2d41e0dbc715a4c40629260d66b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2557281 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Mike Goodey <mgoodey@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Replace I2C_GET_ADDR with I2C_STRIP_FLAGSYuval Peress2020-11-021-1/+1
| | | | | | | | | | | | | | | | | The new I2C_STRIP_FLAGS macro was added to avoid conflict with Zephyr's macro. This CL performs the migration to that new API. BRANCH=none BUG=b:172067439 TEST=make runtests -j and built for various boards: eve, volteer, arcada_ish, atlas, hatch, kohaku, nocturne, samus, and scarlet Change-Id: I0583b647435db96ec268f186252b367bdc4118a6 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511097 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* it83xx/i2c: enable 400kHz timing registers for port A/B/CDino Li2020-09-021-42/+78
| | | | | | | | | | | | | | With this change, port A/B/C will use timing registers to config clock frequency of 400kHz. BUG=b:163384683 BRANCH=none TEST=tlow meet timing when port speed configuration is 400kHz Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: Id4fafafa021966acc33711dd454c109b3bf93766 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2359623 Reviewed-by: Diana Z <dzigterman@chromium.org>
* cleanup: rename kpbs to kbps for i2cJett Rink2020-05-091-2/+2
| | | | | | | | | | | | | | | This changes follows the hdctool change for c2d2 that ensures either kpbs or kbps on the console output will work (CL:2161642) BRANCH=servo BUG=none TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I57e1638a4e8c9a61d58705c70d4d24c7b65e48bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2191132 Commit-Queue: Diana Z <dzigterman@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* ITE: Return an error if i2c unwedge attempt failedDiana Z2020-04-081-1/+7
| | | | | | | | | | | | | | | Checks the return of the i2c unwedge attempt and returns the error if the bus was unable to be unwedged. BRANCH=None BUG=b:153195490 TEST=on waddledee, "apshutdown" can be run from the EC with no i2c wedge issues Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Id0785f099bdf20d622226501f415ac411eea6f81 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2136873 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* main: Initialize I2C pretty earlyAlexandru M Stan2019-10-241-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some devices (like the keyboard, CBI) need I2C access pretty early. Until now I2C would get initialized pretty late in a hook, which was far too late for some stuff. As a result from this change, CONFIG_I2C_MASTER now implies the i2c_init() function will be called at board boot. Some chips (cr50, host tests) needed a stub i2c_init in order to compile cleanly. BUG=b/138384267 TEST=EFS doesn't happen significantly later than it used to TEST=Recovery keys now work with I2C keyboard on jacuzzi TEST=make buildall TEST=Sanity check i2c behavior (booting, "i2scan", "battery") on a variety of ECs: * ampton (ite EC, x86 AP) * bobba (npcx EC, x86 AP) * jacuzzi (stm32f0 EC, ARM AP) * cheza (npcx EC, ARM AP) BRANCH=master Change-Id: Ifa830e8e509ff16b36b4dcc86617869b1cb86ac3 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1772490 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-201-9/+9
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-191-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* it83xx/i2cs: add i2c slave functiontim2019-03-301-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | The I2C function of IT8320 is used as the slave. The slave channel A can support 16-byte FIFO for read and write data. The enhanced I2C channel D, E and F can support read and write 256-byte data by DMA mode. When master transmits data to slave, the interrupt signal will generate, and the data will be saved to buffer. BUG=none BRANCH=none TEST=none Change-Id: I167215352119ec11dfd96eb1f33abc1e2111dead Signed-off-by: tim <tim2.lin@ite.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/1488273 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Tim2 Lin <tim2.lin@ite.corp-partner.google.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* common: replace 1 << digits, with BIT(digits)Gwendal Grignou2019-03-261-2/+2
| | | | | | | | | | | | | | | | Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* it83xx: i2c: remove instructions that aren't necessaryDino Li2017-09-261-198/+93
| | | | | | | | | | | | | | | | | | | | | | - To i2c channel(d/e/f), we remove instructions that aren't necessary. - Changes of i2c_reset(): Before the change, we try to send a START/STOP bit if we get a reset. But i2c_unwedge() already done it, so we just need reset i2c module in i2c_reset(). - Add enhanced_i2c_start() to channel(d/e/f) for each transaction start: We prepare transaction start by calling i2c_reset(), but this doesn't match the definition of i2c_reset(), so we correct it. BRANCH=none BUG=none TEST=1. console commands: "i2cscan", "charger" and "battery". 2. sensors, battery, charger and mux work on reef_it8320. Change-Id: I4e3595479e04a5994a5b19409cfc4e9a46f63d4f Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/674467 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* it83xx: i2c: fix i2c stop bitDino Li2017-09-081-13/+14
| | | | | | | | | | | | | | | | | | | | | We disable i2c interface immediately after stop bit is set. This might caused bus busy bit of status register unable to clear (bus busy bit will be set at start condition and cleared at stop condition). So the next transaction, we won't get a good state to start. This change also fix incorrect stop bit for write transaction: IT83XX_I2C_CTR(p_ch) = xx BRANCH=none BUG=none TEST=Ensure i2c interface is disabled after i2c stop condition. Change-Id: I5416bfcef3f95357c6771dead6b0611b908f787e Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/645407 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* it83xx: i2c: increase clock low timeout to maximumDino Li2017-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This timeout is described in SMBus specification (25ms). Some I2C devices may required longer clock stretch (The I2C specification does not specify any timeout conditions for clock stretching). So we increase this timeout to maximum. NOTE: Because this codebase already handle timeout of an I2C transfer, so maybe we can disable this mechanism. But we don't have any register to execute this, so we maximize the timeout. BRANCH=none BUG=none TEST=console commands: i2cscan, battery, charger, and accelinfo. Change-Id: I5025f640c027105152247212fc688388f645c5ba Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/485203 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* chip/g to chip/lm4: fix more misspellings in commentsMartin Roth2016-11-151-2/+2
| | | | | | | | | | | | | No functional changes. BUG=none BRANCH=none TEST=make buildall passes Change-Id: I0c4fcc900ec0326d6904aa14f298206e62be0fda Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/403418 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
* it83xx: fix i2c moduleDino Li2016-08-221-12/+22
| | | | | | | | | | | | | | | | | | | | | | | | 1. If one i2c transaction includes timeout and done events at the same time, the transaction result will be timeout. Fixed: The transaction is succeed instead of timeout. 2. The interrupt of i2c will not be enabled if an i2c write transaction is split into two or more xfer. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=1. Console commands:'i2cscan', 'i2cxfer', and 'battery'. 2. Use two or more i2c_xfer(the first with flag 'I2C_XFER_START' and the last with flag 'I2C_XFER_STOP') to do a i2c write transaction and no error. Change-Id: Ieb2cb229748ac9504cf1636a2826bbb3097aa55c Reviewed-on: https://chromium-review.googlesource.com/360762 Commit-Ready: Dino Li <Dino.Li@ite.com.tw> Tested-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* chip: it83xx: Add i2c channel d/e/f functionEli Hsu2016-04-141-82/+532
| | | | | | | | | | | | | | | | | | | | | | | [board] 1. Add i2c channel d/e/f setting. 2. Add i2c channel d/e/f pin definition. [chip] 3. change i2c port number. 4. Add i2c channel d/e/f function. 5. Add i2c channel d/e/f interrupt. 6. Add i2c channel d/e/f registers. Signed-off-by: Eli Hsu <eli.hsu@ite.com.tw> BRANCH=none BUG=none TEST=Test by console command "i2cscan","i2cxfer" and "battery" Change-Id: I928f333ec129924795c3b594ad6a2bfdd0b3d220 Reviewed-on: https://chromium-review.googlesource.com/336560 Commit-Ready: Eli Hsu <eli.hsu@ite.com.tw> Tested-by: Eli Hsu <eli.hsu@ite.com.tw> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* core: nds32: add task_wait_event_mask() function to nds32 coreDino Li2016-01-051-1/+2
| | | | | | | | | | | | | | | | | | | | | [task] 1. Copy task_wait_event_mask() function of cortex-m0. [system] 2. Include host_command.h for host_command_pd_request_hibernate(). [i2c] 3. Update i2c handler to use task_wait_event_mask. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=chromium:435611,chromium:435612 TEST=1. console commands: i2cscan, i2cxfer, and battery. Change-Id: If5bb4407460d28c0b021ab133ca4b635ff7bc3c9 Reviewed-on: https://chromium-review.googlesource.com/320440 Commit-Ready: Dino Li <dino.li@ite.com.tw> Tested-by: Dino Li <dino.li@ite.com.tw> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* common: adc/i2c: Mark task_waiting volatileShamile Khan2015-12-011-1/+1
| | | | | | | | | | | | | | | | | | | When Link Time Optimization is turned on, functions that set task_waiting multiple times have one of the sets removed by the linker leading to undesired results. Marking task_waiting volatile alleviates this issue. BUG=chrome-os-partner:46063 TEST=Manually tested on Kunimitsu. Console command adc shows correct value of approx 20000 mV for VBUS. BRANCH=none Change-Id: I85a6e5c9688ae72c45d90fb58296f94b74a301aa Signed-off-by: Shamile Khan <shamile.khan@intel.com> Reviewed-on: https://chromium-review.googlesource.com/314233 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* it8380dev: improve power consumptionDino Li2015-11-171-3/+5
| | | | | | | | | | | | | | | | In doze mode, these improvements help reduce EC power consumption. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=Power consumption has reduced. Change-Id: I8b0fe3301e408134284b4ac5778656ba9b92b0f1 Reviewed-on: https://chromium-review.googlesource.com/312632 Commit-Ready: Dino Li <dino.li@ite.com.tw> Tested-by: Dino Li <dino.li@ite.com.tw> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* it8380dev: fix i2c moduleDino Li2015-10-051-121/+197
| | | | | | | | | | | | | | | | | 1. i2c interrupts are used. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=1. console command 'i2cscan' found devices correctly. 2. console command 'i2cxfer' and 'battery' OK. Change-Id: I4d40488d482318128bc8c549f5c8d3c27abe4a04 Reviewed-on: https://chromium-review.googlesource.com/303001 Commit-Ready: Dino Li <dino.li@ite.com.tw> Tested-by: Dino Li <dino.li@ite.com.tw> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* it8380dev: add i2c control moduleDino Li2015-06-301-0/+468
Add i2c control module for emulation board. To rename CONFIG_ to CONFIG_IT83XX_ for IT83XX series configuration. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=1. console command "i2cscan" found devices correctly. 2. console command "i2cxfer". 2-a. port2 + battery, i2cxfer r, r16, and rlen OK. 2-b. port1 + slave evb, i2cxfer r, r16, rlen, w, and w16 OK. Change-Id: I67165f7dcdef538ba6dd03b47f1621a73cc68379 Reviewed-on: https://chromium-review.googlesource.com/263678 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Dino Li <dino.li@ite.com.tw> Tested-by: Dino Li <dino.li@ite.com.tw>