Skip to contentSkip to conversation

CH7322 CEC controller driver

PATCH Superseded Jeff Chase 3 participants 8 messages May 29, 2020 – Jun 8, 2020 1 message not in the archive

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Jeff Chase

author
#0 lore raw

v3 cover CH7322 CEC controller driver

Add device driver and device tree bindings for a Chrontel CEC conroller. This is an I2C device that can send and receive CEC messages.

Changes from v2:
- fix formatting errors
- mask and unmask interrupt in cec adapter enable

Changes from v1:
- fix formatpatch.pl --strict errors
- additional comments
- enable and program logical address register
- add flags to aid interpreting transmit done status
- move ch7322 out of devicetree trivial devices

Jeff Chase (2):
dt-bindings: Add ch7322 media i2c device
media: cec: i2c: ch7322: Add ch7322 CEC controller driver

 .../bindings/media/i2c/chrontel,ch7322.yaml   |  65 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   8 +
 drivers/media/cec/Kconfig                     |   1 +
 drivers/media/cec/Makefile                    |   2 +-
 drivers/media/cec/i2c/Kconfig                 |  14 +
 drivers/media/cec/i2c/Makefile                |   5 +
 drivers/media/cec/i2c/ch7322.c                | 523 ++++++++++++++++++
 8 files changed, 619 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml
 create mode 100644 drivers/media/cec/i2c/Kconfig
 create mode 100644 drivers/media/cec/i2c/Makefile
 create mode 100644 drivers/media/cec/i2c/ch7322.c
Signature · 1 line
2.27.0.rc0.183.gde8f92d652-goog
author
#1 lore raw

PATCH v3 1/2 dt-bindings: Add ch7322 media i2c device

The ch7322 is a Chrontel CEC controller.

---
 .../bindings/media/i2c/chrontel,ch7322.yaml   | 65 +++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 MAINTAINERS                                   |  7 ++
 3 files changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml
Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml new file +65 -0
new file mode 100644
index 000000000000..d5706e08164c
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/media/i2c/chrontel,ch7322.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Chrontel HDMI-CEC Controller
+
+maintainers:
+  - Jeff Chase <[email protected]>
+
+description: |-
+  The Chrontel CH7322 is a discrete HDMI-CEC controller. It is
+  programmable through I2C and drives a single CEC line.
+
+properties:
+  compatible:
+    const: chrontel,ch7322
+
+  reg:
+    description: I2C device address
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description: |-
+      Reference to the GPIO connected to the RESET pin, if any. This
+      pin is active-low.
+
+  standby-gpios:
+    description: |-
+      Reference to the GPIO connected to the OE pin, if any. When low
+      the device will respond to power status requests with "standby"
+      if in auto mode.
+
+  # see ../cec.txt
+  hdmi-phandle:
+    description: phandle to the HDMI controller
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      ch7322@75 {
+        compatible = "chrontel,ch7322";
+        reg = <0x75>;
+        interrupts = <47 IRQ_TYPE_EDGE_RISING>;
+        standby-gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
+        reset-gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+        hdmi-phandle = <&hdmi>;
+      };
+    };
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index d3891386d671..7794ffccd325 100644
@@ -187,6 +187,8 @@ patternProperties:
     description: ChipOne
   "^chipspark,.*":
     description: ChipSPARK
+  "^chrontel,.*":
+    description: Chrontel, Inc.
   "^chrp,.*":
     description: Common Hardware Reference Platform
   "^chunghwa,.*":
MAINTAINERS +7 -0
index d633a131dcd7..34c6d30e61e5 100644
@@ -4047,6 +4047,13 @@ F:	drivers/power/supply/cros_usbpd-charger.c
 N:	cros_ec
 N:	cros-ec
 
+CHRONTEL CH7322 CEC DRIVER
+M:	Jeff Chase <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/chontel,ch7322.yaml
+
 CIRRUS LOGIC AUDIO CODEC DRIVERS
 M:	James Schulman <[email protected]>
 M:	David Rhodes <[email protected]>
Signature · 1 line
2.27.0.rc0.183.gde8f92d652-goog
maintainer
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: Add ch7322 media i2c device

Quoted 18 lines · Jeff Chase

The ch7322 is a Chrontel CEC controller.

---
 .../bindings/media/i2c/chrontel,ch7322.yaml   | 65 +++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 MAINTAINERS                                   |  7 ++
 3 files changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml
Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml new file +2 -0
new file mode 100644
index 000000000000..d5706e08164c
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2

Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml line 12

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml new file +10 -0
+---
+$id: "http://devicetree.org/schemas/media/i2c/chrontel,ch7322.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Chrontel HDMI-CEC Controller
+
+maintainers:
+  - Jeff Chase <[email protected]>
+
+description: |-

Can drop the '|-' as you don't need any formatting.

Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml new file +11 -0
+  The Chrontel CH7322 is a discrete HDMI-CEC controller. It is
+  programmable through I2C and drives a single CEC line.
+
+properties:
+  compatible:
+    const: chrontel,ch7322
+
+  reg:
+    description: I2C device address
+    maxItems: 1
+

Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml line 33

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml new file +10 -0
+  clocks:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description: |-
+      Reference to the GPIO connected to the RESET pin, if any. This
+      pin is active-low.

