ppm_common: Improved error handling

1) If cci.error is set, cci.complete will also be set.
2) If an unexpected ACK command is received, PPM will set the error
   and cmd_complete bits. It will also clear pending before
   notifying the OS. The PPM state will be restored to the state
   before the ACK was received.

BUG=b:319124643
TEST=make local_tests

Change-Id: I89a4e1f8b78d8121a0eff54eca5c6726fe70430b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/usb/um_ppm/+/5214908
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@google.com>
Commit-Queue: Pavan Holla <pholla@google.com>
Tested-by: Pavan Holla <pholla@google.com>
1 file changed
tree: aeab6030314e383eb615edc0861245cad51c9f30
  1. include/
  2. test/
  3. .gitignore
  4. LICENSE
  5. main.c
  6. Makefile
  7. platform_usermode.c
  8. ppm_common.c
  9. ppm_common.h
  10. README.md
  11. rts5453.c
  12. rts5453.h
  13. rts5453_usermode.c
  14. smbus_usermode.c
  15. smbus_usermode.h
  16. um_ppm_chardev.c
  17. um_ppm_chardev.h
README.md

Usermode PPM implementation

Usermode UCSI PPM implementation for evaluation and testing usage. Try using this with the ucsi_um_test kernel driver.

Setup

For usermode implementations, we use libi2c and libgpiod to provide an smbus implementation. You will need the right libraries to build:

sudo apt-get install libi2c-dev libgpiod-dev

Architecture

┌─────────┐
│OPM      │
│kernel or│
│cli      │
└────┬────┘
     │
     │
     ▼          ┌───────────┐
 ┌────────┐     │ PD Driver │
 │        ├────►│           │
 │  PPM   │     ├───────────┤
 │        │     │           │
 └────────┘     │ I2C Driver│
                └───────────┘

The usermode ppm implementation consists of the PPM task, the PD driver and the I2C driver backing it. The OPM will either be a CLI (for locally triggering some functionality) or the ucsi_um_test kernel module.