All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 00/15] staging: typec: tcpci: move out of staging
@ 2018-05-28  2:52 Li Jun
  2018-05-28  2:52   ` [v6,01/15] " Jun Li
                   ` (15 more replies)
  0 siblings, 16 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

This patch set attempts to move the tcpci drivers out of staging by fix
some tcpci driver issues and define typec and power delivery device
properties, the changes are verified on NXP PTN5110, which is a standard
tcpci typec port controller device with power delivery support, tested
power source and sink with drp config.

Changes for v6:
- Change function name to be typec_find_port_power/data_role for find
  capability, and typec_find_power_role for find one specific power role.
- Fix rt1711h driver move missing.
- Add one patch to improve the error checking in tcpci driver, use IS_ERR()
  instead of PTR_ERR_OR_ZERO().
- Add Rob's Reviewed-by for patch [2/15].
- Misc typos fix.
 
Changes for v5:
- Use "power-role" and "data-role" for typec port power and data capability
  property name.  
- Use macro defintion instead of cryptic numbers for readability of
  power delivery properties(PDO).
- Add one tcpci driver binding string to be "nxp,ptn5110" to follow binding
  name rule "<vendor prefix>,<device>".
- Change operating power property name to be op-sink-microwatt.
- Add one patch(remove unused tcpci_tcpc_config) to resolve bisectablitity
  issue of patch usb: typec: add fwnode to tcpc.
- A minor error handling change to keep the error path and success path
  separate in patch: register port before request irq
- Rebase to latest Greg's tree with max_snk_* removed.

Changes for v4:
- Remove max-sink-* properties as we will purge max_snk_* in tcpm,
  see patch set[4].
- Get typec power and data type value via name string(patch 5).
- Move finding typec and pd properties code from tcpci to tcpm(patch 6)
- Add a compatible string for nxp ptn5110 typec controller in tcpci driver.
  (patch 3)
- Add set cc for drp toggling without try.src/snk in tcpm(patch 10), then
  patch 11 can only update CCx bits for keep disconnect cc line open.
- Update op-sink-microwatt-hours example value to be the right value in
  micorwatts, and accordingly divide 1000 to get its miliwatts value
  in patch 6.
- Add Guenter's Reviewed-by for patch(8/9/12)

[4] https://www.spinics.net/lists/linux-usb/msg167261.html

Changes for v3:
- Use 2 properties to separate power and data capability of typec port:
  "power-type" and "data-type", this is based on Heikki's typec class code
  change[2]. use "try-power-role" to present if the typec port can support
  Try.SNK or Try.SRC.
- 4 sink properties(max_sink_mv/ma/mw and op_sink_mw) are kept because the
  counterpart code is back, see revert patch[3], meanwhile I post a patch
  to fix the reported problem of current source pdo select machinism(which
  completely ignored those 4 sink settings), to see if we can keep current
  code, once it was discussed and have conclusion I can update this
  accordingly.
- Use fwnode to get the connector node for dt setting parse.

Main changes for v2:
- Typec properties are based on general usb connector bindings[1] proposed
  by Andrzej Hajda, use the standard unit suffixes as defined in
  property-units.txt.
- Add 2 infra APIs to get power sink and source config from dt.
- Don't change the set_cc api, to keep the uncontacted cc line open,
  set cc1/cc2 to be open in tcpci driver when set polarity.
- Directly enable vbus detect in tcpci driver rather than add a API.
- Details added in each patch.

[1] https://patchwork.kernel.org/patch/10231447/
[2] https://patchwork.kernel.org/patch/10276483/
[3] https://www.spinics.net/lists/linux-usb/msg166366.html

Li Jun (14):
  dt-bindings: connector: add properties for typec
  dt-bindings: usb: add documentation for typec port controller(TCPCI)
  staging: typec: tcpci: add compatible string for nxp ptn5110
  usb: typec: add fwnode to tcpc
  usb: typec: add API to get typec basic port power and data config
  usb: typec: tcpm: support get typec and pd config from device
    properties
  staging: typec: tcpci: remove unused tcpci_tcpc_config
  staging: typec: tcpci: use IS_ERR() instead of PTR_ERR_OR_ZERO()
  staging: typec: tcpci: enable vbus detection
  typec: tcpm: add starting value for drp toggling
  usb: typec: tcpm: set cc for drp toggling attach
  staging: typec: tcpci: keep the disconnected cc line open
  staging: typec: tcpci: Only touch target bit when enable vconn
  staging: typec: tcpci: move tcpci drivers out of staging

Peter Chen (1):
  staging: typec: tcpci: register port before request irq

 .../bindings/connector/usb-connector.txt           |  44 ++++++
 .../devicetree/bindings/usb/typec-tcpci.txt        |  49 +++++++
 drivers/staging/Kconfig                            |   2 -
 drivers/staging/Makefile                           |   1 -
 drivers/staging/typec/Kconfig                      |  22 ---
 drivers/staging/typec/Makefile                     |   2 -
 drivers/staging/typec/TODO                         |   5 -
 drivers/usb/typec/Kconfig                          |  15 +++
 drivers/usb/typec/Makefile                         |   2 +
 drivers/usb/typec/class.c                          |  50 +++++++
 drivers/{staging => usb}/typec/tcpci.c             |  66 +++++----
 drivers/{staging => usb}/typec/tcpci.h             |   0
 drivers/{staging => usb}/typec/tcpci_rt1711h.c     |   0
 drivers/usb/typec/tcpm.c                           | 148 +++++++++++++++++----
 include/dt-bindings/usb/pd.h                       |  62 +++++++++
 include/linux/usb/tcpm.h                           |   2 +
 include/linux/usb/typec.h                          |   3 +
 17 files changed, 389 insertions(+), 84 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/typec-tcpci.txt
 delete mode 100644 drivers/staging/typec/Kconfig
 delete mode 100644 drivers/staging/typec/Makefile
 delete mode 100644 drivers/staging/typec/TODO
 rename drivers/{staging => usb}/typec/tcpci.c (92%)
 rename drivers/{staging => usb}/typec/tcpci.h (100%)
 rename drivers/{staging => usb}/typec/tcpci_rt1711h.c (100%)
 create mode 100644 include/dt-bindings/usb/pd.h

-- 
2.7.4


^ permalink raw reply	[flat|nested] 75+ messages in thread

* [PATCH v6 01/15] dt-bindings: connector: add properties for typec
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Add bindings supported by current typec driver, so user can pass
all those properties via dt.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 .../bindings/connector/usb-connector.txt           | 44 +++++++++++++++
 include/dt-bindings/usb/pd.h                       | 62 ++++++++++++++++++++++
 2 files changed, 106 insertions(+)

diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt b/Documentation/devicetree/bindings/connector/usb-connector.txt
index e1463f1..8855bfc 100644
--- a/Documentation/devicetree/bindings/connector/usb-connector.txt
+++ b/Documentation/devicetree/bindings/connector/usb-connector.txt
@@ -15,6 +15,33 @@ Optional properties:
 - type: size of the connector, should be specified in case of USB-A, USB-B
   non-fullsize connectors: "mini", "micro".
 
+Optional properties for usb-c-connector:
+- power-role: should be one of "source", "sink" or "dual"(DRP) if typec
+  connector has power support.
+- try-power-role: preferred power role if "dual"(DRP) can support Try.SNK
+  or Try.SRC, should be "sink" for Try.SNK or "source" for Try.SRC.
+- data-role: should be one of "host", "device", "dual"(DRD) if typec
+  connector supports USB data.
+
+Required properties for usb-c-connector with power delivery support:
+- source-pdos: An array of u32 with each entry providing supported power
+  source data object(PDO), the detailed bit definitions of PDO can be found
+  in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.2
+  Source_Capabilities Message, the order of each entry(PDO) should follow
+  the PD spec chapter 6.4.1. Required for power source and power dual role.
+  User can specify the source PDO array via PDO_FIXED/BATT/VAR() defined in
+  dt-bindings/usb/pd.h.
+- sink-pdos: An array of u32 with each entry providing supported power
+  sink data object(PDO), the detailed bit definitions of PDO can be found
+  in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.3
+  Sink Capabilities Message, the order of each entry(PDO) should follow
+  the PD spec chapter 6.4.1. Required for power sink and power dual role.
+  User can specify the sink PDO array via PDO_FIXED/BATT/VAR() defined in
+  dt-bindings/usb/pd.h.
+- op-sink-microwatt: Sink required operating power in microwatt, if source
+  can't offer the power, Capability Mismatch is set. Required for power
+  sink and power dual role.
+
 Required nodes:
 - any data bus to the connector should be modeled using the OF graph bindings
   specified in bindings/graph.txt, unless the bus is between parent node and
@@ -73,3 +100,20 @@ ccic: s2mm005@33 {
 		};
 	};
 };
+
+3. USB-C connector attached to a typec port controller(ptn5110), which has
+power delivery support and enables drp.
+
+typec: ptn5110@50 {
+	...
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+		power-role = "dual";
+		try-power-role = "sink";
+		source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>;
+		sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)
+			     PDO_VAR(5000, 12000, 2000)>;
+		op-sink-microwatt = <10000000>;
+	};
+};
diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
new file mode 100644
index 0000000..7b7a92f
--- /dev/null
+++ b/include/dt-bindings/usb/pd.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __DT_POWER_DELIVERY_H
+#define __DT_POWER_DELIVERY_H
+
+/* Power delivery Power Data Object definitions */
+#define PDO_TYPE_FIXED		0
+#define PDO_TYPE_BATT		1
+#define PDO_TYPE_VAR		2
+#define PDO_TYPE_APDO		3
+
+#define PDO_TYPE_SHIFT		30
+#define PDO_TYPE_MASK		0x3
+
+#define PDO_TYPE(t)	((t) << PDO_TYPE_SHIFT)
+
+#define PDO_VOLT_MASK		0x3ff
+#define PDO_CURR_MASK		0x3ff
+#define PDO_PWR_MASK		0x3ff
+
+#define PDO_FIXED_DUAL_ROLE	(1 << 29) /* Power role swap supported */
+#define PDO_FIXED_SUSPEND	(1 << 28) /* USB Suspend supported (Source) */
+#define PDO_FIXED_HIGHER_CAP	(1 << 28) /* Requires more than vSafe5V (Sink) */
+#define PDO_FIXED_EXTPOWER	(1 << 27) /* Externally powered */
+#define PDO_FIXED_USB_COMM	(1 << 26) /* USB communications capable */
+#define PDO_FIXED_DATA_SWAP	(1 << 25) /* Data role swap supported */
+#define PDO_FIXED_VOLT_SHIFT	10	/* 50mV units */
+#define PDO_FIXED_CURR_SHIFT	0	/* 10mA units */
+
+#define PDO_FIXED_VOLT(mv)	((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT)
+#define PDO_FIXED_CURR(ma)	((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT)
+
+#define PDO_FIXED(mv, ma, flags)			\
+	(PDO_TYPE(PDO_TYPE_FIXED) | (flags) |		\
+	 PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma))
+
+#define VSAFE5V 5000 /* mv units */
+
+#define PDO_BATT_MAX_VOLT_SHIFT	20	/* 50mV units */
+#define PDO_BATT_MIN_VOLT_SHIFT	10	/* 50mV units */
+#define PDO_BATT_MAX_PWR_SHIFT	0	/* 250mW units */
+
+#define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT)
+#define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT)
+#define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT)
+
+#define PDO_BATT(min_mv, max_mv, max_mw)			\
+	(PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) |	\
+	 PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw))
+
+#define PDO_VAR_MAX_VOLT_SHIFT	20	/* 50mV units */
+#define PDO_VAR_MIN_VOLT_SHIFT	10	/* 50mV units */
+#define PDO_VAR_MAX_CURR_SHIFT	0	/* 10mA units */
+
+#define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT)
+#define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT)
+#define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT)
+
+#define PDO_VAR(min_mv, max_mv, max_ma)				\
+	(PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) |	\
+	 PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma))
+
+ #endif /* __DT_POWER_DELIVERY_H */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,01/15] dt-bindings: connector: add properties for typec
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Add bindings supported by current typec driver, so user can pass
all those properties via dt.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 .../bindings/connector/usb-connector.txt           | 44 +++++++++++++++
 include/dt-bindings/usb/pd.h                       | 62 ++++++++++++++++++++++
 2 files changed, 106 insertions(+)

diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt b/Documentation/devicetree/bindings/connector/usb-connector.txt
index e1463f1..8855bfc 100644
--- a/Documentation/devicetree/bindings/connector/usb-connector.txt
+++ b/Documentation/devicetree/bindings/connector/usb-connector.txt
@@ -15,6 +15,33 @@ Optional properties:
 - type: size of the connector, should be specified in case of USB-A, USB-B
   non-fullsize connectors: "mini", "micro".
 
+Optional properties for usb-c-connector:
+- power-role: should be one of "source", "sink" or "dual"(DRP) if typec
+  connector has power support.
+- try-power-role: preferred power role if "dual"(DRP) can support Try.SNK
+  or Try.SRC, should be "sink" for Try.SNK or "source" for Try.SRC.
+- data-role: should be one of "host", "device", "dual"(DRD) if typec
+  connector supports USB data.
+
+Required properties for usb-c-connector with power delivery support:
+- source-pdos: An array of u32 with each entry providing supported power
+  source data object(PDO), the detailed bit definitions of PDO can be found
+  in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.2
+  Source_Capabilities Message, the order of each entry(PDO) should follow
+  the PD spec chapter 6.4.1. Required for power source and power dual role.
+  User can specify the source PDO array via PDO_FIXED/BATT/VAR() defined in
+  dt-bindings/usb/pd.h.
+- sink-pdos: An array of u32 with each entry providing supported power
+  sink data object(PDO), the detailed bit definitions of PDO can be found
+  in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.3
+  Sink Capabilities Message, the order of each entry(PDO) should follow
+  the PD spec chapter 6.4.1. Required for power sink and power dual role.
+  User can specify the sink PDO array via PDO_FIXED/BATT/VAR() defined in
+  dt-bindings/usb/pd.h.
+- op-sink-microwatt: Sink required operating power in microwatt, if source
+  can't offer the power, Capability Mismatch is set. Required for power
+  sink and power dual role.
+
 Required nodes:
 - any data bus to the connector should be modeled using the OF graph bindings
   specified in bindings/graph.txt, unless the bus is between parent node and
@@ -73,3 +100,20 @@ ccic: s2mm005@33 {
 		};
 	};
 };
+
+3. USB-C connector attached to a typec port controller(ptn5110), which has
+power delivery support and enables drp.
+
+typec: ptn5110@50 {
+	...
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+		power-role = "dual";
+		try-power-role = "sink";
+		source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>;
+		sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)
+			     PDO_VAR(5000, 12000, 2000)>;
+		op-sink-microwatt = <10000000>;
+	};
+};
diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
new file mode 100644
index 0000000..7b7a92f
--- /dev/null
+++ b/include/dt-bindings/usb/pd.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __DT_POWER_DELIVERY_H
+#define __DT_POWER_DELIVERY_H
+
+/* Power delivery Power Data Object definitions */
+#define PDO_TYPE_FIXED		0
+#define PDO_TYPE_BATT		1
+#define PDO_TYPE_VAR		2
+#define PDO_TYPE_APDO		3
+
+#define PDO_TYPE_SHIFT		30
+#define PDO_TYPE_MASK		0x3
+
+#define PDO_TYPE(t)	((t) << PDO_TYPE_SHIFT)
+
+#define PDO_VOLT_MASK		0x3ff
+#define PDO_CURR_MASK		0x3ff
+#define PDO_PWR_MASK		0x3ff
+
+#define PDO_FIXED_DUAL_ROLE	(1 << 29) /* Power role swap supported */
+#define PDO_FIXED_SUSPEND	(1 << 28) /* USB Suspend supported (Source) */
+#define PDO_FIXED_HIGHER_CAP	(1 << 28) /* Requires more than vSafe5V (Sink) */
+#define PDO_FIXED_EXTPOWER	(1 << 27) /* Externally powered */
+#define PDO_FIXED_USB_COMM	(1 << 26) /* USB communications capable */
+#define PDO_FIXED_DATA_SWAP	(1 << 25) /* Data role swap supported */
+#define PDO_FIXED_VOLT_SHIFT	10	/* 50mV units */
+#define PDO_FIXED_CURR_SHIFT	0	/* 10mA units */
+
+#define PDO_FIXED_VOLT(mv)	((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT)
+#define PDO_FIXED_CURR(ma)	((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT)
+
+#define PDO_FIXED(mv, ma, flags)			\
+	(PDO_TYPE(PDO_TYPE_FIXED) | (flags) |		\
+	 PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma))
+
+#define VSAFE5V 5000 /* mv units */
+
+#define PDO_BATT_MAX_VOLT_SHIFT	20	/* 50mV units */
+#define PDO_BATT_MIN_VOLT_SHIFT	10	/* 50mV units */
+#define PDO_BATT_MAX_PWR_SHIFT	0	/* 250mW units */
+
+#define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT)
+#define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT)
+#define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT)
+
+#define PDO_BATT(min_mv, max_mv, max_mw)			\
+	(PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) |	\
+	 PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw))
+
+#define PDO_VAR_MAX_VOLT_SHIFT	20	/* 50mV units */
+#define PDO_VAR_MIN_VOLT_SHIFT	10	/* 50mV units */
+#define PDO_VAR_MAX_CURR_SHIFT	0	/* 10mA units */
+
+#define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT)
+#define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT)
+#define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT)
+
+#define PDO_VAR(min_mv, max_mv, max_ma)				\
+	(PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) |	\
+	 PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma))
+
+ #endif /* __DT_POWER_DELIVERY_H */

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 02/15] dt-bindings: usb: add documentation for typec port controller(TCPCI)
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

TCPCI stands for typec port controller interface, its implementation
has full typec port control with power delivery support, it's a
standard i2c slave with GPIO input as irq interface, detail see spec
"Universal Serial Bus Type-C Port Controller Interface Specification
Revision 1.0, Version 1.1"

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 .../devicetree/bindings/usb/typec-tcpci.txt        | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/typec-tcpci.txt b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
new file mode 100644
index 0000000..0dd1469
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
@@ -0,0 +1,49 @@
+TCPCI(Typec port cotroller interface) binding
+---------------------------------------------
+
+Required properties:
+- compatible:       should be set one of following:
+		    - "nxp,ptn5110" for NXP USB PD TCPC PHY IC ptn5110.
+
+- reg:              the i2c slave address of typec port controller device.
+- interrupt-parent: the phandle to the interrupt controller which provides
+                    the interrupt.
+- interrupts:       interrupt specification for tcpci alert.
+
+Required sub-node:
+- connector: The "usb-c-connector" attached to the tcpci chip, the bindings
+  of connector node are specified in
+  Documentation/devicetree/bindings/connector/usb-connector.txt
+
+Example:
+
+ptn5110@50 {
+	compatible = "nxp,ptn5110";
+	reg = <0x50>;
+	interrupt-parent = <&gpio3>;
+	interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+		data-role = "dual";
+		power-role = "dual";
+		try-power-role = "sink";
+		source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>;
+		sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)
+			     PDO_VAR(5000, 12000, 2000)>;
+		op-sink-microwatt = <10000000>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@1 {
+				reg = <1>;
+				usb_con_ss: endpoint {
+					remote-endpoint = <&usb3_data_ss>;
+				};
+			};
+		};
+	};
+};
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,02/15] dt-bindings: usb: add documentation for typec port controller(TCPCI)
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

TCPCI stands for typec port controller interface, its implementation
has full typec port control with power delivery support, it's a
standard i2c slave with GPIO input as irq interface, detail see spec
"Universal Serial Bus Type-C Port Controller Interface Specification
Revision 1.0, Version 1.1"

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 .../devicetree/bindings/usb/typec-tcpci.txt        | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/typec-tcpci.txt b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
new file mode 100644
index 0000000..0dd1469
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/typec-tcpci.txt
@@ -0,0 +1,49 @@
+TCPCI(Typec port cotroller interface) binding
+---------------------------------------------
+
+Required properties:
+- compatible:       should be set one of following:
+		    - "nxp,ptn5110" for NXP USB PD TCPC PHY IC ptn5110.
+
+- reg:              the i2c slave address of typec port controller device.
+- interrupt-parent: the phandle to the interrupt controller which provides
+                    the interrupt.
+- interrupts:       interrupt specification for tcpci alert.
+
+Required sub-node:
+- connector: The "usb-c-connector" attached to the tcpci chip, the bindings
+  of connector node are specified in
+  Documentation/devicetree/bindings/connector/usb-connector.txt
+
+Example:
+
+ptn5110@50 {
+	compatible = "nxp,ptn5110";
+	reg = <0x50>;
+	interrupt-parent = <&gpio3>;
+	interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+		data-role = "dual";
+		power-role = "dual";
+		try-power-role = "sink";
+		source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>;
+		sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)
+			     PDO_VAR(5000, 12000, 2000)>;
+		op-sink-microwatt = <10000000>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@1 {
+				reg = <1>;
+				usb_con_ss: endpoint {
+					remote-endpoint = <&usb3_data_ss>;
+				};
+			};
+		};
+	};
+};

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 03/15] staging: typec: tcpci: add compatible string for nxp ptn5110
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Add nxp ptn5110 typec controller compatible string: "nxp,ptn5110",
which is a standard tcpci chip with power delivery support. Meanwhile
remove "usb,tcpci" because it doesn't follow the binding format rule
and has not been used yet.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 076d97e..dd29288 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -575,7 +575,7 @@ MODULE_DEVICE_TABLE(i2c, tcpci_id);
 
 #ifdef CONFIG_OF
 static const struct of_device_id tcpci_of_match[] = {
-	{ .compatible = "usb,tcpci", },
+	{ .compatible = "nxp,ptn5110", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, tcpci_of_match);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,03/15] staging: typec: tcpci: add compatible string for nxp ptn5110
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Add nxp ptn5110 typec controller compatible string: "nxp,ptn5110",
which is a standard tcpci chip with power delivery support. Meanwhile
remove "usb,tcpci" because it doesn't follow the binding format rule
and has not been used yet.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 076d97e..dd29288 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -575,7 +575,7 @@ MODULE_DEVICE_TABLE(i2c, tcpci_id);
 
 #ifdef CONFIG_OF
 static const struct of_device_id tcpci_of_match[] = {
-	{ .compatible = "usb,tcpci", },
+	{ .compatible = "nxp,ptn5110", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, tcpci_of_match);

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 04/15] usb: typec: add fwnode to tcpc
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Add fwnode handle to get the fwnode so we can get typec configs
it contains.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 7 +++++++
 drivers/usb/typec/tcpm.c      | 1 +
 include/linux/usb/tcpm.h      | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index dd29288..e59547a 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/usb/pd.h>
 #include <linux/usb/tcpm.h>
@@ -474,6 +475,12 @@ static int tcpci_parse_config(struct tcpci *tcpci)
 
 	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
 	tcpci->tcpc.config = &tcpci_tcpc_config;
+	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
+							 "connector");
+	if (!tcpci->tcpc.fwnode) {
+		dev_err(tcpci->dev, "Can't find connector node.\n");
+		return -EINVAL;
+	}
 
 	return 0;
 }
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 0ccd2ce..fcd22e8 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -4581,6 +4581,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	else
 		port->try_role = TYPEC_NO_PREFERRED_ROLE;
 
+	port->typec_caps.fwnode = tcpc->fwnode;
 	port->typec_caps.prefer_role = tcpc->config->default_role;
 	port->typec_caps.type = tcpc->config->type;
 	port->typec_caps.data = tcpc->config->data;
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
index b231b93..193920a 100644
--- a/include/linux/usb/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -110,6 +110,7 @@ enum tcpc_mux_mode {
 /**
  * struct tcpc_dev - Port configuration and callback functions
  * @config:	Pointer to port configuration
+ * @fwnode:	Pointer to port fwnode
  * @get_vbus:	Called to read current VBUS state
  * @get_current_limit:
  *		Optional; called by the tcpm core when configured as a snk
@@ -138,6 +139,7 @@ enum tcpc_mux_mode {
  */
 struct tcpc_dev {
 	const struct tcpc_config *config;
+	struct fwnode_handle *fwnode;
 
 	int (*init)(struct tcpc_dev *dev);
 	int (*get_vbus)(struct tcpc_dev *dev);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,04/15] usb: typec: add fwnode to tcpc
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Add fwnode handle to get the fwnode so we can get typec configs
it contains.

Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 7 +++++++
 drivers/usb/typec/tcpm.c      | 1 +
 include/linux/usb/tcpm.h      | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index dd29288..e59547a 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/usb/pd.h>
 #include <linux/usb/tcpm.h>
@@ -474,6 +475,12 @@ static int tcpci_parse_config(struct tcpci *tcpci)
 
 	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
 	tcpci->tcpc.config = &tcpci_tcpc_config;
+	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
+							 "connector");
+	if (!tcpci->tcpc.fwnode) {
+		dev_err(tcpci->dev, "Can't find connector node.\n");
+		return -EINVAL;
+	}
 
 	return 0;
 }
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 0ccd2ce..fcd22e8 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -4581,6 +4581,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	else
 		port->try_role = TYPEC_NO_PREFERRED_ROLE;
 
