From: Potin Lai <potin.lai@quantatw.com>
To: Guenter Roeck <linux@roeck-us.net>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Patrick Williams <patrick@stwcx.xyz>,
Potin Lai <potin.lai@quantatw.com>
Subject: [PATCH 2/2] usb: typec: fusb302: add support of supported_pd_rev
Date: Tue, 8 Feb 2022 16:20:26 +0800 [thread overview]
Message-ID: <20220208082026.4855-3-potin.lai@quantatw.com> (raw)
In-Reply-To: <20220208082026.4855-1-potin.lai@quantatw.com>
Add support for passing supported PD rev to TCPM.
If "supported-pd-rev" property exist, then return supported_pd_rev as
defined value in DTS, otherwise return PD_MAX_REV
Example of DTS:
fusb302: typec-portc@22 {
compatible = "fcs,fusb302";
reg = <0x22>;
...
supported-pd-rev=<1>; // PD_REV20
...
};
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
---
drivers/usb/typec/tcpm/fusb302.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index 72f9001b0792..8cff92d58b96 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -109,6 +109,9 @@ struct fusb302_chip {
enum typec_cc_status cc2;
u32 snk_pdo[PDO_MAX_OBJECTS];
+ /* supported pd rev */
+ u32 supported_pd_rev;
+
#ifdef CONFIG_DEBUG_FS
struct dentry *dentry;
/* lock for log buffer access */
@@ -1056,6 +1059,13 @@ static int tcpm_pd_transmit(struct tcpc_dev *dev, enum tcpm_transmit_type type,
return ret;
}
+static u32 tcpm_supported_pd_rev(struct tcpc_dev *dev)
+{
+ struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
+ tcpc_dev);
+ return chip->supported_pd_rev;
+}
+
static enum typec_cc_status fusb302_bc_lvl_to_cc(u8 bc_lvl)
{
if (bc_lvl == FUSB_REG_STATUS0_BC_LVL_1230_MAX)
@@ -1129,6 +1139,7 @@ static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev)
fusb302_tcpc_dev->set_roles = tcpm_set_roles;
fusb302_tcpc_dev->start_toggling = tcpm_start_toggling;
fusb302_tcpc_dev->pd_transmit = tcpm_pd_transmit;
+ fusb302_tcpc_dev->supported_pd_rev = tcpm_supported_pd_rev;
}
static const char * const cc_polarity_name[] = {
@@ -1683,6 +1694,7 @@ static int fusb302_probe(struct i2c_client *client,
struct fusb302_chip *chip;
struct i2c_adapter *adapter = client->adapter;
struct device *dev = &client->dev;
+ struct device_node *np = dev->of_node;
const char *name;
int ret = 0;
@@ -1756,6 +1768,14 @@ static int fusb302_probe(struct i2c_client *client,
dev_err(dev, "cannot request IRQ for GPIO Int_N, ret=%d", ret);
goto tcpm_unregister_port;
}
+
+ if (of_property_read_u32(np, "supported-pd-rev",
+ &chip->supported_pd_rev) < 0) {
+ chip->supported_pd_rev = PD_MAX_REV;
+ } else if (chip->supported_pd_rev > PD_MAX_REV) {
+ chip->supported_pd_rev = PD_MAX_REV;
+ }
+
enable_irq_wake(chip->gpio_int_n_irq);
i2c_set_clientdata(client, chip);
--
2.17.1
next prev parent reply other threads:[~2022-02-08 8:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 8:20 [PATCH 0/2] Add a interface for passing supported PD rev from TCPC Potin Lai
2022-02-08 8:20 ` [PATCH 1/2] usb: typec: tcpm: add interface for passing supported_pd_rev from tcpc_dev Potin Lai
2022-02-08 8:41 ` Greg Kroah-Hartman
2022-02-08 8:20 ` Potin Lai [this message]
2022-02-08 11:22 ` [PATCH v2 0/2] Add a interface for passing supported PD rev from TCPC Potin Lai
2022-02-08 11:22 ` [PATCH v2 1/2] usb: typec: tcpm: add interface for passing supported_pd_rev from tcpc_dev Potin Lai
2022-02-08 15:25 ` Guenter Roeck
2022-02-08 16:41 ` kernel test robot
2022-02-09 6:53 ` kernel test robot
2022-02-08 11:22 ` [PATCH v2 2/2] usb: typec: fusb302: add support of supported_pd_rev Potin Lai
2022-02-08 15:22 ` Guenter Roeck
2022-02-09 3:34 ` Potin Lai
2022-02-09 17:50 ` Guenter Roeck
2022-02-11 8:35 ` Potin Lai (賴柏廷)
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=20220208082026.4855-3-potin.lai@quantatw.com \
--to=potin.lai@quantatw.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=patrick@stwcx.xyz \
/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
all inboxes | Powered by JetHome®