Skip to contentSkip to conversation

usb typec: mt6360: Add support for mt6360 Type-C driver

PATCH Superseded cy_huang 2 participants 5 messages Aug 27, 2020

Subsystems (5)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

cy_huang

author
#0 lore raw

PATCH v2 1/3 usb typec: mt6360: Add support for mt6360 Type-C driver

From: ChiYuan Huang <[email protected]>

Mediatek MT6360 is a multi-functional IC that includes USB Type-C. It works with Type-C Port Controller Manager to provide USB PD and USB Type-C functionalities.

---
 drivers/usb/typec/tcpm/Kconfig        |   8 ++
 drivers/usb/typec/tcpm/Makefile       |   1 +
 drivers/usb/typec/tcpm/tcpci_mt6360.c | 212 ++++++++++++++++++++++++++++++++++
 3 files changed, 221 insertions(+)
 create mode 100644 drivers/usb/typec/tcpm/tcpci_mt6360.c
drivers/usb/typec/tcpm/Kconfig +8 -0
index fa3f393..58a64e1 100644
@@ -27,6 +27,14 @@ config TYPEC_RT1711H
 	  Type-C Port Controller Manager to provide USB PD and USB
 	  Type-C functionalities.
 
+config TYPEC_MT6360
+	tristate "Mediatek MT6360 Type-C driver"
+	depends on MFD_MT6360
+	help
+	  Mediatek MT6360 is a multi-functional IC that includes
+	  USB Type-C. It works with Type-C Port Controller Manager
+	  to provide USB PD and USB Type-C functionalities.
+
 endif # TYPEC_TCPCI
 
 config TYPEC_FUSB302
drivers/usb/typec/tcpm/Makefile +1 -0
index a5ff6c8..7592ccb 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_TYPEC_WCOVE)	+= typec_wcove.o
 typec_wcove-y			:= wcove.o
 obj-$(CONFIG_TYPEC_TCPCI)	+= tcpci.o
 obj-$(CONFIG_TYPEC_RT1711H)	+= tcpci_rt1711h.o
+obj-$(CONFIG_TYPEC_MT6360)	+= tcpci_mt6360.o
drivers/usb/typec/tcpm/tcpci_mt6360.c new file +212 -0

212 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 2/3 usb typec: mt6360: Add MT6360 Type-C DT binding documentation

From: ChiYuan Huang <[email protected]>

Add a devicetree binding documentation for the MT6360 Type-C driver.

---
 .../bindings/usb/mediatek,mt6360-tcpc.yaml         | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml
Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml new file +73 -0
new file mode 100644
index 00000000..9e8ab0d
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/usb/mediatek,mt6360-tcpc.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Mediatek MT6360 Type-C Port Switch and Power Delivery controller DT bindings
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  Mediatek MT6360 is a multi-functional device. It integrates charger, ADC, flash, RGB indicators,
+  regulators (BUCKs/LDOs), and TypeC Port Switch with Power Delivery controller.
+  This document only describes MT6360 Type-C Port Switch and Power Delivery controller.
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt6360-tcpc
+
+  interrupts-extended:
+    maxItems: 1
+
+  interrupt-names:
+    items:
+      - const: PD_IRQB
+
+patternProperties:
+  "connector":
+    type: object
+    $ref: ../connector/usb-connector.yaml#
+    description:
+      Properties for usb c connector.
+
+additionalProperties: false
+
+required:
+  - compatible
+  - interrupts-extended
+  - interrupt-names
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/usb/pd.h>
+    i2c0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        mt6360@34 {
+            compatible = "mediatek,mt6360";
+            reg = <0x34>;
+
+            tcpc {
+                compatible = "mediatek,mt6360-tcpc";
+                interrupts-extended = <&gpio26 3 IRQ_TYPE_LEVEL_LOW>;
+                interrupt-names = "PD_IRQB";
+
+                connector {
+                        compatible = "usb-c-connector";
+                        label = "USB-C";
+                        data-role = "dual";
+                        power-role = "dual";
+                        try-power-role = "sink";
+                        source-pdos = <PDO_FIXED(5000, 1000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP)>;
+                        sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP)>;
+                        op-sink-microwatt = <10000000>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v2 3/3 usb typec: mt6360: Prevent the race condition during module remove

In reply to cy_huang

From: ChiYuan Huang <[email protected]>

Prevent the race condition from interrupt and tcpci port unregister during module remove.

---
 drivers/usb/typec/tcpm/tcpci_mt6360.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci_mt6360.c +1 -0
index 6a28193..a381b5d 100644
@@ -164,6 +164,7 @@ static int mt6360_tcpc_remove(struct platform_device *pdev)
 {
 	struct mt6360_tcpc_info *mti = platform_get_drvdata(pdev);
 
+	disable_irq(mti->irq);
 	tcpci_unregister_port(mti->tcpci);
 	return 0;
 }
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH v2 3/3] usb typec: mt6360: Prevent the race condition during module remove

Quoted 6 lines · cy_huang

From: ChiYuan Huang <[email protected]>

Prevent the race condition from interrupt and tcpci port unregister during module remove.

Please squash with the first patch of the series.

Thanks,
Guenter

Quoted 17 lines
---
 drivers/usb/typec/tcpm/tcpci_mt6360.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci_mt6360.c +1 -0
index 6a28193..a381b5d 100644
@@ -164,6 +164,7 @@ static int mt6360_tcpc_remove(struct platform_device *pdev)
 {
 	struct mt6360_tcpc_info *mti = platform_get_drvdata(pdev);
 
+	disable_irq(mti->irq);
 	tcpci_unregister_port(mti->tcpci);
 	return 0;
 }
author
#4 lore raw

Re: [PATCH v2 3/3] usb typec: mt6360: Prevent the race condition during module remove

Guenter Roeck <[email protected]> 於 2020年8月27日 週四 上午11:34寫道:

Quoted 10 lines · cy_huang
Quoted 6 lines

From: ChiYuan Huang <[email protected]>

Prevent the race condition from interrupt and tcpci port unregister during module remove.

Please squash with the first patch of the series.

Done, squash into the first one and resend the patch. Thx.

Quoted 22 lines

Thanks,
Guenter

Quoted 17 lines
---
 drivers/usb/typec/tcpm/tcpci_mt6360.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci_mt6360.c +1 -0
index 6a28193..a381b5d 100644
@@ -164,6 +164,7 @@ static int mt6360_tcpc_remove(struct platform_device *pdev)
 {
      struct mt6360_tcpc_info *mti = platform_get_drvdata(pdev);
 
+     disable_irq(mti->irq);
      tcpci_unregister_port(mti->tcpci);
      return 0;
 }