All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Val Packett <val@packett.cool>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Luca Weiss <luca.weiss@fairphone.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	~postmarketos/upstreaming@lists.sr.ht,
	phone-devel@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 2/2] usb: typec: fsa4480: Report switch & mux events to codec
Date: Mon, 26 Oct 2026 14:15:14 +0100	[thread overview]
Message-ID: <at9SYmvQtGAYaYYn@black.igk.intel.com> (raw)
In-Reply-To: <20261020162101.1527014-3-val@packett.cool>

On Tue, Oct 20, 2026 at 01:20:31PM -0300, Val Packett wrote:
> From: Luca Weiss <luca.weiss@fairphone.com>
> 
> In the Type-C graph, the FSA4480 switch is in between the USB-C connector
> and the audio codec, but the audio codec also needs to receive the
> switch and mux events from the FSA4480.
> 
> Update the driver to get an Type-C mux on the next endpoint and
> broadcast the recevied mux & switch state to it.
> 
> Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
> [val: enable the SENSE/MIC bits; put the refs in fsa4480_remove]
> Signed-off-by: Val Packett <val@packett.cool>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/mux/fsa4480.c | 57 +++++++++++++++++++++++++++++----
>  1 file changed, 50 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/fsa4480.c b/drivers/usb/typec/mux/fsa4480.c
> index bea0c1deec94..3c12d17a25a2 100644
> --- a/drivers/usb/typec/mux/fsa4480.c
> +++ b/drivers/usb/typec/mux/fsa4480.c
> @@ -60,6 +60,9 @@ struct fsa4480 {
>  
>  	struct regmap *regmap;
>  
> +	struct typec_mux *codec;
> +	struct typec_switch *codec_switch;
> +
>  	enum typec_orientation orientation;
>  	unsigned long mode;
>  	unsigned int svid;
> @@ -115,7 +118,8 @@ static int fsa4480_set(struct fsa4480 *fsa)
>  		}
>  	} else if (fsa->mode == TYPEC_MODE_AUDIO) {
>  		/* Audio Accessory Mode, setup to auto Jack Detection */
> -		enable |= FSA4480_ENABLE_USB | FSA4480_ENABLE_AGND;
> +		enable |= FSA4480_ENABLE_USB | FSA4480_ENABLE_AGND |
> +			 FSA4480_ENABLE_SENSE | FSA4480_ENABLE_MIC;
>  	} else
>  		return -EOPNOTSUPP;
>  
> @@ -162,7 +166,11 @@ static int fsa4480_switch_set(struct typec_switch_dev *sw,
>  
>  	mutex_unlock(&fsa->lock);
>  
> -	return ret;
> +	if (ret)
> +		return ret;
> +
> +	/* Report orientation to codec after switch has been done */
> +	return typec_switch_set(fsa->codec_switch, orientation);
>  }
>  
>  static int fsa4480_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state)
> @@ -185,7 +193,11 @@ static int fsa4480_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *st
>  
>  	mutex_unlock(&fsa->lock);
>  
> -	return ret;
> +	if (ret)
> +		return ret;
> +
> +	/* Report event to codec after switch has been done */
> +	return typec_mux_set(fsa->codec, state);
>  }
>  
>  enum {
> @@ -287,6 +299,19 @@ static int fsa4480_probe(struct i2c_client *client)
>  		FIELD_GET(FSA4480_DEVICE_ID_REV_ID, val),
>  		FIELD_GET(FSA4480_DEVICE_ID_VENDOR_ID, val));
>  
> +	/* Get Codec's MUX & Switch devices */
> +	fsa->codec = fwnode_typec_mux_get(dev->fwnode);
> +	if (IS_ERR(fsa->codec))
> +		return dev_err_probe(dev, PTR_ERR(fsa->codec),
> +				     "failed to acquire codec mode-switch\n");
> +
> +	fsa->codec_switch = fwnode_typec_switch_get(dev->fwnode);
> +	if (IS_ERR(fsa->codec_switch)) {
> +		ret = dev_err_probe(dev, PTR_ERR(fsa->codec_switch),
> +				    "failed to acquire codec orientation-switch\n");
> +		goto err_put_mux;
> +	}
> +
>  	/* Safe mode */
>  	fsa->cur_enable = FSA4480_ENABLE_DEVICE | FSA4480_ENABLE_USB;
>  	fsa->mode = TYPEC_STATE_SAFE;
> @@ -310,8 +335,11 @@ static int fsa4480_probe(struct i2c_client *client)
>  	sw_desc.set = fsa4480_switch_set;
>  
>  	fsa->sw = typec_switch_register(dev, &sw_desc);
> -	if (IS_ERR(fsa->sw))
> -		return dev_err_probe(dev, PTR_ERR(fsa->sw), "failed to register typec switch\n");
> +	if (IS_ERR(fsa->sw)) {
> +		ret = dev_err_probe(dev, PTR_ERR(fsa->sw),
> +				    "failed to register typec switch\n");
> +		goto err_put_switch;
> +	}
>  
>  	mux_desc.drvdata = fsa;
>  	mux_desc.fwnode = dev_fwnode(dev);
> @@ -319,12 +347,24 @@ static int fsa4480_probe(struct i2c_client *client)
>  
>  	fsa->mux = typec_mux_register(dev, &mux_desc);
>  	if (IS_ERR(fsa->mux)) {
> -		typec_switch_unregister(fsa->sw);
> -		return dev_err_probe(dev, PTR_ERR(fsa->mux), "failed to register typec mux\n");
> +		ret = dev_err_probe(dev, PTR_ERR(fsa->mux),
> +				    "failed to register typec mux\n");
> +		goto err_unregister_switch;
>  	}
>  
>  	i2c_set_clientdata(client, fsa);
>  	return 0;
> +
> +err_unregister_switch:
> +	typec_switch_unregister(fsa->sw);
> +
> +err_put_switch:
> +	typec_switch_put(fsa->codec_switch);
> +
> +err_put_mux:
> +	typec_mux_put(fsa->codec);
> +
> +	return ret;
>  }
>  
>  static void fsa4480_remove(struct i2c_client *client)
> @@ -333,6 +373,9 @@ static void fsa4480_remove(struct i2c_client *client)
>  
>  	typec_mux_unregister(fsa->mux);
>  	typec_switch_unregister(fsa->sw);
> +
> +	typec_mux_put(fsa->codec);
> +	typec_switch_put(fsa->codec_switch);
>  }
>  
>  static const struct i2c_device_id fsa4480_table[] = {
> -- 
> 2.55.0

-- 
heikki

      parent reply	other threads:[~2026-10-26 13:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 16:20 [PATCH v3 0/2] usb: typec: fsa4480: Support reporting hotplug events to a codec Val Packett
2026-10-20 16:20 ` [PATCH v3 1/2] dt-bindings: usb: fsa4480: Add an optional audio port/endpoint Val Packett
2026-10-20 16:26   ` sashiko-bot
2026-10-20 16:20 ` [PATCH v3 2/2] usb: typec: fsa4480: Report switch & mux events to codec Val Packett
2026-10-20 16:33   ` sashiko-bot
2026-10-26 13:15   ` 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=at9SYmvQtGAYaYYn@black.igk.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=luca.weiss@fairphone.com \
    --cc=neil.armstrong@linaro.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=val@packett.cool \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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 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.