Twinkie: add packet injection capability

Add commands to send PD packets and to tweak individual parameters (TX
clock frequency, RX detection threshold, resistors on CCx).

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:28337
TEST=verify that the PD sniffing is still working by dumping traffic
between Zinger and Samus.
Connect Twinkie to Zinger, set Rd by using "tw res NONE RD" and see VBUS
going to 5V (reading it using "ina 0").
Send a BIST mode 2 request using the following command :
tw send 2 0x1043 50000000
and see the other end starting sending BIST.

Change-Id: I3c8ddf858435ac1c17a43f59351bbaa69603a209
Reviewed-on: https://chromium-review.googlesource.com/227778
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2014-10-30 14:53:23 -07:00
committed by chrome-internal-fetch
parent bacd096372
commit c8d7462fcf
11 changed files with 683 additions and 14 deletions

View File

@@ -1073,6 +1073,9 @@
/* Include all USB Power Delivery modules */
#undef CONFIG_USB_POWER_DELIVERY
/* Alternative configuration keeping only the TX part of PHY */
#undef CONFIG_USB_PD_TX_PHY_ONLY
/* Default state of PD communication enabled flag */
#define CONFIG_USB_PD_COMM_ENABLED 1

View File

@@ -946,6 +946,29 @@ int pd_write_sym(int port, int bit_off, uint32_t val10);
*/
int pd_write_last_edge(int port, int bit_off);
/**
* Do 4B5B encoding on a 32-bit word.
*
* @param port USB-C port number
* @param off current offset in bits inside the message
* @param val32 32-bit word value to encode
* @return new offset in the message in bits.
*/
int encode_word(int port, int off, uint32_t val32);
/**
* Ensure that we have an edge after EOP and we end up at level 0,
* also fill the last byte.
*
* @param port USB-C port number
* @param header PD packet header
* @param cnt number of payload words
* @param data payload content
* @return length of the message in bits.
*/
int prepare_message(int port, uint16_t header, uint8_t cnt,
const uint32_t *data);
/**
* Dump the current PD packet on the console for debug.
*