linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	linux@roeck-us.net, jun.li@nxp.com, devicetree@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH v3 4/4] usb: typec: tcpci: add support to set connector orientation
Date: Tue, 12 Mar 2024 13:27:53 +0200	[thread overview]
Message-ID: <ZfA8OXPOp6Xg5fDb@kuha.fi.intel.com> (raw)
In-Reply-To: <20240226122701.inqpodm6mdfxwjo2@pengutronix.de>

Hi,

I'm sorry to keep you waiting.

On Mon, Feb 26, 2024 at 01:27:01PM +0100, Marco Felsch wrote:
> Hi,
> 
> On 24-02-26, Heikki Krogerus wrote:
> > On Thu, Feb 22, 2024 at 10:09:03PM +0100, Marco Felsch wrote:
> > > This add the support to set the optional connector orientation bit which
> > > is part of the optional CONFIG_STANDARD_OUTPUT register 0x18 [1]. This
> > > allows system designers to connect the tcpc orientation pin directly to
> > > the 2:1 ss-mux.
> > > 
> > > [1] https://www.usb.org/sites/default/files/documents/usb-port_controller_specification_rev2.0_v1.0_0.pdf
> > > 
> > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > ---
> > > v3:
> > > - no changes
> > > v2:
> > > - Make use of fallthrough 
> > > 
> > >  drivers/usb/typec/tcpm/tcpci.c | 44 ++++++++++++++++++++++++++++++++++
> > >  include/linux/usb/tcpci.h      |  8 +++++++
> > >  2 files changed, 52 insertions(+)
> > > 
> > > diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> > > index 7118551827f6..73a52e7f95c2 100644
> > > --- a/drivers/usb/typec/tcpm/tcpci.c
> > > +++ b/drivers/usb/typec/tcpm/tcpci.c
> > > @@ -67,6 +67,18 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val)
> > >  	return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u16));
> > >  }
> > >  
> > > +static bool tcpci_check_std_output_cap(struct regmap *regmap, u8 mask)
> > > +{
> > > +	unsigned int reg;
> > > +	int ret;
> > > +
> > > +	ret = regmap_read(regmap, TCPC_STD_OUTPUT_CAP, &reg);
> > > +	if (ret < 0)
> > > +		return ret;
> > > +
> > > +	return (reg & mask) == mask;
> > > +}
> > > +
> > >  static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
> > >  {
> > >  	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> > > @@ -301,6 +313,28 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
> > >  			   TCPC_TCPC_CTRL_ORIENTATION : 0);
> > >  }
> > >  
> > > +static int tcpci_set_orientation(struct tcpc_dev *tcpc,
> > > +				 enum typec_orientation orientation)
> > > +{
> > > +	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> > > +	unsigned int reg;
> > > +
> > > +	switch (orientation) {
> > > +	case TYPEC_ORIENTATION_NONE:
> > > +		/* We can't put a single output into high impedance */
> > > +		fallthrough;
> > > +	case TYPEC_ORIENTATION_NORMAL:
> > > +		reg = TCPC_CONFIG_STD_OUTPUT_ORIENTATION_NORMAL;
> > > +		break;
> > > +	case TYPEC_ORIENTATION_REVERSE:
> > > +		reg = TCPC_CONFIG_STD_OUTPUT_ORIENTATION_FLIPPED;
> > > +		break;
> > > +	}
> > > +
> > > +	return regmap_update_bits(tcpci->regmap, TCPC_CONFIG_STD_OUTPUT,
> > > +				  TCPC_CONFIG_STD_OUTPUT_ORIENTATION_MASK, reg);
> > > +}
> > > +
> > >  static void tcpci_set_partner_usb_comm_capable(struct tcpc_dev *tcpc, bool capable)
> > >  {
> > >  	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> > > @@ -808,6 +842,9 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
> > >  	if (tcpci->data->vbus_vsafe0v)
> > >  		tcpci->tcpc.is_vbus_vsafe0v = tcpci_is_vbus_vsafe0v;
> > >  
> > > +	if (tcpci->data->set_orientation)
> > > +		tcpci->tcpc.set_orientation = tcpci_set_orientation;
> > 
> > I don't think that flag is needed - not yet at least. Please just call
> > tcpci_check_std_output_cap() directly from here.
> 
> The reason for having it this way was to not break exsisting user like:
> tcpci_rt1711h, tcpci_mt6370, tcpci_maxim which may or may not implement
> the TCPC_STD_OUTPUT_CAP_ORIENTATION. This way the users of
> tcpci_register_port() can decide by on its own if they do have this
> feature or not and how this is checked. I'm fine with your proposal if
> you still think that we can check this unconditional.

Ah, I failed to consider those other glue drivers. This is fine as it
is. I'm really sorry about the delay.

Br,

-- 
heikki

  parent reply	other threads:[~2024-03-12 11:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 21:08 [PATCH v3 0/4] USB-C TCPM Orientation Support Marco Felsch
2024-02-22 21:09 ` [PATCH v3 1/4] dt-bindings: usb: typec-tcpci: add tcpci fallback binding Marco Felsch
2024-02-26  8:56   ` Krzysztof Kozlowski
2024-02-22 21:09 ` [PATCH v3 2/4] usb: typec: tcpci: add generic tcpci fallback compatible Marco Felsch
2024-02-26  8:02   ` Heikki Krogerus
2024-02-22 21:09 ` [PATCH v3 3/4] usb: typec: tcpm: add support to set tcpc connector orientatition Marco Felsch
2024-02-26  8:03   ` Heikki Krogerus
2024-02-22 21:09 ` [PATCH v3 4/4] usb: typec: tcpci: add support to set connector orientation Marco Felsch
2024-02-26  8:13   ` Heikki Krogerus
2024-02-26 12:27     ` Marco Felsch
2024-03-07  9:46       ` Marco Felsch
2024-03-12 11:27       ` Heikki Krogerus [this message]
2024-03-12 11:28   ` Heikki Krogerus

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=ZfA8OXPOp6Xg5fDb@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jun.li@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=m.felsch@pengutronix.de \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).