diff mbox series

[v9,02/15] usb: typec: tcpci: Add set_vbus tcpci callback

Message ID 20200929024004.244992-3-badhri@google.com
State Superseded
Headers show
Series TCPM support for FRS and AutoDischarge Disconnect | expand

Commit Message

Badhri Jagan Sridharan Sept. 29, 2020, 2:39 a.m. UTC
set_vbus callback allows TCPC which are TCPCI based, however,
does not support turning on sink and source mode through
Command.SinkVbus and Command.SourceVbusDefaultVoltage.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
Changes since v1:
- Changing patch version to v6 to fix version number confusion.

Changes since v6:
- Rebase on usb-next

Changes since v7:
- Added Reviewed-by: Heikki
- Rebase change

Change since v8:
- None
---
 drivers/usb/typec/tcpm/tcpci.c | 7 +++++++
 drivers/usb/typec/tcpm/tcpci.h | 1 +
 2 files changed, 8 insertions(+)

Comments

Badhri Jagan Sridharan Oct. 2, 2020, 4:08 p.m. UTC | #1
Hi Greg,

Yes I tested it on usb-next before sending it out.

  630 |  tcpci->tcpc.enable_frs = tcpci_enable_frs;

In https://patchwork.kernel.org/project/linux-usb/list/?series=356837
i.e v9 version of this series,
Patch 7 i.e. https://patchwork.kernel.org/patch/11804847/ is where the
above line is added.

I restested in combinations [1]  [2] [3] [4]. All of them were clear
cherry-picks. I didnt any merge conflicts.

Maybe you are applying patches in a different order ?
If so can you post the git log for me to apply in the same order and test ?

Or Do you want me to rebase on top of usb-testing ?
I didnt see any merge conflicts though.

Thanks,
Badhri


[1] usb-testing all patches in series
https://patchwork.kernel.org/project/linux-usb/list/?series=356837
07684bb88ed4 (HEAD -> usb-testing) usb: typec: tcpci_maxim: Enable
auto discharge disconnect
1c97f5e32ba6 usb: typec: tcpci: Implement Auto discharge disconnect callbacks
1b829a062e6e usb: typec: tcpm: Implement enabling Auto Discharge
disconnect support
7ba4edfd9155 usb: typec: tcpm: Parse frs type-c current from device tree
01d47f2e98ba usb: typec: tcpci_max77759: Fix vbus stuck on upon
diconnecting sink
9e8ed3d8809c usb: typec: tcpci: frs sourcing vbus callback
8804a3f75563 usb: typec: tcpm: frs sourcing vbus callback
69fe6c1c7648 usb: typec: tcpci_maxim: Add support for Sink FRS
0a22d446c026 usb: typec: tcpci: Implement callbacks for FRS
93c622006aa6 usb: typec: tcpm: Add support for Sink Fast Role SWAP(FRS)
14672081f2fd dt-bindings: connector: Add property to set initial
current cap for FRS
58372bd1d8e8 usb: typec: tcpci_maxim: Chip level TCPC driver
c16b09eaf60f dt-bindings: usb: Maxim type-c controller device tree
binding document
32d66c0449e1 usb: typec: tcpci: Add set_vbus tcpci callback
85e90e5054d6 usb: typec: tcpci: Add a getter method to retrieve
tcpm_port reference
97b65223c18f (origin/usb-testing) USB: core: remove polling for
/sys/kernel/debug/usb/devices
da0cb6310094 usb: typec: add support for STUSB160x Type-C controller family

[2] usb-testing: till patch4 in series
https://patchwork.kernel.org/project/linux-usb/list/?series=356837
58372bd1d8e8 (HEAD -> usb-testing) usb: typec: tcpci_maxim: Chip level
TCPC driver
c16b09eaf60f dt-bindings: usb: Maxim type-c controller device tree
binding document
32d66c0449e1 usb: typec: tcpci: Add set_vbus tcpci callback
85e90e5054d6 usb: typec: tcpci: Add a getter method to retrieve
tcpm_port reference
97b65223c18f (origin/usb-testing) USB: core: remove polling for
/sys/kernel/debug/usb/devices
da0cb6310094 usb: typec: add support for STUSB160x Type-C controller family

