public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Cc: linux@roeck-us.net, andersson@kernel.org, robh@kernel.org,
	gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/1] usb: typec: tcpm: Support role-switch remote endpoint in connector
Date: Tue, 28 Mar 2023 17:08:56 +0300	[thread overview]
Message-ID: <ZCL0+COeAkinuaBL@kuha.fi.intel.com> (raw)
In-Reply-To: <20230325011552.2241155-2-bryan.odonoghue@linaro.org>

On Sat, Mar 25, 2023 at 01:15:52AM +0000, Bryan O'Donoghue wrote:
> Right now in TCPM when we want to send a role-switch message the
> remote-endpoint must appear inside of the TCPM bound node, not in the
> connector associated with TCPM.
> 
> &typec {
> 	status = "okay";
> 
> 	port {
> 		typec_role_switch: endpoint {
> 			remote-endpoint = <&dwc3_role_switch>;
> 		};
> 	};
> 
> 	connector {
> 		compatible = "usb-c-connector";
> 
> 		power-role = "source";
> 		data-role = "dual";
> 		self-powered;
> 
> 		ports {
> 			#address-cells = <1>;
> 			#size-cells = <0>;
> 
> 			port@0 {
> 				reg = <0>;
> 				typec_mux: endpoint {
> 					remote-endpoint = <&phy_typec_mux>;
> 				};
> 			};
> 		};
> 	};
> };
> 
> This change makes it possible to declare the remote-endpoint inside of the
> connector of the TCPM e.g.
> 
> &typec {
> 	status = "okay";
> 
> 	connector {
> 		compatible = "usb-c-connector";
> 
> 		power-role = "source";
> 		data-role = "dual";
> 		self-powered;
> 
> 		ports {
> 			#address-cells = <1>;
> 			#size-cells = <0>;
> 
> 			port@0 {
> 				reg = <0>;
> 				typec_role_switch: endpoint {
> 					remote-endpoint = <&dwc3_role_switch>;
> 				};
> 			};
> 			port@1 {
> 				reg = <1>;
> 				typec_mux: endpoint {
> 					remote-endpoint = <&phy_typec_mux>;
> 				};
> 			};
> 		};
> 	};
> };
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 1ee774c263f08..a62fecf3bb44c 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -6515,6 +6515,7 @@ static enum hrtimer_restart send_discover_timer_handler(struct hrtimer *timer)
>  struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>  {
>  	struct tcpm_port *port;
> +	struct fwnode_handle *fwnode;
>  	int err;
>  
>  	if (!dev || !tcpc ||
> @@ -6582,6 +6583,14 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>  		goto out_destroy_wq;
>  	}
>  
> +	if (!port->role_sw) {
> +		fwnode = device_get_named_child_node(port->dev, "connector");

You already have that assigned to tcpc->fwnode, no?

At least drivers/usb/typec/tcpm/tcpci.c assignes it there, and I think
so do the other port controller drivers.

> +		if (fwnode) {
> +			port->role_sw = fwnode_usb_role_switch_get(fwnode);
> +			fwnode_handle_put(fwnode);
> +		}
> +	}

If that is the case, then I think this is enough:

        if (!port->role_sw)
		port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);

Or maybe I missed something. If I did then sorry for the noise :-)

thanks,

-- 
heikki

      reply	other threads:[~2023-03-28 14:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-25  1:15 [RFC PATCH 0/1] Add TCPM connector role-switch endpoint binding Bryan O'Donoghue
2023-03-25  1:15 ` [RFC PATCH 1/1] usb: typec: tcpm: Support role-switch remote endpoint in connector Bryan O'Donoghue
2023-03-28 14:08   ` Heikki Krogerus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZCL0+COeAkinuaBL@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=andersson@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox