diff options
| author | Jack Pham <jackp@codeaurora.org> | 2016-09-28 18:40:14 -0700 |
|---|---|---|
| committer | Jack Pham <jackp@codeaurora.org> | 2016-09-28 18:40:14 -0700 |
| commit | 8b01cb751c82ccdc330b9d70117226b7a9f6e815 (patch) | |
| tree | 47bff79d7defb6bbc7818d547c33d65deab809c5 | |
| parent | 626caf4e54864d90e8d104277f9a1446e487c7e1 (diff) | |
usb: pd: Print out source/sink subtypes
Add additional verbiage to the info logs to help
determine the type of source cable connected: default,
medium or high current. Similarly, if a sink is attached,
indicate whether it is with a powered cable or not.
Change-Id: I0687365827cdbb8a1b7168a2b676b1afd2f576f6
Signed-off-by: Jack Pham <jackp@codeaurora.org>
| -rw-r--r-- | drivers/usb/pd/policy_engine.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c index 82ae0b4fe135..3806d666997b 100644 --- a/drivers/usb/pd/policy_engine.c +++ b/drivers/usb/pd/policy_engine.c @@ -1748,6 +1748,20 @@ static void usbpd_sm(struct work_struct *w) pd->rx_msg_type = pd->rx_msg_len = 0; } +static inline const char *src_current(enum power_supply_typec_mode typec_mode) +{ + switch (typec_mode) { + case POWER_SUPPLY_TYPEC_SOURCE_DEFAULT: + return "default"; + case POWER_SUPPLY_TYPEC_SOURCE_MEDIUM: + return "medium - 1.5A"; + case POWER_SUPPLY_TYPEC_SOURCE_HIGH: + return "high - 3.0A"; + default: + return ""; + } +} + static int psy_changed(struct notifier_block *nb, unsigned long evt, void *ptr) { struct usbpd *pd = container_of(nb, struct usbpd, psy_nb); @@ -1848,7 +1862,8 @@ static int psy_changed(struct notifier_block *nb, unsigned long evt, void *ptr) case POWER_SUPPLY_TYPEC_SOURCE_DEFAULT: case POWER_SUPPLY_TYPEC_SOURCE_MEDIUM: case POWER_SUPPLY_TYPEC_SOURCE_HIGH: - usbpd_info(&pd->dev, "Type-C Source connected\n"); + usbpd_info(&pd->dev, "Type-C Source (%s) connected\n", + src_current(typec_mode)); if (pd->current_pr != PR_SINK) { pd->current_pr = PR_SINK; queue_work(pd->wq, &pd->sm_work); @@ -1858,7 +1873,9 @@ static int psy_changed(struct notifier_block *nb, unsigned long evt, void *ptr) /* Source states */ case POWER_SUPPLY_TYPEC_SINK_POWERED_CABLE: case POWER_SUPPLY_TYPEC_SINK: - usbpd_info(&pd->dev, "Type-C Sink connected\n"); + usbpd_info(&pd->dev, "Type-C Sink%s connected\n", + typec_mode == POWER_SUPPLY_TYPEC_SINK ? + "" : " (powered)"); if (pd->current_pr != PR_SRC) { pd->current_pr = PR_SRC; queue_work(pd->wq, &pd->sm_work); |