[3] usb-next all patches in series
https://patchwork.kernel.org/project/linux-usb/list/?series=356837
62b5171538da (HEAD -> usb-next) usb: typec: tcpci_maxim: Enable auto
discharge disconnect
ea8987805ba6 usb: typec: tcpci: Implement Auto discharge disconnect callbacks
af9a12b19352 usb: typec: tcpm: Implement enabling Auto Discharge
disconnect support
33aec604a529 usb: typec: tcpm: Parse frs type-c current from device tree
31df45f3df20 usb: typec: tcpci_max77759: Fix vbus stuck on upon
diconnecting sink
0945795f170d usb: typec: tcpci: frs sourcing vbus callback
c49080982064 usb: typec: tcpm: frs sourcing vbus callback
67a3ff254cc1 usb: typec: tcpci_maxim: Add support for Sink FRS
299582bbf78f usb: typec: tcpci: Implement callbacks for FRS
bb4eb3fb65df usb: typec: tcpm: Add support for Sink Fast Role SWAP(FRS)
5aad64e80460 dt-bindings: connector: Add property to set initial
current cap for FRS
6c59a16ddee2 usb: typec: tcpci_maxim: Chip level TCPC driver
172274d3e327 dt-bindings: usb: Maxim type-c controller device tree
binding document
bdba308a7164 usb: typec: tcpci: Add set_vbus tcpci callback
66b7b0d83399 usb: typec: tcpci: Add a getter method to retrieve
tcpm_port reference
59ee364bafb2 (origin/usb-next) Merge tag 'thunderbolt-for-v5.10-rc1'
of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt
into usb-next
bf1c67449833 USB: cdc-acm: clean up no-union-descriptor handling

[4] usb-next till patch4 in series
https://patchwork.kernel.org/project/linux-usb/list/?series=356837
6c59a16ddee2 (HEAD -> usb-next) usb: typec: tcpci_maxim: Chip level TCPC driver
172274d3e327 dt-bindings: usb: Maxim type-c controller device tree
binding document
bdba308a7164 usb: typec: tcpci: Add set_vbus tcpci callback
66b7b0d83399 usb: typec: tcpci: Add a getter method to retrieve
tcpm_port reference
59ee364bafb2 (origin/usb-next) Merge tag 'thunderbolt-for-v5.10-rc1'
of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt
into usb-next
bf1c67449833 USB: cdc-acm: clean up no-union-descriptor handling


On Fri, Oct 2, 2020 at 6:40 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>

> On Fri, Oct 02, 2020 at 03:39:52PM +0200, Greg Kroah-Hartman wrote:

> > On Mon, Sep 28, 2020 at 07:39:51PM -0700, Badhri Jagan Sridharan wrote:

> > > set_vbus callback allows TCPC which are TCPCI based, however,

> > > does not support turning on sink and source mode through

> > > Command.SinkVbus and Command.SourceVbusDefaultVoltage.

> > >

> > > Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

> > > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> >

> > This patch breaks the build, are you sure you tested it?

>

> Sorry, not this patch, patch 4:

>

> drivers/usb/typec/tcpm/tcpci.c: In function ‘tcpci_register_port’:

> drivers/usb/typec/tcpm/tcpci.c:630:13: error: ‘struct tcpc_dev’ has no member named ‘enable_frs’

>   630 |  tcpci->tcpc.enable_frs = tcpci_enable_frs;

>       |             ^

>

>

> thanks,

>

> greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index b960fe5a0f28..d6a6fac82d48 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -328,6 +328,13 @@  static int tcpci_set_vbus(struct tcpc_dev *tcpc, bool source, bool sink)
 	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
 	int ret;
 
+	if (tcpci->data->set_vbus) {
+		ret = tcpci->data->set_vbus(tcpci, tcpci->data, source, sink);
+		/* Bypass when ret > 0 */
+		if (ret != 0)
+			return ret < 0 ? ret : 0;
+	}
+
 	/* Disable both source and sink first before enabling anything */
 
 	if (!source) {
diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h
index 04c49a0b0368..4d441bdf24d5 100644
--- a/drivers/usb/typec/tcpm/tcpci.h
+++ b/drivers/usb/typec/tcpm/tcpci.h
@@ -144,6 +144,7 @@  struct tcpci_data {
 			 bool enable);
 	int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data,
 				  enum typec_cc_status cc);
+	int (*set_vbus)(struct tcpci *tcpci, struct tcpci_data *data, bool source, bool sink);
 };
 
 struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);