Skip to contentSkip to conversation

*** SUBJECT HERE ***

PATCH Applied Adam Thomson 2 participants 9 messages Sep 10, 2018 – Sep 11, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover *** SUBJECT HERE ***

This patch set adds DT bindings support for PPS APDOs, and updates the FUSB302 to use the generic connector bindings allowing for PPS support in this Type-C port controller. Existing FUSB302 device specific bindings still work, but are now deprecated in favour of the generic connector approach.

Changes in v2:
- Added Reviewed-by tags to patches
- Rebase code against latest usb-next branch (v4.19-rc2)

Adam Thomson (3):
dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings
dt-bindings: usb: fusb302: Use usb-connector bindings for
configuration
usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling

 .../bindings/connector/usb-connector.txt           |  8 +++---
 .../devicetree/bindings/usb/fcs,fusb302.txt        | 32 +++++++++++++++++-----
 drivers/usb/typec/fusb302/fusb302.c                |  3 ++
 include/dt-bindings/usb/pd.h                       | 26 ++++++++++++++++++
 4 files changed, 58 insertions(+), 11 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings

Add support for PPS APDOs to connector bindings so a port controller can specify support for PPS, as per existing FIXED/BATT/VAR PDOs.

---
 .../bindings/connector/usb-connector.txt           |  8 +++----
 include/dt-bindings/usb/pd.h                       | 26 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/connector/usb-connector.txt +4 -4
index 8855bfc..d90e17e 100644
@@ -29,15 +29,15 @@ Required properties for usb-c-connector with power delivery support:
   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.
+  User can specify the source PDO array via PDO_FIXED/BATT/VAR/PPS_APDO()
+  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.
+  User can specify the sink PDO array via PDO_FIXED/BATT/VAR/PPS_APDO() 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.
include/dt-bindings/usb/pd.h +26 -0
index 7b7a92f..985f2bb 100644
@@ -59,4 +59,30 @@
 	(PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) |	\
 	 PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma))
 
+#define APDO_TYPE_PPS		0
+
+#define PDO_APDO_TYPE_SHIFT	28	/* Only valid value currently is 0x0 - PPS */
+#define PDO_APDO_TYPE_MASK	0x3
+
+#define PDO_APDO_TYPE(t)	((t) << PDO_APDO_TYPE_SHIFT)
+
+#define PDO_PPS_APDO_MAX_VOLT_SHIFT	17	/* 100mV units */
+#define PDO_PPS_APDO_MIN_VOLT_SHIFT	8	/* 100mV units */
+#define PDO_PPS_APDO_MAX_CURR_SHIFT	0	/* 50mA units */
+
+#define PDO_PPS_APDO_VOLT_MASK	0xff
+#define PDO_PPS_APDO_CURR_MASK	0x7f
+
+#define PDO_PPS_APDO_MIN_VOLT(mv)	\
+	((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MIN_VOLT_SHIFT)
+#define PDO_PPS_APDO_MAX_VOLT(mv)	\
+	((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MAX_VOLT_SHIFT)
+#define PDO_PPS_APDO_MAX_CURR(ma)	\
+	((((ma) / 50) & PDO_PPS_APDO_CURR_MASK) << PDO_PPS_APDO_MAX_CURR_SHIFT)
+
+#define PDO_PPS_APDO(min_mv, max_mv, max_ma)					\
+	(PDO_TYPE(PDO_TYPE_APDO) | PDO_APDO_TYPE(APDO_TYPE_PPS) |		\
+	 PDO_PPS_APDO_MIN_VOLT(min_mv) | PDO_PPS_APDO_MAX_VOLT(max_mv) |	\
+	 PDO_PPS_APDO_MAX_CURR(max_ma))
+
  #endif /* __DT_POWER_DELIVERY_H */
Signature · 1 line
1.9.1
maintainer Applied
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings

Hi Adam,

Quoted 5 lines · Adam Thomson

Add support for PPS APDOs to connector bindings so a port controller can specify support for PPS, as per existing FIXED/BATT/VAR PDOs.

I've applied this patch to my tree:
https://github.com/krohei/linux/commit/adae44a671f47e94d6aa0fba8fb51b78d40c505d

I will resend it to Greg together with all the other Type-C patches that are ready next week after v4.19-rc4 unless Greg has picked it himself before that.

Thanks,

Signature · 1 line
heikki
#3 lore raw

RE: [PATCH v2 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings

Quoted 9 lines · Heikki Krogerus

Hi Adam,

Quoted 5 lines · Adam Thomson

Add support for PPS APDOs to connector bindings so a port controller can specify support for PPS, as per existing FIXED/BATT/VAR PDOs.

Quoted 7 lines

I've applied this patch to my tree:
https://github.com/krohei/linux/commit/adae44a671f47e94d6aa0fba8fb51b78d40c
505d

I will resend it to Greg together with all the other Type-C patches that are ready next week after v4.19-rc4 unless Greg has picked it himself before that.

Ok, thanks for the update. Saw your patch to tidy up file locations so was anticipating the need for a rebase, but this will save me job. :)

#4 lore raw

PATCH 2/3 dt-bindings: usb: fusb302: Use usb-connector bindings for configuration

In reply to Adam Thomson

There are now generic usb-connector bindings which can be used to define a port controllers configuration for USB-PD, so device specific bindings are no longer necessary.

This update deprecates 'fcs,operating-sink-microwatt', and references the 'usb-connector' bindings instead to achieve the required port config.

---
 .../devicetree/bindings/usb/fcs,fusb302.txt        | 32 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/usb/fcs,fusb302.txt +25 -7
index 6087dc7..a5d011d 100644
@@ -5,10 +5,19 @@ Required properties :
 - reg                    : I2C slave address
 - interrupts             : Interrupt specifier
 
-Optional properties :
-- fcs,operating-sink-microwatt :
-			   Minimum amount of power accepted from a sink
-			   when negotiating
+Required sub-node:
+- connector : The "usb-c-connector" attached to the FUSB302 IC. The bindings
+  of the connector node are specified in:
+
+	Documentation/devicetree/bindings/connector/usb-connector.txt
+
+Deprecated properties :
+- fcs,max-sink-microvolt : Maximum sink voltage accepted by port controller
+- fcs,max-sink-microamp : Maximum sink current accepted by port controller
+- fcs,max-sink-microwatt : Maximum sink power accepted by port controller
+- fcs,operating-sink-microwatt : Minimum amount of power accepted from a sink
+  when negotiating
+
 
 Example:
 
@@ -17,7 +26,16 @@ fusb302: typec-portc@54 {
 	reg = <0x54>;
 	interrupt-parent = <&nmi_intc>;
 	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
-	fcs,max-sink-microvolt = <12000000>;
-	fcs,max-sink-microamp = <3000000>;
-	fcs,max-sink-microwatt = <36000000>;
+
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+		power-role = "dual";
+		try-power-role = "sink";
+		source-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)>;
+		sink-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)
+			     PDO_VAR(3000, 12000, 3000)
+			     PDO_PPS_APDO(3000, 11000, 3000)>;
+		op-sink-microwatt = <10000000>;
+	};
 };
