linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Li Jun <jun.li@nxp.com>
Cc: robh+dt@kernel.org, shawnguo@kernel.org,
	gregkh@linuxfoundation.org, linux@roeck-us.net,
	linux-usb@vger.kernel.org, linux-imx@nxp.com,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/4] usb: typec: add typec orientation switch support via mux controller
Date: Thu, 20 May 2021 15:33:32 +0300	[thread overview]
Message-ID: <YKZXHG7BSSZssiBg@kuha.fi.intel.com> (raw)
In-Reply-To: <1621408490-23811-4-git-send-email-jun.li@nxp.com>

On Wed, May 19, 2021 at 03:14:49PM +0800, Li Jun wrote:
> Some dedicated mux block can use existing mux controller as a
> mux provider, typec port as a consumer to select channel for
> orientation switch, this can be an alternate way to current
> typec_switch interface.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  drivers/usb/typec/class.c     | 26 +++++++++++++++++++++++++-
>  drivers/usb/typec/class.h     |  2 ++
>  drivers/usb/typec/mux.c       | 34 ++++++++++++++++++++++++++++++++++
>  include/linux/usb/typec_mux.h |  4 ++++
>  4 files changed, 65 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index a29bf2c32233..1bb0275e6204 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -1601,6 +1601,7 @@ static void typec_release(struct device *dev)
>  	ida_simple_remove(&typec_index_ida, port->id);
>  	ida_destroy(&port->mode_ids);
>  	typec_switch_put(port->sw);
> +	typec_mux_control_switch_put(port->mux_control_switch);
>  	typec_mux_put(port->mux);
>  	kfree(port->cap);
>  	kfree(port);
> @@ -1816,6 +1817,13 @@ int typec_set_orientation(struct typec_port *port,
>  	if (ret)
>  		return ret;
>  
> +	if (!port->sw) {
> +		ret = typec_mux_control_switch_set(port->mux_control_switch,
> +				port->mux_control_switch_states[orientation]);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	port->orientation = orientation;
>  	sysfs_notify(&port->dev.kobj, NULL, "orientation");
>  	kobject_uevent(&port->dev.kobj, KOBJ_CHANGE);
> @@ -1991,7 +1999,7 @@ struct typec_port *typec_register_port(struct device *parent,
>  				       const struct typec_capability *cap)
>  {
>  	struct typec_port *port;
> -	int ret;
> +	int ret = 0;
>  	int id;
>  
>  	port = kzalloc(sizeof(*port), GFP_KERNEL);
> @@ -2068,6 +2076,22 @@ struct typec_port *typec_register_port(struct device *parent,
>  		return ERR_PTR(ret);
>  	}
>  
> +	if (!port->sw) {
> +		/* Try to get typec switch via general mux controller */
> +		port->mux_control_switch = typec_mux_control_switch_get(&port->dev);
> +		if (IS_ERR(port->mux_control_switch))
> +			ret = PTR_ERR(port->mux_control_switch);
> +		else if (port->mux_control_switch)
> +			ret = device_property_read_u32_array(&port->dev,
> +					"mux-control-switch-states",
> +					port->mux_control_switch_states,
> +					3);
> +		if (ret) {
> +			put_device(&port->dev);
> +			return ERR_PTR(ret);
> +		}
> +	}

Why not just do that inside fwnode_typec_switch_get() and handle the
whole thing in drivers/usb/typec/mux.c (or in its own file if you
prefer)?

You'll just need to register a "wrapper" Type-C switch object for the
OF mux controller, but that should not be a problem. That way you
don't need to export any new functions, touch this file or anything
else.


thanks,

-- 
heikki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-05-20 12:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  7:14 [PATCH 0/4] typec switch " Li Jun
2021-05-19  7:14 ` [PATCH 1/4] dt-bindings: connector: Add typec orientation switch properties Li Jun
2021-05-21  1:30   ` Rob Herring
2021-05-25 11:48     ` Jun Li
2021-05-19  7:14 ` [PATCH 2/4] usb: typec: use typec cap fwnode's of_node for typec port Li Jun
2021-05-20 12:38   ` Heikki Krogerus
2021-05-19  7:14 ` [PATCH 3/4] usb: typec: add typec orientation switch support via mux controller Li Jun
2021-05-20 12:33   ` Heikki Krogerus [this message]
2021-05-21  8:37     ` Heikki Krogerus
2021-05-25 11:46       ` Jun Li
2021-05-26  9:16         ` Heikki Krogerus
2021-05-31 11:58           ` Jun Li
2021-05-21 13:02     ` Jun Li
2021-05-19  7:14 ` [PATCH 4/4] arm64: dts: imx8mp-evk: enable usb0 with typec connector Li Jun

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=YKZXHG7BSSZssiBg@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jun.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    --subject='Re: [PATCH 3/4] usb: typec: add typec orientation switch support via mux controller' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).