diff mbox series

[01/11] dt-bindings: extcon: ptn5150: Convert binding to DT schema

Message ID 20200812162958.6180-1-krzk@kernel.org
State Superseded, archived
Headers show
Series [01/11] dt-bindings: extcon: ptn5150: Convert binding to DT schema | expand

Checks

Context Check Description
robh/checkpatch warning total: 0 errors, 2 warnings, 53 lines checked
robh/dt-meta-schema success

Commit Message

Krzysztof Kozlowski Aug. 12, 2020, 4:29 p.m. UTC
Convert the ptn-5150 extcon driver bindings to DT schema format using
json-schema.  The differences with original bindings document:
 - Use "gpios" suffix for the "int" and "vbus" gpio,
 - Skip generic properties like "reg" or "pinctrl".

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 .../bindings/extcon/extcon-ptn5150.txt        | 27 ----------
 .../bindings/extcon/extcon-ptn5150.yaml       | 53 +++++++++++++++++++
 2 files changed, 53 insertions(+), 27 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt
 create mode 100644 Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml

Comments

Krzysztof Kozlowski Aug. 13, 2020, 6:03 a.m. UTC | #1
On Wed, Aug 12, 2020 at 06:29:55PM +0200, Krzysztof Kozlowski wrote:
> When machine boots up, the USB could be already in OTG mode.  In such
> case there will be no interrupt coming to ptn5150 device and driver will
> report default state of nothing connected.  Detection of USB connection
> would happen on first unplug of the cable.
> 
> Factor out code for checking current connection mode and call it right
> after probe so the existing USB mode will be properly reported.
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/extcon/extcon-ptn5150.c | 93 ++++++++++++++++++---------------
>  1 file changed, 50 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> index a57fef384a29..bbb185378e4b 100644
> --- a/drivers/extcon/extcon-ptn5150.c
> +++ b/drivers/extcon/extcon-ptn5150.c
> @@ -5,6 +5,7 @@
>  // Based on extcon-sm5502.c driver
>  // Copyright (c) 2018-2019 by Vijai Kumar K
>  // Author: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
> +// Copyright (c) 2020 Krzysztof Kozlowski <krzk@kernel.org>
>  
>  #include <linux/err.h>
>  #include <linux/i2c.h>
> @@ -83,12 +84,50 @@ static const struct regmap_config ptn5150_regmap_config = {
>  	.max_register	= PTN5150_REG_END,
>  };
>  
> +static void ptn5150_check_state(struct ptn5150_info *info)
> +{
> +	unsigned int port_status, reg_data, vbus;
> +	int ret;
> +
> +	ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, &reg_data);
> +	if (ret) {
> +		dev_err(info->dev, "failed to read CC STATUS %d\n", ret);
> +		mutex_unlock(&info->mutex);

There is a double mutex unlock here, I'll send a v2.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt
deleted file mode 100644
index 936fbdf12815..000000000000
--- a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.txt
+++ /dev/null
@@ -1,27 +0,0 @@ 
-* PTN5150 CC (Configuration Channel) Logic device
-
-PTN5150 is a small thin low power CC logic chip supporting the USB Type-C
-connector application with CC control logic detection and indication functions.
-It is interfaced to the host controller using an I2C interface.
-
-Required properties:
-- compatible: should be "nxp,ptn5150"
-- reg: specifies the I2C slave address of the device
-- int-gpio: should contain a phandle and GPIO specifier for the GPIO pin
-	connected to the PTN5150's INTB pin.
-- vbus-gpio: should contain a phandle and GPIO specifier for the GPIO pin which
-	is used to control VBUS.
-- pinctrl-names : a pinctrl state named "default" must be defined.
-- pinctrl-0 : phandle referencing pin configuration of interrupt and vbus
-	control.
-
-Example:
-	ptn5150@1d {
-		compatible = "nxp,ptn5150";
-		reg = <0x1d>;
-		int-gpio = <&msmgpio 78 GPIO_ACTIVE_HIGH>;
-		vbus-gpio = <&msmgpio 148 GPIO_ACTIVE_HIGH>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&ptn5150_default>;
-		status = "okay";
-	};
diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
new file mode 100644
index 000000000000..f6316f12028b
--- /dev/null
+++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
@@ -0,0 +1,53 @@ 
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/extcon/extcon-ptn5150.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: PTN5150 CC (Configuration Channel) Logic device
+
+maintainers:
+  - Krzysztof Kozlowski <krzk@kernel.org>
+
+description: |
+  PTN5150 is a small thin low power CC logic chip supporting the USB Type-C
+  connector application with CC control logic detection and indication
+  functions.  It is interfaced to the host controller using an I2C interface.
+
+properties:
+  compatible:
+    const: nxp,ptn5150
+
+  int-gpios:
+    description:
+      GPIO pin (input) connected to the PTN5150's INTB pin.
+
+  reg:
+    maxItems: 1
+
+  vbus-gpios:
+    description:
+      GPIO pin (output) used to control VBUS.
+
+required:
+  - compatible
+  - int-gpios
+  - reg
+  - vbus-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ptn5150@1d {
+            compatible = "nxp,ptn5150";
+            reg = <0x1d>;
+            int-gpios = <&msmgpio 78 GPIO_ACTIVE_HIGH>;
+            vbus-gpios = <&msmgpio 148 GPIO_ACTIVE_HIGH>;
+        };
+    };