Skip to contentSkip to conversation

Add Richtek RT1719 USBPD controller support

PATCH Superseded cy_huang 2 participants 4 messages Jan 14, 2022

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

cy_huang

author
#0 lore raw

cover Add Richtek RT1719 USBPD controller support

From: ChiYuan Huang <[email protected]>

This patch series add Richtek RT1719 sink only USBPD typec controller support.

ChiYuan Huang (2):
dt-bindings: usb: rt1719: Add binding for Richtek RT1719
usb: typec: rt1719: Add support for Richtek RT1719

 .../devicetree/bindings/usb/richtek,rt1719.yaml    |  85 ++
 drivers/usb/typec/Kconfig                          |  12 +
 drivers/usb/typec/Makefile                         |   1 +
 drivers/usb/typec/rt1719.c                         | 976 +++++++++++++++++++++
 4 files changed, 1074 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/richtek,rt1719.yaml
 create mode 100644 drivers/usb/typec/rt1719.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/2 dt-bindings: usb: rt1719: Add binding for Richtek RT1719

From: ChiYuan Huang <[email protected]>

Add binding for Richtek RT1719.

---
 .../devicetree/bindings/usb/richtek,rt1719.yaml    | 85 ++++++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/richtek,rt1719.yaml
Documentation/devicetree/bindings/usb/richtek,rt1719.yaml new file +85 -0
new file mode 100644
index 00000000..65a93f7
@@ -0,0 +1,85 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/usb/richtek,rt1719.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Richtek RT1719 sink-only Type-C PD controller bindings
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  The RT1719 is a sink-only USB Type-C contoller that complies with the latest
+  USB Type-C and PD standards. It does the USB Type-C detection including attach
+  and orientation. It integrates the physical layer of the USB BMC power
+  delivery protocol to allow up to 100W of power. The BMC PD block enables full
+  support for alternative interfaces of the Type-C specification.
+
+properties:
+  compatible:
+    enum:
+      - richtek,rt1719
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  wakeup-source:
+    description: enable IRQ remote wakeup, see power/wakeup-source.txt
+    type: boolean
+
+  connector:
+    type: object
+    $ref: ../connector/usb-connector.yaml#
+    description:
+      Properties for usb c connector.
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - connector
+  - interrupts
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c0 {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      rt1719@43 {
+        compatible = "richtek,rt1719";
+        reg = <0x43>;
+        interrupts-extended = <&gpio26 2 IRQ_TYPE_LEVEL_LOW>;
+        wakeup-source;
+
+        connector {
+          compatible = "usb-c-connector";
+          label = "USB-C";
+
+          ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            port@0 {
+              reg = <0>;
+              endpoint {
+                remote-endpoint = <&usb_hs>;
+              };
+            };
+            port@1 {
+              reg = <1>;
+              endpoint {
+                remote-endpoint = <&usb_ss>;
+              };
+            };
+          };
+        };
+      };
+    };
+...
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/2 usb: typec: rt1719: Add support for Richtek RT1719

In reply to cy_huang

From: ChiYuan Huang <[email protected]>

Richtek RT1719 is a sink-only Type-C PD controller it complies with latest USB Type-C and PD standards. It integrates the physical layer of USB power delivery protocol to allow up to 100W of power.

---
 drivers/usb/typec/Kconfig  |  12 +
 drivers/usb/typec/Makefile |   1 +
 drivers/usb/typec/rt1719.c | 976 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 989 insertions(+)
 create mode 100644 drivers/usb/typec/rt1719.c
drivers/usb/typec/Kconfig +12 -0
index ab480f3..bc918ca 100644
@@ -52,6 +52,18 @@ source "drivers/usb/typec/ucsi/Kconfig"
 
 source "drivers/usb/typec/tipd/Kconfig"
 
+config TYPEC_RT1719
+	tristate "Richtek RT1719 Sink Only Type-C controller driver"
+	depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Say Y or M here if your system has Richtek RT1719 sink only
+	  Type-C port controller driver.
+
+	  If you choose to build this driver as a dynamically linked module, the
+	  module will be called rt1719.ko
+
 config TYPEC_HD3SS3220
 	tristate "TI HD3SS3220 Type-C DRP Port controller driver"
 	depends on I2C
