Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp443907lqi; Thu, 7 Mar 2024 01:46:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXVhPIwVJb6FUdC8jv9ppAfSipwYjxbd/xXm+Qiks4PUv4l8vEN89IXgDotbmg79zDrdphOO1htroQOYmoqleJt0yUfY9AqHPFb3irASA== X-Google-Smtp-Source: AGHT+IGxMo9oN9MP2bONhxTf1IHzSMwO39u0vZfeY8I7mbucXjRtG7r3rEP8EXZJYQnQdK/9l4iT X-Received: by 2002:a05:620a:89b:b0:788:22ee:ab6 with SMTP id b27-20020a05620a089b00b0078822ee0ab6mr7162826qka.51.1709804803317; Thu, 07 Mar 2024 01:46:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709804803; cv=pass; d=google.com; s=arc-20160816; b=OW86dVLLP1Nks30X01UCBhlA2pWj4AZTrF4ppWSK1Cvmvs3GvoEbwx7tusbEJ9pdiV nYehd6qX225M84kTGR8O9yBmW+cfOqGHwlnU3j3CRqE8FZIm7oGiGVZ2hh50enbPIveV C4qo2lmpIx6828cPvEbFcD6X8UGZF4ZNMmHoySdoyylqZeQ5r5ZEeIqpJiYmVgFHQjMO 5it1kiwsHdCNPK5/SWr3WdqI58x2eaeTp7RNEx5Hxmny+BMs8yH2dedy0tiYEzfCHnkx JbP649NYVbFjvrmG3BFeYdWWRsFUkuOfgY50MP5yQKwsWydvJKij1hYquReQQbR6W3+U NQGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=MoymAYWp4NUQ8gRd4qAZXFYdL+SVlMK1CCYQQBJu8kI=; fh=EvbmuiOY7eCaHqssvElkE5eF1+wjq7pG/x4Y7gF7MPA=; b=V8lg9uRGPK3VQkFiIduDhxUg3xogFgekdO+aCvPkRiEF9F+3PjmK9sKyC18tyGJ3wX 4Tj/vBH+fgOI+D6+SJP9VM9aV0cXIDeLnAWIgc1XvYUbgNvoRpSk6a2KbgpN7YHxodU9 R2AIMI+wTI8aF9Dq9tX4IY9qBDMFEloMAYhra90NC/goukVviSWD4kuAf5nmDxh9dMSJ 0gR/yRbVScTKWbB+i6ynwvArG+bHoO7x/cmDTM2fKyCp7VDwPcERS+h2sWEpN1ItpVKj DaBy32JtlfbYyrnGpcIYIUPB8HaB7iT+ru3CGucpF5MvmqljYQ1/7UjKgmqr4a0p61iG A72w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-95247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95247-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g22-20020a05620a40d600b0078849fa4cb7si292867qko.201.2024.03.07.01.46.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 01:46:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-95247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95247-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 019671C21C26 for ; Thu, 7 Mar 2024 09:46:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D5F384FCB; Thu, 7 Mar 2024 09:46:36 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8C6184FA7 for ; Thu, 7 Mar 2024 09:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709804796; cv=none; b=DsQ6Qi/SogOtkJxIh/7juxyrxzYdokhpR4rYwXiYgfmwoSRkFWxxsIMFSuSbWb59fUStAJft0yI2ZfIX77GMAMOpnO5S1NsTscKL9lPaUBGNa083mauRucxVuaIjB5I8LVCiIf3uI83srfzF6h4xegYnzBma+TPU96KAYvfxH54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709804796; c=relaxed/simple; bh=wmbWd6x+OjGeqEW39eS7Q3JfTpXKvNC6d/RLscj6RgE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oJDXH+KEZacYFlI7cdgXaUETZP9emQDFLr4GxiMfwkxwpl7HBuFfb7CQvNcaOw255BrnlAPBVy8ibykcGAZ/mftemqxlJ6dx0xaaRluCKLqDIlEbFKBbmY9Rqq79tsW3gFEhN1291n7j/hrabyhQvGjSTrMd9xLamRCf9NXHsGk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1riAKS-0002L8-Ue; Thu, 07 Mar 2024 10:46:20 +0100 Received: from [2a0a:edc0:2:b01:1d::c5] (helo=pty.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1riAKR-004uji-0B; Thu, 07 Mar 2024 10:46:19 +0100 Received: from mfe by pty.whiteo.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1riAKQ-006MWO-2u; Thu, 07 Mar 2024 10:46:18 +0100 Date: Thu, 7 Mar 2024 10:46:18 +0100 From: Marco Felsch To: Heikki Krogerus Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, kernel@pengutronix.de, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux@roeck-us.net, jun.li@nxp.com Subject: Re: [PATCH v3 4/4] usb: typec: tcpci: add support to set connector orientation Message-ID: <20240307094618.b3yhzlq4y6y6qfqf@pengutronix.de> References: <20240222210903.208901-1-m.felsch@pengutronix.de> <20240222210903.208901-5-m.felsch@pengutronix.de> <20240226122701.inqpodm6mdfxwjo2@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240226122701.inqpodm6mdfxwjo2@pengutronix.de> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Hi, gentle ping, since Greg started to pick the other patches. On 24-02-26, 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 > > > --- > > > 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, ®); > > > + 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. ^ ? Regards, Marco > Regards, > Marco > > > > err = tcpci_parse_config(tcpci); > > > if (err < 0) > > > return ERR_PTR(err); > > > @@ -851,6 +888,13 @@ static int tcpci_probe(struct i2c_client *client) > > > if (err < 0) > > > return err; > > > > > > + err = tcpci_check_std_output_cap(chip->data.regmap, > > > + TCPC_STD_OUTPUT_CAP_ORIENTATION); > > > + if (err < 0) > > > + return err; > > > + > > > + chip->data.set_orientation = err; > > > + > > > chip->tcpci = tcpci_register_port(&client->dev, &chip->data); > > > if (IS_ERR(chip->tcpci)) > > > return PTR_ERR(chip->tcpci); > > > diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h > > > index 467e8045e9f8..f2bfb4250366 100644 > > > --- a/include/linux/usb/tcpci.h > > > +++ b/include/linux/usb/tcpci.h > > > @@ -47,6 +47,9 @@ > > > #define TCPC_SINK_FAST_ROLE_SWAP BIT(0) > > > > > > #define TCPC_CONFIG_STD_OUTPUT 0x18 > > > +#define TCPC_CONFIG_STD_OUTPUT_ORIENTATION_MASK BIT(0) > > > +#define TCPC_CONFIG_STD_OUTPUT_ORIENTATION_NORMAL 0 > > > +#define TCPC_CONFIG_STD_OUTPUT_ORIENTATION_FLIPPED 1 > > > > > > #define TCPC_TCPC_CTRL 0x19 > > > #define TCPC_TCPC_CTRL_ORIENTATION BIT(0) > > > @@ -127,6 +130,7 @@ > > > #define TCPC_DEV_CAP_2 0x26 > > > #define TCPC_STD_INPUT_CAP 0x28 > > > #define TCPC_STD_OUTPUT_CAP 0x29 > > > +#define TCPC_STD_OUTPUT_CAP_ORIENTATION BIT(0) > > > > > > #define TCPC_MSG_HDR_INFO 0x2e > > > #define TCPC_MSG_HDR_INFO_DATA_ROLE BIT(3) > > > @@ -198,12 +202,16 @@ struct tcpci; > > > * Chip level drivers are expected to check for contaminant and call > > > * tcpm_clean_port when the port is clean to put the port back into > > > * toggling state. > > > + * @set_orientation: > > > + * Optional; Enable setting the connector orientation > > > + * CONFIG_STANDARD_OUTPUT (0x18) bit0. > > > */ > > > struct tcpci_data { > > > struct regmap *regmap; > > > unsigned char TX_BUF_BYTE_x_hidden:1; > > > unsigned char auto_discharge_disconnect:1; > > > unsigned char vbus_vsafe0v:1; > > > + unsigned char set_orientation:1; > > > > > > int (*init)(struct tcpci *tcpci, struct tcpci_data *data); > > > int (*set_vconn)(struct tcpci *tcpci, struct tcpci_data *data, > > > -- > > > 2.39.2 > > > > -- > > heikki > > > >