+	port->typec_caps.fwnode = tcpc->fwnode;
 	port->typec_caps.prefer_role = tcpc->config->default_role;
 	port->typec_caps.type = tcpc->config->type;
 	port->typec_caps.data = tcpc->config->data;
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
index b231b93..193920a 100644
--- a/include/linux/usb/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -110,6 +110,7 @@ enum tcpc_mux_mode {
 /**
  * struct tcpc_dev - Port configuration and callback functions
  * @config:	Pointer to port configuration
+ * @fwnode:	Pointer to port fwnode
  * @get_vbus:	Called to read current VBUS state
  * @get_current_limit:
  *		Optional; called by the tcpm core when configured as a snk
@@ -138,6 +139,7 @@ enum tcpc_mux_mode {
  */
 struct tcpc_dev {
 	const struct tcpc_config *config;
+	struct fwnode_handle *fwnode;
 
 	int (*init)(struct tcpc_dev *dev);
 	int (*get_vbus)(struct tcpc_dev *dev);

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

This patch adds 3 APIs to get the typec port power and data type,
and preferred power role by its name string.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/class.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/typec.h |  3 +++
 2 files changed, 53 insertions(+)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 53df10d..4c7d18c 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -802,6 +802,12 @@ static const char * const typec_port_types[] = {
 	[TYPEC_PORT_DRP] = "dual",
 };
 
+static const char * const typec_data_caps[] = {
+	[TYPEC_PORT_DFP] = "host",
+	[TYPEC_PORT_UFP] = "device",
+	[TYPEC_PORT_DRD] = "dual",
+};
+
 static const char * const typec_port_types_drp[] = {
 	[TYPEC_PORT_SRC] = "dual [source] sink",
 	[TYPEC_PORT_SNK] = "dual source [sink]",
@@ -1252,6 +1258,50 @@ void typec_set_pwr_opmode(struct typec_port *port,
 }
 EXPORT_SYMBOL_GPL(typec_set_pwr_opmode);
 
+/**
+ * typec_find_port_power_role - Get the typec port power capability
+ * @name: port power capability string
+ *
+ * This routine is used to find the typec_port_type by its string name.
+ *
+ * Returns typec_port_type if success, otherwise negative error code.
+ */
+int typec_find_port_power_role(const char *name)
+{
+	return match_string(typec_port_types, ARRAY_SIZE(typec_port_types),
+			    name);
+}
+EXPORT_SYMBOL_GPL(typec_find_power_type);
+
+/**
+ * typec_find_power_role - Find the typec one specific power role
+ * @name: power role string
+ *
+ * This routine is used to find the typec_role by its string name.
+ *
+ * Returns typec_role if success, otherwise negative error code.
+ */
+int typec_find_power_role(const char *name)
+{
+	return match_string(typec_roles, ARRAY_SIZE(typec_roles), name);
+}
+EXPORT_SYMBOL_GPL(typec_find_preferred_role);
+
+/**
+ * typec_find_port_data_role - Get the typec port data capability
+ * @name: port data capability string
+ *
+ * This routine is used to find the typec_port_data by its string name.
+ *
+ * Returns typec_port_data if success, otherwise negative error code.
+ */
+int typec_find_port_data_role(const char *name)
+{
+	return match_string(typec_data_caps, ARRAY_SIZE(typec_data_caps),
+			    name);
+}
+EXPORT_SYMBOL_GPL(typec_find_data_type);
+
 /* ------------------------------------------ */
 /* API for Multiplexer/DeMultiplexer Switches */
 
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 672b39b..15f8d9a 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -267,4 +267,7 @@ int typec_set_orientation(struct typec_port *port,
 			  enum typec_orientation orientation);
 int typec_set_mode(struct typec_port *port, int mode);
 
+int typec_find_port_power_role(const char *name);
+int typec_find_power_role(const char *name);
+int typec_find_port_data_role(const char *name);
 #endif /* __LINUX_USB_TYPEC_H */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

This patch adds 3 APIs to get the typec port power and data type,
and preferred power role by its name string.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/class.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/typec.h |  3 +++
 2 files changed, 53 insertions(+)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 53df10d..4c7d18c 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -802,6 +802,12 @@ static const char * const typec_port_types[] = {
 	[TYPEC_PORT_DRP] = "dual",
 };
 
+static const char * const typec_data_caps[] = {
+	[TYPEC_PORT_DFP] = "host",
+	[TYPEC_PORT_UFP] = "device",
+	[TYPEC_PORT_DRD] = "dual",
+};
+
 static const char * const typec_port_types_drp[] = {
 	[TYPEC_PORT_SRC] = "dual [source] sink",
 	[TYPEC_PORT_SNK] = "dual source [sink]",
@@ -1252,6 +1258,50 @@ void typec_set_pwr_opmode(struct typec_port *port,
 }
 EXPORT_SYMBOL_GPL(typec_set_pwr_opmode);
 
+/**
+ * typec_find_port_power_role - Get the typec port power capability
+ * @name: port power capability string
+ *
+ * This routine is used to find the typec_port_type by its string name.
+ *
+ * Returns typec_port_type if success, otherwise negative error code.
+ */
+int typec_find_port_power_role(const char *name)
+{
+	return match_string(typec_port_types, ARRAY_SIZE(typec_port_types),
+			    name);
+}
+EXPORT_SYMBOL_GPL(typec_find_power_type);
+
+/**
+ * typec_find_power_role - Find the typec one specific power role
+ * @name: power role string
+ *
+ * This routine is used to find the typec_role by its string name.
+ *
+ * Returns typec_role if success, otherwise negative error code.
+ */
+int typec_find_power_role(const char *name)
+{
+	return match_string(typec_roles, ARRAY_SIZE(typec_roles), name);
+}
+EXPORT_SYMBOL_GPL(typec_find_preferred_role);
+
+/**
+ * typec_find_port_data_role - Get the typec port data capability
+ * @name: port data capability string
+ *
+ * This routine is used to find the typec_port_data by its string name.
+ *
+ * Returns typec_port_data if success, otherwise negative error code.
+ */
+int typec_find_port_data_role(const char *name)
+{
+	return match_string(typec_data_caps, ARRAY_SIZE(typec_data_caps),
+			    name);
+}
+EXPORT_SYMBOL_GPL(typec_find_data_type);
+
 /* ------------------------------------------ */
 /* API for Multiplexer/DeMultiplexer Switches */
 
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 672b39b..15f8d9a 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -267,4 +267,7 @@ int typec_set_orientation(struct typec_port *port,
 			  enum typec_orientation orientation);
 int typec_set_mode(struct typec_port *port, int mode);
 
+int typec_find_port_power_role(const char *name);
+int typec_find_power_role(const char *name);
+int typec_find_port_data_role(const char *name);
 #endif /* __LINUX_USB_TYPEC_H */

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 06/15] usb: typec: tcpm: support get typec and pd config from device properties
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

This patch adds support of get typec and power delivery config from
firmware description.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm.c | 132 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 110 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index fcd22e8..aa17cd5 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -4241,6 +4241,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
 	return nr_vdo;
 }
 
+static int tcpm_fw_get_caps(struct tcpm_port *port,
+			    struct fwnode_handle *fwnode)
+{
+	const char *cap_str;
+	int ret;
+	u32 mw;
+
+	if (!port || !fwnode)
+		return -EINVAL;
+
+	/* USB data support is optional */
+	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
+	if (ret == 0) {
+		port->typec_caps.data = typec_find_port_data_role(cap_str);
+		if (port->typec_caps.data < 0)
+			return -EINVAL;
+	}
+
+	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
+	if (ret < 0)
+		return ret;
+
+	port->typec_caps.type = typec_find_port_power_role(cap_str);
+	if (port->typec_caps.type < 0)
+		return -EINVAL;
+	port->port_type = port->typec_caps.type;
+
+	if (port->port_type == TYPEC_PORT_SNK)
+		goto sink;
+
+	/* Get soruce pdos */
+	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
+					     NULL, 0);
+	if (ret <= 0)
+		return -EINVAL;
+
+	port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
+	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
+					     port->src_pdo, port->nr_src_pdo);
+	if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo,
+					    port->nr_src_pdo))
+		return -EINVAL;
+
+	if (port->port_type == TYPEC_PORT_SRC)
+		return 0;
+
+	/* Get the preferred power role for DRP */
+	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
+	if (ret < 0)
+		return ret;
+
+	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
+	if (port->typec_caps.prefer_role < 0)
+		return -EINVAL;
+sink:
+	/* Get sink pdos */
+	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
+					     NULL, 0);
+	if (ret <= 0)
+		return -EINVAL;
+
+	port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
+	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
+					     port->snk_pdo, port->nr_snk_pdo);
+	if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo,
+					    port->nr_snk_pdo))
+		return -EINVAL;
+
+	if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0)
+		return -EINVAL;
+	port->operating_snk_mw = mw / 1000;
+
+	return 0;
+}
+
 int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
 				    unsigned int nr_pdo)
 {
@@ -4526,12 +4601,36 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
 	return PTR_ERR_OR_ZERO(port->psy);
 }
 
+static int tcpm_copy_caps(struct tcpm_port *port,
+			  const struct tcpc_config *tcfg)
+{
+	if (tcpm_validate_caps(port, tcfg->src_pdo, tcfg->nr_src_pdo) ||
+	    tcpm_validate_caps(port, tcfg->snk_pdo, tcfg->nr_snk_pdo))
+		return -EINVAL;
+
+	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcfg->src_pdo,
+					  tcfg->nr_src_pdo);
+	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcfg->snk_pdo,
+					  tcfg->nr_snk_pdo);
+
+	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcfg->snk_vdo,
+					  tcfg->nr_snk_vdo);
+
+	port->operating_snk_mw = tcfg->operating_snk_mw;
+
+	port->typec_caps.prefer_role = tcfg->default_role;
+	port->typec_caps.type = tcfg->type;
+	port->typec_caps.data = tcfg->data;
+
+	return 0;
+}
+
 struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 {
 	struct tcpm_port *port;
 	int i, err;
 
-	if (!dev || !tcpc || !tcpc->config ||
+	if (!dev || !tcpc ||
 	    !tcpc->get_vbus || !tcpc->set_cc || !tcpc->get_cc ||
 	    !tcpc->set_polarity || !tcpc->set_vconn || !tcpc->set_vbus ||
 	    !tcpc->set_pd_rx || !tcpc->set_roles || !tcpc->pd_transmit)
@@ -4561,30 +4660,19 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	init_completion(&port->pps_complete);
 	tcpm_debugfs_init(port);
 
-	if (tcpm_validate_caps(port, tcpc->config->src_pdo,
-			       tcpc->config->nr_src_pdo) ||
-	    tcpm_validate_caps(port, tcpc->config->snk_pdo,
-			       tcpc->config->nr_snk_pdo)) {
-		err = -EINVAL;
+	if (tcpc->config)
+		err = tcpm_copy_caps(port, tcpc->config);
+	else
+		err = tcpm_fw_get_caps(port, tcpc->fwnode);
+	if (err < 0)
 		goto out_destroy_wq;
-	}
-	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcpc->config->src_pdo,
-					  tcpc->config->nr_src_pdo);
-	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo,
-					  tcpc->config->nr_snk_pdo);
-	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo,
-					  tcpc->config->nr_snk_vdo);
-
-	port->operating_snk_mw = tcpc->config->operating_snk_mw;
-	if (!tcpc->config->try_role_hw)
-		port->try_role = tcpc->config->default_role;
+
+	if (!tcpc->config || !tcpc->config->try_role_hw)
+		port->try_role = port->typec_caps.prefer_role;
 	else
 		port->try_role = TYPEC_NO_PREFERRED_ROLE;
 
 	port->typec_caps.fwnode = tcpc->fwnode;
-	port->typec_caps.prefer_role = tcpc->config->default_role;
-	port->typec_caps.type = tcpc->config->type;
-	port->typec_caps.data = tcpc->config->data;
 	port->typec_caps.revision = 0x0120;	/* Type-C spec release 1.2 */
 	port->typec_caps.pd_revision = 0x0300;	/* USB-PD spec release 3.0 */
 	port->typec_caps.dr_set = tcpm_dr_set;
@@ -4594,7 +4682,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->typec_caps.port_type_set = tcpm_port_type_set;
 
 	port->partner_desc.identity = &port->partner_ident;
-	port->port_type = tcpc->config->type;
+	port->port_type = port->typec_caps.type;
 
 	port->role_sw = usb_role_switch_get(port->dev);
 	if (IS_ERR(port->role_sw)) {
@@ -4612,7 +4700,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 		goto out_destroy_wq;
 	}
 
-	if (tcpc->config->alt_modes) {
+	if (tcpc->config && tcpc->config->alt_modes) {
 		const struct typec_altmode_desc *paltmode = tcpc->config->alt_modes;
 
 		i = 0;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,06/15] usb: typec: tcpm: support get typec and pd config from device properties
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

This patch adds support of get typec and power delivery config from
firmware description.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm.c | 132 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 110 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index fcd22e8..aa17cd5 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -4241,6 +4241,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
 	return nr_vdo;
 }
 
+static int tcpm_fw_get_caps(struct tcpm_port *port,
+			    struct fwnode_handle *fwnode)
+{
+	const char *cap_str;
+	int ret;
+	u32 mw;
+
+	if (!port || !fwnode)
+		return -EINVAL;
+
+	/* USB data support is optional */
+	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
+	if (ret == 0) {
+		port->typec_caps.data = typec_find_port_data_role(cap_str);
+		if (port->typec_caps.data < 0)
+			return -EINVAL;
+	}
+
+	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
+	if (ret < 0)
+		return ret;
+
+	port->typec_caps.type = typec_find_port_power_role(cap_str);
+	if (port->typec_caps.type < 0)
+		return -EINVAL;
+	port->port_type = port->typec_caps.type;
+
+	if (port->port_type == TYPEC_PORT_SNK)
+		goto sink;
+
+	/* Get soruce pdos */
+	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
+					     NULL, 0);
+	if (ret <= 0)
+		return -EINVAL;
+
+	port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
+	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
+					     port->src_pdo, port->nr_src_pdo);
+	if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo,
+					    port->nr_src_pdo))
+		return -EINVAL;
+
+	if (port->port_type == TYPEC_PORT_SRC)
+		return 0;
+
+	/* Get the preferred power role for DRP */
+	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
+	if (ret < 0)
+		return ret;
+
+	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
+	if (port->typec_caps.prefer_role < 0)
+		return -EINVAL;
+sink:
+	/* Get sink pdos */
+	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
+					     NULL, 0);
+	if (ret <= 0)
+		return -EINVAL;
+
+	port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
+	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
+					     port->snk_pdo, port->nr_snk_pdo);
+	if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo,
+					    port->nr_snk_pdo))
+		return -EINVAL;
+
+	if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0)
+		return -EINVAL;
+	port->operating_snk_mw = mw / 1000;
+
+	return 0;
+}
+
 int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
 				    unsigned int nr_pdo)
 {
@@ -4526,12 +4601,36 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
 	return PTR_ERR_OR_ZERO(port->psy);
 }
 
+static int tcpm_copy_caps(struct tcpm_port *port,
+			  const struct tcpc_config *tcfg)
+{
+	if (tcpm_validate_caps(port, tcfg->src_pdo, tcfg->nr_src_pdo) ||
+	    tcpm_validate_caps(port, tcfg->snk_pdo, tcfg->nr_snk_pdo))
+		return -EINVAL;
+
+	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcfg->src_pdo,
+					  tcfg->nr_src_pdo);
+	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcfg->snk_pdo,
+					  tcfg->nr_snk_pdo);
+
+	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcfg->snk_vdo,
+					  tcfg->nr_snk_vdo);
+
+	port->operating_snk_mw = tcfg->operating_snk_mw;
+
+	port->typec_caps.prefer_role = tcfg->default_role;
+	port->typec_caps.type = tcfg->type;
+	port->typec_caps.data = tcfg->data;
+
+	return 0;
+}
+
 struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 {
 	struct tcpm_port *port;
 	int i, err;
 
-	if (!dev || !tcpc || !tcpc->config ||
+	if (!dev || !tcpc ||
 	    !tcpc->get_vbus || !tcpc->set_cc || !tcpc->get_cc ||
 	    !tcpc->set_polarity || !tcpc->set_vconn || !tcpc->set_vbus ||
 	    !tcpc->set_pd_rx || !tcpc->set_roles || !tcpc->pd_transmit)
@@ -4561,30 +4660,19 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	init_completion(&port->pps_complete);
 	tcpm_debugfs_init(port);
 
-	if (tcpm_validate_caps(port, tcpc->config->src_pdo,
-			       tcpc->config->nr_src_pdo) ||
-	    tcpm_validate_caps(port, tcpc->config->snk_pdo,
-			       tcpc->config->nr_snk_pdo)) {
-		err = -EINVAL;
+	if (tcpc->config)
+		err = tcpm_copy_caps(port, tcpc->config);
+	else
+		err = tcpm_fw_get_caps(port, tcpc->fwnode);
+	if (err < 0)
 		goto out_destroy_wq;
-	}
-	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcpc->config->src_pdo,
-					  tcpc->config->nr_src_pdo);
-	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo,
-					  tcpc->config->nr_snk_pdo);
-	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo,
-					  tcpc->config->nr_snk_vdo);
-
-	port->operating_snk_mw = tcpc->config->operating_snk_mw;
-	if (!tcpc->config->try_role_hw)
-		port->try_role = tcpc->config->default_role;
+
+	if (!tcpc->config || !tcpc->config->try_role_hw)
+		port->try_role = port->typec_caps.prefer_role;
 	else
 		port->try_role = TYPEC_NO_PREFERRED_ROLE;
 
 	port->typec_caps.fwnode = tcpc->fwnode;
-	port->typec_caps.prefer_role = tcpc->config->default_role;
-	port->typec_caps.type = tcpc->config->type;
-	port->typec_caps.data = tcpc->config->data;
 	port->typec_caps.revision = 0x0120;	/* Type-C spec release 1.2 */
 	port->typec_caps.pd_revision = 0x0300;	/* USB-PD spec release 3.0 */
 	port->typec_caps.dr_set = tcpm_dr_set;
@@ -4594,7 +4682,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->typec_caps.port_type_set = tcpm_port_type_set;
 
 	port->partner_desc.identity = &port->partner_ident;
-	port->port_type = tcpc->config->type;
+	port->port_type = port->typec_caps.type;
 
 	port->role_sw = usb_role_switch_get(port->dev);
 	if (IS_ERR(port->role_sw)) {
@@ -4612,7 +4700,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 		goto out_destroy_wq;
 	}
 
-	if (tcpc->config->alt_modes) {
+	if (tcpc->config && tcpc->config->alt_modes) {
 		const struct typec_altmode_desc *paltmode = tcpc->config->alt_modes;
 
 		i = 0;

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 07/15] staging: typec: tcpci: remove unused tcpci_tcpc_config
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Since we will use config settings via device properties, so
remove the hard code tcpci_tcpc_config.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index e59547a..076498a 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -464,17 +464,10 @@ static const struct regmap_config tcpci_regmap_config = {
 	.max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */
 };
 
-static const struct tcpc_config tcpci_tcpc_config = {
-	.type = TYPEC_PORT_DFP,
-	.default_role = TYPEC_SINK,
-};
-
 static int tcpci_parse_config(struct tcpci *tcpci)
 {
 	tcpci->controls_vbus = true; /* XXX */
 
-	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
-	tcpci->tcpc.config = &tcpci_tcpc_config;
 	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
 							 "connector");
 	if (!tcpci->tcpc.fwnode) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,07/15] staging: typec: tcpci: remove unused tcpci_tcpc_config
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Since we will use config settings via device properties, so
remove the hard code tcpci_tcpc_config.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index e59547a..076498a 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -464,17 +464,10 @@ static const struct regmap_config tcpci_regmap_config = {
 	.max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */
 };
 
-static const struct tcpc_config tcpci_tcpc_config = {
-	.type = TYPEC_PORT_DFP,
-	.default_role = TYPEC_SINK,
-};
-
 static int tcpci_parse_config(struct tcpci *tcpci)
 {
 	tcpci->controls_vbus = true; /* XXX */
 
-	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
-	tcpci->tcpc.config = &tcpci_tcpc_config;
 	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
 							 "connector");
 	if (!tcpci->tcpc.fwnode) {

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 08/15] staging: typec: tcpci: use IS_ERR() instead of PTR_ERR_OR_ZERO()
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

As tcpm_register_port() and tcpci_register_port() never return
NULL and NULL is not a success in this case, use IS_ERR() to check
the return value of both.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 076498a..b63f147 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -509,7 +509,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
 		return ERR_PTR(err);
 
 	tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc);
-	if (PTR_ERR_OR_ZERO(tcpci->port))
+	if (IS_ERR(tcpci->port))
 		return ERR_CAST(tcpci->port);
 
 	return tcpci;
@@ -551,7 +551,7 @@ static int tcpci_probe(struct i2c_client *client,
 		return err;
 
 	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
-	if (PTR_ERR_OR_ZERO(chip->tcpci))
+	if (IS_ERR(chip->tcpci))
 		return PTR_ERR(chip->tcpci);
 
 	i2c_set_clientdata(client, chip);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,08/15] staging: typec: tcpci: use IS_ERR() instead of PTR_ERR_OR_ZERO()
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

As tcpm_register_port() and tcpci_register_port() never return
NULL and NULL is not a success in this case, use IS_ERR() to check
the return value of both.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 076498a..b63f147 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -509,7 +509,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
 		return ERR_PTR(err);
 
 	tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc);
-	if (PTR_ERR_OR_ZERO(tcpci->port))
+	if (IS_ERR(tcpci->port))
 		return ERR_CAST(tcpci->port);
 
 	return tcpci;
@@ -551,7 +551,7 @@ static int tcpci_probe(struct i2c_client *client,
 		return err;
 
 	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
-	if (PTR_ERR_OR_ZERO(chip->tcpci))
+	if (IS_ERR(chip->tcpci))
 		return PTR_ERR(chip->tcpci);
 
 	i2c_set_clientdata(client, chip);

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 09/15] staging: typec: tcpci: register port before request irq
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

From: Peter Chen <peter.chen@nxp.com>

With that we can clear any pending events and the port is registered
so driver can be ready to handle typec events once we request irq.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index b63f147..3b35fce 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -537,24 +537,27 @@ static int tcpci_probe(struct i2c_client *client,
 	if (IS_ERR(chip->data.regmap))
 		return PTR_ERR(chip->data.regmap);
 
+	i2c_set_clientdata(client, chip);
+
 	/* Disable chip interrupts before requesting irq */
 	err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val,
 			       sizeof(u16));
 	if (err < 0)
 		return err;
 
+	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
+	if (IS_ERR(chip->tcpci))
+		return PTR_ERR(chip->tcpci);
+
 	err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
 					_tcpci_irq,
 					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
 					dev_name(&client->dev), chip);
-	if (err < 0)
+	if (err < 0) {
+		tcpci_unregister_port(chip->tcpci);
 		return err;
+	}
 
-	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
-	if (IS_ERR(chip->tcpci))
-		return PTR_ERR(chip->tcpci);
-
-	i2c_set_clientdata(client, chip);
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,09/15] staging: typec: tcpci: register port before request irq
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

From: Peter Chen <peter.chen@nxp.com>

With that we can clear any pending events and the port is registered
so driver can be ready to handle typec events once we request irq.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index b63f147..3b35fce 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -537,24 +537,27 @@ static int tcpci_probe(struct i2c_client *client,
 	if (IS_ERR(chip->data.regmap))
 		return PTR_ERR(chip->data.regmap);
 
+	i2c_set_clientdata(client, chip);
+
 	/* Disable chip interrupts before requesting irq */
 	err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val,
 			       sizeof(u16));
 	if (err < 0)
 		return err;
 
+	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
+	if (IS_ERR(chip->tcpci))
+		return PTR_ERR(chip->tcpci);
+
 	err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
 					_tcpci_irq,
 					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
 					dev_name(&client->dev), chip);
-	if (err < 0)
+	if (err < 0) {
+		tcpci_unregister_port(chip->tcpci);
 		return err;
+	}
 
-	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
-	if (IS_ERR(chip->tcpci))
-		return PTR_ERR(chip->tcpci);
-
-	i2c_set_clientdata(client, chip);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 10/15] staging: typec: tcpci: enable vbus detection
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

TCPCI implementation may need SW to enable VBUS detection to generate
power status events.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 3b35fce..4d3b0ae 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -373,6 +373,12 @@ static int tcpci_init(struct tcpc_dev *tcpc)
 	if (ret < 0)
 		return ret;
 
+	/* Enable Vbus detection */
+	ret = regmap_write(tcpci->regmap, TCPC_COMMAND,
+			   TCPC_CMD_ENABLE_VBUS_DETECT);
+	if (ret < 0)
+		return ret;
+
 	reg = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_FAILED |
 		TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_RX_STATUS |
 		TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,10/15] staging: typec: tcpci: enable vbus detection
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

TCPCI implementation may need SW to enable VBUS detection to generate
power status events.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 3b35fce..4d3b0ae 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -373,6 +373,12 @@ static int tcpci_init(struct tcpc_dev *tcpc)
 	if (ret < 0)
 		return ret;
 
+	/* Enable Vbus detection */
+	ret = regmap_write(tcpci->regmap, TCPC_COMMAND,
+			   TCPC_CMD_ENABLE_VBUS_DETECT);
+	if (ret < 0)
+		return ret;
+
 	reg = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_FAILED |
 		TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_RX_STATUS |
 		TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS;

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 11/15] typec: tcpm: add starting value for drp toggling
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

As DRP port autonomously toggles the Rp/Rd need a start value to
begin with, so add one parameter for it in tcpm_start_drp_toggling.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index aa17cd5..d885bff 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -2436,15 +2436,15 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
 	return 0;
 }
 
-static bool tcpm_start_drp_toggling(struct tcpm_port *port)
+static bool tcpm_start_drp_toggling(struct tcpm_port *port,
+				    enum typec_cc_status cc)
 {
 	int ret;
 
 	if (port->tcpc->start_drp_toggling &&
 	    port->port_type == TYPEC_PORT_DRP) {
 		tcpm_log_force(port, "Start DRP toggling");
-		ret = port->tcpc->start_drp_toggling(port->tcpc,
-						     tcpm_rp_cc(port));
+		ret = port->tcpc->start_drp_toggling(port->tcpc, cc);
 		if (!ret)
 			return true;
 	}
@@ -2752,7 +2752,7 @@ static void run_state_machine(struct tcpm_port *port)
 		if (!port->non_pd_role_swap)
 			tcpm_swap_complete(port, -ENOTCONN);
 		tcpm_src_detach(port);
-		if (tcpm_start_drp_toggling(port)) {
+		if (tcpm_start_drp_toggling(port, tcpm_rp_cc(port))) {
 			tcpm_set_state(port, DRP_TOGGLING, 0);
 			break;
 		}
@@ -2927,7 +2927,7 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_swap_complete(port, -ENOTCONN);
 		tcpm_pps_complete(port, -ENOTCONN);
 		tcpm_snk_detach(port);
-		if (tcpm_start_drp_toggling(port)) {
+		if (tcpm_start_drp_toggling(port, TYPEC_CC_RD)) {
 			tcpm_set_state(port, DRP_TOGGLING, 0);
 			break;
 		}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,11/15] typec: tcpm: add starting value for drp toggling
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

As DRP port autonomously toggles the Rp/Rd need a start value to
begin with, so add one parameter for it in tcpm_start_drp_toggling.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index aa17cd5..d885bff 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -2436,15 +2436,15 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
 	return 0;
 }
 
-static bool tcpm_start_drp_toggling(struct tcpm_port *port)
+static bool tcpm_start_drp_toggling(struct tcpm_port *port,
+				    enum typec_cc_status cc)
 {
 	int ret;
 
 	if (port->tcpc->start_drp_toggling &&
 	    port->port_type == TYPEC_PORT_DRP) {
 		tcpm_log_force(port, "Start DRP toggling");
-		ret = port->tcpc->start_drp_toggling(port->tcpc,
-						     tcpm_rp_cc(port));
+		ret = port->tcpc->start_drp_toggling(port->tcpc, cc);
 		if (!ret)
 			return true;
 	}
@@ -2752,7 +2752,7 @@ static void run_state_machine(struct tcpm_port *port)
 		if (!port->non_pd_role_swap)
 			tcpm_swap_complete(port, -ENOTCONN);
 		tcpm_src_detach(port);
-		if (tcpm_start_drp_toggling(port)) {
+		if (tcpm_start_drp_toggling(port, tcpm_rp_cc(port))) {
 			tcpm_set_state(port, DRP_TOGGLING, 0);
 			break;
 		}
@@ -2927,7 +2927,7 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_swap_complete(port, -ENOTCONN);
 		tcpm_pps_complete(port, -ENOTCONN);
 		tcpm_snk_detach(port);
-		if (tcpm_start_drp_toggling(port)) {
+		if (tcpm_start_drp_toggling(port, TYPEC_CC_RD)) {
 			tcpm_set_state(port, DRP_TOGGLING, 0);
 			break;
 		}

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

In case of drp toggling, we may need set correct cc value for role control
after attach as it may never been set.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index d885bff..98ea916 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	tcpm_set_attached_state(port, false);
 	port->try_src_count = 0;
 	port->try_snk_count = 0;
+	port->cc_req = TYPEC_CC_OPEN;
 	port->supply_voltage = 0;
 	port->current_limit = 0;
 	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
@@ -2831,6 +2832,8 @@ static void run_state_machine(struct tcpm_port *port)
 		break;
 
 	case SRC_ATTACHED:
+		if (port->cc_req == TYPEC_CC_OPEN)
+			tcpm_set_cc(port, tcpm_rp_cc(port));
 		ret = tcpm_src_attach(port);
 		tcpm_set_state(port, SRC_UNATTACHED,
 			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
@@ -3004,6 +3007,8 @@ static void run_state_machine(struct tcpm_port *port)
 		tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE);
 		break;
 	case SNK_ATTACHED:
+		if (port->cc_req == TYPEC_CC_OPEN)
+			tcpm_set_cc(port, TYPEC_CC_RD);
 		ret = tcpm_snk_attach(port);
 		if (ret < 0)
 			tcpm_set_state(port, SNK_UNATTACHED, 0);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

In case of drp toggling, we may need set correct cc value for role control
after attach as it may never been set.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index d885bff..98ea916 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	tcpm_set_attached_state(port, false);
 	port->try_src_count = 0;
 	port->try_snk_count = 0;
+	port->cc_req = TYPEC_CC_OPEN;
 	port->supply_voltage = 0;
 	port->current_limit = 0;
 	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
@@ -2831,6 +2832,8 @@ static void run_state_machine(struct tcpm_port *port)
 		break;
 
 	case SRC_ATTACHED:
+		if (port->cc_req == TYPEC_CC_OPEN)
+			tcpm_set_cc(port, tcpm_rp_cc(port));
 		ret = tcpm_src_attach(port);
 		tcpm_set_state(port, SRC_UNATTACHED,
 			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
@@ -3004,6 +3007,8 @@ static void run_state_machine(struct tcpm_port *port)
 		tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE);
 		break;
 	case SNK_ATTACHED:
+		if (port->cc_req == TYPEC_CC_OPEN)
+			tcpm_set_cc(port, TYPEC_CC_RD);
 		ret = tcpm_snk_attach(port);
 		if (ret < 0)
 			tcpm_set_state(port, SNK_UNATTACHED, 0);

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 13/15] staging: typec: tcpci: keep the disconnected cc line open
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

While set polarity, we should keep the disconnected cc line to be
open.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 4d3b0ae..11c2d37 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -185,15 +185,25 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
 			      enum typec_cc_polarity polarity)
 {
 	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
+	unsigned int reg;
 	int ret;
 
-	ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
-			   (polarity == TYPEC_POLARITY_CC2) ?
-			   TCPC_TCPC_CTRL_ORIENTATION : 0);
+	/* Keep the disconnect cc line open */
+	ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &reg);
 	if (ret < 0)
 		return ret;
 
-	return 0;
+	if (polarity == TYPEC_POLARITY_CC2)
+		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT;
+	else
+		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT;
+	ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
+	if (ret < 0)
+		return ret;
+
+	return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
+			   (polarity == TYPEC_POLARITY_CC2) ?
+			   TCPC_TCPC_CTRL_ORIENTATION : 0);
 }
 
 static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,13/15] staging: typec: tcpci: keep the disconnected cc line open
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

