From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Sven Peter <sven@svenpeter.dev>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Guido Günther" <agx@sigxcpu.org>,
"Hector Martin" <marcan@marcan.st>,
"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: typec: tipd: Forward plug orientation to typec subsystem
Date: Wed, 2 Mar 2022 14:06:00 +0200 [thread overview]
Message-ID: <Yh9dqPh69wcI3har@kuha.fi.intel.com> (raw)
In-Reply-To: <20220226125912.59828-1-sven@svenpeter.dev>
On Sat, Feb 26, 2022 at 01:59:12PM +0100, Sven Peter wrote:
> In order to bring up the USB3 PHY on the Apple M1 we need to know the
> orientation of the Type-C cable. Extract it from the status register and
> forward it to the typec subsystem.
>
> Signed-off-by: Sven Peter <sven@svenpeter.dev>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tipd/core.c | 5 +++++
> drivers/usb/typec/tipd/tps6598x.h | 1 +
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 7ffcda94d323..16b4560216ba 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -256,6 +256,10 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status)
> typec_set_pwr_opmode(tps->port, mode);
> typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
> typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
> + if (TPS_STATUS_TO_UPSIDE_DOWN(status))
> + typec_set_orientation(tps->port, TYPEC_ORIENTATION_REVERSE);
> + else
> + typec_set_orientation(tps->port, TYPEC_ORIENTATION_NORMAL);
> tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), true);
>
> tps->partner = typec_register_partner(tps->port, &desc);
> @@ -278,6 +282,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status)
> typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
> typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
> typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
> + typec_set_orientation(tps->port, TYPEC_ORIENTATION_NONE);
> tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), false);
>
> power_supply_changed(tps->psy);
> diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h
> index 3dae84c524fb..527857549d69 100644
> --- a/drivers/usb/typec/tipd/tps6598x.h
> +++ b/drivers/usb/typec/tipd/tps6598x.h
> @@ -17,6 +17,7 @@
> /* TPS_REG_STATUS bits */
> #define TPS_STATUS_PLUG_PRESENT BIT(0)
> #define TPS_STATUS_PLUG_UPSIDE_DOWN BIT(4)
> +#define TPS_STATUS_TO_UPSIDE_DOWN(s) (!!((s) & TPS_STATUS_PLUG_UPSIDE_DOWN))
> #define TPS_STATUS_PORTROLE BIT(5)
> #define TPS_STATUS_TO_TYPEC_PORTROLE(s) (!!((s) & TPS_STATUS_PORTROLE))
> #define TPS_STATUS_DATAROLE BIT(6)
> --
> 2.25.1
thanks,
--
heikki
prev parent reply other threads:[~2022-03-02 12:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-26 12:59 [PATCH] usb: typec: tipd: Forward plug orientation to typec subsystem Sven Peter
2022-03-02 12:06 ` 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=Yh9dqPh69wcI3har@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=agx@sigxcpu.org \
--cc=alyssa@rosenzweig.io \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=sven@svenpeter.dev \
/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