All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] usb: typec: tcpm: Add callback to notify pd_capable partner
@ 2021-03-11 10:03 Badhri Jagan Sridharan
  2021-03-11 10:03 ` [PATCH 2/4] usb: typec: tcpci: Add tcpc chip level callbacks Badhri Jagan Sridharan
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Badhri Jagan Sridharan @ 2021-03-11 10:03 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman, Rob Herring
  Cc: linux-usb, linux-kernel, Kyle Tso, devicetree, Badhri Jagan Sridharan

This change informs lower level tcpc drivers of pd_capable
partner. This is useful while setting current limit for the
charging path.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 20 +++++++++++++++-----
 include/linux/usb/tcpm.h      |  3 +++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 11d0c40bc47d..e9886e850b84 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -952,6 +952,16 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv)
 	return ret;
 }
 
+static void tcpm_set_pd_capable(struct tcpm_port *port, bool capable)
+{
+	tcpm_log(port, "Partner pd capable %s", capable ? "true" : "false");
+
+	if (port->tcpc->set_pd_capable)
+		port->tcpc->set_pd_capable(port->tcpc, capable);
+
+	port->pd_capable = capable;
+}
+
 static int tcpm_set_attached_state(struct tcpm_port *port, bool attached)
 {
 	return port->tcpc->set_roles(port->tcpc, attached, port->pwr_role,
@@ -3444,7 +3454,7 @@ static int tcpm_src_attach(struct tcpm_port *port)
 	if (ret < 0)
 		goto out_disable_vconn;
 
-	port->pd_capable = false;
+	tcpm_set_pd_capable(port, false);
 
 	port->partner = NULL;
 
@@ -3509,7 +3519,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	tcpm_unregister_altmodes(port);
 	tcpm_typec_disconnect(port);
 	port->attached = false;
-	port->pd_capable = false;
+	tcpm_set_pd_capable(port, false);
 	port->pps_data.supported = false;
 	tcpm_set_partner_usb_comm_capable(port, false);
 
@@ -3583,7 +3593,7 @@ static int tcpm_snk_attach(struct tcpm_port *port)
 	if (ret < 0)
 		return ret;
 
-	port->pd_capable = false;
+	tcpm_set_pd_capable(port, false);
 
 	port->partner = NULL;
 
@@ -3813,7 +3823,7 @@ static void run_state_machine(struct tcpm_port *port)
 			 */
 			/* port->hard_reset_count = 0; */
 			port->caps_count = 0;
-			port->pd_capable = true;
+			tcpm_set_pd_capable(port, true);
 			tcpm_set_state_cond(port, SRC_SEND_CAPABILITIES_TIMEOUT,
 					    PD_T_SEND_SOURCE_CAP);
 		}
@@ -4074,7 +4084,7 @@ static void run_state_machine(struct tcpm_port *port)
 		}
 		break;
 	case SNK_NEGOTIATE_CAPABILITIES:
-		port->pd_capable = true;
+		tcpm_set_pd_capable(port, true);
 		tcpm_set_partner_usb_comm_capable(port,
 						  !!(port->source_caps[0] & PDO_FIXED_USB_COMM));
 		port->hard_reset_count = 0;
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
index 42fcfbe10590..d5d7293bc34d 100644
--- a/include/linux/usb/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -112,6 +112,8 @@ enum tcpm_transmit_type {
  *              Optional; The USB Communications Capable bit indicates if port
  *              partner is capable of communication over the USB data lines
  *              (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
+ * @set_pd_capable:
+ *		Optional; Called to notify if the partner is pd capable.
  */
 struct tcpc_dev {
 	struct fwnode_handle *fwnode;
@@ -144,6 +146,7 @@ struct tcpc_dev {
 						 bool pps_active, u32 requested_vbus_voltage);
 	bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
 	void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
+	void (*set_pd_capable)(struct tcpc_dev *dev, bool enable);
 };
 
 struct tcpm_port;
-- 
2.31.0.rc2.261.g7f71774620-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-03-24 20:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 10:03 [PATCH 1/4] usb: typec: tcpm: Add callback to notify pd_capable partner Badhri Jagan Sridharan
2021-03-11 10:03 ` [PATCH 2/4] usb: typec: tcpci: Add tcpc chip level callbacks Badhri Jagan Sridharan
2021-03-11 10:03 ` [PATCH 3/4] usb: typec: tcpci_maxim: configure charging & data paths Badhri Jagan Sridharan
2021-03-11 13:33   ` Heikki Krogerus
2021-03-12  5:08     ` Badhri Jagan Sridharan
2021-03-16 22:02       ` Badhri Jagan Sridharan
2021-03-11 10:03 ` [PATCH 4/4] dt-bindings: usb: Add chg-psy-name property Maxim 33359 binding Badhri Jagan Sridharan
2021-03-24 14:50   ` Rob Herring
2021-03-24 20:01     ` Badhri Jagan Sridharan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.