While set polarity, we should keep the disconnected cc line to be
open.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 4d3b0ae..11c2d37 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -185,15 +185,25 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
 			      enum typec_cc_polarity polarity)
 {
 	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
+	unsigned int reg;
 	int ret;
 
-	ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
-			   (polarity == TYPEC_POLARITY_CC2) ?
-			   TCPC_TCPC_CTRL_ORIENTATION : 0);
+	/* Keep the disconnect cc line open */
+	ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &reg);
 	if (ret < 0)
 		return ret;
 
-	return 0;
+	if (polarity == TYPEC_POLARITY_CC2)
+		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT;
+	else
+		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT;
+	ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
+	if (ret < 0)
+		return ret;
+
+	return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
+			   (polarity == TYPEC_POLARITY_CC2) ?
+			   TCPC_TCPC_CTRL_ORIENTATION : 0);
 }
 
 static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 14/15] staging: typec: tcpci: Only touch target bit when enable vconn
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

We need regmap_update_bits to avoid touch any other bits when
enable or disable vconn.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 11c2d37..ac6b418 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -218,12 +218,9 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
 			return ret;
 	}
 
-	ret = regmap_write(tcpci->regmap, TCPC_POWER_CTRL,
-			   enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return regmap_update_bits(tcpci->regmap, TCPC_POWER_CTRL,
+				TCPC_POWER_CTRL_VCONN_ENABLE,
+				enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
 }
 
 static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,14/15] staging: typec: tcpci: Only touch target bit when enable vconn
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

We need regmap_update_bits to avoid touch any other bits when
enable or disable vconn.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/typec/tcpci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 11c2d37..ac6b418 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -218,12 +218,9 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
 			return ret;
 	}
 
-	ret = regmap_write(tcpci->regmap, TCPC_POWER_CTRL,
-			   enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return regmap_update_bits(tcpci->regmap, TCPC_POWER_CTRL,
+				TCPC_POWER_CTRL_VCONN_ENABLE,
+				enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
 }
 
 static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached,

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [PATCH v6 15/15] staging: typec: tcpci: move tcpci drivers out of staging
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Li Jun @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Move TCPCI(Typec port controller interface) driver and rt1711h
driver out of staging.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/Kconfig                        |  2 --
 drivers/staging/Makefile                       |  1 -
 drivers/staging/typec/Kconfig                  | 22 ----------------------
 drivers/staging/typec/Makefile                 |  2 --
 drivers/staging/typec/TODO                     |  5 -----
 drivers/usb/typec/Kconfig                      | 15 +++++++++++++++
 drivers/usb/typec/Makefile                     |  2 ++
 drivers/{staging => usb}/typec/tcpci.c         |  0
 drivers/{staging => usb}/typec/tcpci.h         |  0
 drivers/{staging => usb}/typec/tcpci_rt1711h.c |  0
 10 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index d5926f0..d83ff66 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -112,8 +112,6 @@ source "drivers/staging/greybus/Kconfig"
 
 source "drivers/staging/vc04_services/Kconfig"
 
-source "drivers/staging/typec/Kconfig"
-
 source "drivers/staging/vboxvideo/Kconfig"
 
 source "drivers/staging/pi433/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 919753c..a71ec1f 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -2,7 +2,6 @@
 # Makefile for staging directory
 
 obj-y				+= media/
-obj-y				+= typec/
 obj-$(CONFIG_IPX)		+= ipx/
 obj-$(CONFIG_NCP_FS)		+= ncpfs/
 obj-$(CONFIG_PRISM2_USB)	+= wlan-ng/
diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig
deleted file mode 100644
index 3aa981f..0000000
--- a/drivers/staging/typec/Kconfig
+++ /dev/null
@@ -1,22 +0,0 @@
-menu "USB Power Delivery and Type-C drivers"
-
-if TYPEC_TCPM
-
-config TYPEC_TCPCI
-	tristate "Type-C Port Controller Interface driver"
-	depends on I2C
-	select REGMAP_I2C
-	help
-	  Type-C Port Controller driver for TCPCI-compliant controller.
-
-config TYPEC_RT1711H
-	tristate "Richtek RT1711H Type-C chip driver"
-	select TYPEC_TCPCI
-	help
-	  Richtek RT1711H Type-C chip driver that works with
-	  Type-C Port Controller Manager to provide USB PD and USB
-	  Type-C functionalities.
-
-endif
-
-endmenu
diff --git a/drivers/staging/typec/Makefile b/drivers/staging/typec/Makefile
deleted file mode 100644
index 7803d48..0000000
--- a/drivers/staging/typec/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-$(CONFIG_TYPEC_TCPCI)	+= tcpci.o
-obj-$(CONFIG_TYPEC_RT1711H)	+= tcpci_rt1711h.o
diff --git a/drivers/staging/typec/TODO b/drivers/staging/typec/TODO
deleted file mode 100644
index 53fe2f7..0000000
--- a/drivers/staging/typec/TODO
+++ /dev/null
@@ -1,5 +0,0 @@
-tcpci:
-- Test with real hardware
-
-Please send patches to Guenter Roeck <linux@roeck-us.net> and copy
-Heikki Krogerus <heikki.krogerus@linux.intel.com>.
diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 2c8eab1..972fd19 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -56,6 +56,21 @@ config TYPEC_TCPM
 
 if TYPEC_TCPM
 
+config TYPEC_TCPCI
+	tristate "Type-C Port Controller Interface driver"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Type-C Port Controller driver for TCPCI-compliant controller.
+
+config TYPEC_RT1711H
+	tristate "Richtek RT1711H Type-C chip driver"
+	select TYPEC_TCPCI
+	help
+	  Richtek RT1711H Type-C chip driver that works with
+	  Type-C Port Controller Manager to provide USB PD and USB
+	  Type-C functionalities.
+
 source "drivers/usb/typec/fusb302/Kconfig"
 
 config TYPEC_WCOVE
diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index 1f599a6..46f86ee 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -7,3 +7,5 @@ obj-$(CONFIG_TYPEC_WCOVE)	+= typec_wcove.o
 obj-$(CONFIG_TYPEC_UCSI)	+= ucsi/
 obj-$(CONFIG_TYPEC_TPS6598X)	+= tps6598x.o
 obj-$(CONFIG_TYPEC)		+= mux/
+obj-$(CONFIG_TYPEC_TCPCI)	+= tcpci.o
+obj-$(CONFIG_TYPEC_RT1711H)	+= tcpci_rt1711h.o
diff --git a/drivers/staging/typec/tcpci.c b/drivers/usb/typec/tcpci.c
similarity index 100%
rename from drivers/staging/typec/tcpci.c
rename to drivers/usb/typec/tcpci.c
diff --git a/drivers/staging/typec/tcpci.h b/drivers/usb/typec/tcpci.h
similarity index 100%
rename from drivers/staging/typec/tcpci.h
rename to drivers/usb/typec/tcpci.h
diff --git a/drivers/staging/typec/tcpci_rt1711h.c b/drivers/usb/typec/tcpci_rt1711h.c
similarity index 100%
rename from drivers/staging/typec/tcpci_rt1711h.c
rename to drivers/usb/typec/tcpci_rt1711h.c
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,15/15] staging: typec: tcpci: move tcpci drivers out of staging
@ 2018-05-28  2:52   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-28  2:52 UTC (permalink / raw)
  To: robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	jun.li, linux-usb, devicetree, linux-imx

Move TCPCI(Typec port controller interface) driver and rt1711h
driver out of staging.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/staging/Kconfig                        |  2 --
 drivers/staging/Makefile                       |  1 -
 drivers/staging/typec/Kconfig                  | 22 ----------------------
 drivers/staging/typec/Makefile                 |  2 --
 drivers/staging/typec/TODO                     |  5 -----
 drivers/usb/typec/Kconfig                      | 15 +++++++++++++++
 drivers/usb/typec/Makefile                     |  2 ++
 drivers/{staging => usb}/typec/tcpci.c         |  0
 drivers/{staging => usb}/typec/tcpci.h         |  0
 drivers/{staging => usb}/typec/tcpci_rt1711h.c |  0
 10 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index d5926f0..d83ff66 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -112,8 +112,6 @@ source "drivers/staging/greybus/Kconfig"
 
 source "drivers/staging/vc04_services/Kconfig"
 
-source "drivers/staging/typec/Kconfig"
-
 source "drivers/staging/vboxvideo/Kconfig"
 
 source "drivers/staging/pi433/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 919753c..a71ec1f 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -2,7 +2,6 @@
 # Makefile for staging directory
 
 obj-y				+= media/
-obj-y				+= typec/
 obj-$(CONFIG_IPX)		+= ipx/
 obj-$(CONFIG_NCP_FS)		+= ncpfs/
 obj-$(CONFIG_PRISM2_USB)	+= wlan-ng/
diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig
deleted file mode 100644
index 3aa981f..0000000
--- a/drivers/staging/typec/Kconfig
+++ /dev/null
@@ -1,22 +0,0 @@
-menu "USB Power Delivery and Type-C drivers"
-
-if TYPEC_TCPM
-
-config TYPEC_TCPCI
-	tristate "Type-C Port Controller Interface driver"
-	depends on I2C
-	select REGMAP_I2C
-	help
-	  Type-C Port Controller driver for TCPCI-compliant controller.
-
-config TYPEC_RT1711H
-	tristate "Richtek RT1711H Type-C chip driver"
-	select TYPEC_TCPCI
-	help
-	  Richtek RT1711H Type-C chip driver that works with
-	  Type-C Port Controller Manager to provide USB PD and USB
-	  Type-C functionalities.
-
-endif
-
-endmenu
diff --git a/drivers/staging/typec/Makefile b/drivers/staging/typec/Makefile
deleted file mode 100644
index 7803d48..0000000
--- a/drivers/staging/typec/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-$(CONFIG_TYPEC_TCPCI)	+= tcpci.o
-obj-$(CONFIG_TYPEC_RT1711H)	+= tcpci_rt1711h.o
diff --git a/drivers/staging/typec/TODO b/drivers/staging/typec/TODO
deleted file mode 100644
index 53fe2f7..0000000
--- a/drivers/staging/typec/TODO
+++ /dev/null
@@ -1,5 +0,0 @@
-tcpci:
-- Test with real hardware
-
-Please send patches to Guenter Roeck <linux@roeck-us.net> and copy
-Heikki Krogerus <heikki.krogerus@linux.intel.com>.
diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 2c8eab1..972fd19 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -56,6 +56,21 @@ config TYPEC_TCPM
 
 if TYPEC_TCPM
 
+config TYPEC_TCPCI
+	tristate "Type-C Port Controller Interface driver"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Type-C Port Controller driver for TCPCI-compliant controller.
+
+config TYPEC_RT1711H
+	tristate "Richtek RT1711H Type-C chip driver"
+	select TYPEC_TCPCI
+	help
+	  Richtek RT1711H Type-C chip driver that works with
+	  Type-C Port Controller Manager to provide USB PD and USB
+	  Type-C functionalities.
+
 source "drivers/usb/typec/fusb302/Kconfig"
 
 config TYPEC_WCOVE
diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index 1f599a6..46f86ee 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -7,3 +7,5 @@ obj-$(CONFIG_TYPEC_WCOVE)	+= typec_wcove.o
 obj-$(CONFIG_TYPEC_UCSI)	+= ucsi/
 obj-$(CONFIG_TYPEC_TPS6598X)	+= tps6598x.o
 obj-$(CONFIG_TYPEC)		+= mux/
+obj-$(CONFIG_TYPEC_TCPCI)	+= tcpci.o
+obj-$(CONFIG_TYPEC_RT1711H)	+= tcpci_rt1711h.o
diff --git a/drivers/staging/typec/tcpci.c b/drivers/usb/typec/tcpci.c
similarity index 100%
rename from drivers/staging/typec/tcpci.c
rename to drivers/usb/typec/tcpci.c
diff --git a/drivers/staging/typec/tcpci.h b/drivers/usb/typec/tcpci.h
similarity index 100%
rename from drivers/staging/typec/tcpci.h
rename to drivers/usb/typec/tcpci.h
diff --git a/drivers/staging/typec/tcpci_rt1711h.c b/drivers/usb/typec/tcpci_rt1711h.c
similarity index 100%
rename from drivers/staging/typec/tcpci_rt1711h.c
rename to drivers/usb/typec/tcpci_rt1711h.c

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-30  4:25     ` kbuild test robot
  0 siblings, 0 replies; 75+ messages in thread
From: kbuild test robot @ 2018-05-30  4:25 UTC (permalink / raw)
  To: Li Jun
  Cc: kbuild-all, robh+dt, gregkh, heikki.krogerus, linux, cw00.choi,
	a.hajda, shufan_lee, peter.chen, garsilva, gsomlo, linux-usb,
	devicetree, linux-imx

[-- Attachment #1: Type: text/plain, Size: 4364 bytes --]

Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.17-rc7 next-20180529]
[cannot apply to staging/staging-testing]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Li-Jun/staging-typec-tcpci-move-out-of-staging/20180530-110011
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: i386-randconfig-x017-201821 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/linkage.h:7:0,
                    from include/linux/kernel.h:7,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:19,
                    from include/linux/device.h:16,
                    from drivers/usb/typec/class.c:9:
>> drivers/usb/typec/class.c:1274:19: error: 'typec_find_power_type' undeclared here (not in a function); did you mean 'typec_find_power_role'?
    EXPORT_SYMBOL_GPL(typec_find_power_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
>> drivers/usb/typec/class.c:1274:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_power_type);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb/typec/class.c:1288:19: error: 'typec_find_preferred_role' undeclared here (not in a function); did you mean 'typec_find_power_role'?
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb/typec/class.c:1288:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb/typec/class.c:1303:19: error: 'typec_find_data_type' undeclared here (not in a function); did you mean 'typec_find_power_type'?
    EXPORT_SYMBOL_GPL(typec_find_data_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb/typec/class.c:1303:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_data_type);
    ^~~~~~~~~~~~~~~~~

vim +1274 drivers/usb/typec/class.c

  1260	
  1261	/**
  1262	 * typec_find_port_power_role - Get the typec port power capability
  1263	 * @name: port power capability string
  1264	 *
  1265	 * This routine is used to find the typec_port_type by its string name.
  1266	 *
  1267	 * Returns typec_port_type if success, otherwise negative error code.
  1268	 */
  1269	int typec_find_port_power_role(const char *name)
  1270	{
  1271		return match_string(typec_port_types, ARRAY_SIZE(typec_port_types),
  1272				    name);
  1273	}
> 1274	EXPORT_SYMBOL_GPL(typec_find_power_type);
  1275	
  1276	/**
  1277	 * typec_find_power_role - Find the typec one specific power role
  1278	 * @name: power role string
  1279	 *
  1280	 * This routine is used to find the typec_role by its string name.
  1281	 *
  1282	 * Returns typec_role if success, otherwise negative error code.
  1283	 */
  1284	int typec_find_power_role(const char *name)
  1285	{
  1286		return match_string(typec_roles, ARRAY_SIZE(typec_roles), name);
  1287	}
> 1288	EXPORT_SYMBOL_GPL(typec_find_preferred_role);
  1289	
  1290	/**
  1291	 * typec_find_port_data_role - Get the typec port data capability
  1292	 * @name: port data capability string
  1293	 *
  1294	 * This routine is used to find the typec_port_data by its string name.
  1295	 *
  1296	 * Returns typec_port_data if success, otherwise negative error code.
  1297	 */
  1298	int typec_find_port_data_role(const char *name)
  1299	{
  1300		return match_string(typec_data_caps, ARRAY_SIZE(typec_data_caps),
  1301				    name);
  1302	}
> 1303	EXPORT_SYMBOL_GPL(typec_find_data_type);
  1304	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29759 bytes --]

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-30  4:25     ` kbuild test robot
  0 siblings, 0 replies; 75+ messages in thread
From: kbuild test robot @ 2018-05-30  4:25 UTC (permalink / raw)
  To: Li Jun
  Cc: kbuild-all, robh+dt, gregkh, heikki.krogerus, linux, cw00.choi,
	a.hajda, shufan_lee, peter.chen, garsilva, gsomlo, linux-usb,
	devicetree, linux-imx

Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.17-rc7 next-20180529]
[cannot apply to staging/staging-testing]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Li-Jun/staging-typec-tcpci-move-out-of-staging/20180530-110011
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: i386-randconfig-x017-201821 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/linkage.h:7:0,
                    from include/linux/kernel.h:7,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:19,
                    from include/linux/device.h:16,
                    from drivers/usb/typec/class.c:9:
>> drivers/usb/typec/class.c:1274:19: error: 'typec_find_power_type' undeclared here (not in a function); did you mean 'typec_find_power_role'?
    EXPORT_SYMBOL_GPL(typec_find_power_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
>> drivers/usb/typec/class.c:1274:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_power_type);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb/typec/class.c:1288:19: error: 'typec_find_preferred_role' undeclared here (not in a function); did you mean 'typec_find_power_role'?
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb/typec/class.c:1288:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb/typec/class.c:1303:19: error: 'typec_find_data_type' undeclared here (not in a function); did you mean 'typec_find_power_type'?
    EXPORT_SYMBOL_GPL(typec_find_data_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb/typec/class.c:1303:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_data_type);
    ^~~~~~~~~~~~~~~~~

vim +1274 drivers/usb/typec/class.c

  1260	
  1261	/**
  1262	 * typec_find_port_power_role - Get the typec port power capability
  1263	 * @name: port power capability string
  1264	 *
  1265	 * This routine is used to find the typec_port_type by its string name.
  1266	 *
  1267	 * Returns typec_port_type if success, otherwise negative error code.
  1268	 */
  1269	int typec_find_port_power_role(const char *name)
  1270	{
  1271		return match_string(typec_port_types, ARRAY_SIZE(typec_port_types),
  1272				    name);
  1273	}
> 1274	EXPORT_SYMBOL_GPL(typec_find_power_type);
  1275	
  1276	/**
  1277	 * typec_find_power_role - Find the typec one specific power role
  1278	 * @name: power role string
  1279	 *
  1280	 * This routine is used to find the typec_role by its string name.
  1281	 *
  1282	 * Returns typec_role if success, otherwise negative error code.
  1283	 */
  1284	int typec_find_power_role(const char *name)
  1285	{
  1286		return match_string(typec_roles, ARRAY_SIZE(typec_roles), name);
  1287	}
> 1288	EXPORT_SYMBOL_GPL(typec_find_preferred_role);
  1289	
  1290	/**
  1291	 * typec_find_port_data_role - Get the typec port data capability
  1292	 * @name: port data capability string
  1293	 *
  1294	 * This routine is used to find the typec_port_data by its string name.
  1295	 *
  1296	 * Returns typec_port_data if success, otherwise negative error code.
  1297	 */
  1298	int typec_find_port_data_role(const char *name)
  1299	{
  1300		return match_string(typec_data_caps, ARRAY_SIZE(typec_data_caps),
  1301				    name);
  1302	}
> 1303	EXPORT_SYMBOL_GPL(typec_find_data_type);
  1304
---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 75+ messages in thread

* RE: [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-30  5:56       ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-30  5:56 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, robh+dt, gregkh, heikki.krogerus, linux, cw00.choi,
	a.hajda, shufan_lee, Peter Chen, garsilva, gsomlo, linux-usb,
	devicetree, dl-linux-imx

Hi
> -----Original Message-----
> From: kbuild test robot [mailto:lkp@intel.com]
> Sent: 2018年5月30日 12:26
> To: Jun Li <jun.li@nxp.com>
> Cc: kbuild-all@01.org; robh+dt@kernel.org; gregkh@linuxfoundation.org;
> heikki.krogerus@linux.intel.com; linux@roeck-us.net;
> cw00.choi@samsung.com; a.hajda@samsung.com; shufan_lee@richtek.com;
> Peter Chen <peter.chen@nxp.com>; garsilva@embeddedor.com;
> gsomlo@gmail.com; Jun Li <jun.li@nxp.com>; linux-usb@vger.kernel.org;
> devicetree@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH v6 05/15] usb: typec: add API to get typec basic port power
> and data config
> 
> Hi Li,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on usb/usb-testing] [also build test ERROR on v4.17-rc7
> next-20180529] [cannot apply to staging/staging-testing] [if your patch is
> applied to the wrong git tree, please drop us a note to help improve the
> system]
> 
> url:
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
> b.com%2F0day-ci%2Flinux%2Fcommits%2FLi-Jun%2Fstaging-typec-tcpci-move-
> out-of-staging%2F20180530-110011&data=02%7C01%7Cjun.li%40nxp.com%7
> C56116c50269f48ac2af208d5c5e590b3%7C686ea1d3bc2b4c6fa92cd99c5c301
> 635%7C0%7C0%7C636632515483673101&sdata=0DFAYwcBjlLN1SmO%2BvCG
> s1YLoyjLCjlh89TTyHH1TFs%3D&reserved=0
> base:
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fgregkh%2Fusb.git&data=
> 02%7C01%7Cjun.li%40nxp.com%7C56116c50269f48ac2af208d5c5e590b3%7C6
> 86ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636632515483673101&sd
> ata=OJnSzPSGMdKkV9w2wT8a7OjwKIME2g0VGmVxJerIhTc%3D&reserved=0
> usb-testing
> config: i386-randconfig-x017-201821 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/linkage.h:7:0,
>                     from include/linux/kernel.h:7,
>                     from include/linux/list.h:9,
>                     from include/linux/kobject.h:19,
>                     from include/linux/device.h:16,
>                     from drivers/usb/typec/class.c:9:
> >> drivers/usb/typec/class.c:1274:19: error: 'typec_find_power_type'
> undeclared here (not in a function); did you mean 'typec_find_power_role'?
>     EXPORT_SYMBOL_GPL(typec_find_power_type);
>                       ^
>    include/linux/export.h:65:16: note: in definition of macro
> '___EXPORT_SYMBOL'
>      extern typeof(sym) sym;      \
>                    ^~~
> >> drivers/usb/typec/class.c:1274:1: note: in expansion of macro
> 'EXPORT_SYMBOL_GPL'
>     EXPORT_SYMBOL_GPL(typec_find_power_type);
>     ^~~~~~~~~~~~~~~~~
> >> drivers/usb/typec/class.c:1288:19: error: 'typec_find_preferred_role'
> undeclared here (not in a function); did you mean 'typec_find_power_role'?
>     EXPORT_SYMBOL_GPL(typec_find_preferred_role);
>                       ^
>    include/linux/export.h:65:16: note: in definition of macro
> '___EXPORT_SYMBOL'
>      extern typeof(sym) sym;      \
>                    ^~~
>    drivers/usb/typec/class.c:1288:1: note: in expansion of macro
> 'EXPORT_SYMBOL_GPL'
>     EXPORT_SYMBOL_GPL(typec_find_preferred_role);
>     ^~~~~~~~~~~~~~~~~
> >> drivers/usb/typec/class.c:1303:19: error: 'typec_find_data_type' undeclared
> here (not in a function); did you mean 'typec_find_power_type'?
>     EXPORT_SYMBOL_GPL(typec_find_data_type);
>                       ^
>    include/linux/export.h:65:16: note: in definition of macro
> '___EXPORT_SYMBOL'
>      extern typeof(sym) sym;      \
>                    ^~~
>    drivers/usb/typec/class.c:1303:1: note: in expansion of macro
> 'EXPORT_SYMBOL_GPL'
>     EXPORT_SYMBOL_GPL(typec_find_data_type);
>     ^~~~~~~~~~~~~~~~~
> 
> vim +1274 drivers/usb/typec/class.c

Will fix all above 3 export symbol mismatch.

