summaryrefslogtreecommitdiff
path: root/driver/nfc
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-01-21 10:16:46 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-25 21:38:52 +0000
commit10a919e0124ac226f299c18b7819dcce7cead3a2 (patch)
tree3318024a98ac8a67542dc6fd80539769a4a67c9b /driver/nfc
parentb1d414b7799cddd11f7d02fdd7c23325e5d18ac1 (diff)
downloadchrome-ec-10a919e0124ac226f299c18b7819dcce7cead3a2.tar.gz
ctn730: Print payload and handle download mode
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>
Diffstat (limited to 'driver/nfc')
-rw-r--r--driver/nfc/ctn730.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c
index 1d60fb3f2e..5528b8c5ec 100644
--- a/driver/nfc/ctn730.c
+++ b/driver/nfc/ctn730.c
@@ -5,6 +5,7 @@
#include "common.h"
#include "console.h"
+#include "gpio.h"
#include "i2c.h"
#include "peripheral_charger.h"
#include "timer.h"
@@ -15,6 +16,9 @@
* Configuration
*/
+/* Print additional data */
+#define CTN730_DEBUG
+
/*
* When ctn730 is asleep, I2C is ignored but can wake it up. I2C will be resent
* after this delay.
@@ -220,10 +224,9 @@ static int _i2c_read(int i2c_port, uint8_t *in, int in_len)
static void _print_header(const struct ctn730_msg *msg)
{
- CPRINTS("%s_%s LEN=%d",
+ CPRINTS("%s_%s",
_text_instruction(msg->instruction),
- _text_message_type(msg->message_type),
- msg->length);
+ _text_message_type(msg->message_type));
}
static int _send_command(struct pchg *ctx, const struct ctn730_msg *cmd)
@@ -307,6 +310,9 @@ static int _process_payload_response(struct pchg *ctx, struct ctn730_msg *res)
if (rv)
return rv;
+ if (IS_ENABLED(CTN730_DEBUG))
+ CPRINTS("Payload: %ph", HEX_BUF(buf, len));
+
switch (res->instruction) {
case WLC_HOST_CTRL_RESET:
if (len != WLC_HOST_CTRL_RESET_RSP_SIZE
@@ -350,10 +356,15 @@ static int _process_payload_event(struct pchg *ctx, struct ctn730_msg *res)
if (rv)
return rv;
+ if (IS_ENABLED(CTN730_DEBUG))
+ CPRINTS("Payload: %ph", HEX_BUF(buf, len));
+
switch (res->instruction) {
case WLC_HOST_CTRL_RESET:
if (buf[0] == WLC_HOST_CTRL_RESET_EVT_NORMAL_MODE)
ctx->event = PCHG_EVENT_INITIALIZED;
+ else if (buf[0] == WLC_HOST_CTRL_RESET_EVT_DOWNLOAD_MODE)
+ ctx->event = PCHG_EVENT_NONE;
else
return EC_ERROR_INVAL;
break;