Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: typec: tcpm: Add get_current_limit tcpc_dev callback

A Rp signalling the default current limit indicates that we're possibly
connected to an USB2 power-source. In some cases the type-c port-controller
may provide the capability to detect the current-limit in this case,
through e.g. BC1.2 detection.

This commit adds an optional get_current_limit tcpc_dev callback which
allows the port-controller to provide current-limit detection for when
the CC pin is pulled up with Rp.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Hans de Goede and committed by
Greg Kroah-Hartman
ea62cfc7 26e59b35

+11 -1
+4 -1
drivers/staging/typec/tcpm.c
··· 685 685 break; 686 686 case TYPEC_CC_RP_DEF: 687 687 default: 688 - limit = 0; 688 + if (port->tcpc->get_current_limit) 689 + limit = port->tcpc->get_current_limit(port->tcpc); 690 + else 691 + limit = 0; 689 692 break; 690 693 } 691 694
+7
drivers/staging/typec/tcpm.h
··· 109 109 110 110 int (*init)(struct tcpc_dev *dev); 111 111 int (*get_vbus)(struct tcpc_dev *dev); 112 + /* 113 + * This optional callback gets called by the tcpm core when configured 114 + * as a snk and cc=Rp-def. This allows the tcpm to provide a fallback 115 + * current-limit detection method for the cc=Rp-def case. E.g. some 116 + * tcpcs may include BC1.2 charger detection and use that in this case. 117 + */ 118 + int (*get_current_limit)(struct tcpc_dev *dev); 112 119 int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc); 113 120 int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1, 114 121 enum typec_cc_status *cc2);