Li Jun
> 
>   1260
>   1261	/**
>   1262	 * typec_find_port_power_role - Get the typec port power capability
>   1263	 * @name: port power capability string
>   1264	 *
>   1265	 * This routine is used to find the typec_port_type by its string name.
>   1266	 *
>   1267	 * Returns typec_port_type if success, otherwise negative error
> code.
>   1268	 */
>   1269	int typec_find_port_power_role(const char *name)
>   1270	{
>   1271		return match_string(typec_port_types,
> ARRAY_SIZE(typec_port_types),
>   1272				    name);
>   1273	}
> > 1274	EXPORT_SYMBOL_GPL(typec_find_power_type);
>   1275
>   1276	/**
>   1277	 * typec_find_power_role - Find the typec one specific power role
>   1278	 * @name: power role string
>   1279	 *
>   1280	 * This routine is used to find the typec_role by its string name.
>   1281	 *
>   1282	 * Returns typec_role if success, otherwise negative error code.
>   1283	 */
>   1284	int typec_find_power_role(const char *name)
>   1285	{
>   1286		return match_string(typec_roles, ARRAY_SIZE(typec_roles),
> name);
>   1287	}
> > 1288	EXPORT_SYMBOL_GPL(typec_find_preferred_role);
>   1289
>   1290	/**
>   1291	 * typec_find_port_data_role - Get the typec port data capability
>   1292	 * @name: port data capability string
>   1293	 *
>   1294	 * This routine is used to find the typec_port_data by its string name.
>   1295	 *
>   1296	 * Returns typec_port_data if success, otherwise negative error
> code.
>   1297	 */
>   1298	int typec_find_port_data_role(const char *name)
>   1299	{
>   1300		return match_string(typec_data_caps,
> ARRAY_SIZE(typec_data_caps),
>   1301				    name);
>   1302	}
> > 1303	EXPORT_SYMBOL_GPL(typec_find_data_type);
>   1304
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology
> Center
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.0
> 1.org%2Fpipermail%2Fkbuild-all&data=02%7C01%7Cjun.li%40nxp.com%7C561
> 16c50269f48ac2af208d5c5e590b3%7C686ea1d3bc2b4c6fa92cd99c5c301635%
> 7C0%7C0%7C636632515483673101&sdata=Dc5nz3r2TWU76saOKc03d2DBUe
> htMfokRBfKEbzFQ9s%3D&reserved=0                   Intel Corporation

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-30  5:56       ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-05-30  5:56 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, robh+dt, gregkh, heikki.krogerus, linux, cw00.choi,
	a.hajda, shufan_lee, Peter Chen, garsilva, gsomlo, linux-usb,
	devicetree, dl-linux-imx

SGkNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbToga2J1aWxkIHRlc3Qgcm9i
b3QgW21haWx0bzpsa3BAaW50ZWwuY29tXQ0KPiBTZW50OiAyMDE4xOo11MIzMMjVIDEyOjI2DQo+
IFRvOiBKdW4gTGkgPGp1bi5saUBueHAuY29tPg0KPiBDYzoga2J1aWxkLWFsbEAwMS5vcmc7IHJv
YmgrZHRAa2VybmVsLm9yZzsgZ3JlZ2toQGxpbnV4Zm91bmRhdGlvbi5vcmc7DQo+IGhlaWtraS5r
cm9nZXJ1c0BsaW51eC5pbnRlbC5jb207IGxpbnV4QHJvZWNrLXVzLm5ldDsNCj4gY3cwMC5jaG9p
QHNhbXN1bmcuY29tOyBhLmhhamRhQHNhbXN1bmcuY29tOyBzaHVmYW5fbGVlQHJpY2h0ZWsuY29t
Ow0KPiBQZXRlciBDaGVuIDxwZXRlci5jaGVuQG54cC5jb20+OyBnYXJzaWx2YUBlbWJlZGRlZG9y
LmNvbTsNCj4gZ3NvbWxvQGdtYWlsLmNvbTsgSnVuIExpIDxqdW4ubGlAbnhwLmNvbT47IGxpbnV4
LXVzYkB2Z2VyLmtlcm5lbC5vcmc7DQo+IGRldmljZXRyZWVAdmdlci5rZXJuZWwub3JnOyBkbC1s
aW51eC1pbXggPGxpbnV4LWlteEBueHAuY29tPg0KPiBTdWJqZWN0OiBSZTogW1BBVENIIHY2IDA1
LzE1XSB1c2I6IHR5cGVjOiBhZGQgQVBJIHRvIGdldCB0eXBlYyBiYXNpYyBwb3J0IHBvd2VyDQo+
IGFuZCBkYXRhIGNvbmZpZw0KPiANCj4gSGkgTGksDQo+IA0KPiBUaGFuayB5b3UgZm9yIHRoZSBw
YXRjaCEgWWV0IHNvbWV0aGluZyB0byBpbXByb3ZlOg0KPiANCj4gW2F1dG8gYnVpbGQgdGVzdCBF
UlJPUiBvbiB1c2IvdXNiLXRlc3RpbmddIFthbHNvIGJ1aWxkIHRlc3QgRVJST1Igb24gdjQuMTct
cmM3DQo+IG5leHQtMjAxODA1MjldIFtjYW5ub3QgYXBwbHkgdG8gc3RhZ2luZy9zdGFnaW5nLXRl
c3RpbmddIFtpZiB5b3VyIHBhdGNoIGlzDQo+IGFwcGxpZWQgdG8gdGhlIHdyb25nIGdpdCB0cmVl
LCBwbGVhc2UgZHJvcCB1cyBhIG5vdGUgdG8gaGVscCBpbXByb3ZlIHRoZQ0KPiBzeXN0ZW1dDQo+
IA0KPiB1cmw6DQo+IGh0dHBzOi8vZW1lYTAxLnNhZmVsaW5rcy5wcm90ZWN0aW9uLm91dGxvb2su
Y29tLz91cmw9aHR0cHMlM0ElMkYlMkZnaXRodQ0KPiBiLmNvbSUyRjBkYXktY2klMkZsaW51eCUy
RmNvbW1pdHMlMkZMaS1KdW4lMkZzdGFnaW5nLXR5cGVjLXRjcGNpLW1vdmUtDQo+IG91dC1vZi1z
dGFnaW5nJTJGMjAxODA1MzAtMTEwMDExJmRhdGE9MDIlN0MwMSU3Q2p1bi5saSU0MG54cC5jb20l
Nw0KPiBDNTYxMTZjNTAyNjlmNDhhYzJhZjIwOGQ1YzVlNTkwYjMlN0M2ODZlYTFkM2JjMmI0YzZm
YTkyY2Q5OWM1YzMwMQ0KPiA2MzUlN0MwJTdDMCU3QzYzNjYzMjUxNTQ4MzY3MzEwMSZzZGF0YT0w
REZBWXdjQmpsTE4xU21PJTJCdkNHDQo+IHMxWUxveWpMQ2psaDg5VFR5SEgxVEZzJTNEJnJlc2Vy
dmVkPTANCj4gYmFzZToNCj4gaHR0cHM6Ly9lbWVhMDEuc2FmZWxpbmtzLnByb3RlY3Rpb24ub3V0
bG9vay5jb20vP3VybD1odHRwcyUzQSUyRiUyRmdpdC5rZQ0KPiBybmVsLm9yZyUyRnB1YiUyRnNj
bSUyRmxpbnV4JTJGa2VybmVsJTJGZ2l0JTJGZ3JlZ2toJTJGdXNiLmdpdCZkYXRhPQ0KPiAwMiU3
QzAxJTdDanVuLmxpJTQwbnhwLmNvbSU3QzU2MTE2YzUwMjY5ZjQ4YWMyYWYyMDhkNWM1ZTU5MGIz
JTdDNg0KPiA4NmVhMWQzYmMyYjRjNmZhOTJjZDk5YzVjMzAxNjM1JTdDMCU3QzAlN0M2MzY2MzI1
MTU0ODM2NzMxMDEmc2QNCj4gYXRhPU9KblN6UFNHTWRLa1Y5dzJ3VDhhN09qd0tJTUUyZzBWR21W
eEplckloVGMlM0QmcmVzZXJ2ZWQ9MA0KPiB1c2ItdGVzdGluZw0KPiBjb25maWc6IGkzODYtcmFu
ZGNvbmZpZy14MDE3LTIwMTgyMSAoYXR0YWNoZWQgYXMgLmNvbmZpZykNCj4gY29tcGlsZXI6IGdj
Yy03IChEZWJpYW4gNy4zLjAtMTYpIDcuMy4wDQo+IHJlcHJvZHVjZToNCj4gICAgICAgICAjIHNh
dmUgdGhlIGF0dGFjaGVkIC5jb25maWcgdG8gbGludXggYnVpbGQgdHJlZQ0KPiAgICAgICAgIG1h
a2UgQVJDSD1pMzg2DQo+IA0KPiBBbGwgZXJyb3Ivd2FybmluZ3MgKG5ldyBvbmVzIHByZWZpeGVk
IGJ5ID4+KToNCj4gDQo+ICAgIEluIGZpbGUgaW5jbHVkZWQgZnJvbSBpbmNsdWRlL2xpbnV4L2xp
bmthZ2UuaDo3OjAsDQo+ICAgICAgICAgICAgICAgICAgICAgZnJvbSBpbmNsdWRlL2xpbnV4L2tl
cm5lbC5oOjcsDQo+ICAgICAgICAgICAgICAgICAgICAgZnJvbSBpbmNsdWRlL2xpbnV4L2xpc3Qu
aDo5LA0KPiAgICAgICAgICAgICAgICAgICAgIGZyb20gaW5jbHVkZS9saW51eC9rb2JqZWN0Lmg6
MTksDQo+ICAgICAgICAgICAgICAgICAgICAgZnJvbSBpbmNsdWRlL2xpbnV4L2RldmljZS5oOjE2
LA0KPiAgICAgICAgICAgICAgICAgICAgIGZyb20gZHJpdmVycy91c2IvdHlwZWMvY2xhc3MuYzo5
Og0KPiA+PiBkcml2ZXJzL3VzYi90eXBlYy9jbGFzcy5jOjEyNzQ6MTk6IGVycm9yOiAndHlwZWNf
ZmluZF9wb3dlcl90eXBlJw0KPiB1bmRlY2xhcmVkIGhlcmUgKG5vdCBpbiBhIGZ1bmN0aW9uKTsg
ZGlkIHlvdSBtZWFuICd0eXBlY19maW5kX3Bvd2VyX3JvbGUnPw0KPiAgICAgRVhQT1JUX1NZTUJP
TF9HUEwodHlwZWNfZmluZF9wb3dlcl90eXBlKTsNCj4gICAgICAgICAgICAgICAgICAgICAgIF4N
Cj4gICAgaW5jbHVkZS9saW51eC9leHBvcnQuaDo2NToxNjogbm90ZTogaW4gZGVmaW5pdGlvbiBv
ZiBtYWNybw0KPiAnX19fRVhQT1JUX1NZTUJPTCcNCj4gICAgICBleHRlcm4gdHlwZW9mKHN5bSkg
c3ltOyAgICAgIFwNCj4gICAgICAgICAgICAgICAgICAgIF5+fg0KPiA+PiBkcml2ZXJzL3VzYi90
eXBlYy9jbGFzcy5jOjEyNzQ6MTogbm90ZTogaW4gZXhwYW5zaW9uIG9mIG1hY3JvDQo+ICdFWFBP
UlRfU1lNQk9MX0dQTCcNCj4gICAgIEVYUE9SVF9TWU1CT0xfR1BMKHR5cGVjX2ZpbmRfcG93ZXJf
dHlwZSk7DQo+ICAgICBefn5+fn5+fn5+fn5+fn5+fg0KPiA+PiBkcml2ZXJzL3VzYi90eXBlYy9j
bGFzcy5jOjEyODg6MTk6IGVycm9yOiAndHlwZWNfZmluZF9wcmVmZXJyZWRfcm9sZScNCj4gdW5k
ZWNsYXJlZCBoZXJlIChub3QgaW4gYSBmdW5jdGlvbik7IGRpZCB5b3UgbWVhbiAndHlwZWNfZmlu
ZF9wb3dlcl9yb2xlJz8NCj4gICAgIEVYUE9SVF9TWU1CT0xfR1BMKHR5cGVjX2ZpbmRfcHJlZmVy
cmVkX3JvbGUpOw0KPiAgICAgICAgICAgICAgICAgICAgICAgXg0KPiAgICBpbmNsdWRlL2xpbnV4
L2V4cG9ydC5oOjY1OjE2OiBub3RlOiBpbiBkZWZpbml0aW9uIG9mIG1hY3JvDQo+ICdfX19FWFBP
UlRfU1lNQk9MJw0KPiAgICAgIGV4dGVybiB0eXBlb2Yoc3ltKSBzeW07ICAgICAgXA0KPiAgICAg
ICAgICAgICAgICAgICAgXn5+DQo+ICAgIGRyaXZlcnMvdXNiL3R5cGVjL2NsYXNzLmM6MTI4ODox
OiBub3RlOiBpbiBleHBhbnNpb24gb2YgbWFjcm8NCj4gJ0VYUE9SVF9TWU1CT0xfR1BMJw0KPiAg
ICAgRVhQT1JUX1NZTUJPTF9HUEwodHlwZWNfZmluZF9wcmVmZXJyZWRfcm9sZSk7DQo+ICAgICBe
fn5+fn5+fn5+fn5+fn5+fg0KPiA+PiBkcml2ZXJzL3VzYi90eXBlYy9jbGFzcy5jOjEzMDM6MTk6
IGVycm9yOiAndHlwZWNfZmluZF9kYXRhX3R5cGUnIHVuZGVjbGFyZWQNCj4gaGVyZSAobm90IGlu
IGEgZnVuY3Rpb24pOyBkaWQgeW91IG1lYW4gJ3R5cGVjX2ZpbmRfcG93ZXJfdHlwZSc/DQo+ICAg
ICBFWFBPUlRfU1lNQk9MX0dQTCh0eXBlY19maW5kX2RhdGFfdHlwZSk7DQo+ICAgICAgICAgICAg
ICAgICAgICAgICBeDQo+ICAgIGluY2x1ZGUvbGludXgvZXhwb3J0Lmg6NjU6MTY6IG5vdGU6IGlu
IGRlZmluaXRpb24gb2YgbWFjcm8NCj4gJ19fX0VYUE9SVF9TWU1CT0wnDQo+ICAgICAgZXh0ZXJu
IHR5cGVvZihzeW0pIHN5bTsgICAgICBcDQo+ICAgICAgICAgICAgICAgICAgICBefn4NCj4gICAg
ZHJpdmVycy91c2IvdHlwZWMvY2xhc3MuYzoxMzAzOjE6IG5vdGU6IGluIGV4cGFuc2lvbiBvZiBt
YWNybw0KPiAnRVhQT1JUX1NZTUJPTF9HUEwnDQo+ICAgICBFWFBPUlRfU1lNQk9MX0dQTCh0eXBl
Y19maW5kX2RhdGFfdHlwZSk7DQo+ICAgICBefn5+fn5+fn5+fn5+fn5+fg0KPiANCj4gdmltICsx
Mjc0IGRyaXZlcnMvdXNiL3R5cGVjL2NsYXNzLmMNCg0KV2lsbCBmaXggYWxsIGFib3ZlIDMgZXhw
b3J0IHN5bWJvbCBtaXNtYXRjaC4NCg0KTGkgSnVuDQo+IA0KPiAgIDEyNjANCj4gICAxMjYxCS8q
Kg0KPiAgIDEyNjIJICogdHlwZWNfZmluZF9wb3J0X3Bvd2VyX3JvbGUgLSBHZXQgdGhlIHR5cGVj
IHBvcnQgcG93ZXIgY2FwYWJpbGl0eQ0KPiAgIDEyNjMJICogQG5hbWU6IHBvcnQgcG93ZXIgY2Fw
YWJpbGl0eSBzdHJpbmcNCj4gICAxMjY0CSAqDQo+ICAgMTI2NQkgKiBUaGlzIHJvdXRpbmUgaXMg
dXNlZCB0byBmaW5kIHRoZSB0eXBlY19wb3J0X3R5cGUgYnkgaXRzIHN0cmluZyBuYW1lLg0KPiAg
IDEyNjYJICoNCj4gICAxMjY3CSAqIFJldHVybnMgdHlwZWNfcG9ydF90eXBlIGlmIHN1Y2Nlc3Ms
IG90aGVyd2lzZSBuZWdhdGl2ZSBlcnJvcg0KPiBjb2RlLg0KPiAgIDEyNjgJICovDQo+ICAgMTI2
OQlpbnQgdHlwZWNfZmluZF9wb3J0X3Bvd2VyX3JvbGUoY29uc3QgY2hhciAqbmFtZSkNCj4gICAx
MjcwCXsNCj4gICAxMjcxCQlyZXR1cm4gbWF0Y2hfc3RyaW5nKHR5cGVjX3BvcnRfdHlwZXMsDQo+
IEFSUkFZX1NJWkUodHlwZWNfcG9ydF90eXBlcyksDQo+ICAgMTI3MgkJCQkgICAgbmFtZSk7DQo+
ICAgMTI3Mwl9DQo+ID4gMTI3NAlFWFBPUlRfU1lNQk9MX0dQTCh0eXBlY19maW5kX3Bvd2VyX3R5
cGUpOw0KPiAgIDEyNzUNCj4gICAxMjc2CS8qKg0KPiAgIDEyNzcJICogdHlwZWNfZmluZF9wb3dl
cl9yb2xlIC0gRmluZCB0aGUgdHlwZWMgb25lIHNwZWNpZmljIHBvd2VyIHJvbGUNCj4gICAxMjc4
CSAqIEBuYW1lOiBwb3dlciByb2xlIHN0cmluZw0KPiAgIDEyNzkJICoNCj4gICAxMjgwCSAqIFRo
aXMgcm91dGluZSBpcyB1c2VkIHRvIGZpbmQgdGhlIHR5cGVjX3JvbGUgYnkgaXRzIHN0cmluZyBu
YW1lLg0KPiAgIDEyODEJICoNCj4gICAxMjgyCSAqIFJldHVybnMgdHlwZWNfcm9sZSBpZiBzdWNj
ZXNzLCBvdGhlcndpc2UgbmVnYXRpdmUgZXJyb3IgY29kZS4NCj4gICAxMjgzCSAqLw0KPiAgIDEy
ODQJaW50IHR5cGVjX2ZpbmRfcG93ZXJfcm9sZShjb25zdCBjaGFyICpuYW1lKQ0KPiAgIDEyODUJ
ew0KPiAgIDEyODYJCXJldHVybiBtYXRjaF9zdHJpbmcodHlwZWNfcm9sZXMsIEFSUkFZX1NJWkUo
dHlwZWNfcm9sZXMpLA0KPiBuYW1lKTsNCj4gICAxMjg3CX0NCj4gPiAxMjg4CUVYUE9SVF9TWU1C
T0xfR1BMKHR5cGVjX2ZpbmRfcHJlZmVycmVkX3JvbGUpOw0KPiAgIDEyODkNCj4gICAxMjkwCS8q
Kg0KPiAgIDEyOTEJICogdHlwZWNfZmluZF9wb3J0X2RhdGFfcm9sZSAtIEdldCB0aGUgdHlwZWMg
cG9ydCBkYXRhIGNhcGFiaWxpdHkNCj4gICAxMjkyCSAqIEBuYW1lOiBwb3J0IGRhdGEgY2FwYWJp
bGl0eSBzdHJpbmcNCj4gICAxMjkzCSAqDQo+ICAgMTI5NAkgKiBUaGlzIHJvdXRpbmUgaXMgdXNl
ZCB0byBmaW5kIHRoZSB0eXBlY19wb3J0X2RhdGEgYnkgaXRzIHN0cmluZyBuYW1lLg0KPiAgIDEy
OTUJICoNCj4gICAxMjk2CSAqIFJldHVybnMgdHlwZWNfcG9ydF9kYXRhIGlmIHN1Y2Nlc3MsIG90
aGVyd2lzZSBuZWdhdGl2ZSBlcnJvcg0KPiBjb2RlLg0KPiAgIDEyOTcJICovDQo+ICAgMTI5OAlp
bnQgdHlwZWNfZmluZF9wb3J0X2RhdGFfcm9sZShjb25zdCBjaGFyICpuYW1lKQ0KPiAgIDEyOTkJ
ew0KPiAgIDEzMDAJCXJldHVybiBtYXRjaF9zdHJpbmcodHlwZWNfZGF0YV9jYXBzLA0KPiBBUlJB
WV9TSVpFKHR5cGVjX2RhdGFfY2FwcyksDQo+ICAgMTMwMQkJCQkgICAgbmFtZSk7DQo+ICAgMTMw
Mgl9DQo+ID4gMTMwMwlFWFBPUlRfU1lNQk9MX0dQTCh0eXBlY19maW5kX2RhdGFfdHlwZSk7DQo+
ICAgMTMwNA0KPiANCj4gLS0tDQo+IDAtREFZIGtlcm5lbCB0ZXN0IGluZnJhc3RydWN0dXJlICAg
ICAgICAgICAgICAgIE9wZW4gU291cmNlIFRlY2hub2xvZ3kNCj4gQ2VudGVyDQo+IGh0dHBzOi8v
ZW1lYTAxLnNhZmVsaW5rcy5wcm90ZWN0aW9uLm91dGxvb2suY29tLz91cmw9aHR0cHMlM0ElMkYl
MkZsaXN0cy4wDQo+IDEub3JnJTJGcGlwZXJtYWlsJTJGa2J1aWxkLWFsbCZkYXRhPTAyJTdDMDEl
N0NqdW4ubGklNDBueHAuY29tJTdDNTYxDQo+IDE2YzUwMjY5ZjQ4YWMyYWYyMDhkNWM1ZTU5MGIz
JTdDNjg2ZWExZDNiYzJiNGM2ZmE5MmNkOTljNWMzMDE2MzUlDQo+IDdDMCU3QzAlN0M2MzY2MzI1
MTU0ODM2NzMxMDEmc2RhdGE9RGM1bnozcjJUV1U3NnNhT0tjMDNkMkRCVWUNCj4gaHRNZm9rUkJm
S0ViekZROXMlM0QmcmVzZXJ2ZWQ9MCAgICAgICAgICAgICAgICAgICBJbnRlbCBDb3Jwb3JhdGlv
bg0K
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-30  6:43     ` kbuild test robot
  0 siblings, 0 replies; 75+ messages in thread
From: kbuild test robot @ 2018-05-30  6:43 UTC (permalink / raw)
  To: Li Jun
  Cc: kbuild-all, robh+dt, gregkh, heikki.krogerus, linux, cw00.choi,
	a.hajda, shufan_lee, peter.chen, garsilva, gsomlo, linux-usb,
	devicetree, linux-imx

[-- Attachment #1: Type: text/plain, Size: 4277 bytes --]

Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.17-rc7 next-20180529]
[cannot apply to staging/staging-testing]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Li-Jun/staging-typec-tcpci-move-out-of-staging/20180530-110011
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: i386-randconfig-s1-201821 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from include/linux/linkage.h:7:0,
                    from include/linux/kernel.h:7,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:19,
                    from include/linux/device.h:16,
                    from drivers/usb//typec/class.c:9:
>> drivers/usb//typec/class.c:1274:19: error: 'typec_find_power_type' undeclared here (not in a function)
    EXPORT_SYMBOL_GPL(typec_find_power_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb//typec/class.c:1274:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_power_type);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb//typec/class.c:1288:19: error: 'typec_find_preferred_role' undeclared here (not in a function)
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb//typec/class.c:1288:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb//typec/class.c:1303:19: error: 'typec_find_data_type' undeclared here (not in a function)
    EXPORT_SYMBOL_GPL(typec_find_data_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb//typec/class.c:1303:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_data_type);
    ^~~~~~~~~~~~~~~~~

vim +/typec_find_power_type +1274 drivers/usb//typec/class.c

  1260	
  1261	/**
  1262	 * typec_find_port_power_role - Get the typec port power capability
  1263	 * @name: port power capability string
  1264	 *
  1265	 * This routine is used to find the typec_port_type by its string name.
  1266	 *
  1267	 * Returns typec_port_type if success, otherwise negative error code.
  1268	 */
  1269	int typec_find_port_power_role(const char *name)
  1270	{
  1271		return match_string(typec_port_types, ARRAY_SIZE(typec_port_types),
  1272				    name);
  1273	}
> 1274	EXPORT_SYMBOL_GPL(typec_find_power_type);
  1275	
  1276	/**
  1277	 * typec_find_power_role - Find the typec one specific power role
  1278	 * @name: power role string
  1279	 *
  1280	 * This routine is used to find the typec_role by its string name.
  1281	 *
  1282	 * Returns typec_role if success, otherwise negative error code.
  1283	 */
  1284	int typec_find_power_role(const char *name)
  1285	{
  1286		return match_string(typec_roles, ARRAY_SIZE(typec_roles), name);
  1287	}
> 1288	EXPORT_SYMBOL_GPL(typec_find_preferred_role);
  1289	
  1290	/**
  1291	 * typec_find_port_data_role - Get the typec port data capability
  1292	 * @name: port data capability string
  1293	 *
  1294	 * This routine is used to find the typec_port_data by its string name.
  1295	 *
  1296	 * Returns typec_port_data if success, otherwise negative error code.
  1297	 */
  1298	int typec_find_port_data_role(const char *name)
  1299	{
  1300		return match_string(typec_data_caps, ARRAY_SIZE(typec_data_caps),
  1301				    name);
  1302	}
> 1303	EXPORT_SYMBOL_GPL(typec_find_data_type);
  1304	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26505 bytes --]

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-05-30  6:43     ` kbuild test robot
  0 siblings, 0 replies; 75+ messages in thread
From: kbuild test robot @ 2018-05-30  6:43 UTC (permalink / raw)
  To: Li Jun
  Cc: kbuild-all, robh+dt, gregkh, heikki.krogerus, linux, cw00.choi,
	a.hajda, shufan_lee, peter.chen, garsilva, gsomlo, linux-usb,
	devicetree, linux-imx

Hi Li,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.17-rc7 next-20180529]
[cannot apply to staging/staging-testing]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Li-Jun/staging-typec-tcpci-move-out-of-staging/20180530-110011
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: i386-randconfig-s1-201821 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from include/linux/linkage.h:7:0,
                    from include/linux/kernel.h:7,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:19,
                    from include/linux/device.h:16,
                    from drivers/usb//typec/class.c:9:
>> drivers/usb//typec/class.c:1274:19: error: 'typec_find_power_type' undeclared here (not in a function)
    EXPORT_SYMBOL_GPL(typec_find_power_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb//typec/class.c:1274:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_power_type);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb//typec/class.c:1288:19: error: 'typec_find_preferred_role' undeclared here (not in a function)
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb//typec/class.c:1288:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_preferred_role);
    ^~~~~~~~~~~~~~~~~
>> drivers/usb//typec/class.c:1303:19: error: 'typec_find_data_type' undeclared here (not in a function)
    EXPORT_SYMBOL_GPL(typec_find_data_type);
                      ^
   include/linux/export.h:65:16: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                   ^~~
   drivers/usb//typec/class.c:1303:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(typec_find_data_type);
    ^~~~~~~~~~~~~~~~~

vim +/typec_find_power_type +1274 drivers/usb//typec/class.c

  1260	
  1261	/**
  1262	 * typec_find_port_power_role - Get the typec port power capability
  1263	 * @name: port power capability string
  1264	 *
  1265	 * This routine is used to find the typec_port_type by its string name.
  1266	 *
  1267	 * Returns typec_port_type if success, otherwise negative error code.
  1268	 */
  1269	int typec_find_port_power_role(const char *name)
  1270	{
  1271		return match_string(typec_port_types, ARRAY_SIZE(typec_port_types),
  1272				    name);
  1273	}
> 1274	EXPORT_SYMBOL_GPL(typec_find_power_type);
  1275	
  1276	/**
  1277	 * typec_find_power_role - Find the typec one specific power role
  1278	 * @name: power role string
  1279	 *
  1280	 * This routine is used to find the typec_role by its string name.
  1281	 *
  1282	 * Returns typec_role if success, otherwise negative error code.
  1283	 */
  1284	int typec_find_power_role(const char *name)
  1285	{
  1286		return match_string(typec_roles, ARRAY_SIZE(typec_roles), name);
  1287	}
> 1288	EXPORT_SYMBOL_GPL(typec_find_preferred_role);
  1289	
  1290	/**
  1291	 * typec_find_port_data_role - Get the typec port data capability
  1292	 * @name: port data capability string
  1293	 *
  1294	 * This routine is used to find the typec_port_data by its string name.
  1295	 *
  1296	 * Returns typec_port_data if success, otherwise negative error code.
  1297	 */
  1298	int typec_find_port_data_role(const char *name)
  1299	{
  1300		return match_string(typec_data_caps, ARRAY_SIZE(typec_data_caps),
  1301				    name);
  1302	}
> 1303	EXPORT_SYMBOL_GPL(typec_find_data_type);
  1304
---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 01/15] dt-bindings: connector: add properties for typec
@ 2018-05-31  0:13     ` Rob Herring
  0 siblings, 0 replies; 75+ messages in thread
From: Rob Herring @ 2018-05-31  0:13 UTC (permalink / raw)
  To: Li Jun
  Cc: gregkh, heikki.krogerus, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:33AM +0800, Li Jun wrote:
> Add bindings supported by current typec driver, so user can pass
> all those properties via dt.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  .../bindings/connector/usb-connector.txt           | 44 +++++++++++++++
>  include/dt-bindings/usb/pd.h                       | 62 ++++++++++++++++++++++
>  2 files changed, 106 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,01/15] dt-bindings: connector: add properties for typec
@ 2018-05-31  0:13     ` Rob Herring
  0 siblings, 0 replies; 75+ messages in thread