How many? (maxItems: 1)

Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml line 35

Quoted 2 lines
Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml new file +2 -0
+
+  standby-gpios:

How many?

Quoted 64 lines
Documentation/devicetree/bindings/media/i2c/chrontel,ch7322.yaml new file +30 -0
+    description: |-
+      Reference to the GPIO connected to the OE pin, if any. When low
+      the device will respond to power status requests with "standby"
+      if in auto mode.
+
+  # see ../cec.txt
+  hdmi-phandle:
+    description: phandle to the HDMI controller
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      ch7322@75 {
+        compatible = "chrontel,ch7322";
+        reg = <0x75>;
+        interrupts = <47 IRQ_TYPE_EDGE_RISING>;
+        standby-gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
+        reset-gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+        hdmi-phandle = <&hdmi>;
+      };
+    };
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index d3891386d671..7794ffccd325 100644
@@ -187,6 +187,8 @@ patternProperties:
     description: ChipOne
   "^chipspark,.*":
     description: ChipSPARK
+  "^chrontel,.*":
+    description: Chrontel, Inc.
   "^chrp,.*":
     description: Common Hardware Reference Platform
   "^chunghwa,.*":
MAINTAINERS +7 -0
index d633a131dcd7..34c6d30e61e5 100644
@@ -4047,6 +4047,13 @@ F:	drivers/power/supply/cros_usbpd-charger.c
 N:	cros_ec
 N:	cros-ec
 
+CHRONTEL CH7322 CEC DRIVER
+M:	Jeff Chase <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	Documentation/devicetree/bindings/media/i2c/chontel,ch7322.yaml
+
 CIRRUS LOGIC AUDIO CODEC DRIVERS
 M:	James Schulman <[email protected]>
 M:	David Rhodes <[email protected]>
Signature · 1 line
2.27.0.rc0.183.gde8f92d652-goog
author
#3 lore raw

PATCH v3 2/2 media: cec: i2c: ch7322: Add ch7322 CEC controller driver

In reply to Jeff Chase

Add a CEC device driver for the Chrontel ch7322 CEC conroller. This is an I2C device capable of sending and receiving CEC messages.

---
 MAINTAINERS                    |   1 +
 drivers/media/cec/Kconfig      |   1 +
 drivers/media/cec/Makefile     |   2 +-
 drivers/media/cec/i2c/Kconfig  |  14 +
 drivers/media/cec/i2c/Makefile |   5 +
 drivers/media/cec/i2c/ch7322.c | 523 +++++++++++++++++++++++++++++++++
 6 files changed, 545 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/cec/i2c/Kconfig
 create mode 100644 drivers/media/cec/i2c/Makefile
 create mode 100644 drivers/media/cec/i2c/ch7322.c
MAINTAINERS +1 -0
index 34c6d30e61e5..43e876395686 100644
@@ -4053,6 +4053,7 @@ L:	[email protected]
 S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	Documentation/devicetree/bindings/media/i2c/chontel,ch7322.yaml
+F:	drivers/media/cec/i2c/ch7322.c
 
 CIRRUS LOGIC AUDIO CODEC DRIVERS
 M:	James Schulman <[email protected]>
drivers/media/cec/Kconfig +1 -0
index eea74b7cfa8c..3e934aa239ab 100644
@@ -33,6 +33,7 @@ menuconfig MEDIA_CEC_SUPPORT
 	  adapter that supports HDMI CEC.
 
 if MEDIA_CEC_SUPPORT
+source "drivers/media/cec/i2c/Kconfig"
 source "drivers/media/cec/platform/Kconfig"
 source "drivers/media/cec/usb/Kconfig"
 endif
drivers/media/cec/Makefile +1 -1
index 74e80e1b3571..23539339bc81 100644
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y += core/ platform/ usb/
+obj-y += core/ i2c/ platform/ usb/
drivers/media/cec/i2c/Kconfig new file +14 -0
new file mode 100644
index 000000000000..e445ca2110b3
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# I2C drivers
+
+config CEC_CH7322
+	tristate "Chrontel CH7322 CEC controller"
+	select I2C
+	select REGMAP_I2C
+	select CEC_CORE
+	help
+	  This is a driver for the Chrontel CH7322 CEC controller. It uses the
+	  generic CEC framework interface.
+	  CEC bus is present in the HDMI connector and enables communication
+	  between compatible devices.
drivers/media/cec/i2c/Makefile new file +5 -0
new file mode 100644
index 000000000000..d7496dfd0fa4
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the CEC I2C device drivers.
+#
+obj-$(CONFIG_CEC_CH7322) += ch7322.o
drivers/media/cec/i2c/ch7322.c new file +523 -0

523 lines not on this page · raw message

Signature · 1 line
2.27.0.rc0.183.gde8f92d652-goog

