linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 3/3] usb: typec: fsa4480: add support for Audio Accessory Mode
Date: Mon, 26 Jun 2023 11:32:36 +0300	[thread overview]
Message-ID: <ZJlNJGNdaknLmXar@kuha.fi.intel.com> (raw)
In-Reply-To: <20230614-topic-sm8550-upstream-type-c-audio-v1-3-15a92565146b@linaro.org>

On Wed, Jun 14, 2023 at 03:10:41PM +0200, Neil Armstrong wrote:
> The FSA4480 Type-C switch supports switching the Audio R/L,
> AGND and MIC signals to the USB-C DP/DM and SBU1/2 to support
> the Audio Accessory Mode.
> 
> The FSA4480 has an integrated Audio jack detection mechanism
> to automatically mux the AGND, MIX and Sense to the correct
> SBU lines to support 3 pole and both 4 pole TRRS pinouts.
> 
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>

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

> ---
>  drivers/usb/typec/mux/fsa4480.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/usb/typec/mux/fsa4480.c b/drivers/usb/typec/mux/fsa4480.c
> index b2913594a58f..45f5683b7d81 100644
> --- a/drivers/usb/typec/mux/fsa4480.c
> +++ b/drivers/usb/typec/mux/fsa4480.c
> @@ -25,15 +25,24 @@
>  #define FSA4480_DELAY_L_MIC	0x0e
>  #define FSA4480_DELAY_L_SENSE	0x0f
>  #define FSA4480_DELAY_L_AGND	0x10
> +#define FSA4480_FUNCTION_ENABLE	0x12
>  #define FSA4480_RESET		0x1e
>  #define FSA4480_MAX_REGISTER	0x1f
>  
>  #define FSA4480_ENABLE_DEVICE	BIT(7)
>  #define FSA4480_ENABLE_SBU	GENMASK(6, 5)
>  #define FSA4480_ENABLE_USB	GENMASK(4, 3)
> +#define FSA4480_ENABLE_SENSE	BIT(2)
> +#define FSA4480_ENABLE_MIC	BIT(1)
> +#define FSA4480_ENABLE_AGND	BIT(0)
>  
>  #define FSA4480_SEL_SBU_REVERSE	GENMASK(6, 5)
>  #define FSA4480_SEL_USB		GENMASK(4, 3)
> +#define FSA4480_SEL_SENSE	BIT(2)
> +#define FSA4480_SEL_MIC		BIT(1)
> +#define FSA4480_SEL_AGND	BIT(0)
> +
> +#define FSA4480_ENABLE_AUTO_JACK_DETECT	BIT(0)
>  
>  struct fsa4480 {
>  	struct i2c_client *client;
> @@ -95,6 +104,9 @@ static int fsa4480_set(struct fsa4480 *fsa)
>  		default:
>  			return -EOPNOTSUPP;
>  		}
> +	} else if (fsa->mode == TYPEC_MODE_AUDIO) {
> +		/* Audio Accessory Mode, setup to auto Jack Detection */
> +		enable |= FSA4480_ENABLE_USB | FSA4480_ENABLE_AGND;
>  	} else
>  		return -EOPNOTSUPP;
>  
> @@ -110,6 +122,11 @@ static int fsa4480_set(struct fsa4480 *fsa)
>  	regmap_write(fsa->regmap, FSA4480_SWITCH_SELECT, sel);
>  	regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, enable);
>  
> +	/* Start AUDIO JACK DETECTION to setup MIC, AGND & Sense muxes */
> +	if (enable & FSA4480_ENABLE_AGND)
> +		regmap_write(fsa->regmap, FSA4480_FUNCTION_ENABLE,
> +			     FSA4480_ENABLE_AUTO_JACK_DETECT);
> +
>  	if (enable & FSA4480_ENABLE_SBU) {
>  		/* 15us to allow the SBU switch to turn on again */
>  		usleep_range(15, 1000);

thanks,

-- 
heikki

      parent reply	other threads:[~2023-06-26  8:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 13:10 [PATCH 0/3] typec: support Audio Accessory mode on FSA4480 Neil Armstrong
2023-06-14 13:10 ` [PATCH 1/3] usb: typec: ucsi: call typec_set_mode on non-altmode partner change Neil Armstrong
2023-06-14 13:11   ` Krzysztof Kozlowski
2023-06-26  8:12   ` Heikki Krogerus
2023-06-26 13:23     ` Neil Armstrong
2023-06-26 14:43       ` Greg Kroah-Hartman
2023-06-14 13:10 ` [PATCH 2/3] usb: typec: fsa4480: rework mux & switch setup to handle more states Neil Armstrong
2023-06-14 13:12   ` Krzysztof Kozlowski
2023-06-26  8:30   ` Heikki Krogerus
2023-06-14 13:10 ` [PATCH 3/3] usb: typec: fsa4480: add support for Audio Accessory Mode Neil Armstrong
2023-06-14 13:12   ` Krzysztof Kozlowski
2023-06-26  8:32   ` 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=ZJlNJGNdaknLmXar@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=neil.armstrong@linaro.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;
as well as URLs for NNTP newsgroup(s).