From: Rob Herring @ 2018-05-31  0:13 UTC (permalink / raw)
  To: Li Jun
  Cc: gregkh, heikki.krogerus, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:33AM +0800, Li Jun wrote:
> Add bindings supported by current typec driver, so user can pass
> all those properties via dt.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  .../bindings/connector/usb-connector.txt           | 44 +++++++++++++++
>  include/dt-bindings/usb/pd.h                       | 62 ++++++++++++++++++++++
>  2 files changed, 106 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 00/15] staging: typec: tcpci: move out of staging
  2018-05-28  2:52 [PATCH v6 00/15] staging: typec: tcpci: move out of staging Li Jun
                   ` (14 preceding siblings ...)
  2018-05-28  2:52   ` [v6,15/15] " Jun Li
@ 2018-06-06 21:44 ` Mats Karrman
  2018-06-07  0:47   ` Jun Li
  15 siblings, 1 reply; 75+ messages in thread
From: Mats Karrman @ 2018-06-06 21:44 UTC (permalink / raw)
  To: Li Jun, robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	linux-usb, devicetree, linux-imx

Hello Li Jun,

I have been testing these patches on top of usb-next using an i.MX6,
a nxp ptn5110 evaluation board and a bunch of usbc devices. So far
everything seem to work fine! :-)
However, I have only tested host mode and I have some test cases
left I want to cover.

Just to let you know your patches are not forgotten :-)

BR // Mats

On 2018-05-28 04:52, Li Jun wrote:
> This patch set attempts to move the tcpci drivers out of staging by fix
> some tcpci driver issues and define typec and power delivery device
> properties, the changes are verified on NXP PTN5110, which is a standard
> tcpci typec port controller device with power delivery support, tested
> power source and sink with drp config.
>
> Changes for v6:
> - Change function name to be typec_find_port_power/data_role for find
>    capability, and typec_find_power_role for find one specific power role.
> - Fix rt1711h driver move missing.
> - Add one patch to improve the error checking in tcpci driver, use IS_ERR()
>    instead of PTR_ERR_OR_ZERO().
> - Add Rob's Reviewed-by for patch [2/15].
> - Misc typos fix.
>   
> Changes for v5:
> - Use "power-role" and "data-role" for typec port power and data capability
>    property name.
> - Use macro defintion instead of cryptic numbers for readability of
>    power delivery properties(PDO).
> - Add one tcpci driver binding string to be "nxp,ptn5110" to follow binding
>    name rule "<vendor prefix>,<device>".
> - Change operating power property name to be op-sink-microwatt.
> - Add one patch(remove unused tcpci_tcpc_config) to resolve bisectablitity
>    issue of patch usb: typec: add fwnode to tcpc.
> - A minor error handling change to keep the error path and success path
>    separate in patch: register port before request irq
> - Rebase to latest Greg's tree with max_snk_* removed.
>
> Changes for v4:
> - Remove max-sink-* properties as we will purge max_snk_* in tcpm,
>    see patch set[4].
> - Get typec power and data type value via name string(patch 5).
> - Move finding typec and pd properties code from tcpci to tcpm(patch 6)
> - Add a compatible string for nxp ptn5110 typec controller in tcpci driver.
>    (patch 3)
> - Add set cc for drp toggling without try.src/snk in tcpm(patch 10), then
>    patch 11 can only update CCx bits for keep disconnect cc line open.
> - Update op-sink-microwatt-hours example value to be the right value in
>    micorwatts, and accordingly divide 1000 to get its miliwatts value
>    in patch 6.
> - Add Guenter's Reviewed-by for patch(8/9/12)
>
> [4] https://www.spinics.net/lists/linux-usb/msg167261.html
>
> Changes for v3:
> - Use 2 properties to separate power and data capability of typec port:
>    "power-type" and "data-type", this is based on Heikki's typec class code
>    change[2]. use "try-power-role" to present if the typec port can support
>    Try.SNK or Try.SRC.
> - 4 sink properties(max_sink_mv/ma/mw and op_sink_mw) are kept because the
>    counterpart code is back, see revert patch[3], meanwhile I post a patch
>    to fix the reported problem of current source pdo select machinism(which
>    completely ignored those 4 sink settings), to see if we can keep current
>    code, once it was discussed and have conclusion I can update this
>    accordingly.
> - Use fwnode to get the connector node for dt setting parse.
>
> Main changes for v2:
> - Typec properties are based on general usb connector bindings[1] proposed
>    by Andrzej Hajda, use the standard unit suffixes as defined in
>    property-units.txt.
> - Add 2 infra APIs to get power sink and source config from dt.
> - Don't change the set_cc api, to keep the uncontacted cc line open,
>    set cc1/cc2 to be open in tcpci driver when set polarity.
> - Directly enable vbus detect in tcpci driver rather than add a API.
> - Details added in each patch.
>
> [1] https://patchwork.kernel.org/patch/10231447/
> [2] https://patchwork.kernel.org/patch/10276483/
> [3] https://www.spinics.net/lists/linux-usb/msg166366.html
>
> Li Jun (14):
>    dt-bindings: connector: add properties for typec
>    dt-bindings: usb: add documentation for typec port controller(TCPCI)
>    staging: typec: tcpci: add compatible string for nxp ptn5110
>    usb: typec: add fwnode to tcpc
>    usb: typec: add API to get typec basic port power and data config
>    usb: typec: tcpm: support get typec and pd config from device
>      properties
>    staging: typec: tcpci: remove unused tcpci_tcpc_config
>    staging: typec: tcpci: use IS_ERR() instead of PTR_ERR_OR_ZERO()
>    staging: typec: tcpci: enable vbus detection
>    typec: tcpm: add starting value for drp toggling
>    usb: typec: tcpm: set cc for drp toggling attach
>    staging: typec: tcpci: keep the disconnected cc line open
>    staging: typec: tcpci: Only touch target bit when enable vconn
>    staging: typec: tcpci: move tcpci drivers out of staging
>
> Peter Chen (1):
>    staging: typec: tcpci: register port before request irq
>
>   .../bindings/connector/usb-connector.txt           |  44 ++++++
>   .../devicetree/bindings/usb/typec-tcpci.txt        |  49 +++++++
>   drivers/staging/Kconfig                            |   2 -
>   drivers/staging/Makefile                           |   1 -
>   drivers/staging/typec/Kconfig                      |  22 ---
>   drivers/staging/typec/Makefile                     |   2 -
>   drivers/staging/typec/TODO                         |   5 -
>   drivers/usb/typec/Kconfig                          |  15 +++
>   drivers/usb/typec/Makefile                         |   2 +
>   drivers/usb/typec/class.c                          |  50 +++++++
>   drivers/{staging => usb}/typec/tcpci.c             |  66 +++++----
>   drivers/{staging => usb}/typec/tcpci.h             |   0
>   drivers/{staging => usb}/typec/tcpci_rt1711h.c     |   0
>   drivers/usb/typec/tcpm.c                           | 148 +++++++++++++++++----
>   include/dt-bindings/usb/pd.h                       |  62 +++++++++
>   include/linux/usb/tcpm.h                           |   2 +
>   include/linux/usb/typec.h                          |   3 +
>   17 files changed, 389 insertions(+), 84 deletions(-)
>   create mode 100644 Documentation/devicetree/bindings/usb/typec-tcpci.txt
>   delete mode 100644 drivers/staging/typec/Kconfig
>   delete mode 100644 drivers/staging/typec/Makefile
>   delete mode 100644 drivers/staging/typec/TODO
>   rename drivers/{staging => usb}/typec/tcpci.c (92%)
>   rename drivers/{staging => usb}/typec/tcpci.h (100%)
>   rename drivers/{staging => usb}/typec/tcpci_rt1711h.c (100%)
>   create mode 100644 include/dt-bindings/usb/pd.h
>

^ permalink raw reply	[flat|nested] 75+ messages in thread

* RE: [PATCH v6 00/15] staging: typec: tcpci: move out of staging
  2018-06-06 21:44 ` [PATCH v6 00/15] staging: typec: tcpci: move " Mats Karrman
@ 2018-06-07  0:47   ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-06-07  0:47 UTC (permalink / raw)
  To: Mats Karrman, robh+dt, gregkh, heikki.krogerus, linux
  Cc: cw00.choi, a.hajda, shufan_lee, Peter Chen, garsilva, gsomlo,
	linux-usb, devicetree, dl-linux-imx

Hi Mats,
> -----Original Message-----
> From: Mats Karrman [mailto:mats.dev.list@gmail.com]
> Sent: 2018年6月7日 5:45
> To: Jun Li <jun.li@nxp.com>; robh+dt@kernel.org; gregkh@linuxfoundation.org;
> heikki.krogerus@linux.intel.com; linux@roeck-us.net
> Cc: cw00.choi@samsung.com; a.hajda@samsung.com; shufan_lee@richtek.com;
> Peter Chen <peter.chen@nxp.com>; garsilva@embeddedor.com;
> gsomlo@gmail.com; linux-usb@vger.kernel.org; devicetree@vger.kernel.org;
> dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH v6 00/15] staging: typec: tcpci: move out of staging
> 
> Hello Li Jun,
> 
> I have been testing these patches on top of usb-next using an i.MX6, a nxp
> ptn5110 evaluation board and a bunch of usbc devices. So far everything seem to
> work fine! :-) However, I have only tested host mode and I have some test cases
> left I want to cover.
> 
> Just to let you know your patches are not forgotten :-)

Good to know that, thanks, Mats, those patches was tested on my i.MX8M
HW with PTN5110 for both source and sink mode, hope you can test your
device mode as well soon.

Li Jun

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-06-11 11:08     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 11:08 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

Hi Jun,

On Mon, May 28, 2018 at 10:52:37AM +0800, Li Jun wrote:
> This patch adds 3 APIs to get the typec port power and data type,
> and preferred power role by its name string.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  drivers/usb/typec/class.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/usb/typec.h |  3 +++
>  2 files changed, 53 insertions(+)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 53df10d..4c7d18c 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -802,6 +802,12 @@ static const char * const typec_port_types[] = {
>  	[TYPEC_PORT_DRP] = "dual",
>  };
>  
> +static const char * const typec_data_caps[] = {
> +	[TYPEC_PORT_DFP] = "host",
> +	[TYPEC_PORT_UFP] = "device",
> +	[TYPEC_PORT_DRD] = "dual",
> +};

Since I guess you need to fix this patch in any case, could you rename
that to "typec_port_data_roles".

And while at it, how about using this as an opportunity to rename
typec_port_types to typec_port_power_roles?

So this just a suggestion, no need to actually change it :-) :

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index abbd33939109..97f7eb0e9879 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -918,12 +918,18 @@ static const char * const typec_data_roles[] = {
        [TYPEC_HOST]    = "host",
 };

-static const char * const typec_port_types[] = {
+static const char * const typec_port_power_roles[] = {
        [TYPEC_PORT_SRC] = "source",
        [TYPEC_PORT_SNK] = "sink",
        [TYPEC_PORT_DRP] = "dual",
 };

+static const char * const typec_port_data_roles[] = {
+       [TYPEC_PORT_DFP] = "host",
+       [TYPEC_PORT_UFP] = "device",
+       [TYPEC_PORT_DRD] = "dual",
+};
+
 static const char * const typec_port_types_drp[] = {
        [TYPEC_PORT_SRC] = "dual [source] sink",
        [TYPEC_PORT_SNK] = "dual source [sink]",
@@ -1054,7 +1060,7 @@ static ssize_t power_role_store(struct device *dev,
        mutex_lock(&port->port_type_lock);
        if (port->port_type != TYPEC_PORT_DRP) {
                dev_dbg(dev, "port type fixed at \"%s\"",
-                            typec_port_types[port->port_type]);
+                       typec_port_power_roles[port->port_type]);
                ret = -EOPNOTSUPP;
                goto unlock_and_ret;
        }
@@ -1095,7 +1101,7 @@ port_type_store(struct device *dev, struct device_attribute *attr,
                return -EOPNOTSUPP;
        }

-       ret = sysfs_match_string(typec_port_types, buf);
+       ret = sysfs_match_string(typec_port_power_roles, buf);
        if (ret < 0)
                return ret;

@@ -1129,7 +1135,7 @@ port_type_show(struct device *dev, struct device_attribute *attr,
                return sprintf(buf, "%s\n",
                               typec_port_types_drp[port->port_type]);

-       return sprintf(buf, "[%s]\n", typec_port_types[port->cap->type]);
+       return sprintf(buf, "[%s]\n", typec_port_power_roles[port->cap->type]);
 }
 static DEVICE_ATTR_RW(port_type);


Thanks,

-- 
heikki

^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [v6,05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-06-11 11:08     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 11:08 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

Hi Jun,

On Mon, May 28, 2018 at 10:52:37AM +0800, Li Jun wrote:
> This patch adds 3 APIs to get the typec port power and data type,
> and preferred power role by its name string.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  drivers/usb/typec/class.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/usb/typec.h |  3 +++
>  2 files changed, 53 insertions(+)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 53df10d..4c7d18c 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -802,6 +802,12 @@ static const char * const typec_port_types[] = {
>  	[TYPEC_PORT_DRP] = "dual",
>  };
>  
> +static const char * const typec_data_caps[] = {
> +	[TYPEC_PORT_DFP] = "host",
> +	[TYPEC_PORT_UFP] = "device",
> +	[TYPEC_PORT_DRD] = "dual",
> +};

Since I guess you need to fix this patch in any case, could you rename
that to "typec_port_data_roles".

And while at it, how about using this as an opportunity to rename
typec_port_types to typec_port_power_roles?

So this just a suggestion, no need to actually change it :-) :


Thanks,

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index abbd33939109..97f7eb0e9879 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -918,12 +918,18 @@ static const char * const typec_data_roles[] = {
        [TYPEC_HOST]    = "host",
 };

-static const char * const typec_port_types[] = {
+static const char * const typec_port_power_roles[] = {
        [TYPEC_PORT_SRC] = "source",
        [TYPEC_PORT_SNK] = "sink",
        [TYPEC_PORT_DRP] = "dual",
 };

+static const char * const typec_port_data_roles[] = {
+       [TYPEC_PORT_DFP] = "host",
+       [TYPEC_PORT_UFP] = "device",
+       [TYPEC_PORT_DRD] = "dual",
+};
+
 static const char * const typec_port_types_drp[] = {
        [TYPEC_PORT_SRC] = "dual [source] sink",
        [TYPEC_PORT_SNK] = "dual source [sink]",
@@ -1054,7 +1060,7 @@ static ssize_t power_role_store(struct device *dev,
        mutex_lock(&port->port_type_lock);
        if (port->port_type != TYPEC_PORT_DRP) {
                dev_dbg(dev, "port type fixed at \"%s\"",
-                            typec_port_types[port->port_type]);
+                       typec_port_power_roles[port->port_type]);
                ret = -EOPNOTSUPP;
                goto unlock_and_ret;
        }
@@ -1095,7 +1101,7 @@ port_type_store(struct device *dev, struct device_attribute *attr,
                return -EOPNOTSUPP;
        }

-       ret = sysfs_match_string(typec_port_types, buf);
+       ret = sysfs_match_string(typec_port_power_roles, buf);
        if (ret < 0)
                return ret;

@@ -1129,7 +1135,7 @@ port_type_show(struct device *dev, struct device_attribute *attr,
                return sprintf(buf, "%s\n",
                               typec_port_types_drp[port->port_type]);

-       return sprintf(buf, "[%s]\n", typec_port_types[port->cap->type]);
+       return sprintf(buf, "[%s]\n", typec_port_power_roles[port->cap->type]);
 }
 static DEVICE_ATTR_RW(port_type);


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 04/15] usb: typec: add fwnode to tcpc
@ 2018-06-11 11:44     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 11:44 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:36AM +0800, Li Jun wrote:
> Add fwnode handle to get the fwnode so we can get typec configs
> it contains.
> 
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/staging/typec/tcpci.c | 7 +++++++
>  drivers/usb/typec/tcpm.c      | 1 +
>  include/linux/usb/tcpm.h      | 2 ++
>  3 files changed, 10 insertions(+)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index dd29288..e59547a 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -10,6 +10,7 @@
>  #include <linux/module.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>
>  #include <linux/usb/pd.h>
>  #include <linux/usb/tcpm.h>
> @@ -474,6 +475,12 @@ static int tcpci_parse_config(struct tcpci *tcpci)
>  
>  	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
>  	tcpci->tcpc.config = &tcpci_tcpc_config;
> +	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
> +							 "connector");
> +	if (!tcpci->tcpc.fwnode) {
> +		dev_err(tcpci->dev, "Can't find connector node.\n");
> +		return -EINVAL;
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 0ccd2ce..fcd22e8 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4581,6 +4581,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>  	else
>  		port->try_role = TYPEC_NO_PREFERRED_ROLE;
>  
> +	port->typec_caps.fwnode = tcpc->fwnode;
>  	port->typec_caps.prefer_role = tcpc->config->default_role;
>  	port->typec_caps.type = tcpc->config->type;
>  	port->typec_caps.data = tcpc->config->data;
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index b231b93..193920a 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -110,6 +110,7 @@ enum tcpc_mux_mode {
>  /**
>   * struct tcpc_dev - Port configuration and callback functions
>   * @config:	Pointer to port configuration
> + * @fwnode:	Pointer to port fwnode
>   * @get_vbus:	Called to read current VBUS state
>   * @get_current_limit:
>   *		Optional; called by the tcpm core when configured as a snk
> @@ -138,6 +139,7 @@ enum tcpc_mux_mode {
>   */
>  struct tcpc_dev {
>  	const struct tcpc_config *config;
> +	struct fwnode_handle *fwnode;
>  
>  	int (*init)(struct tcpc_dev *dev);
>  	int (*get_vbus)(struct tcpc_dev *dev);
> -- 
> 2.7.4

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,04/15] usb: typec: add fwnode to tcpc
@ 2018-06-11 11:44     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 11:44 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:36AM +0800, Li Jun wrote:
> Add fwnode handle to get the fwnode so we can get typec configs
> it contains.
> 
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/staging/typec/tcpci.c | 7 +++++++
>  drivers/usb/typec/tcpm.c      | 1 +
>  include/linux/usb/tcpm.h      | 2 ++
>  3 files changed, 10 insertions(+)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index dd29288..e59547a 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -10,6 +10,7 @@
>  #include <linux/module.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>
>  #include <linux/usb/pd.h>
>  #include <linux/usb/tcpm.h>
> @@ -474,6 +475,12 @@ static int tcpci_parse_config(struct tcpci *tcpci)
>  
>  	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
>  	tcpci->tcpc.config = &tcpci_tcpc_config;
> +	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
> +							 "connector");
> +	if (!tcpci->tcpc.fwnode) {
> +		dev_err(tcpci->dev, "Can't find connector node.\n");
> +		return -EINVAL;
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 0ccd2ce..fcd22e8 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4581,6 +4581,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>  	else
>  		port->try_role = TYPEC_NO_PREFERRED_ROLE;
>  
> +	port->typec_caps.fwnode = tcpc->fwnode;
>  	port->typec_caps.prefer_role = tcpc->config->default_role;
>  	port->typec_caps.type = tcpc->config->type;
>  	port->typec_caps.data = tcpc->config->data;
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index b231b93..193920a 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -110,6 +110,7 @@ enum tcpc_mux_mode {
>  /**
>   * struct tcpc_dev - Port configuration and callback functions
>   * @config:	Pointer to port configuration
> + * @fwnode:	Pointer to port fwnode
>   * @get_vbus:	Called to read current VBUS state
>   * @get_current_limit:
>   *		Optional; called by the tcpm core when configured as a snk
> @@ -138,6 +139,7 @@ enum tcpc_mux_mode {
>   */
>  struct tcpc_dev {
>  	const struct tcpc_config *config;
> +	struct fwnode_handle *fwnode;
>  
>  	int (*init)(struct tcpc_dev *dev);
>  	int (*get_vbus)(struct tcpc_dev *dev);
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 06/15] usb: typec: tcpm: support get typec and pd config from device properties
@ 2018-06-11 12:05     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:05 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:38AM +0800, Li Jun wrote:
> This patch adds support of get typec and power delivery config from
> firmware description.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

This looks good to me, assuming that everybody agrees with the names
used in the bindings. As usual, I would like Guenter to check tcpm.c
changes. I'm putting a few nitpicks below, but in any case:

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

> ---
>  drivers/usb/typec/tcpm.c | 132 +++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 110 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index fcd22e8..aa17cd5 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4241,6 +4241,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
>  	return nr_vdo;
>  }
>  
> +static int tcpm_fw_get_caps(struct tcpm_port *port,
> +			    struct fwnode_handle *fwnode)
> +{
> +	const char *cap_str;
> +	int ret;
> +	u32 mw;
> +
> +	if (!port || !fwnode)

if (!fwnode) is enough.

> +		return -EINVAL;
> +
> +	/* USB data support is optional */
> +	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> +	if (ret == 0) {
> +		port->typec_caps.data = typec_find_port_data_role(cap_str);
> +		if (port->typec_caps.data < 0)
> +			return -EINVAL;
> +	}
> +
> +	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.type = typec_find_port_power_role(cap_str);
> +	if (port->typec_caps.type < 0)
> +		return -EINVAL;
> +	port->port_type = port->typec_caps.type;
> +
> +	if (port->port_type == TYPEC_PORT_SNK)
> +		goto sink;
> +
> +	/* Get soruce pdos */

s/soruce/source/

> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     port->src_pdo, port->nr_src_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo,
> +					    port->nr_src_pdo))
> +		return -EINVAL;
> +
> +	if (port->port_type == TYPEC_PORT_SRC)
> +		return 0;
> +
> +	/* Get the preferred power role for DRP */
> +	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
> +	if (port->typec_caps.prefer_role < 0)
> +		return -EINVAL;
> +sink:
> +	/* Get sink pdos */
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     port->snk_pdo, port->nr_snk_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo,
> +					    port->nr_snk_pdo))
> +		return -EINVAL;
> +
> +	if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0)
> +		return -EINVAL;
> +	port->operating_snk_mw = mw / 1000;
> +
> +	return 0;
> +}

Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,06/15] usb: typec: tcpm: support get typec and pd config from device properties
@ 2018-06-11 12:05     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:05 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:38AM +0800, Li Jun wrote:
> This patch adds support of get typec and power delivery config from
> firmware description.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

This looks good to me, assuming that everybody agrees with the names
used in the bindings. As usual, I would like Guenter to check tcpm.c
changes. I'm putting a few nitpicks below, but in any case:

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

> ---
>  drivers/usb/typec/tcpm.c | 132 +++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 110 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index fcd22e8..aa17cd5 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4241,6 +4241,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
>  	return nr_vdo;
>  }
>  
> +static int tcpm_fw_get_caps(struct tcpm_port *port,
> +			    struct fwnode_handle *fwnode)
> +{
> +	const char *cap_str;
> +	int ret;
> +	u32 mw;
> +
> +	if (!port || !fwnode)

if (!fwnode) is enough.

> +		return -EINVAL;
> +
> +	/* USB data support is optional */
> +	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> +	if (ret == 0) {
> +		port->typec_caps.data = typec_find_port_data_role(cap_str);
> +		if (port->typec_caps.data < 0)
> +			return -EINVAL;
> +	}
> +
> +	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.type = typec_find_port_power_role(cap_str);
> +	if (port->typec_caps.type < 0)
> +		return -EINVAL;
> +	port->port_type = port->typec_caps.type;
> +
> +	if (port->port_type == TYPEC_PORT_SNK)
> +		goto sink;
> +
> +	/* Get soruce pdos */

s/soruce/source/

> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     port->src_pdo, port->nr_src_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo,
> +					    port->nr_src_pdo))
> +		return -EINVAL;
> +
> +	if (port->port_type == TYPEC_PORT_SRC)
> +		return 0;
> +
> +	/* Get the preferred power role for DRP */
> +	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
> +	if (port->typec_caps.prefer_role < 0)
> +		return -EINVAL;
> +sink:
> +	/* Get sink pdos */
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     port->snk_pdo, port->nr_snk_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo,
> +					    port->nr_snk_pdo))
> +		return -EINVAL;
> +
> +	if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0)
> +		return -EINVAL;
> +	port->operating_snk_mw = mw / 1000;
> +
> +	return 0;
> +}

Thanks,

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 11/15] typec: tcpm: add starting value for drp toggling
@ 2018-06-11 12:28     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:28 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:43AM +0800, Li Jun wrote:
> As DRP port autonomously toggles the Rp/Rd need a start value to
> begin with, so add one parameter for it in tcpm_start_drp_toggling.
> 
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/usb/typec/tcpm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index aa17cd5..d885bff 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -2436,15 +2436,15 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
>  	return 0;
>  }
>  
> -static bool tcpm_start_drp_toggling(struct tcpm_port *port)
> +static bool tcpm_start_drp_toggling(struct tcpm_port *port,
> +				    enum typec_cc_status cc)
>  {
>  	int ret;
>  
>  	if (port->tcpc->start_drp_toggling &&
>  	    port->port_type == TYPEC_PORT_DRP) {
>  		tcpm_log_force(port, "Start DRP toggling");
> -		ret = port->tcpc->start_drp_toggling(port->tcpc,
> -						     tcpm_rp_cc(port));
> +		ret = port->tcpc->start_drp_toggling(port->tcpc, cc);
>  		if (!ret)
>  			return true;
>  	}
> @@ -2752,7 +2752,7 @@ static void run_state_machine(struct tcpm_port *port)
>  		if (!port->non_pd_role_swap)
>  			tcpm_swap_complete(port, -ENOTCONN);
>  		tcpm_src_detach(port);
> -		if (tcpm_start_drp_toggling(port)) {
> +		if (tcpm_start_drp_toggling(port, tcpm_rp_cc(port))) {
>  			tcpm_set_state(port, DRP_TOGGLING, 0);
>  			break;
>  		}
> @@ -2927,7 +2927,7 @@ static void run_state_machine(struct tcpm_port *port)
>  			tcpm_swap_complete(port, -ENOTCONN);
>  		tcpm_pps_complete(port, -ENOTCONN);
>  		tcpm_snk_detach(port);
> -		if (tcpm_start_drp_toggling(port)) {
> +		if (tcpm_start_drp_toggling(port, TYPEC_CC_RD)) {
>  			tcpm_set_state(port, DRP_TOGGLING, 0);
>  			break;
>  		}
> -- 
> 2.7.4

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,11/15] typec: tcpm: add starting value for drp toggling
@ 2018-06-11 12:28     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:28 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:43AM +0800, Li Jun wrote:
> As DRP port autonomously toggles the Rp/Rd need a start value to
> begin with, so add one parameter for it in tcpm_start_drp_toggling.
> 
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/usb/typec/tcpm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index aa17cd5..d885bff 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -2436,15 +2436,15 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
>  	return 0;
>  }
>  
> -static bool tcpm_start_drp_toggling(struct tcpm_port *port)
> +static bool tcpm_start_drp_toggling(struct tcpm_port *port,
> +				    enum typec_cc_status cc)
>  {
>  	int ret;
>  
>  	if (port->tcpc->start_drp_toggling &&
>  	    port->port_type == TYPEC_PORT_DRP) {
>  		tcpm_log_force(port, "Start DRP toggling");
> -		ret = port->tcpc->start_drp_toggling(port->tcpc,
> -						     tcpm_rp_cc(port));
> +		ret = port->tcpc->start_drp_toggling(port->tcpc, cc);
>  		if (!ret)
>  			return true;
>  	}
> @@ -2752,7 +2752,7 @@ static void run_state_machine(struct tcpm_port *port)
>  		if (!port->non_pd_role_swap)
>  			tcpm_swap_complete(port, -ENOTCONN);
>  		tcpm_src_detach(port);
> -		if (tcpm_start_drp_toggling(port)) {
> +		if (tcpm_start_drp_toggling(port, tcpm_rp_cc(port))) {
>  			tcpm_set_state(port, DRP_TOGGLING, 0);
>  			break;
>  		}
> @@ -2927,7 +2927,7 @@ static void run_state_machine(struct tcpm_port *port)
>  			tcpm_swap_complete(port, -ENOTCONN);
>  		tcpm_pps_complete(port, -ENOTCONN);
>  		tcpm_snk_detach(port);
> -		if (tcpm_start_drp_toggling(port)) {
> +		if (tcpm_start_drp_toggling(port, TYPEC_CC_RD)) {
>  			tcpm_set_state(port, DRP_TOGGLING, 0);
>  			break;
>  		}
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-11 12:29     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:29 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:44AM +0800, Li Jun wrote:
> In case of drp toggling, we may need set correct cc value for role control
> after attach as it may never been set.

Is this something that should be considered as a fix?

> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  drivers/usb/typec/tcpm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index d885bff..98ea916 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
>  	tcpm_set_attached_state(port, false);
>  	port->try_src_count = 0;
>  	port->try_snk_count = 0;
> +	port->cc_req = TYPEC_CC_OPEN;
>  	port->supply_voltage = 0;
>  	port->current_limit = 0;
>  	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
> @@ -2831,6 +2832,8 @@ static void run_state_machine(struct tcpm_port *port)
>  		break;
>  
>  	case SRC_ATTACHED:
> +		if (port->cc_req == TYPEC_CC_OPEN)
> +			tcpm_set_cc(port, tcpm_rp_cc(port));
>  		ret = tcpm_src_attach(port);
>  		tcpm_set_state(port, SRC_UNATTACHED,
>  			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
> @@ -3004,6 +3007,8 @@ static void run_state_machine(struct tcpm_port *port)
>  		tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE);
>  		break;
>  	case SNK_ATTACHED:
> +		if (port->cc_req == TYPEC_CC_OPEN)
> +			tcpm_set_cc(port, TYPEC_CC_RD);
>  		ret = tcpm_snk_attach(port);
>  		if (ret < 0)
>  			tcpm_set_state(port, SNK_UNATTACHED, 0);

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-11 12:29     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:29 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:44AM +0800, Li Jun wrote:
> In case of drp toggling, we may need set correct cc value for role control
> after attach as it may never been set.

Is this something that should be considered as a fix?

> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
>  drivers/usb/typec/tcpm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index d885bff..98ea916 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
>  	tcpm_set_attached_state(port, false);
>  	port->try_src_count = 0;
>  	port->try_snk_count = 0;
> +	port->cc_req = TYPEC_CC_OPEN;
>  	port->supply_voltage = 0;
>  	port->current_limit = 0;
>  	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
> @@ -2831,6 +2832,8 @@ static void run_state_machine(struct tcpm_port *port)
>  		break;
>  
>  	case SRC_ATTACHED:
> +		if (port->cc_req == TYPEC_CC_OPEN)
> +			tcpm_set_cc(port, tcpm_rp_cc(port));
>  		ret = tcpm_src_attach(port);
>  		tcpm_set_state(port, SRC_UNATTACHED,
>  			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
> @@ -3004,6 +3007,8 @@ static void run_state_machine(struct tcpm_port *port)
>  		tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE);
>  		break;
>  	case SNK_ATTACHED:
> +		if (port->cc_req == TYPEC_CC_OPEN)
> +			tcpm_set_cc(port, TYPEC_CC_RD);
>  		ret = tcpm_snk_attach(port);
>  		if (ret < 0)
>  			tcpm_set_state(port, SNK_UNATTACHED, 0);

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 03/15] staging: typec: tcpci: add compatible string for nxp ptn5110
@ 2018-06-11 12:32     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:32 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:35AM +0800, Li Jun wrote:
> Add nxp ptn5110 typec controller compatible string: "nxp,ptn5110",
> which is a standard tcpci chip with power delivery support. Meanwhile
> remove "usb,tcpci" because it doesn't follow the binding format rule
> and has not been used yet.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 076d97e..dd29288 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -575,7 +575,7 @@ MODULE_DEVICE_TABLE(i2c, tcpci_id);
>  
>  #ifdef CONFIG_OF
>  static const struct of_device_id tcpci_of_match[] = {
> -	{ .compatible = "usb,tcpci", },
> +	{ .compatible = "nxp,ptn5110", },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, tcpci_of_match);

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,03/15] staging: typec: tcpci: add compatible string for nxp ptn5110
@ 2018-06-11 12:32     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:32 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:35AM +0800, Li Jun wrote:
> Add nxp ptn5110 typec controller compatible string: "nxp,ptn5110",
> which is a standard tcpci chip with power delivery support. Meanwhile
> remove "usb,tcpci" because it doesn't follow the binding format rule
> and has not been used yet.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 076d97e..dd29288 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -575,7 +575,7 @@ MODULE_DEVICE_TABLE(i2c, tcpci_id);
>  
>  #ifdef CONFIG_OF
>  static const struct of_device_id tcpci_of_match[] = {
> -	{ .compatible = "usb,tcpci", },
> +	{ .compatible = "nxp,ptn5110", },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, tcpci_of_match);

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 07/15] staging: typec: tcpci: remove unused tcpci_tcpc_config
@ 2018-06-11 12:33     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:33 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:39AM +0800, Li Jun wrote:
> Since we will use config settings via device properties, so
> remove the hard code tcpci_tcpc_config.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index e59547a..076498a 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -464,17 +464,10 @@ static const struct regmap_config tcpci_regmap_config = {
>  	.max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */
>  };
>  
> -static const struct tcpc_config tcpci_tcpc_config = {
> -	.type = TYPEC_PORT_DFP,
> -	.default_role = TYPEC_SINK,
> -};
> -
>  static int tcpci_parse_config(struct tcpci *tcpci)
>  {
>  	tcpci->controls_vbus = true; /* XXX */
>  
> -	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
> -	tcpci->tcpc.config = &tcpci_tcpc_config;
>  	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
>  							 "connector");
>  	if (!tcpci->tcpc.fwnode) {
> -- 
> 2.7.4

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,07/15] staging: typec: tcpci: remove unused tcpci_tcpc_config
@ 2018-06-11 12:33     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:33 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:39AM +0800, Li Jun wrote:
> Since we will use config settings via device properties, so
> remove the hard code tcpci_tcpc_config.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index e59547a..076498a 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -464,17 +464,10 @@ static const struct regmap_config tcpci_regmap_config = {
>  	.max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */
>  };
>  
> -static const struct tcpc_config tcpci_tcpc_config = {
> -	.type = TYPEC_PORT_DFP,
> -	.default_role = TYPEC_SINK,
> -};
> -
>  static int tcpci_parse_config(struct tcpci *tcpci)
>  {
>  	tcpci->controls_vbus = true; /* XXX */
>  
> -	/* TODO: Populate struct tcpc_config from ACPI/device-tree */
> -	tcpci->tcpc.config = &tcpci_tcpc_config;
>  	tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev,
>  							 "connector");
>  	if (!tcpci->tcpc.fwnode) {
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 08/15] staging: typec: tcpci: use IS_ERR() instead of PTR_ERR_OR_ZERO()
@ 2018-06-11 12:34     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:34 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:40AM +0800, Li Jun wrote:
> As tcpm_register_port() and tcpci_register_port() never return
> NULL and NULL is not a success in this case, use IS_ERR() to check
> the return value of both.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 076498a..b63f147 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -509,7 +509,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
>  		return ERR_PTR(err);
>  
>  	tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc);
> -	if (PTR_ERR_OR_ZERO(tcpci->port))
> +	if (IS_ERR(tcpci->port))
>  		return ERR_CAST(tcpci->port);
>  
>  	return tcpci;
> @@ -551,7 +551,7 @@ static int tcpci_probe(struct i2c_client *client,
>  		return err;
>  
>  	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
> -	if (PTR_ERR_OR_ZERO(chip->tcpci))
> +	if (IS_ERR(chip->tcpci))
>  		return PTR_ERR(chip->tcpci);
>  
>  	i2c_set_clientdata(client, chip);

Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,08/15] staging: typec: tcpci: use IS_ERR() instead of PTR_ERR_OR_ZERO()
@ 2018-06-11 12:34     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:34 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:40AM +0800, Li Jun wrote:
> As tcpm_register_port() and tcpci_register_port() never return
> NULL and NULL is not a success in this case, use IS_ERR() to check
> the return value of both.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 076498a..b63f147 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -509,7 +509,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
>  		return ERR_PTR(err);
>  
>  	tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc);
> -	if (PTR_ERR_OR_ZERO(tcpci->port))
> +	if (IS_ERR(tcpci->port))
>  		return ERR_CAST(tcpci->port);
>  
>  	return tcpci;
> @@ -551,7 +551,7 @@ static int tcpci_probe(struct i2c_client *client,
>  		return err;
>  
>  	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
> -	if (PTR_ERR_OR_ZERO(chip->tcpci))
> +	if (IS_ERR(chip->tcpci))
>  		return PTR_ERR(chip->tcpci);
>  
>  	i2c_set_clientdata(client, chip);

Thanks,

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 09/15] staging: typec: tcpci: register port before request irq
@ 2018-06-11 12:35     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:35 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:41AM +0800, Li Jun wrote:
> From: Peter Chen <peter.chen@nxp.com>
> 
> With that we can clear any pending events and the port is registered
> so driver can be ready to handle typec events once we request irq.
> 
> Signed-off-by: Peter Chen <peter.chen@nxp.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index b63f147..3b35fce 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -537,24 +537,27 @@ static int tcpci_probe(struct i2c_client *client,
>  	if (IS_ERR(chip->data.regmap))
>  		return PTR_ERR(chip->data.regmap);
>  
> +	i2c_set_clientdata(client, chip);
> +
>  	/* Disable chip interrupts before requesting irq */
>  	err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val,
>  			       sizeof(u16));
>  	if (err < 0)
>  		return err;
>  
> +	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
> +	if (IS_ERR(chip->tcpci))
> +		return PTR_ERR(chip->tcpci);
> +
>  	err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
>  					_tcpci_irq,
>  					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
>  					dev_name(&client->dev), chip);
> -	if (err < 0)
> +	if (err < 0) {
> +		tcpci_unregister_port(chip->tcpci);
>  		return err;
> +	}
>  
> -	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
> -	if (IS_ERR(chip->tcpci))
> -		return PTR_ERR(chip->tcpci);
> -
> -	i2c_set_clientdata(client, chip);
>  	return 0;
>  }

Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,09/15] staging: typec: tcpci: register port before request irq
@ 2018-06-11 12:35     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:35 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:41AM +0800, Li Jun wrote:
> From: Peter Chen <peter.chen@nxp.com>
> 
> With that we can clear any pending events and the port is registered
> so driver can be ready to handle typec events once we request irq.
> 
> Signed-off-by: Peter Chen <peter.chen@nxp.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index b63f147..3b35fce 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -537,24 +537,27 @@ static int tcpci_probe(struct i2c_client *client,
>  	if (IS_ERR(chip->data.regmap))
>  		return PTR_ERR(chip->data.regmap);
>  
> +	i2c_set_clientdata(client, chip);
> +
>  	/* Disable chip interrupts before requesting irq */
>  	err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val,
>  			       sizeof(u16));
>  	if (err < 0)
>  		return err;
>  
> +	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
> +	if (IS_ERR(chip->tcpci))
> +		return PTR_ERR(chip->tcpci);
> +
>  	err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
>  					_tcpci_irq,
>  					IRQF_ONESHOT | IRQF_TRIGGER_LOW,
>  					dev_name(&client->dev), chip);
> -	if (err < 0)
> +	if (err < 0) {
> +		tcpci_unregister_port(chip->tcpci);
>  		return err;
> +	}
>  
> -	chip->tcpci = tcpci_register_port(&client->dev, &chip->data);
> -	if (IS_ERR(chip->tcpci))
> -		return PTR_ERR(chip->tcpci);
> -
> -	i2c_set_clientdata(client, chip);
>  	return 0;
>  }

Thanks,

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 10/15] staging: typec: tcpci: enable vbus detection
@ 2018-06-11 12:36     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:36 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:42AM +0800, Li Jun wrote:
> TCPCI implementation may need SW to enable VBUS detection to generate
> power status events.
> 
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 3b35fce..4d3b0ae 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -373,6 +373,12 @@ static int tcpci_init(struct tcpc_dev *tcpc)
>  	if (ret < 0)
>  		return ret;
>  
> +	/* Enable Vbus detection */
> +	ret = regmap_write(tcpci->regmap, TCPC_COMMAND,
> +			   TCPC_CMD_ENABLE_VBUS_DETECT);
> +	if (ret < 0)
> +		return ret;
> +
>  	reg = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_FAILED |
>  		TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_RX_STATUS |
>  		TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS;

Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,10/15] staging: typec: tcpci: enable vbus detection
@ 2018-06-11 12:36     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 12:36 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:42AM +0800, Li Jun wrote:
> TCPCI implementation may need SW to enable VBUS detection to generate
> power status events.
> 
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Li Jun <jun.li@nxp.com>

FWIW:

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

> ---
>  drivers/staging/typec/tcpci.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 3b35fce..4d3b0ae 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -373,6 +373,12 @@ static int tcpci_init(struct tcpc_dev *tcpc)
>  	if (ret < 0)
>  		return ret;
>  
> +	/* Enable Vbus detection */
> +	ret = regmap_write(tcpci->regmap, TCPC_COMMAND,
> +			   TCPC_CMD_ENABLE_VBUS_DETECT);
> +	if (ret < 0)
> +		return ret;
> +
>  	reg = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_FAILED |
>  		TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_RX_STATUS |
>  		TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_CC_STATUS;

Thanks,

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 13/15] staging: typec: tcpci: keep the disconnected cc line open
@ 2018-06-11 13:14     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 13:14 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:45AM +0800, Li Jun wrote:
> While set polarity, we should keep the disconnected cc line to be
> open.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/staging/typec/tcpci.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 4d3b0ae..11c2d37 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -185,15 +185,25 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
>  			      enum typec_cc_polarity polarity)
>  {
>  	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> +	unsigned int reg;
>  	int ret;
>  
> -	ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
> -			   (polarity == TYPEC_POLARITY_CC2) ?
> -			   TCPC_TCPC_CTRL_ORIENTATION : 0);
> +	/* Keep the disconnect cc line open */
> +	ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &reg);
>  	if (ret < 0)
>  		return ret;
>  
> -	return 0;
> +	if (polarity == TYPEC_POLARITY_CC2)
> +		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT;
> +	else
> +		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT;
> +	ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
> +	if (ret < 0)
> +		return ret;
> +
> +	return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
> +			   (polarity == TYPEC_POLARITY_CC2) ?
> +			   TCPC_TCPC_CTRL_ORIENTATION : 0);
>  }
>  
>  static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)

Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,13/15] staging: typec: tcpci: keep the disconnected cc line open
@ 2018-06-11 13:14     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 13:14 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:45AM +0800, Li Jun wrote:
> While set polarity, we should keep the disconnected cc line to be
> open.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/staging/typec/tcpci.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 4d3b0ae..11c2d37 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -185,15 +185,25 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc,
>  			      enum typec_cc_polarity polarity)
>  {
>  	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> +	unsigned int reg;
>  	int ret;
>  
> -	ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
> -			   (polarity == TYPEC_POLARITY_CC2) ?
> -			   TCPC_TCPC_CTRL_ORIENTATION : 0);
> +	/* Keep the disconnect cc line open */
> +	ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, &reg);
>  	if (ret < 0)
>  		return ret;
>  
> -	return 0;
> +	if (polarity == TYPEC_POLARITY_CC2)
> +		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT;
> +	else
> +		reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT;
> +	ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg);
> +	if (ret < 0)
> +		return ret;
> +
> +	return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL,
> +			   (polarity == TYPEC_POLARITY_CC2) ?
> +			   TCPC_TCPC_CTRL_ORIENTATION : 0);
>  }
>  
>  static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)

Thanks,

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 14/15] staging: typec: tcpci: Only touch target bit when enable vconn
@ 2018-06-11 13:15     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 13:15 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:46AM +0800, Li Jun wrote:
> We need regmap_update_bits to avoid touch any other bits when
> enable or disable vconn.
> 
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/staging/typec/tcpci.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 11c2d37..ac6b418 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -218,12 +218,9 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
>  			return ret;
>  	}
>  
> -	ret = regmap_write(tcpci->regmap, TCPC_POWER_CTRL,
> -			   enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> +	return regmap_update_bits(tcpci->regmap, TCPC_POWER_CTRL,
> +				TCPC_POWER_CTRL_VCONN_ENABLE,
> +				enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
>  }
>  
>  static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached,

Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,14/15] staging: typec: tcpci: Only touch target bit when enable vconn
@ 2018-06-11 13:15     ` Heikki Krogerus
  0 siblings, 0 replies; 75+ messages in thread
