summaryrefslogtreecommitdiff
path: root/common/i2c_trace.c
Commit message (Collapse)AuthorAgeFilesLines
* common: Sort header filesJeremy Bettis2022-11-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | Sort all includes in common with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I70c2ed7bb2ce50c968f3e2dbdc274de3a455129a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049889 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Tomasz Michalec <tmichalec@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* i2ctrace: add safety checkBoris Mittelberg2022-11-101-1/+1
| | | | | | | | | | | | | | Prevent NULL dereference coming from get_i2c_port BUG=b:64477774 BRANCH=none TEST=none Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: Ib430832e135a8f48cd3773acd2ce9894444f7efe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019346 Reviewed-by: caveh jalali <caveh@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* tree-wide: const-ify argv for console commandsCaveh Jalali2022-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This updates the API for console commands from "int cmd(int argc, char **argv)" to "int cmd(int argc, const char **argv)" which is more accurate and in line with common convention. BRANCH=none BUG=b:244387210 TEST="make buildall" passes TEST="zmake build -a" passes TEST="util/compare_build.sh -b all" passes TEST="./twister -v -T zephyr/test" passes Cq-Depend: chrome-internal:4960125 Cq-Depend: chrome-internal:4959932 Change-Id: I57de9f35b85b8f3c7119df36aefb2abf25d2625f Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863941 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* common/i2c_trace.c: Format with clang-formatJack Rosenthal2022-06-281-39/+25
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: Ie311c38df6e602bd2a3003f1edc5869e8c9084ff Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729638 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* I2C trace: Add error prints to trace resultsDiana Z2022-04-011-2/+4
| | | | | | | | | | | | | | | | | | | | | Add printing of error conditions to the i2ctrace results. Otherwise, we may blindly print the target's data which has not actually been populated with valid results. BRANCH=None BUG=b:221286700 TEST=on nipperkin, write to a nonexistent i2c device and verify the trace shows an error instead of junk read data: 22-03-31 13:50:24.711 > i2cxfer r 8 0x49 0x00 22-03-31 13:50:29.960 i2c: 8:0x49 wr 0x00 error: 1 22-03-31 13:50:29.963 Unknown error Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie268ead6b733499c5f5e79afa70d10d834e7898f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3564798 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Feels: Aseda Aboagye <aaboagye@chromium.org>
* zephyr: Avoid referencing name field when using ZephyrAndrew McRae2021-12-221-0/+4
| | | | | | | | | | | | | | | When building a Zephyr based board, avoid referencing the i2c_port_t field 'name' (which is not defined for Zephyr) in the i2ctrace module. BUG=b:211321681 TEST=make -j buildall; zmake configure -b nivviks BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I7ae42607b7233aa809b8b39a54d98521c6bc40ce Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3347348 Reviewed-by: Yuval Peress <peress@google.com>
* COIL: Remove non-inclusive words from i2c codeDossym Nurmukhanov2021-01-121-28/+28
| | | | | | | | | | | BUG=none BRANCH=none TEST=Build npcx9 and coachz boards Signed-off-by: dossym@chromium.org Change-Id: I7f2ccd80e595e0ee24ff56ecde8d810a1f8b98cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2622067 Reviewed-by: Nicolas Boichat <drinkcat@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>
* i2c: Fix port bug with i2ctrace and i2cscan commandsEdward Hill2020-04-071-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 'port' is not the index into i2c_ports[]. Fix i2ctrace and i2cscan to use get_i2c_port() to find the matching port in i2c_ports[] table. Add the port name to the 'i2ctrace list' output to make it clear which port it is. > i2ctrace list id port address -- ---- ------- 0 8 ap_audio 0x4A 1 9 ap_hdmi 0x5A to 0x5F 2 3 ap_mux 0x30 3 4 thermal 0x40 4 5 sensor 0x50 BUG=none BRANCH=none TEST=i2ctrace for I2C_PORT_AP_HDMI on Zork: i2ctrace enable 9 0x4a Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I7b897ac9154751a46ef5961aded569aaec49bfd4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2136526 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* i2c: Cleanup I2C tracing outputKeith Short2020-03-101-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The output of the I2C tracing is hard to parse, especially for reads to I2C registers. This change creates only a single I2C trace for each I2C transfer (instead of 2 entries), and labels the write and read parts of the I2C transaction clearly. Example output (TCPC device during disconnect): i2c: 1:0x20 wr 0x10 rd 0x01 0x00 i2c: 1:0x20 wr 0x10 0x01 0x00 i2c: 1:0x20 wr 0x1A rd 0x1A i2c: 1:0x20 wr 0x1D rd 0x10 i2c: 1:0x20 wr 0x1C rd 0x70 i2c: 1:0x20 wr 0x2F 0x21 i2c: 1:0x20 wr 0x1C 0x70 i2c: 1:0x20 wr 0x2F 0x00 i2c: 1:0x20 wr 0x1C rd 0x70 i2c: 1:0x20 wr 0x1C 0x60 BUG=none BRANCH=none TEST=make buildall TEST=Enable CONFIG_I2C_DEBUG and verify output. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I077196e70ae3abb6c462cf08a3f944b43fdcf82a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2091573 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* i2c: don't output trace line for 0 length dataDenis Brockus2019-12-021-0/+3
| | | | | | | | | | | | | | | | | Write I2C operations always displayed a line indicating a read of port:addr with nothing following. Just don't output any lines that have no data to display. BUG=none BRANCH=none TEST=i2ctrace should not display lines with no data Change-Id: I1ba4bf3e627c47e62c68a592473431fcc195420a Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1940776 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-201-5/+5
| | | | | | | | | | | | | | | | | | | 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-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* common: add i2c tracing functionalityJack Rosenthal2019-07-171-0/+201
crbug.com/982442 requests a way for developers to enable tracing of i2c commands when debugging. This adds a new debug feature, the i2ctrace command, which provides that. The command is guarded by CONFIG_I2C_DEBUG. BUG=chromium:982442 BRANCH=none TEST=enabled CONFIG_I2C_DEBUG on arcada_ish, made sure that command functioned as it says on the tin Change-Id: I9c762271237cbf131e5ef7c0f605c89af4f209fd Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699347 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>