Signature · 1 line
1.9.1
maintainer Applied
#5 lore raw

Re: [PATCH v2 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration

Hi Adam,

Quoted 10 lines · Adam Thomson

There are now generic usb-connector bindings which can be used to define a port controllers configuration for USB-PD, so device specific bindings are no longer necessary.

This update deprecates 'fcs,operating-sink-microwatt', and references the 'usb-connector' bindings instead to achieve the required port config.

I've applied this patch to my tree:
https://github.com/krohei/linux/commit/2b486e5939148f1623ecbc8dbe20432e12460e16

I will resend it to Greg together with all the other Type-C patches that are ready next week after v4.19-rc4 unless Greg has picked it himself before that.

Thanks,

Signature · 1 line
heikki
#6 lore raw

PATCH 3/3 usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling

In reply to Adam Thomson

This update populates the tcpc handle's fwnode pointer with the child usb-connector node, if it exists, so that TCPM can perform generic property handling to define the ports capabilities.

---
 drivers/usb/typec/fusb302/fusb302.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/typec/fusb302/fusb302.c +3 -0
index 82bed98..1b464c9 100644
@@ -1736,6 +1736,9 @@ static int fusb302_probe(struct i2c_client *client,
 	chip->tcpc_dev.config = &chip->tcpc_config;
 	mutex_init(&chip->lock);
 
+	chip->tcpc_dev.fwnode =
+		device_get_named_child_node(dev, "connector");
+
 	if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", &v))
 		chip->tcpc_config.operating_snk_mw = v / 1000;
 
Signature · 1 line
1.9.1
maintainer Applied
#7 lore raw

Re: [PATCH v2 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling

Hi Adam,

Quoted 7 lines · Adam Thomson

This update populates the tcpc handle's fwnode pointer with the child usb-connector node, if it exists, so that TCPM can perform generic property handling to define the ports capabilities.

I've applied this patch to my tree:
https://github.com/krohei/linux/commit/bc5614cfe29eb48494eaf88845f57a49ae5c1967

I will resend it to Greg together with all the other Type-C patches that are ready next week after v4.19-rc4 unless Greg has picked it himself before that.

Thanks,

Signature · 1 line
heikki
#8 lore raw
In reply to Adam Thomson
Quoted 4 lines · Adam Thomson

This patch set adds DT bindings support for PPS APDOs, and updates the FUSB302 to use the generic connector bindings allowing for PPS support in this Type-C port controller. Existing FUSB302 device specific bindings still work, but are now deprecated in favour of the generic connector approach.

Please ignore as suffering finger trouble. Will resend with patches corrected.

Quoted 19 lines

Changes in v2:
- Added Reviewed-by tags to patches
- Rebase code against latest usb-next branch (v4.19-rc2)

Adam Thomson (3):
dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings
dt-bindings: usb: fusb302: Use usb-connector bindings for
configuration
usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling

 .../bindings/connector/usb-connector.txt           |  8 +++---
 .../devicetree/bindings/usb/fcs,fusb302.txt        | 32 +++++++++++++++++-----
 drivers/usb/typec/fusb302/fusb302.c                |  3 ++
 include/dt-bindings/usb/pd.h                       | 26 ++++++++++++++++++
 4 files changed, 58 insertions(+), 11 deletions(-)

--
1.9.1