From: Heikki Krogerus @ 2018-06-11 13:15 UTC (permalink / raw)
  To: Li Jun
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	peter.chen, garsilva, gsomlo, linux-usb, devicetree, linux-imx

On Mon, May 28, 2018 at 10:52:46AM +0800, Li Jun wrote:
> We need regmap_update_bits to avoid touch any other bits when
> enable or disable vconn.
> 
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Li Jun <jun.li@nxp.com>

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

> ---
>  drivers/staging/typec/tcpci.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
> index 11c2d37..ac6b418 100644
> --- a/drivers/staging/typec/tcpci.c
> +++ b/drivers/staging/typec/tcpci.c
> @@ -218,12 +218,9 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
>  			return ret;
>  	}
>  
> -	ret = regmap_write(tcpci->regmap, TCPC_POWER_CTRL,
> -			   enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> +	return regmap_update_bits(tcpci->regmap, TCPC_POWER_CTRL,
> +				TCPC_POWER_CTRL_VCONN_ENABLE,
> +				enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
>  }
>  
>  static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached,

Thanks,

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 06/15] usb: typec: tcpm: support get typec and pd config from device properties
@ 2018-06-11 13:27     ` Guenter Roeck
  0 siblings, 0 replies; 75+ messages in thread
From: Guenter Roeck @ 2018-06-11 13:27 UTC (permalink / raw)
  To: Li Jun, robh+dt, gregkh, heikki.krogerus
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	linux-usb, devicetree, linux-imx

On 05/27/2018 07:52 PM, Li Jun wrote:
> This patch adds support of get typec and power delivery config from
> firmware description.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

Except for the nitpick. on top of Heikki's comments:

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/usb/typec/tcpm.c | 132 +++++++++++++++++++++++++++++++++++++++--------
>   1 file changed, 110 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index fcd22e8..aa17cd5 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4241,6 +4241,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
>   	return nr_vdo;
>   }
>   
> +static int tcpm_fw_get_caps(struct tcpm_port *port,
> +			    struct fwnode_handle *fwnode)
> +{
> +	const char *cap_str;
> +	int ret;
> +	u32 mw;
> +
> +	if (!port || !fwnode)
> +		return -EINVAL;
> +
> +	/* USB data support is optional */
> +	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> +	if (ret == 0) {
> +		port->typec_caps.data = typec_find_port_data_role(cap_str);
> +		if (port->typec_caps.data < 0)
> +			return -EINVAL;
> +	}
> +
> +	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.type = typec_find_port_power_role(cap_str);
> +	if (port->typec_caps.type < 0)
> +		return -EINVAL;
> +	port->port_type = port->typec_caps.type;
> +
> +	if (port->port_type == TYPEC_PORT_SNK)
> +		goto sink;
> +
> +	/* Get soruce pdos */
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     port->src_pdo, port->nr_src_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo,
> +					    port->nr_src_pdo))
> +		return -EINVAL;
> +
> +	if (port->port_type == TYPEC_PORT_SRC)
> +		return 0;
> +
> +	/* Get the preferred power role for DRP */
> +	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
> +	if (port->typec_caps.prefer_role < 0)
> +		return -EINVAL;
> +sink:
> +	/* Get sink pdos */
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     port->snk_pdo, port->nr_snk_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo,
> +					    port->nr_snk_pdo))
> +		return -EINVAL;
> +
> +	if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0)
> +		return -EINVAL;
> +	port->operating_snk_mw = mw / 1000;
> +

"mw" should be "uw", really. The variable never holds "milliwatt".

> +	return 0;
> +}
> +
>   int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
>   				    unsigned int nr_pdo)
>   {
> @@ -4526,12 +4601,36 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
>   	return PTR_ERR_OR_ZERO(port->psy);
>   }
>   
> +static int tcpm_copy_caps(struct tcpm_port *port,
> +			  const struct tcpc_config *tcfg)
> +{
> +	if (tcpm_validate_caps(port, tcfg->src_pdo, tcfg->nr_src_pdo) ||
> +	    tcpm_validate_caps(port, tcfg->snk_pdo, tcfg->nr_snk_pdo))
> +		return -EINVAL;
> +
> +	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcfg->src_pdo,
> +					  tcfg->nr_src_pdo);
> +	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcfg->snk_pdo,
> +					  tcfg->nr_snk_pdo);
> +
> +	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcfg->snk_vdo,
> +					  tcfg->nr_snk_vdo);
> +
> +	port->operating_snk_mw = tcfg->operating_snk_mw;
> +
> +	port->typec_caps.prefer_role = tcfg->default_role;
> +	port->typec_caps.type = tcfg->type;
> +	port->typec_caps.data = tcfg->data;
> +
> +	return 0;
> +}
> +
>   struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   {
>   	struct tcpm_port *port;
>   	int i, err;
>   
> -	if (!dev || !tcpc || !tcpc->config ||
> +	if (!dev || !tcpc ||
>   	    !tcpc->get_vbus || !tcpc->set_cc || !tcpc->get_cc ||
>   	    !tcpc->set_polarity || !tcpc->set_vconn || !tcpc->set_vbus ||
>   	    !tcpc->set_pd_rx || !tcpc->set_roles || !tcpc->pd_transmit)
> @@ -4561,30 +4660,19 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   	init_completion(&port->pps_complete);
>   	tcpm_debugfs_init(port);
>   
> -	if (tcpm_validate_caps(port, tcpc->config->src_pdo,
> -			       tcpc->config->nr_src_pdo) ||
> -	    tcpm_validate_caps(port, tcpc->config->snk_pdo,
> -			       tcpc->config->nr_snk_pdo)) {
> -		err = -EINVAL;
> +	if (tcpc->config)
> +		err = tcpm_copy_caps(port, tcpc->config);
> +	else
> +		err = tcpm_fw_get_caps(port, tcpc->fwnode);
> +	if (err < 0)
>   		goto out_destroy_wq;
> -	}
> -	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcpc->config->src_pdo,
> -					  tcpc->config->nr_src_pdo);
> -	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo,
> -					  tcpc->config->nr_snk_pdo);
> -	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo,
> -					  tcpc->config->nr_snk_vdo);
> -
> -	port->operating_snk_mw = tcpc->config->operating_snk_mw;
> -	if (!tcpc->config->try_role_hw)
> -		port->try_role = tcpc->config->default_role;
> +
> +	if (!tcpc->config || !tcpc->config->try_role_hw)
> +		port->try_role = port->typec_caps.prefer_role;
>   	else
>   		port->try_role = TYPEC_NO_PREFERRED_ROLE;
> 
>   	port->typec_caps.fwnode = tcpc->fwnode;
> -	port->typec_caps.prefer_role = tcpc->config->default_role;
> -	port->typec_caps.type = tcpc->config->type;
> -	port->typec_caps.data = tcpc->config->data;
>   	port->typec_caps.revision = 0x0120;	/* Type-C spec release 1.2 */
>   	port->typec_caps.pd_revision = 0x0300;	/* USB-PD spec release 3.0 */
>   	port->typec_caps.dr_set = tcpm_dr_set;
> @@ -4594,7 +4682,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   	port->typec_caps.port_type_set = tcpm_port_type_set;
>   
>   	port->partner_desc.identity = &port->partner_ident;
> -	port->port_type = tcpc->config->type;
> +	port->port_type = port->typec_caps.type;
>   
>   	port->role_sw = usb_role_switch_get(port->dev);
>   	if (IS_ERR(port->role_sw)) {
> @@ -4612,7 +4700,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   		goto out_destroy_wq;
>   	}
>   
> -	if (tcpc->config->alt_modes) {
> +	if (tcpc->config && tcpc->config->alt_modes) {
>   		const struct typec_altmode_desc *paltmode = tcpc->config->alt_modes;
>   
>   		i = 0;
> 

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,06/15] usb: typec: tcpm: support get typec and pd config from device properties
@ 2018-06-11 13:27     ` Guenter Roeck
  0 siblings, 0 replies; 75+ messages in thread
From: Guenter Roeck @ 2018-06-11 13:27 UTC (permalink / raw)
  To: Li Jun, robh+dt, gregkh, heikki.krogerus
  Cc: cw00.choi, a.hajda, shufan_lee, peter.chen, garsilva, gsomlo,
	linux-usb, devicetree, linux-imx

On 05/27/2018 07:52 PM, Li Jun wrote:
> This patch adds support of get typec and power delivery config from
> firmware description.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

