linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] *** SUBJECT HERE ***
@ 2018-09-10 12:19 Adam Thomson
  2018-09-10 12:19 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:19 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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(-)

-- 
1.9.1


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

* [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings
  2018-09-10 12:19 [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
@ 2018-09-10 12:19 ` Adam Thomson
  2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
  2018-09-11 14:34   ` Heikki Krogerus
  2018-09-10 12:19 ` [PATCH 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration Adam Thomson
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:19 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../bindings/connector/usb-connector.txt           |  8 +++----
 include/dt-bindings/usb/pd.h                       | 26 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt b/Documentation/devicetree/bindings/connector/usb-connector.txt
index 8855bfc..d90e17e 100644
--- a/Documentation/devicetree/bindings/connector/usb-connector.txt
+++ b/Documentation/devicetree/bindings/connector/usb-connector.txt
@@ -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.
diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
index 7b7a92f..985f2bb 100644
--- a/include/dt-bindings/usb/pd.h
+++ b/include/dt-bindings/usb/pd.h
@@ -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 */
-- 
1.9.1


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

* [PATCH 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration
  2018-09-10 12:19 [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
  2018-09-10 12:19 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
@ 2018-09-10 12:19 ` Adam Thomson
  2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
  2018-09-11 14:36   ` Heikki Krogerus
  2018-09-10 12:19 ` [PATCH 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling Adam Thomson
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:19 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/usb/fcs,fusb302.txt        | 32 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt
index 6087dc7..a5d011d 100644
--- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt
+++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt
@@ -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>;
+	};
 };
-- 
1.9.1


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

* [PATCH 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling
  2018-09-10 12:19 [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
  2018-09-10 12:19 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
  2018-09-10 12:19 ` [PATCH 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration Adam Thomson
@ 2018-09-10 12:19 ` Adam Thomson
  2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
  2018-09-11 14:37   ` Heikki Krogerus
  2018-09-10 12:21 ` [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
  2018-09-10 12:24 ` [PATCH v2 0/3] dt-bindings: connector: Add USB-PD PPS APDO support Adam Thomson
  4 siblings, 2 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:19 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/usb/typec/fusb302/fusb302.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index 82bed98..1b464c9 100644
--- a/drivers/usb/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -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;
 
-- 
1.9.1


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

* RE: [PATCH 0/3] *** SUBJECT HERE ***
  2018-09-10 12:19 [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
                   ` (2 preceding siblings ...)
  2018-09-10 12:19 ` [PATCH 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling Adam Thomson
@ 2018-09-10 12:21 ` Adam Thomson
  2018-09-10 12:24 ` [PATCH v2 0/3] dt-bindings: connector: Add USB-PD PPS APDO support Adam Thomson
  4 siblings, 0 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:21 UTC (permalink / raw)
  To: Adam Thomson, Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, Support Opensource

On 10 September 2018 13:19, Adam Thomson wrote:

> 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.

> 
> 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


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

* [PATCH v2 0/3] dt-bindings: connector: Add USB-PD PPS APDO support
  2018-09-10 12:19 [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
                   ` (3 preceding siblings ...)
  2018-09-10 12:21 ` [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
@ 2018-09-10 12:24 ` Adam Thomson
  4 siblings, 0 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:24 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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(-)

-- 
1.9.1


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

* [PATCH v2 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings
  2018-09-10 12:19 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
@ 2018-09-10 12:24   ` Adam Thomson
  2018-09-11 14:34   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:24 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../bindings/connector/usb-connector.txt           |  8 +++----
 include/dt-bindings/usb/pd.h                       | 26 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt b/Documentation/devicetree/bindings/connector/usb-connector.txt
index 8855bfc..d90e17e 100644
--- a/Documentation/devicetree/bindings/connector/usb-connector.txt
+++ b/Documentation/devicetree/bindings/connector/usb-connector.txt
@@ -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.
diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
index 7b7a92f..985f2bb 100644
--- a/include/dt-bindings/usb/pd.h
+++ b/include/dt-bindings/usb/pd.h
@@ -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 */
-- 
1.9.1


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

* [PATCH v2 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration
  2018-09-10 12:19 ` [PATCH 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration Adam Thomson
@ 2018-09-10 12:24   ` Adam Thomson
  2018-09-11 14:36   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:24 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/usb/fcs,fusb302.txt        | 32 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt
index 6087dc7..a5d011d 100644
--- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt
+++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt
@@ -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>;
+	};
 };
-- 
1.9.1


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

* [PATCH v2 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling
  2018-09-10 12:19 ` [PATCH 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling Adam Thomson
@ 2018-09-10 12:24   ` Adam Thomson
  2018-09-11 14:37   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-10 12:24 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/usb/typec/fusb302/fusb302.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index 82bed98..1b464c9 100644
--- a/drivers/usb/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -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;
 
-- 
1.9.1


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

* Re: [PATCH v2 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings
  2018-09-10 12:19 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
  2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
@ 2018-09-11 14:34   ` Heikki Krogerus
  2018-09-11 14:44     ` Adam Thomson
  1 sibling, 1 reply; 15+ messages in thread
From: Heikki Krogerus @ 2018-09-11 14:34 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, Rob Herring, Mark Rutland,
	Hans de Goede, Li Jun, linux-usb, devicetree, linux-kernel,
	support.opensource

Hi Adam,

On Mon, Sep 10, 2018 at 01:24:26PM +0100, Adam Thomson wrote:
> Add support for PPS APDOs to connector bindings so a port controller
> can specify support for PPS, as per existing FIXED/BATT/VAR PDOs.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Reviewed-by: Rob Herring <robh@kernel.org>

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,

-- 
heikki

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

* Re: [PATCH v2 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration
  2018-09-10 12:19 ` [PATCH 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration Adam Thomson
  2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
@ 2018-09-11 14:36   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Heikki Krogerus @ 2018-09-11 14:36 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, Rob Herring, Mark Rutland,
	Hans de Goede, Li Jun, linux-usb, devicetree, linux-kernel,
	support.opensource

Hi Adam,

On Mon, Sep 10, 2018 at 01:24:27PM +0100, Adam Thomson wrote:
> 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.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Reviewed-by: Rob Herring <robh@kernel.org>

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,

-- 
heikki

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

* Re: [PATCH v2 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling
  2018-09-10 12:19 ` [PATCH 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling Adam Thomson
  2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
@ 2018-09-11 14:37   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Heikki Krogerus @ 2018-09-11 14:37 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, Rob Herring, Mark Rutland,
	Hans de Goede, Li Jun, linux-usb, devicetree, linux-kernel,
	support.opensource

Hi Adam,

On Mon, Sep 10, 2018 at 01:24:28PM +0100, Adam Thomson wrote:
> 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.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>

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,

-- 
heikki

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

* RE: [PATCH v2 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings
  2018-09-11 14:34   ` Heikki Krogerus
@ 2018-09-11 14:44     ` Adam Thomson
  0 siblings, 0 replies; 15+ messages in thread
From: Adam Thomson @ 2018-09-11 14:44 UTC (permalink / raw)
  To: Heikki Krogerus, Adam Thomson
  Cc: Guenter Roeck, Greg Kroah-Hartman, Rob Herring, Mark Rutland,
	Hans de Goede, Li Jun, linux-usb, devicetree, linux-kernel,
	Support Opensource

On 11 September 2018 15:35, Heikki Krogerus wrote:

> Hi Adam,
> 
> On Mon, Sep 10, 2018 at 01:24:26PM +0100, Adam Thomson wrote:
> > Add support for PPS APDOs to connector bindings so a port controller
> > can specify support for PPS, as per existing FIXED/BATT/VAR PDOs.
> >
> > Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> > Reviewed-by: Rob Herring <robh@kernel.org>
> 
> 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. :)

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

* Re: [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs  to bindings
  2018-08-21 12:28 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
@ 2018-08-31 12:16   ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2018-08-31 12:16 UTC (permalink / raw)
  To: Adam Thomson
  Cc: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Mark Rutland,
	Hans de Goede, Li Jun, linux-usb, devicetree, linux-kernel,
	support.opensource

On Tue, 21 Aug 2018 13:28:21 +0100, Adam Thomson wrote:
> Add support for PPS APDOs to connector bindings so a port controller
> can specify support for PPS, as per existing FIXED/BATT/VAR PDOs.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> ---
>  .../bindings/connector/usb-connector.txt           |  8 +++----
>  include/dt-bindings/usb/pd.h                       | 26 ++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 4 deletions(-)
> 

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

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

* [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings
  2018-08-21 12:28 [PATCH " Adam Thomson
@ 2018-08-21 12:28 ` Adam Thomson
  2018-08-31 12:16   ` Rob Herring
  0 siblings, 1 reply; 15+ messages in thread
From: Adam Thomson @ 2018-08-21 12:28 UTC (permalink / raw)
  To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Hans de Goede, Li Jun
  Cc: linux-usb, devicetree, linux-kernel, support.opensource

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

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 .../bindings/connector/usb-connector.txt           |  8 +++----
 include/dt-bindings/usb/pd.h                       | 26 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt b/Documentation/devicetree/bindings/connector/usb-connector.txt
index 8855bfc..d90e17e 100644
--- a/Documentation/devicetree/bindings/connector/usb-connector.txt
+++ b/Documentation/devicetree/bindings/connector/usb-connector.txt
@@ -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.
diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
index 7b7a92f..985f2bb 100644
--- a/include/dt-bindings/usb/pd.h
+++ b/include/dt-bindings/usb/pd.h
@@ -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 */
-- 
1.9.1


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

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

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10 12:19 [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
2018-09-10 12:19 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
2018-09-11 14:34   ` Heikki Krogerus
2018-09-11 14:44     ` Adam Thomson
2018-09-10 12:19 ` [PATCH 2/3] dt-bindings: usb: fusb302: Use usb-connector bindings for configuration Adam Thomson
2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
2018-09-11 14:36   ` Heikki Krogerus
2018-09-10 12:19 ` [PATCH 3/3] usb: typec: fusb302: Populate tcpc fwnode for TCPM property handling Adam Thomson
2018-09-10 12:24   ` [PATCH v2 " Adam Thomson
2018-09-11 14:37   ` Heikki Krogerus
2018-09-10 12:21 ` [PATCH 0/3] *** SUBJECT HERE *** Adam Thomson
2018-09-10 12:24 ` [PATCH v2 0/3] dt-bindings: connector: Add USB-PD PPS APDO support Adam Thomson
  -- strict thread matches above, loose matches on Subject: below --
2018-08-21 12:28 [PATCH " Adam Thomson
2018-08-21 12:28 ` [PATCH 1/3] dt-bindings: connector: Add support for USB-PD PPS APDOs to bindings Adam Thomson
2018-08-31 12:16   ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).