drivers/usb/typec/Makefile +1 -0
index 57870a2..441dd6c 100644
@@ -9,4 +9,5 @@ obj-$(CONFIG_TYPEC_TPS6598X)	+= tipd/
 obj-$(CONFIG_TYPEC_HD3SS3220)	+= hd3ss3220.o
 obj-$(CONFIG_TYPEC_QCOM_PMIC)	+= qcom-pmic-typec.o
 obj-$(CONFIG_TYPEC_STUSB160X) 	+= stusb160x.o
+obj-$(CONFIG_TYPEC_RT1719)	+= rt1719.o
 obj-$(CONFIG_TYPEC)		+= mux/
drivers/usb/typec/rt1719.c new file +976 -0

976 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH 2/2] usb: typec: rt1719: Add support for Richtek RT1719

Thank you for the patch! Perhaps something to improve:

Hi cy_huang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on robh/for-next v5.16 next-20220114] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/cy_huang/Add-Richtek-RT1719-USBPD-controller-support/20220115-000058
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20220115/202201150209.qTlXJwWM-lkp(a)intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/20efb31d7403b57c80a61a6c416d780ad561a2bd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cy_huang/Add-Richtek-RT1719-USBPD-controller-support/20220115-000058 git checkout 20efb31d7403b57c80a61a6c416d780ad561a2bd
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/usb/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/usb/typec/rt1719.c: In function 'rt1719_usbpd_request_voltage':

>> drivers/usb/typec/rt1719.c:492:65: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     492 |                                  RT1719_EVALMODE_MASK | src_sel + 1);
         |                                                         ~~~~~~~~^~~

vim +492 drivers/usb/typec/rt1719.c

437
438 static int rt1719_usbpd_request_voltage(struct rt1719_data *data)
439 {
440 u32 src_voltage;
441 int snk_sel, src_sel = -1;
442 int i, ret;
443
444 if (!data->attached || !data->pd_capable || data->spdo_sel <= 0)
445 return -EINVAL;
446
447 src_voltage = pdo_fixed_voltage(data->spdos[data->spdo_sel - 1]);
448 if (src_voltage == data->req_voltage)
449 return 0;
450
451 switch (data->req_voltage) {
452 case 5000:
453 snk_sel = RT1719_SNKCAP_5V;
454 break;
455 case 9000:
456 snk_sel = RT1719_SNKCAP_9V;
457 break;
458 case 12000:
459 snk_sel = RT1719_SNKCAP_12V;
460 break;
461 case 15000:
462 snk_sel = RT1719_SNKCAP_15V;
463 break;
464 case 20000:
465 snk_sel = RT1719_SNKCAP_20V;
466 break;
467 default:
468 return -EINVAL;
469 }
470
471 if (!(data->snkcaps[snk_sel] & RT1719_PSEL_SUPPORT))
472 return -EINVAL;
473
474 for (i = 0; i < data->spdo_num; i++) {
475 enum pd_pdo_type type = pdo_type(data->spdos[i]);
476
477 if (type != PDO_TYPE_FIXED)
478 continue;
479
480 src_voltage = pdo_fixed_voltage(data->spdos[i]);
481 if (src_voltage == data->req_voltage) {
482 src_sel = i;
483 break;
484 }
485 }
486
487 if (src_sel == -1)
488 return -ENOTSUPP;
489
490 ret = regmap_update_bits(data->regmap, RT1719_REG_TXCTRL1,
491 RT1719_EVALMODE_MASK | RT1719_REQSRCPDO_MASK,

 > 492					 RT1719_EVALMODE_MASK | src_sel + 1);

493 ret |= regmap_update_bits(data->regmap, RT1719_REG_TXCTRL2,
494 RT1719_TXSPDOREQ_MASK, RT1719_TXSPDOREQ_MASK);
495 if (ret)
496 return ret;
497
498 reinit_completion(&data->req_completion);
499 ret = wait_for_completion_timeout(&data->req_completion,
500 msecs_to_jiffies(400));
501 if (!ret)
502 return -ETIMEDOUT;
503
504 return 0;
505 }
506

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org