A message that is not in the archive (sent off-list or not yet received): CALTkaQ2OR+bc2QGeucA5aP3SiM5HLnx5=DoZQ51E_1d99Hb5Uw@mail.gmail.com

author
#5 lore raw

PATCH v3 2/2 media: cec: i2c: ch7322: Add ch7322 CEC controller driver

(Resending as plain text, sorry)

drivers/media/cec/i2c/ch7322.c line 371

Quoted 13 lines
drivers/media/cec/i2c/ch7322.c new file +13 -0
+static int ch7322_cec_adap_enable(struct cec_adapter *adap, bool enable)
+{
+       struct ch7322 *ch7322 = cec_get_drvdata(adap);
+       int ret;
+
+       if (enable)
+               ret = ch7322_unmask_interrupt(ch7322);
+       else
+               ret = ch7322_mask_interrupt(ch7322);
+
+       return ret;
+}
+

I just realized that doing this here is broken -- the driver depends on the interrupt to detect when the physical address changes. I could mask only the tx/rx interrupt here instead but that is starting to feel a bit pointless.

I haven't looked into the cec notifier mechanism yet but would it be better to try to use that instead if possible and just ignore this device's physical address detection? Then I could do more of a proper reset in this enable op. But I'm not sure if I can properly associate the device with an HDMI port on my platform unless I make some changes to coreboot.

Thanks,
Jeff

#6 lore raw

Re: Fwd: [PATCH v3 2/2] media: cec: i2c: ch7322: Add ch7322 CEC controller driver

Quoted 12 lines · Jeff Chase

(Resending as plain text, sorry)

Quoted 10 lines
drivers/media/cec/i2c/ch7322.c new file +10 -0
+static int ch7322_cec_adap_enable(struct cec_adapter *adap, bool enable)
+{
+       struct ch7322 *ch7322 = cec_get_drvdata(adap);
+       int ret;
+
+       if (enable)
+               ret = ch7322_unmask_interrupt(ch7322);
+       else
+               ret = ch7322_mask_interrupt(ch7322);
+
Quoted 8 lines

drivers/media/cec/i2c/ch7322.c line 172

Quoted 3 lines
drivers/media/cec/i2c/ch7322.c new file +3 -0
+       return ret;
+}
+

I just realized that doing this here is broken -- the driver depends on the interrupt to detect when the physical address changes. I could mask only the tx/rx interrupt here instead but that is starting to feel a bit pointless.

Ah, OK. Just drop this then.

Quoted 7 lines

I haven't looked into the cec notifier mechanism yet but would it be better to try to use that instead if possible and just ignore this device's physical address detection? Then I could do more of a proper reset in this enable op. But I'm not sure if I can properly associate the device with an HDMI port on my platform unless I make some changes to coreboot.

I don't think this is useful: it's nice to have the CEC adapter do the physical address detection.

One question about that though: if there is no physical address, can this driver still transmit CEC messages? Specifically Image View On. This is important to wake up displays that pull down the HPD when in standby.

The easiest way to test this is with a Pulse-Eight CEC adapter.

See also the section "CEC Without HPD" here:

https://hverkuil.home.xs4all.nl/cec-status.txt

Regards,

Hans

author
#7 lore raw

Re: Fwd: [PATCH v3 2/2] media: cec: i2c: ch7322: Add ch7322 CEC controller driver

Quoted 7 lines
Quoted 6 lines

I haven't looked into the cec notifier mechanism yet but would it be better to try to use that instead if possible and just ignore this device's physical address detection? Then I could do more of a proper reset in this enable op. But I'm not sure if I can properly associate the device with an HDMI port on my platform unless I make some changes to coreboot.

Quoted 6 lines

I don't think this is useful: it's nice to have the CEC adapter do the physical address detection.

One question about that though: if there is no physical address, can this driver still transmit CEC messages? Specifically Image View On. This is important to wake up displays that pull down the HPD when in standby.

Yes it can. I just verified this with the kwikwai analyzer.

Thanks,
Jeff

#8 lore raw

Re: Fwd: [PATCH v3 2/2] media: cec: i2c: ch7322: Add ch7322 CEC controller driver

Quoted 7 lines · Jeff Chase
Quoted 7 lines
Quoted 6 lines

I haven't looked into the cec notifier mechanism yet but would it be better to try to use that instead if possible and just ignore this device's physical address detection? Then I could do more of a proper reset in this enable op. But I'm not sure if I can properly associate the device with an HDMI port on my platform unless I make some changes to coreboot.

Quoted 8 lines
Quoted 6 lines

I don't think this is useful: it's nice to have the CEC adapter do the physical address detection.

One question about that though: if there is no physical address, can this driver still transmit CEC messages? Specifically Image View On. This is important to wake up displays that pull down the HPD when in standby.

Yes it can. I just verified this with the kwikwai analyzer.

Good.

Once I have Rob's Ack for the binding patch I will make a pull request for this series.

BTW, you wouldn't happen to know a cheap device that uses this chip/driver?

It would be nice to add this to my collection of CEC devices.

Regards,

Hans