Except for the nitpick. on top of Heikki's comments:

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/usb/typec/tcpm.c | 132 +++++++++++++++++++++++++++++++++++++++--------
>   1 file changed, 110 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index fcd22e8..aa17cd5 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -4241,6 +4241,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
>   	return nr_vdo;
>   }
>   
> +static int tcpm_fw_get_caps(struct tcpm_port *port,
> +			    struct fwnode_handle *fwnode)
> +{
> +	const char *cap_str;
> +	int ret;
> +	u32 mw;
> +
> +	if (!port || !fwnode)
> +		return -EINVAL;
> +
> +	/* USB data support is optional */
> +	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
> +	if (ret == 0) {
> +		port->typec_caps.data = typec_find_port_data_role(cap_str);
> +		if (port->typec_caps.data < 0)
> +			return -EINVAL;
> +	}
> +
> +	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.type = typec_find_port_power_role(cap_str);
> +	if (port->typec_caps.type < 0)
> +		return -EINVAL;
> +	port->port_type = port->typec_caps.type;
> +
> +	if (port->port_type == TYPEC_PORT_SNK)
> +		goto sink;
> +
> +	/* Get soruce pdos */
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "source-pdos",
> +					     port->src_pdo, port->nr_src_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo,
> +					    port->nr_src_pdo))
> +		return -EINVAL;
> +
> +	if (port->port_type == TYPEC_PORT_SRC)
> +		return 0;
> +
> +	/* Get the preferred power role for DRP */
> +	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
> +	if (ret < 0)
> +		return ret;
> +
> +	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
> +	if (port->typec_caps.prefer_role < 0)
> +		return -EINVAL;
> +sink:
> +	/* Get sink pdos */
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     NULL, 0);
> +	if (ret <= 0)
> +		return -EINVAL;
> +
> +	port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS);
> +	ret = fwnode_property_read_u32_array(fwnode, "sink-pdos",
> +					     port->snk_pdo, port->nr_snk_pdo);
> +	if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo,
> +					    port->nr_snk_pdo))
> +		return -EINVAL;
> +
> +	if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0)
> +		return -EINVAL;
> +	port->operating_snk_mw = mw / 1000;
> +

"mw" should be "uw", really. The variable never holds "milliwatt".

> +	return 0;
> +}
> +
>   int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
>   				    unsigned int nr_pdo)
>   {
> @@ -4526,12 +4601,36 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
>   	return PTR_ERR_OR_ZERO(port->psy);
>   }
>   
> +static int tcpm_copy_caps(struct tcpm_port *port,
> +			  const struct tcpc_config *tcfg)
> +{
> +	if (tcpm_validate_caps(port, tcfg->src_pdo, tcfg->nr_src_pdo) ||
> +	    tcpm_validate_caps(port, tcfg->snk_pdo, tcfg->nr_snk_pdo))
> +		return -EINVAL;
> +
> +	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcfg->src_pdo,
> +					  tcfg->nr_src_pdo);
> +	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcfg->snk_pdo,
> +					  tcfg->nr_snk_pdo);
> +
> +	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcfg->snk_vdo,
> +					  tcfg->nr_snk_vdo);
> +
> +	port->operating_snk_mw = tcfg->operating_snk_mw;
> +
> +	port->typec_caps.prefer_role = tcfg->default_role;
> +	port->typec_caps.type = tcfg->type;
> +	port->typec_caps.data = tcfg->data;
> +
> +	return 0;
> +}
> +
>   struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   {
>   	struct tcpm_port *port;
>   	int i, err;
>   
> -	if (!dev || !tcpc || !tcpc->config ||
> +	if (!dev || !tcpc ||
>   	    !tcpc->get_vbus || !tcpc->set_cc || !tcpc->get_cc ||
>   	    !tcpc->set_polarity || !tcpc->set_vconn || !tcpc->set_vbus ||
>   	    !tcpc->set_pd_rx || !tcpc->set_roles || !tcpc->pd_transmit)
> @@ -4561,30 +4660,19 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   	init_completion(&port->pps_complete);
>   	tcpm_debugfs_init(port);
>   
> -	if (tcpm_validate_caps(port, tcpc->config->src_pdo,
> -			       tcpc->config->nr_src_pdo) ||
> -	    tcpm_validate_caps(port, tcpc->config->snk_pdo,
> -			       tcpc->config->nr_snk_pdo)) {
> -		err = -EINVAL;
> +	if (tcpc->config)
> +		err = tcpm_copy_caps(port, tcpc->config);
> +	else
> +		err = tcpm_fw_get_caps(port, tcpc->fwnode);
> +	if (err < 0)
>   		goto out_destroy_wq;
> -	}
> -	port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcpc->config->src_pdo,
> -					  tcpc->config->nr_src_pdo);
> -	port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo,
> -					  tcpc->config->nr_snk_pdo);
> -	port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo,
> -					  tcpc->config->nr_snk_vdo);
> -
> -	port->operating_snk_mw = tcpc->config->operating_snk_mw;
> -	if (!tcpc->config->try_role_hw)
> -		port->try_role = tcpc->config->default_role;
> +
> +	if (!tcpc->config || !tcpc->config->try_role_hw)
> +		port->try_role = port->typec_caps.prefer_role;
>   	else
>   		port->try_role = TYPEC_NO_PREFERRED_ROLE;
> 
>   	port->typec_caps.fwnode = tcpc->fwnode;
> -	port->typec_caps.prefer_role = tcpc->config->default_role;
> -	port->typec_caps.type = tcpc->config->type;
> -	port->typec_caps.data = tcpc->config->data;
>   	port->typec_caps.revision = 0x0120;	/* Type-C spec release 1.2 */
>   	port->typec_caps.pd_revision = 0x0300;	/* USB-PD spec release 3.0 */
>   	port->typec_caps.dr_set = tcpm_dr_set;
> @@ -4594,7 +4682,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   	port->typec_caps.port_type_set = tcpm_port_type_set;
>   
>   	port->partner_desc.identity = &port->partner_ident;
> -	port->port_type = tcpc->config->type;
> +	port->port_type = port->typec_caps.type;
>   
>   	port->role_sw = usb_role_switch_get(port->dev);
>   	if (IS_ERR(port->role_sw)) {
> @@ -4612,7 +4700,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>   		goto out_destroy_wq;
>   	}
>   
> -	if (tcpc->config->alt_modes) {
> +	if (tcpc->config && tcpc->config->alt_modes) {
>   		const struct typec_altmode_desc *paltmode = tcpc->config->alt_modes;
>   
>   		i = 0;
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 75+ messages in thread

* Re: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-11 13:35       ` Guenter Roeck
  0 siblings, 0 replies; 75+ messages in thread
From: Guenter Roeck @ 2018-06-11 13:35 UTC (permalink / raw)
  To: Heikki Krogerus, Li Jun
  Cc: robh+dt, gregkh, cw00.choi, a.hajda, shufan_lee, peter.chen,
	garsilva, gsomlo, linux-usb, devicetree, linux-imx

On 06/11/2018 05:29 AM, Heikki Krogerus wrote:
> On Mon, May 28, 2018 at 10:52:44AM +0800, Li Jun wrote:
>> In case of drp toggling, we may need set correct cc value for role control
>> after attach as it may never been set.
> 
> Is this something that should be considered as a fix?
> 

The problem with this patch is that it hides a problem. CC should have been set
by the time a port reaches the attached state. The patch means that there is
a state machine path where this does not happen. I'd rather understand that
path and fix the problem where it happens.

Guenter

>> Signed-off-by: Li Jun <jun.li@nxp.com>
>> ---
>>   drivers/usb/typec/tcpm.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
>> index d885bff..98ea916 100644
>> --- a/drivers/usb/typec/tcpm.c
>> +++ b/drivers/usb/typec/tcpm.c
>> @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
>>   	tcpm_set_attached_state(port, false);
>>   	port->try_src_count = 0;
>>   	port->try_snk_count = 0;
>> +	port->cc_req = TYPEC_CC_OPEN;
>>   	port->supply_voltage = 0;
>>   	port->current_limit = 0;
>>   	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
>> @@ -2831,6 +2832,8 @@ static void run_state_machine(struct tcpm_port *port)
>>   		break;
>>   
>>   	case SRC_ATTACHED:
>> +		if (port->cc_req == TYPEC_CC_OPEN)
>> +			tcpm_set_cc(port, tcpm_rp_cc(port));
>>   		ret = tcpm_src_attach(port);
>>   		tcpm_set_state(port, SRC_UNATTACHED,
>>   			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
>> @@ -3004,6 +3007,8 @@ static void run_state_machine(struct tcpm_port *port)
>>   		tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE);
>>   		break;
>>   	case SNK_ATTACHED:
>> +		if (port->cc_req == TYPEC_CC_OPEN)
>> +			tcpm_set_cc(port, TYPEC_CC_RD);
>>   		ret = tcpm_snk_attach(port);
>>   		if (ret < 0)
>>   			tcpm_set_state(port, SNK_UNATTACHED, 0);
> 

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-11 13:35       ` Guenter Roeck
  0 siblings, 0 replies; 75+ messages in thread
From: Guenter Roeck @ 2018-06-11 13:35 UTC (permalink / raw)
  To: Heikki Krogerus, Li Jun
  Cc: robh+dt, gregkh, cw00.choi, a.hajda, shufan_lee, peter.chen,
	garsilva, gsomlo, linux-usb, devicetree, linux-imx

On 06/11/2018 05:29 AM, Heikki Krogerus wrote:
> On Mon, May 28, 2018 at 10:52:44AM +0800, Li Jun wrote:
>> In case of drp toggling, we may need set correct cc value for role control
>> after attach as it may never been set.
> 
> Is this something that should be considered as a fix?
> 

The problem with this patch is that it hides a problem. CC should have been set
by the time a port reaches the attached state. The patch means that there is
a state machine path where this does not happen. I'd rather understand that
path and fix the problem where it happens.

Guenter

>> Signed-off-by: Li Jun <jun.li@nxp.com>
>> ---
>>   drivers/usb/typec/tcpm.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
>> index d885bff..98ea916 100644
>> --- a/drivers/usb/typec/tcpm.c
>> +++ b/drivers/usb/typec/tcpm.c
>> @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
>>   	tcpm_set_attached_state(port, false);
>>   	port->try_src_count = 0;
>>   	port->try_snk_count = 0;
>> +	port->cc_req = TYPEC_CC_OPEN;
>>   	port->supply_voltage = 0;
>>   	port->current_limit = 0;
>>   	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
>> @@ -2831,6 +2832,8 @@ static void run_state_machine(struct tcpm_port *port)
>>   		break;
>>   
>>   	case SRC_ATTACHED:
>> +		if (port->cc_req == TYPEC_CC_OPEN)
>> +			tcpm_set_cc(port, tcpm_rp_cc(port));
>>   		ret = tcpm_src_attach(port);
>>   		tcpm_set_state(port, SRC_UNATTACHED,
>>   			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON);
>> @@ -3004,6 +3007,8 @@ static void run_state_machine(struct tcpm_port *port)
>>   		tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE);
>>   		break;
>>   	case SNK_ATTACHED:
>> +		if (port->cc_req == TYPEC_CC_OPEN)
>> +			tcpm_set_cc(port, TYPEC_CC_RD);
>>   		ret = tcpm_snk_attach(port);
>>   		if (ret < 0)
>>   			tcpm_set_state(port, SNK_UNATTACHED, 0);
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 75+ messages in thread

* RE: [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-06-13  9:47       ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-06-13  9:47 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	Peter Chen, garsilva, gsomlo, linux-usb, devicetree,
	dl-linux-imx

Hi Heikki,
> -----Original Message-----
> From: Heikki Krogerus [mailto:heikki.krogerus@linux.intel.com]
> Sent: 2018年6月11日 19:09
> To: Jun Li <jun.li@nxp.com>
> Cc: robh+dt@kernel.org; gregkh@linuxfoundation.org; linux@roeck-us.net;
> cw00.choi@samsung.com; a.hajda@samsung.com; shufan_lee@richtek.com;
> Peter Chen <peter.chen@nxp.com>; garsilva@embeddedor.com;
> gsomlo@gmail.com; linux-usb@vger.kernel.org; devicetree@vger.kernel.org;
> dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH v6 05/15] usb: typec: add API to get typec basic port power
> and data config
> 
> Hi Jun,
> 
> On Mon, May 28, 2018 at 10:52:37AM +0800, Li Jun wrote:
> > This patch adds 3 APIs to get the typec port power and data type, and
> > preferred power role by its name string.
> >
> > Signed-off-by: Li Jun <jun.li@nxp.com>
> > ---
> >  drivers/usb/typec/class.c | 50
> > +++++++++++++++++++++++++++++++++++++++++++++++
> >  include/linux/usb/typec.h |  3 +++
> >  2 files changed, 53 insertions(+)
> >
> > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> > index 53df10d..4c7d18c 100644
> > --- a/drivers/usb/typec/class.c
> > +++ b/drivers/usb/typec/class.c
> > @@ -802,6 +802,12 @@ static const char * const typec_port_types[] = {
> >  	[TYPEC_PORT_DRP] = "dual",
> >  };
> >
> > +static const char * const typec_data_caps[] = {
> > +	[TYPEC_PORT_DFP] = "host",
> > +	[TYPEC_PORT_UFP] = "device",
> > +	[TYPEC_PORT_DRD] = "dual",
> > +};
> 
> Since I guess you need to fix this patch in any case, could you rename that to
> "typec_port_data_roles".

OK.

> 
> And while at it, how about using this as an opportunity to rename
> typec_port_types to typec_port_power_roles?
> 
> So this just a suggestion, no need to actually change it :-) :

Also OK for me, I can rename it by this chance.

> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index
> abbd33939109..97f7eb0e9879 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -918,12 +918,18 @@ static const char * const typec_data_roles[] = {
>         [TYPEC_HOST]    = "host",
>  };
> 
> -static const char * const typec_port_types[] = {
> +static const char * const typec_port_power_roles[] = {
>         [TYPEC_PORT_SRC] = "source",
>         [TYPEC_PORT_SNK] = "sink",
>         [TYPEC_PORT_DRP] = "dual",
>  };
> 
> +static const char * const typec_port_data_roles[] = {
> +       [TYPEC_PORT_DFP] = "host",
> +       [TYPEC_PORT_UFP] = "device",
> +       [TYPEC_PORT_DRD] = "dual",
> +};
> +
>  static const char * const typec_port_types_drp[] = {
>         [TYPEC_PORT_SRC] = "dual [source] sink",
>         [TYPEC_PORT_SNK] = "dual source [sink]", @@ -1054,7 +1060,7 @@
> static ssize_t power_role_store(struct device *dev,
>         mutex_lock(&port->port_type_lock);
>         if (port->port_type != TYPEC_PORT_DRP) {
>                 dev_dbg(dev, "port type fixed at \"%s\"",
> -                            typec_port_types[port->port_type]);
> +                       typec_port_power_roles[port->port_type]);
>                 ret = -EOPNOTSUPP;
>                 goto unlock_and_ret;
>         }
> @@ -1095,7 +1101,7 @@ port_type_store(struct device *dev, struct
> device_attribute *attr,
>                 return -EOPNOTSUPP;
>         }
> 
> -       ret = sysfs_match_string(typec_port_types, buf);
> +       ret = sysfs_match_string(typec_port_power_roles, buf);
>         if (ret < 0)
>                 return ret;
> 
> @@ -1129,7 +1135,7 @@ port_type_show(struct device *dev, struct
> device_attribute *attr,
>                 return sprintf(buf, "%s\n",
>                                typec_port_types_drp[port->port_type]);
> 
> -       return sprintf(buf, "[%s]\n", typec_port_types[port->cap->type]);
> +       return sprintf(buf, "[%s]\n",
> + typec_port_power_roles[port->cap->type]);
>  }
>  static DEVICE_ATTR_RW(port_type);
> 
> 
> Thanks,
> 
> --
> heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,05/15] usb: typec: add API to get typec basic port power and data config
@ 2018-06-13  9:47       ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-06-13  9:47 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: robh+dt, gregkh, linux, cw00.choi, a.hajda, shufan_lee,
	Peter Chen, garsilva, gsomlo, linux-usb, devicetree,
	dl-linux-imx

Hi Heikki,
> -----Original Message-----
> From: Heikki Krogerus [mailto:heikki.krogerus@linux.intel.com]
> Sent: 2018年6月11日 19:09
> To: Jun Li <jun.li@nxp.com>
> Cc: robh+dt@kernel.org; gregkh@linuxfoundation.org; linux@roeck-us.net;
> cw00.choi@samsung.com; a.hajda@samsung.com; shufan_lee@richtek.com;
> Peter Chen <peter.chen@nxp.com>; garsilva@embeddedor.com;
> gsomlo@gmail.com; linux-usb@vger.kernel.org; devicetree@vger.kernel.org;
> dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH v6 05/15] usb: typec: add API to get typec basic port power
> and data config
> 
> Hi Jun,
> 
> On Mon, May 28, 2018 at 10:52:37AM +0800, Li Jun wrote:
> > This patch adds 3 APIs to get the typec port power and data type, and
> > preferred power role by its name string.
> >
> > Signed-off-by: Li Jun <jun.li@nxp.com>
> > ---
> >  drivers/usb/typec/class.c | 50
> > +++++++++++++++++++++++++++++++++++++++++++++++
> >  include/linux/usb/typec.h |  3 +++
> >  2 files changed, 53 insertions(+)
> >
> > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> > index 53df10d..4c7d18c 100644
> > --- a/drivers/usb/typec/class.c
> > +++ b/drivers/usb/typec/class.c
> > @@ -802,6 +802,12 @@ static const char * const typec_port_types[] = {
> >  	[TYPEC_PORT_DRP] = "dual",
> >  };
> >
> > +static const char * const typec_data_caps[] = {
> > +	[TYPEC_PORT_DFP] = "host",
> > +	[TYPEC_PORT_UFP] = "device",
> > +	[TYPEC_PORT_DRD] = "dual",
> > +};
> 
> Since I guess you need to fix this patch in any case, could you rename that to
> "typec_port_data_roles".

OK.

> 
> And while at it, how about using this as an opportunity to rename
> typec_port_types to typec_port_power_roles?
> 
> So this just a suggestion, no need to actually change it :-) :

Also OK for me, I can rename it by this chance.

> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index
> abbd33939109..97f7eb0e9879 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -918,12 +918,18 @@ static const char * const typec_data_roles[] = {
>         [TYPEC_HOST]    = "host",
>  };
> 
> -static const char * const typec_port_types[] = {
> +static const char * const typec_port_power_roles[] = {
>         [TYPEC_PORT_SRC] = "source",
>         [TYPEC_PORT_SNK] = "sink",
>         [TYPEC_PORT_DRP] = "dual",
>  };
> 
> +static const char * const typec_port_data_roles[] = {
> +       [TYPEC_PORT_DFP] = "host",
> +       [TYPEC_PORT_UFP] = "device",
> +       [TYPEC_PORT_DRD] = "dual",
> +};
> +
>  static const char * const typec_port_types_drp[] = {
>         [TYPEC_PORT_SRC] = "dual [source] sink",
>         [TYPEC_PORT_SNK] = "dual source [sink]", @@ -1054,7 +1060,7 @@
> static ssize_t power_role_store(struct device *dev,
>         mutex_lock(&port->port_type_lock);
>         if (port->port_type != TYPEC_PORT_DRP) {
>                 dev_dbg(dev, "port type fixed at \"%s\"",
> -                            typec_port_types[port->port_type]);
> +                       typec_port_power_roles[port->port_type]);
>                 ret = -EOPNOTSUPP;
>                 goto unlock_and_ret;
>         }
> @@ -1095,7 +1101,7 @@ port_type_store(struct device *dev, struct
> device_attribute *attr,
>                 return -EOPNOTSUPP;
>         }
> 
> -       ret = sysfs_match_string(typec_port_types, buf);
> +       ret = sysfs_match_string(typec_port_power_roles, buf);
>         if (ret < 0)
>                 return ret;
> 
> @@ -1129,7 +1135,7 @@ port_type_show(struct device *dev, struct
> device_attribute *attr,
>                 return sprintf(buf, "%s\n",
>                                typec_port_types_drp[port->port_type]);
> 
> -       return sprintf(buf, "[%s]\n", typec_port_types[port->cap->type]);
> +       return sprintf(buf, "[%s]\n",
> + typec_port_power_roles[port->cap->type]);
>  }
>  static DEVICE_ATTR_RW(port_type);
> 
> 
> Thanks,
> 
> --
> heikki

^ permalink raw reply	[flat|nested] 75+ messages in thread

* RE: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-13 11:06         ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-06-13 11:06 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, shufan_lee
  Cc: robh+dt, gregkh, cw00.choi, a.hajda, Peter Chen, garsilva,
	gsomlo, linux-usb, devicetree, dl-linux-imx

Hi,
> -----Original Message-----
> From: Guenter Roeck [mailto:groeck7@gmail.com] On Behalf Of Guenter Roeck
> Sent: 2018年6月11日 21:35
> To: Heikki Krogerus <heikki.krogerus@linux.intel.com>; Jun Li <jun.li@nxp.com>
> Cc: robh+dt@kernel.org; gregkh@linuxfoundation.org; cw00.choi@samsung.com;
> a.hajda@samsung.com; shufan_lee@richtek.com; Peter Chen
> <peter.chen@nxp.com>; garsilva@embeddedor.com; gsomlo@gmail.com;
> linux-usb@vger.kernel.org; devicetree@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>
> Subject: Re: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
> 
> On 06/11/2018 05:29 AM, Heikki Krogerus wrote:
> > On Mon, May 28, 2018 at 10:52:44AM +0800, Li Jun wrote:
> >> In case of drp toggling, we may need set correct cc value for role
> >> control after attach as it may never been set.
> >
> > Is this something that should be considered as a fix?
> >
> 
> The problem with this patch is that it hides a problem. CC should have been set
> by the time a port reaches the attached state. The patch means that there is a
> state machine path where this does not happen. I'd rather understand that path
> and fix the problem where it happens.

Here is my previous explanation about this state machine path[1]

[1]https://www.spinics.net/lists/linux-usb/msg167467.html

The physical CC line state is correct, just the Role Control register value
may mismatch on some(e.g. shufan's) HW, if the common change in tcpm
is not the right way, I have to ask shufan to try resolve this in his custom
rt1711h driver.

I understand the concern of setting cc at attached state is late, should be
done before that, how about I move this in cc_change like below:

@@ -3492,10 +3492,13 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
        switch (port->state) {
        case DRP_TOGGLING:
                if (tcpm_port_is_debug(port) || tcpm_port_is_audio(port) ||
-                   tcpm_port_is_source(port))
+                   tcpm_port_is_source(port)) {
+                       tcpm_set_cc(port, tcpm_rp_cc(port));
                        tcpm_set_state(port, SRC_ATTACH_WAIT, 0);
-               else if (tcpm_port_is_sink(port))
+               } else if (tcpm_port_is_sink(port)) {
+                       if (port->cc_req == TYPEC_CC_OPEN)
                        tcpm_set_state(port, SNK_ATTACH_WAIT, 0);
+               }
                break;
        case SRC_UNATTACHED:
        case ACC_UNATTACHED:

thanks
Li Jun

> 
> Guenter
> 
> >> Signed-off-by: Li Jun <jun.li@nxp.com>
> >> ---
> >>   drivers/usb/typec/tcpm.c | 5 +++++
> >>   1 file changed, 5 insertions(+)
> >>
> >> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> >> index d885bff..98ea916 100644
> >> --- a/drivers/usb/typec/tcpm.c
> >> +++ b/drivers/usb/typec/tcpm.c
> >> @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
> >>   	tcpm_set_attached_state(port, false);
> >>   	port->try_src_count = 0;
> >>   	port->try_snk_count = 0;
> >> +	port->cc_req = TYPEC_CC_OPEN;
> >>   	port->supply_voltage = 0;
> >>   	port->current_limit = 0;
> >>   	port->usb_type = POWER_SUPPLY_USB_TYPE_C; @@ -2831,6 +2832,8
> @@
> >> static void run_state_machine(struct tcpm_port *port)
> >>   		break;
> >>
> >>   	case SRC_ATTACHED:
> >> +		if (port->cc_req == TYPEC_CC_OPEN)
> >> +			tcpm_set_cc(port, tcpm_rp_cc(port));
> >>   		ret = tcpm_src_attach(port);
> >>   		tcpm_set_state(port, SRC_UNATTACHED,
> >>   			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON); @@ -3004,6
> +3007,8 @@
> >> static void run_state_machine(struct tcpm_port *port)
> >>   		tcpm_set_state(port, SNK_UNATTACHED,
> PD_T_PD_DEBOUNCE);
> >>   		break;
> >>   	case SNK_ATTACHED:
> >> +		if (port->cc_req == TYPEC_CC_OPEN)
> >> +			tcpm_set_cc(port, TYPEC_CC_RD);
> >>   		ret = tcpm_snk_attach(port);
> >>   		if (ret < 0)
> >>   			tcpm_set_state(port, SNK_UNATTACHED, 0);
> >


^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-13 11:06         ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-06-13 11:06 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, shufan_lee
  Cc: robh+dt, gregkh, cw00.choi, a.hajda, Peter Chen, garsilva,
	gsomlo, linux-usb, devicetree, dl-linux-imx

SGksDQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IEd1ZW50ZXIgUm9lY2sg
W21haWx0bzpncm9lY2s3QGdtYWlsLmNvbV0gT24gQmVoYWxmIE9mIEd1ZW50ZXIgUm9lY2sNCj4g
U2VudDogMjAxOOW5tDbmnIgxMeaXpSAyMTozNQ0KPiBUbzogSGVpa2tpIEtyb2dlcnVzIDxoZWlr
a2kua3JvZ2VydXNAbGludXguaW50ZWwuY29tPjsgSnVuIExpIDxqdW4ubGlAbnhwLmNvbT4NCj4g
Q2M6IHJvYmgrZHRAa2VybmVsLm9yZzsgZ3JlZ2toQGxpbnV4Zm91bmRhdGlvbi5vcmc7IGN3MDAu
Y2hvaUBzYW1zdW5nLmNvbTsNCj4gYS5oYWpkYUBzYW1zdW5nLmNvbTsgc2h1ZmFuX2xlZUByaWNo
dGVrLmNvbTsgUGV0ZXIgQ2hlbg0KPiA8cGV0ZXIuY2hlbkBueHAuY29tPjsgZ2Fyc2lsdmFAZW1i
ZWRkZWRvci5jb207IGdzb21sb0BnbWFpbC5jb207DQo+IGxpbnV4LXVzYkB2Z2VyLmtlcm5lbC5v
cmc7IGRldmljZXRyZWVAdmdlci5rZXJuZWwub3JnOyBkbC1saW51eC1pbXgNCj4gPGxpbnV4LWlt
eEBueHAuY29tPg0KPiBTdWJqZWN0OiBSZTogW1BBVENIIHY2IDEyLzE1XSB1c2I6IHR5cGVjOiB0
Y3BtOiBzZXQgY2MgZm9yIGRycCB0b2dnbGluZyBhdHRhY2gNCj4gDQo+IE9uIDA2LzExLzIwMTgg
MDU6MjkgQU0sIEhlaWtraSBLcm9nZXJ1cyB3cm90ZToNCj4gPiBPbiBNb24sIE1heSAyOCwgMjAx
OCBhdCAxMDo1Mjo0NEFNICswODAwLCBMaSBKdW4gd3JvdGU6DQo+ID4+IEluIGNhc2Ugb2YgZHJw
IHRvZ2dsaW5nLCB3ZSBtYXkgbmVlZCBzZXQgY29ycmVjdCBjYyB2YWx1ZSBmb3Igcm9sZQ0KPiA+
PiBjb250cm9sIGFmdGVyIGF0dGFjaCBhcyBpdCBtYXkgbmV2ZXIgYmVlbiBzZXQuDQo+ID4NCj4g
PiBJcyB0aGlzIHNvbWV0aGluZyB0aGF0IHNob3VsZCBiZSBjb25zaWRlcmVkIGFzIGEgZml4Pw0K
PiA+DQo+IA0KPiBUaGUgcHJvYmxlbSB3aXRoIHRoaXMgcGF0Y2ggaXMgdGhhdCBpdCBoaWRlcyBh
IHByb2JsZW0uIENDIHNob3VsZCBoYXZlIGJlZW4gc2V0DQo+IGJ5IHRoZSB0aW1lIGEgcG9ydCBy
ZWFjaGVzIHRoZSBhdHRhY2hlZCBzdGF0ZS4gVGhlIHBhdGNoIG1lYW5zIHRoYXQgdGhlcmUgaXMg
YQ0KPiBzdGF0ZSBtYWNoaW5lIHBhdGggd2hlcmUgdGhpcyBkb2VzIG5vdCBoYXBwZW4uIEknZCBy
YXRoZXIgdW5kZXJzdGFuZCB0aGF0IHBhdGgNCj4gYW5kIGZpeCB0aGUgcHJvYmxlbSB3aGVyZSBp
dCBoYXBwZW5zLg0KDQpIZXJlIGlzIG15IHByZXZpb3VzIGV4cGxhbmF0aW9uIGFib3V0IHRoaXMg
c3RhdGUgbWFjaGluZSBwYXRoWzFdDQoNClsxXWh0dHBzOi8vd3d3LnNwaW5pY3MubmV0L2xpc3Rz
L2xpbnV4LXVzYi9tc2cxNjc0NjcuaHRtbA0KDQpUaGUgcGh5c2ljYWwgQ0MgbGluZSBzdGF0ZSBp
cyBjb3JyZWN0LCBqdXN0IHRoZSBSb2xlIENvbnRyb2wgcmVnaXN0ZXIgdmFsdWUNCm1heSBtaXNt
YXRjaCBvbiBzb21lKGUuZy4gc2h1ZmFuJ3MpIEhXLCBpZiB0aGUgY29tbW9uIGNoYW5nZSBpbiB0
Y3BtDQppcyBub3QgdGhlIHJpZ2h0IHdheSwgSSBoYXZlIHRvIGFzayBzaHVmYW4gdG8gdHJ5IHJl
c29sdmUgdGhpcyBpbiBoaXMgY3VzdG9tDQpydDE3MTFoIGRyaXZlci4NCg0KSSB1bmRlcnN0YW5k
IHRoZSBjb25jZXJuIG9mIHNldHRpbmcgY2MgYXQgYXR0YWNoZWQgc3RhdGUgaXMgbGF0ZSwgc2hv
dWxkIGJlDQpkb25lIGJlZm9yZSB0aGF0LCBob3cgYWJvdXQgSSBtb3ZlIHRoaXMgaW4gY2NfY2hh
bmdlIGxpa2UgYmVsb3c6DQoNCkBAIC0zNDkyLDEwICszNDkyLDEzIEBAIHN0YXRpYyB2b2lkIF90
Y3BtX2NjX2NoYW5nZShzdHJ1Y3QgdGNwbV9wb3J0ICpwb3J0LCBlbnVtIHR5cGVjX2NjX3N0YXR1
cyBjYzEsDQogICAgICAgIHN3aXRjaCAocG9ydC0+c3RhdGUpIHsNCiAgICAgICAgY2FzZSBEUlBf
VE9HR0xJTkc6DQogICAgICAgICAgICAgICAgaWYgKHRjcG1fcG9ydF9pc19kZWJ1Zyhwb3J0KSB8
fCB0Y3BtX3BvcnRfaXNfYXVkaW8ocG9ydCkgfHwNCi0gICAgICAgICAgICAgICAgICAgdGNwbV9w
b3J0X2lzX3NvdXJjZShwb3J0KSkNCisgICAgICAgICAgICAgICAgICAgdGNwbV9wb3J0X2lzX3Nv
dXJjZShwb3J0KSkgew0KKyAgICAgICAgICAgICAgICAgICAgICAgdGNwbV9zZXRfY2MocG9ydCwg
dGNwbV9ycF9jYyhwb3J0KSk7DQogICAgICAgICAgICAgICAgICAgICAgICB0Y3BtX3NldF9zdGF0
ZShwb3J0LCBTUkNfQVRUQUNIX1dBSVQsIDApOw0KLSAgICAgICAgICAgICAgIGVsc2UgaWYgKHRj
cG1fcG9ydF9pc19zaW5rKHBvcnQpKQ0KKyAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGNwbV9w
b3J0X2lzX3NpbmsocG9ydCkpIHsNCisgICAgICAgICAgICAgICAgICAgICAgIGlmIChwb3J0LT5j
Y19yZXEgPT0gVFlQRUNfQ0NfT1BFTikNCiAgICAgICAgICAgICAgICAgICAgICAgIHRjcG1fc2V0
X3N0YXRlKHBvcnQsIFNOS19BVFRBQ0hfV0FJVCwgMCk7DQorICAgICAgICAgICAgICAgfQ0KICAg
ICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICBjYXNlIFNSQ19VTkFUVEFDSEVEOg0KICAgICAg
ICBjYXNlIEFDQ19VTkFUVEFDSEVEOg0KDQp0aGFua3MNCkxpIEp1bg0KDQo+IA0KPiBHdWVudGVy
DQo+IA0KPiA+PiBTaWduZWQtb2ZmLWJ5OiBMaSBKdW4gPGp1bi5saUBueHAuY29tPg0KPiA+PiAt
LS0NCj4gPj4gICBkcml2ZXJzL3VzYi90eXBlYy90Y3BtLmMgfCA1ICsrKysrDQo+ID4+ICAgMSBm
aWxlIGNoYW5nZWQsIDUgaW5zZXJ0aW9ucygrKQ0KPiA+Pg0KPiA+PiBkaWZmIC0tZ2l0IGEvZHJp
dmVycy91c2IvdHlwZWMvdGNwbS5jIGIvZHJpdmVycy91c2IvdHlwZWMvdGNwbS5jDQo+ID4+IGlu
ZGV4IGQ4ODViZmYuLjk4ZWE5MTYgMTAwNjQ0DQo+ID4+IC0tLSBhL2RyaXZlcnMvdXNiL3R5cGVj
L3RjcG0uYw0KPiA+PiArKysgYi9kcml2ZXJzL3VzYi90eXBlYy90Y3BtLmMNCj4gPj4gQEAgLTI1
OTksNiArMjU5OSw3IEBAIHN0YXRpYyB2b2lkIHRjcG1fcmVzZXRfcG9ydChzdHJ1Y3QgdGNwbV9w
b3J0ICpwb3J0KQ0KPiA+PiAgIAl0Y3BtX3NldF9hdHRhY2hlZF9zdGF0ZShwb3J0LCBmYWxzZSk7
DQo+ID4+ICAgCXBvcnQtPnRyeV9zcmNfY291bnQgPSAwOw0KPiA+PiAgIAlwb3J0LT50cnlfc25r
X2NvdW50ID0gMDsNCj4gPj4gKwlwb3J0LT5jY19yZXEgPSBUWVBFQ19DQ19PUEVOOw0KPiA+PiAg
IAlwb3J0LT5zdXBwbHlfdm9sdGFnZSA9IDA7DQo+ID4+ICAgCXBvcnQtPmN1cnJlbnRfbGltaXQg
PSAwOw0KPiA+PiAgIAlwb3J0LT51c2JfdHlwZSA9IFBPV0VSX1NVUFBMWV9VU0JfVFlQRV9DOyBA
QCAtMjgzMSw2ICsyODMyLDgNCj4gQEANCj4gPj4gc3RhdGljIHZvaWQgcnVuX3N0YXRlX21hY2hp
bmUoc3RydWN0IHRjcG1fcG9ydCAqcG9ydCkNCj4gPj4gICAJCWJyZWFrOw0KPiA+Pg0KPiA+PiAg
IAljYXNlIFNSQ19BVFRBQ0hFRDoNCj4gPj4gKwkJaWYgKHBvcnQtPmNjX3JlcSA9PSBUWVBFQ19D
Q19PUEVOKQ0KPiA+PiArCQkJdGNwbV9zZXRfY2MocG9ydCwgdGNwbV9ycF9jYyhwb3J0KSk7DQo+
ID4+ICAgCQlyZXQgPSB0Y3BtX3NyY19hdHRhY2gocG9ydCk7DQo+ID4+ICAgCQl0Y3BtX3NldF9z
dGF0ZShwb3J0LCBTUkNfVU5BVFRBQ0hFRCwNCj4gPj4gICAJCQkgICAgICAgcmV0IDwgMCA/IDAg
OiBQRF9UX1BTX1NPVVJDRV9PTik7IEBAIC0zMDA0LDYNCj4gKzMwMDcsOCBAQA0KPiA+PiBzdGF0
aWMgdm9pZCBydW5fc3RhdGVfbWFjaGluZShzdHJ1Y3QgdGNwbV9wb3J0ICpwb3J0KQ0KPiA+PiAg
IAkJdGNwbV9zZXRfc3RhdGUocG9ydCwgU05LX1VOQVRUQUNIRUQsDQo+IFBEX1RfUERfREVCT1VO
Q0UpOw0KPiA+PiAgIAkJYnJlYWs7DQo+ID4+ICAgCWNhc2UgU05LX0FUVEFDSEVEOg0KPiA+PiAr
CQlpZiAocG9ydC0+Y2NfcmVxID09IFRZUEVDX0NDX09QRU4pDQo+ID4+ICsJCQl0Y3BtX3NldF9j
Yyhwb3J0LCBUWVBFQ19DQ19SRCk7DQo+ID4+ICAgCQlyZXQgPSB0Y3BtX3Nua19hdHRhY2gocG9y
dCk7DQo+ID4+ICAgCQlpZiAocmV0IDwgMCkNCj4gPj4gICAJCQl0Y3BtX3NldF9zdGF0ZShwb3J0
LCBTTktfVU5BVFRBQ0hFRCwgMCk7DQo+ID4NCg0K
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 75+ messages in thread

* RE: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-13 11:14           ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-06-13 11:14 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, shufan_lee
  Cc: robh+dt, gregkh, cw00.choi, a.hajda, Peter Chen, garsilva,
	gsomlo, linux-usb, devicetree, dl-linux-imx

Hi
> -----Original Message-----
> From: Jun Li
> Sent: 2018年6月13日 19:07
> To: Guenter Roeck <linux@roeck-us.net>; Heikki Krogerus
> <heikki.krogerus@linux.intel.com>; shufan_lee@richtek.com
> Cc: robh+dt@kernel.org; gregkh@linuxfoundation.org; cw00.choi@samsung.com;
> a.hajda@samsung.com; Peter Chen <peter.chen@nxp.com>;
> garsilva@embeddedor.com; gsomlo@gmail.com; linux-usb@vger.kernel.org;
> devicetree@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: RE: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
> 
> Hi,
> > -----Original Message-----
> > From: Guenter Roeck [mailto:groeck7@gmail.com] On Behalf Of Guenter
> > Roeck
> > Sent: 2018年6月11日 21:35
> > To: Heikki Krogerus <heikki.krogerus@linux.intel.com>; Jun Li
> > <jun.li@nxp.com>
> > Cc: robh+dt@kernel.org; gregkh@linuxfoundation.org;
> > cw00.choi@samsung.com; a.hajda@samsung.com; shufan_lee@richtek.com;
> > Peter Chen <peter.chen@nxp.com>; garsilva@embeddedor.com;
> > gsomlo@gmail.com; linux-usb@vger.kernel.org;
> > devicetree@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> > Subject: Re: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp
> > toggling attach
> >
> > On 06/11/2018 05:29 AM, Heikki Krogerus wrote:
> > > On Mon, May 28, 2018 at 10:52:44AM +0800, Li Jun wrote:
> > >> In case of drp toggling, we may need set correct cc value for role
> > >> control after attach as it may never been set.
> > >
> > > Is this something that should be considered as a fix?
> > >
> >
> > The problem with this patch is that it hides a problem. CC should have
> > been set by the time a port reaches the attached state. The patch
> > means that there is a state machine path where this does not happen.
> > I'd rather understand that path and fix the problem where it happens.
> 
> Here is my previous explanation about this state machine path[1]
> 
> [1]https://www.spinics.net/lists/linux-usb/msg167467.html
> 
> The physical CC line state is correct, just the Role Control register value may
> mismatch on some(e.g. shufan's) HW, if the common change in tcpm is not the
> right way, I have to ask shufan to try resolve this in his custom rt1711h driver.
> 
> I understand the concern of setting cc at attached state is late, should be done
> before that, how about I move this in cc_change like below:
> 
> @@ -3492,10 +3492,13 @@ static void _tcpm_cc_change(struct tcpm_port *port,
> enum typec_cc_status cc1,
>         switch (port->state) {
>         case DRP_TOGGLING:
>                 if (tcpm_port_is_debug(port) || tcpm_port_is_audio(port) ||
> -                   tcpm_port_is_source(port))
> +                   tcpm_port_is_source(port)) {
> +                       tcpm_set_cc(port, tcpm_rp_cc(port));
>                         tcpm_set_state(port, SRC_ATTACH_WAIT, 0);
> -               else if (tcpm_port_is_sink(port))
> +               } else if (tcpm_port_is_sink(port)) {
> +                       if (port->cc_req == TYPEC_CC_OPEN)

Sorry, here should be:

+               } else if (tcpm_port_is_sink(port)) {
+                       tcpm_set_cc(port, TYPEC_CC_RD);
                        tcpm_set_state(port, SNK_ATTACH_WAIT, 0);
+               }
>                         tcpm_set_state(port, SNK_ATTACH_WAIT, 0);
> +               }
>                 break;
>         case SRC_UNATTACHED:
>         case ACC_UNATTACHED:
> 
> thanks
> Li Jun
> 
> >
> > Guenter
> >
> > >> Signed-off-by: Li Jun <jun.li@nxp.com>
> > >> ---
> > >>   drivers/usb/typec/tcpm.c | 5 +++++
> > >>   1 file changed, 5 insertions(+)
> > >>
> > >> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > >> index d885bff..98ea916 100644
> > >> --- a/drivers/usb/typec/tcpm.c
> > >> +++ b/drivers/usb/typec/tcpm.c
> > >> @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port
> *port)
> > >>   	tcpm_set_attached_state(port, false);
> > >>   	port->try_src_count = 0;
> > >>   	port->try_snk_count = 0;
> > >> +	port->cc_req = TYPEC_CC_OPEN;
> > >>   	port->supply_voltage = 0;
> > >>   	port->current_limit = 0;
> > >>   	port->usb_type = POWER_SUPPLY_USB_TYPE_C; @@ -2831,6 +2832,8
> > @@
> > >> static void run_state_machine(struct tcpm_port *port)
> > >>   		break;
> > >>
> > >>   	case SRC_ATTACHED:
> > >> +		if (port->cc_req == TYPEC_CC_OPEN)
> > >> +			tcpm_set_cc(port, tcpm_rp_cc(port));
> > >>   		ret = tcpm_src_attach(port);
> > >>   		tcpm_set_state(port, SRC_UNATTACHED,
> > >>   			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON); @@ -3004,6
> > +3007,8 @@
> > >> static void run_state_machine(struct tcpm_port *port)
> > >>   		tcpm_set_state(port, SNK_UNATTACHED,
> > PD_T_PD_DEBOUNCE);
> > >>   		break;
> > >>   	case SNK_ATTACHED:
> > >> +		if (port->cc_req == TYPEC_CC_OPEN)
> > >> +			tcpm_set_cc(port, TYPEC_CC_RD);
> > >>   		ret = tcpm_snk_attach(port);
> > >>   		if (ret < 0)
> > >>   			tcpm_set_state(port, SNK_UNATTACHED, 0);
> > >


^ permalink raw reply	[flat|nested] 75+ messages in thread

* [v6,12/15] usb: typec: tcpm: set cc for drp toggling attach
@ 2018-06-13 11:14           ` Jun Li
  0 siblings, 0 replies; 75+ messages in thread
From: Jun Li @ 2018-06-13 11:14 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, shufan_lee
  Cc: robh+dt, gregkh, cw00.choi, a.hajda, Peter Chen, garsilva,
	gsomlo, linux-usb, devicetree, dl-linux-imx

Hi
> -----Original Message-----
> From: Jun Li
> Sent: 2018年6月13日 19:07
> To: Guenter Roeck <linux@roeck-us.net>; Heikki Krogerus
> <heikki.krogerus@linux.intel.com>; shufan_lee@richtek.com
> Cc: robh+dt@kernel.org; gregkh@linuxfoundation.org; cw00.choi@samsung.com;
> a.hajda@samsung.com; Peter Chen <peter.chen@nxp.com>;
> garsilva@embeddedor.com; gsomlo@gmail.com; linux-usb@vger.kernel.org;
> devicetree@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: RE: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach
> 
> Hi,
> > -----Original Message-----
> > From: Guenter Roeck [mailto:groeck7@gmail.com] On Behalf Of Guenter
> > Roeck
> > Sent: 2018年6月11日 21:35
> > To: Heikki Krogerus <heikki.krogerus@linux.intel.com>; Jun Li
> > <jun.li@nxp.com>
> > Cc: robh+dt@kernel.org; gregkh@linuxfoundation.org;
> > cw00.choi@samsung.com; a.hajda@samsung.com; shufan_lee@richtek.com;
> > Peter Chen <peter.chen@nxp.com>; garsilva@embeddedor.com;
> > gsomlo@gmail.com; linux-usb@vger.kernel.org;
> > devicetree@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> > Subject: Re: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp
> > toggling attach
> >
> > On 06/11/2018 05:29 AM, Heikki Krogerus wrote:
> > > On Mon, May 28, 2018 at 10:52:44AM +0800, Li Jun wrote:
> > >> In case of drp toggling, we may need set correct cc value for role
> > >> control after attach as it may never been set.
> > >
> > > Is this something that should be considered as a fix?
> > >
> >
> > The problem with this patch is that it hides a problem. CC should have
> > been set by the time a port reaches the attached state. The patch
> > means that there is a state machine path where this does not happen.
> > I'd rather understand that path and fix the problem where it happens.
> 
> Here is my previous explanation about this state machine path[1]
> 
> [1]https://www.spinics.net/lists/linux-usb/msg167467.html
> 
> The physical CC line state is correct, just the Role Control register value may
> mismatch on some(e.g. shufan's) HW, if the common change in tcpm is not the
> right way, I have to ask shufan to try resolve this in his custom rt1711h driver.
> 
> I understand the concern of setting cc at attached state is late, should be done
> before that, how about I move this in cc_change like below:
> 
> @@ -3492,10 +3492,13 @@ static void _tcpm_cc_change(struct tcpm_port *port,
> enum typec_cc_status cc1,
>         switch (port->state) {
>         case DRP_TOGGLING:
>                 if (tcpm_port_is_debug(port) || tcpm_port_is_audio(port) ||
> -                   tcpm_port_is_source(port))
> +                   tcpm_port_is_source(port)) {
> +                       tcpm_set_cc(port, tcpm_rp_cc(port));
>                         tcpm_set_state(port, SRC_ATTACH_WAIT, 0);
> -               else if (tcpm_port_is_sink(port))
> +               } else if (tcpm_port_is_sink(port)) {
> +                       if (port->cc_req == TYPEC_CC_OPEN)

Sorry, here should be:

+               } else if (tcpm_port_is_sink(port)) {
+                       tcpm_set_cc(port, TYPEC_CC_RD);
                        tcpm_set_state(port, SNK_ATTACH_WAIT, 0);
+               }
>                         tcpm_set_state(port, SNK_ATTACH_WAIT, 0);
> +               }
>                 break;
>         case SRC_UNATTACHED:
>         case ACC_UNATTACHED:
> 
> thanks
> Li Jun
> 
> >
> > Guenter
> >
> > >> Signed-off-by: Li Jun <jun.li@nxp.com>
> > >> ---
> > >>   drivers/usb/typec/tcpm.c | 5 +++++
> > >>   1 file changed, 5 insertions(+)
> > >>
> > >> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> > >> index d885bff..98ea916 100644
> > >> --- a/drivers/usb/typec/tcpm.c
> > >> +++ b/drivers/usb/typec/tcpm.c
> > >> @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port
> *port)
> > >>   	tcpm_set_attached_state(port, false);
> > >>   	port->try_src_count = 0;
> > >>   	port->try_snk_count = 0;
> > >> +	port->cc_req = TYPEC_CC_OPEN;
> > >>   	port->supply_voltage = 0;
> > >>   	port->current_limit = 0;
> > >>   	port->usb_type = POWER_SUPPLY_USB_TYPE_C; @@ -2831,6 +2832,8
> > @@
> > >> static void run_state_machine(struct tcpm_port *port)
> > >>   		break;
> > >>
> > >>   	case SRC_ATTACHED:
> > >> +		if (port->cc_req == TYPEC_CC_OPEN)
> > >> +			tcpm_set_cc(port, tcpm_rp_cc(port));
> > >>   		ret = tcpm_src_attach(port);
> > >>   		tcpm_set_state(port, SRC_UNATTACHED,
> > >>   			       ret < 0 ? 0 : PD_T_PS_SOURCE_ON); @@ -3004,6
> > +3007,8 @@
> > >> static void run_state_machine(struct tcpm_port *port)
> > >>   		tcpm_set_state(port, SNK_UNATTACHED,
> > PD_T_PD_DEBOUNCE);
> > >>   		break;
> > >>   	case SNK_ATTACHED:
> > >> +		if (port->cc_req == TYPEC_CC_OPEN)
> > >> +			tcpm_set_cc(port, TYPEC_CC_RD);
> > >>   		ret = tcpm_snk_attach(port);
> > >>   		if (ret < 0)
> > >>   			tcpm_set_state(port, SNK_UNATTACHED, 0);
> > >

^ permalink raw reply	[flat|nested] 75+ messages in thread

end of thread, other threads:[~2018-06-13 11:14 UTC | newest]

Thread overview: 75+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-28  2:52 [PATCH v6 00/15] staging: typec: tcpci: move out of staging Li Jun
2018-05-28  2:52 ` [PATCH v6 01/15] dt-bindings: connector: add properties for typec Li Jun
2018-05-28  2:52   ` [v6,01/15] " Jun Li
2018-05-31  0:13   ` [PATCH v6 01/15] " Rob Herring
2018-05-31  0:13     ` [v6,01/15] " Rob Herring
2018-05-28  2:52 ` [PATCH v6 02/15] dt-bindings: usb: add documentation for typec port controller(TCPCI) Li Jun
2018-05-28  2:52   ` [v6,02/15] " Jun Li
2018-05-28  2:52 ` [PATCH v6 03/15] staging: typec: tcpci: add compatible string for nxp ptn5110 Li Jun
2018-05-28  2:52   ` [v6,03/15] " Jun Li
2018-06-11 12:32   ` [PATCH v6 03/15] " Heikki Krogerus
2018-06-11 12:32     ` [v6,03/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 04/15] usb: typec: add fwnode to tcpc Li Jun
2018-05-28  2:52   ` [v6,04/15] " Jun Li
2018-06-11 11:44   ` [PATCH v6 04/15] " Heikki Krogerus
2018-06-11 11:44     ` [v6,04/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 05/15] usb: typec: add API to get typec basic port power and data config Li Jun
2018-05-28  2:52   ` [v6,05/15] " Jun Li
2018-05-30  4:25   ` [PATCH v6 05/15] " kbuild test robot
2018-05-30  4:25     ` [v6,05/15] " kbuild test robot
2018-05-30  5:56     ` [PATCH v6 05/15] " Jun Li
2018-05-30  5:56       ` [v6,05/15] " Jun Li
2018-05-30  6:43   ` [PATCH v6 05/15] " kbuild test robot
2018-05-30  6:43     ` [v6,05/15] " kbuild test robot
2018-06-11 11:08   ` [PATCH v6 05/15] " Heikki Krogerus
2018-06-11 11:08     ` [v6,05/15] " Heikki Krogerus
2018-06-13  9:47     ` [PATCH v6 05/15] " Jun Li
2018-06-13  9:47       ` [v6,05/15] " Jun Li
2018-05-28  2:52 ` [PATCH v6 06/15] usb: typec: tcpm: support get typec and pd config from device properties Li Jun
2018-05-28  2:52   ` [v6,06/15] " Jun Li
2018-06-11 12:05   ` [PATCH v6 06/15] " Heikki Krogerus
2018-06-11 12:05     ` [v6,06/15] " Heikki Krogerus
2018-06-11 13:27   ` [PATCH v6 06/15] " Guenter Roeck
2018-06-11 13:27     ` [v6,06/15] " Guenter Roeck
2018-05-28  2:52 ` [PATCH v6 07/15] staging: typec: tcpci: remove unused tcpci_tcpc_config Li Jun
2018-05-28  2:52   ` [v6,07/15] " Jun Li
2018-06-11 12:33   ` [PATCH v6 07/15] " Heikki Krogerus
2018-06-11 12:33     ` [v6,07/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 08/15] staging: typec: tcpci: use IS_ERR() instead of PTR_ERR_OR_ZERO() Li Jun
2018-05-28  2:52   ` [v6,08/15] " Jun Li
2018-06-11 12:34   ` [PATCH v6 08/15] " Heikki Krogerus
2018-06-11 12:34     ` [v6,08/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 09/15] staging: typec: tcpci: register port before request irq Li Jun
2018-05-28  2:52   ` [v6,09/15] " Jun Li
2018-06-11 12:35   ` [PATCH v6 09/15] " Heikki Krogerus
2018-06-11 12:35     ` [v6,09/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 10/15] staging: typec: tcpci: enable vbus detection Li Jun
2018-05-28  2:52   ` [v6,10/15] " Jun Li
2018-06-11 12:36   ` [PATCH v6 10/15] " Heikki Krogerus
2018-06-11 12:36     ` [v6,10/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 11/15] typec: tcpm: add starting value for drp toggling Li Jun
2018-05-28  2:52   ` [v6,11/15] " Jun Li
2018-06-11 12:28   ` [PATCH v6 11/15] " Heikki Krogerus
2018-06-11 12:28     ` [v6,11/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach Li Jun
2018-05-28  2:52   ` [v6,12/15] " Jun Li
2018-06-11 12:29   ` [PATCH v6 12/15] " Heikki Krogerus
2018-06-11 12:29     ` [v6,12/15] " Heikki Krogerus
2018-06-11 13:35     ` [PATCH v6 12/15] " Guenter Roeck
2018-06-11 13:35       ` [v6,12/15] " Guenter Roeck
2018-06-13 11:06       ` [PATCH v6 12/15] " Jun Li
2018-06-13 11:06         ` [v6,12/15] " Jun Li
2018-06-13 11:14         ` [PATCH v6 12/15] " Jun Li
2018-06-13 11:14           ` [v6,12/15] " Jun Li
2018-05-28  2:52 ` [PATCH v6 13/15] staging: typec: tcpci: keep the disconnected cc line open Li Jun
2018-05-28  2:52   ` [v6,13/15] " Jun Li
2018-06-11 13:14   ` [PATCH v6 13/15] " Heikki Krogerus
2018-06-11 13:14     ` [v6,13/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 14/15] staging: typec: tcpci: Only touch target bit when enable vconn Li Jun
2018-05-28  2:52   ` [v6,14/15] " Jun Li
2018-06-11 13:15   ` [PATCH v6 14/15] " Heikki Krogerus
2018-06-11 13:15     ` [v6,14/15] " Heikki Krogerus
2018-05-28  2:52 ` [PATCH v6 15/15] staging: typec: tcpci: move tcpci drivers out of staging Li Jun
2018-05-28  2:52   ` [v6,15/15] " Jun Li
2018-06-06 21:44 ` [PATCH v6 00/15] staging: typec: tcpci: move " Mats Karrman
2018-06-07  0:47   ` Jun Li

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.