From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: Adding tps65986 to your tps6598x driver
Date: Wed, 22 Apr 2020 16:44:05 +0300 [thread overview]
Message-ID: <20200422134405.GD618654@kuha.fi.intel.com> (raw)
In-Reply-To: <20200422132533.GC618654@kuha.fi.intel.com>
[-- Attachment #1: Type: text/plain, Size: 248 bytes --]
On Wed, Apr 22, 2020 at 04:25:36PM +0300, Heikki Krogerus wrote:
> I'm attaching a diff that has all the changes that you should need to
> do to the tps6598x.c in order to get the role swapping working on your
> board.
Trying again...
--
heikki
[-- Attachment #2: role_switch_for_tps6598x.diff --]
[-- Type: text/plain, Size: 2580 bytes --]
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 0698addd1185..5f51397f0007 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/interrupt.h>
+#include <linux/usb/role.h>
#include <linux/usb/typec.h>
/* Register offsets */
@@ -94,6 +95,8 @@ struct tps6598x {
struct typec_port *port;
struct typec_partner *partner;
struct usb_pd_identity partner_identity;
+
+ struct usb_role_switch *role_sw;
};
/*
@@ -175,6 +178,18 @@ tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
return tps6598x_block_write(tps, reg, val, 4);
}
+static int tps6598x_set_data_role(struct tps6598x *tps,
+ enum typec_data_role role)
+{
+ enum usb_role usb_role;
+
+ usb_role = role == TYPEC_HOST ? USB_ROLE_HOST : USB_ROLE_DEVICE;
+
+ typec_set_data_role(tps->port, role);
+
+ return usb_role_switch_set_role(tps->role_sw, usb_role);
+}
+
static int tps6598x_read_partner_identity(struct tps6598x *tps)
{
struct tps6598x_rx_identity_reg id;
@@ -220,7 +235,7 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status)
typec_set_pwr_opmode(tps->port, mode);
typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
- typec_set_data_role(tps->port, TPS_STATUS_DATAROLE(status));
+ tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status));
tps->partner = typec_register_partner(tps->port, &desc);
if (IS_ERR(tps->partner))
@@ -241,6 +256,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status)
typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
typec_set_data_role(tps->port, TPS_STATUS_DATAROLE(status));
+ usb_role_switch_set_role(tps->role_sw, USB_ROLE_NONE);
}
static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd,
@@ -328,7 +344,7 @@ static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role)
goto out_unlock;
}
- typec_set_data_role(tps->port, role);
+ ret = tps6598x_set_data_role(tps, role);
out_unlock:
mutex_unlock(&tps->lock);
@@ -472,6 +488,10 @@ static int tps6598x_probe(struct i2c_client *client)
if (ret < 0 || !vid)
return -ENODEV;
+ tps->role_sw = usb_role_switch_get(&client->dev);
+ if (IS_ERR(tps->role_sw))
+ return PTR_ERR(tps->role_sw);
+
/*
* Checking can the adapter handle SMBus protocol. If it can not, the
* driver needs to take care of block reads separately.
next prev parent reply other threads:[~2020-04-22 13:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d4a9214a-7a55-72ea-75b9-8388bc39d0dd@linaro.org>
[not found] ` <20200414151505.GK2828150@kuha.fi.intel.com>
[not found] ` <d64d7b21-4f03-05e8-e0db-aa8c75ba847e@linaro.org>
2020-04-22 13:25 ` Adding tps65986 to your tps6598x driver Heikki Krogerus
2020-04-22 13:44 ` Heikki Krogerus [this message]
2020-04-22 14:50 ` Bryan O'Donoghue
2020-04-29 14:03 ` Heikki Krogerus
2020-04-29 17:04 ` Bryan O'Donoghue
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=20200422134405.GD618654@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=bryan.odonoghue@linaro.org \
--cc=linux-usb@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.