summaryrefslogtreecommitdiff
path: root/driver/nfc/ctn730.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-711/+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>
* ctn730: Handle messages with no payload properlyDaisuke Nojiri2021-06-281-14/+26
| | | | | | | | | | | | | | | Messages without payload are allowed in the specification though they're currently not used in the implementation. This patch makes ctn730 driver properly handle such messages. BUG=b:192087974, b:190841496 BRANCH=None TEST=make run-pchg_fuzz Change-Id: I2d53ba3d45eb3684db7777627d392b1c8570b5ca Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2987906 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Fuzz PCHG and ctn730 driverDaisuke Nojiri2021-06-171-113/+2
| | | | | | | | | | | | | | | | This patch adds a fuzz test for PCHG and ctn730 driver. With the given corpus, the test currently reaches all the normal mode states. BUG=b:190841496 BRANCH=trogdor TEST=make run-pchg_fuzz TEST=pchg_fuzz.exe -seed=1 -runs=1000000 -dict=fuzz/pchg_fuzz.corpus Change-Id: I6eedbbbdbf3396dfa2b98ca302e16d142ea251d5 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2956076
* PCHG: Handle WLC_CHG_CTRL_DEVICE_STATE_DEVICE_DOCKEDDaisuke Nojiri2021-06-111-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We'll extend the period for a stylus to be statically charged so that EEPROM corruption can be avoided by not entering negotiated mode with a depleted battery. During this static charge period, the user currently doesn't see any charging indication. To prevent users from removing a stylus, we'll add a new state 'device docked' to ctn730. The EC firmware is updated to handle this new state as follows: - PCHG_STATE_DETECTED will be reused to indicate a device is in proximity but not ready for communication. - PCHG_STATE_CONNECTED will be added to indicate a device is ready for digital communication. This is formerly called DETECTED. - CTN730 driver produces PCHG_EVENT_DETECTED on 'docked' event and PCHG_EVENT_CONNECTED on 'detected' event. - When DEVICE_UNDOCKED is received in PCHG_STATE_DETECTED, transition to PCHG_STATE_ENABLED. BUG=b:189323070, b:173235954 BRANCH=trogdor TEST=Verify unpowered listener board can be detected. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7fa83f6dd31cf74eab7c158e557ddc09f8976798 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2920628 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Support firmware updateDaisuke Nojiri2021-04-051-0/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds EC_CMD_PCHG_UPDATE, which allows the host to update firmware of ctn730 via I2C. An updater (e.g. ectool) is expected to issue EC_PCHG_UPDATE_CMD_OPEN, multiple EC_PCHG_UPDATE_CMD_WRITEs, then EC_PCHG_UPDATE_CLOSE. Each sub-command completion is notified to the host via EC_MKBP_EVENT_PCHG. An updater is supposed to wait for the previous sub-command to complete before proceeding to the next. Example: localhost ~ # ectool pchg 0 State: DOWNLOAD (6) FW Version: 0x104 localhost ~ # ectool pchg 0 update 0x207000 0x105 /path/to/image.bin Update file /path/to/image.bin (85632 bytes) is opened. Writing firmware (port=0 ver=0x105 addr=0x207000 bsize=128): ********************************************************************** FW update session closed (CRC32=0x7bd5c66f). localhost ~ # ectool pchg 0 reset Reset port 0 complete localhost ~ # ectool pchg 0 State: ENABLED (2) FW Version: 0x105 BUG=b:182600604, b:173235954 BRANCH=trogdor TEST=ectool pchg 0 update 0x201200 0x105 /tmp/user_ee_X0.1_V1.5.bin TEST=ectool pchg 0 reset Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I9c62f1714dd69428ab5870c443cb4eb77881a6c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757099
* ctn730: Print firmware versionDaisuke Nojiri2021-03-241-0/+1
| | | | | | | | | | | | | | | | | | This patch makes ctn730 driver print the firmware version. EC_CMD_PCHG is updated to version 1 and returns firmware version of a charger chip. Version 0 of EC_CMD_PCHG is deprecated. BUG=b:182600604, b:173235954, b:183151376 BRANCH=Trogdor TEST=Verify firmware version is printed on EC console. TEST=ectool pchg 0 (for version 1) TEST=cat /sys/class/power_supply/PCHG0/* (for version 0) "ERR kernel: [ 33.394847] cros-ec-pchg cros-ec-pchg.13.auto: Unable to get port.0 status (err:-524)" Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib7bb9a7225fe914bc6c8d600d0f4766dbf75ace8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757098
* Coachz: Change stylus detection interval from 100 to 500 mshanwenchao2021-03-221-1/+1
| | | | | | | | | | | | | | | | | | EE confirmed detection interval from 100 to 500 ms, power consumption reduce to 11 mW from 26 mW. But the pen detection time becomes longer. BRANCH=trogdor BUG=b:181359593 TEST=check the stylus detection Signed-off-by: hanwenchao <hanwenchao@huaqin.corp-partner.google.com> Change-Id: I9c2f9f6def4ccf18bc06f1f628cda73be051f91c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2721321 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* ctn730: Make reset pulse 15 usecDaisuke Nojiri2021-03-181-1/+6
| | | | | | | | | | | | | | | | | | | This patch changes the reset pulse from 1 msec to 15 usec. The datasheet says the minimum reset pulse length is 10 usec. This is better not to be a sleep especially if it's long (e.g. ~1 ms) since the PCHG state machine may try to access the I2C bus, which is held low by ctn730 during reset. BUG=b:173235954 BRANCH=trogdor TEST=Stylus connect, disconnect, charge events are triggered as expected. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ibe611b32bd0f88ad875b24c38bbea577d8d4ec10 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2770505 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Support reset to firmware update modeDaisuke Nojiri2021-03-181-19/+59
| | | | | | | | | | | | | | | | | | | | | | | This patch allows a charger chip to reset to firmware update mode (a.k.a. download mode). Actual firmware update will be added in a separate patch. Currently, a reset event causes the state machine to unconditionally transition to normal mode. This patch makes the state machine check 'mode' field in the context to decide whether it transitions to normal mode or not. This patch also makes ctn730 driver explicitly return PCHG_EVENT_*_ERROR while PCHG_EVENT_NONE was returned previously. BUG=b:173235954 BRANCH=trogdor TEST=Stylus connect, disconnect, charge events are triggered as expected. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I10dbd25d0b3d5284952e57d4ade2949e9594c8d1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2770503
* PCHG: Handle reset eventDaisuke Nojiri2021-03-091-1/+10
| | | | | | | | | | | | | | | | | | | | Currently, PCHG assumes PCHG chips are reset only on POR and ignores reset events. This can cause the state machine to be in an unexpected state when a reset happens asynchronously. This patch allows PCHG to handle chip reset events. It also makes the task explicitly reset PCHG chips at start-up so that everything will start in known & clean states. BUG=b:181745891,b:181036152,b:173235954 BRANCH=trogdor TEST=Verify PCHG behaves expectedly across cold reset, warm reset, suspend & resume. Repeat the test with and without stylus. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ia3dd1fe7ebc8dd6f4ee8149a4c25918922143fc3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2741282 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Get SOC proactively when device is detectedDaisuke Nojiri2021-02-121-3/+27
| | | | | | | | | | | | | | | | | This patch makes PCHG send CHG_CTRL_CHARGING_INFO_CMD when a stylus is detected. This will allow the EC to report 'full' to the host even if charging doesn't start (because the stylus is already charged). BUG=b:179390065,b:173235954 BRANCH=trogdor TEST=CoachZ. Re-attach charged stylus and verify PCHG_STATE_FULL is reported. Change-Id: Id8578e2d3d21294fb08a21933f12ecee7f2bd062 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2691729 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ctn730: Add delay between INITIALIZATION and ENABLE (2)Daisuke Nojiri2021-01-291-3/+9
| | | | | | | | | | | | | | | ctn730 isn't immediately ready for i2c write after normal mode initialization. This patch adds 5 msec delay between WLC_HOST_CTRL_RESET_EVT_NORMAL_MODE and ENABLE_CMD. BUG=b:173235954, b:178096436 BRANCH=trogdor TEST=CoachZ Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib3dd96637d772a611cd12d394df492276481c412 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2657722 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Revert "ctn730: Add delay between INITIALIZATION and ENABLE"Daisuke Nojiri2021-01-291-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit de6e089385317a4379fa2e884d11da4453784a00. Reason for revert: Replaced by CL:2657722 Original change's description: > ctn730: Add delay between INITIALIZATION and ENABLE > > ctn730 isn't immediately ready for i2c write after normal mode > initialization. > > This patch adds 5 msec delay between INITIALIZATION and ENABLE > commands. > > BUG=b:173235954, b:178096436 > BRANCH=trogdor > TEST=CoachZ > > Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> > Change-Id: Ic3c51212c2f9a7bca827b040166aa18ec0a06b63 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2656765 > Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Bug: b:173235954 Bug: b:178096436 Change-Id: If9323c6e40e7b88b5393ff645f2fe89e6231b2c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2657968 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* ctn730: Add delay between INITIALIZATION and ENABLEDaisuke Nojiri2021-01-281-0/+6
| | | | | | | | | | | | | | | | | ctn730 isn't immediately ready for i2c write after normal mode initialization. This patch adds 5 msec delay between INITIALIZATION and ENABLE commands. BUG=b:173235954, b:178096436 BRANCH=trogdor TEST=CoachZ Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ic3c51212c2f9a7bca827b040166aa18ec0a06b63 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2656765 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ctn730: Print payload and handle download modeDaisuke Nojiri2021-01-251-3/+14
| | | | | | | | | | | | | This patch makes ctn730 driver print payload and handle download mode. BUG=b:173235954 BRANCH=trogdor TEST=CoachZ Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I74626c726c18c30a039fc521e419688796db9c3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2646124 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ctn730: Resend i2c on any errorDaisuke Nojiri2021-01-071-2/+2
| | | | | | | | | | | | | | | | | | Currently, ctn730 driver resends i2c frame only if EC_ERROR_BUSY is returned. The i2c error in this case varies chip to chip. NPCX i2c returns EC_ERROR_UNKNOWN, for example. Instead of expecting a specific error, this patch makes CTN730 driver resend I2C on any error. BUG=b:176725734 BRANCH=None TEST=On CoachZ. Verified 'Failed to read/write' disappeared. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I0b461935810aa253c8399cc2a6f9573a4aab123d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2611915 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ctn730: Add BIST commandDaisuke Nojiri2020-12-101-44/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the BIST console command to ctn730 driver. BIST-0x04 command allows the host to detect a listener without a battery. BIST-0x01 command switches on the RF field. This allows the host to charge a depleted battery. > pchg 0 disable PCHG: ->INITIALIZED > ctn730 0 bist 4 RSP header: RSP, BIST, LEN=13 STATUS_OK 00 04 76 54 42 f9 6b 80 00 04 02 00 00 >ctn730 0 bist 1 STATUS_OK BUG=b:173235954 BRANCH=Trogdor TEST=See the description above. Used a mockup stylus on CoachZ. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I92ffde8670248abe21e9823e6bb73a1d4fab0af2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2554352 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Add ctn730 driverDaisuke Nojiri2020-11-241-0/+480
CTN730 is a NFC/WLC transmitter (a.k.a. poller), which communicates with a receiver (a.k.a. listener) to transfer power wirelessly. BUG=b:173235954 BRANCH=Trogdor TEST=See the description of CL:2538536. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Icf5df30d2dffe617887ff6a591ea5b4a753cb3d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2538539 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>