Skip to contentSkip to conversation

dt-binding: Add DSI/LVDS TC358775 bridge bindings

PATCH Superseded Vinay Simha BN 3 participants 6 messages Jun 18, 2020 – Jun 20, 2020

Subsystems (4)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 dt-binding: Add DSI/LVDS TC358775 bridge bindings

---
v1:
Initial version wast .txt file

v2:
From txt to yaml file format

v3:
* Andrzej Hajda review comments incorporated
dual port lvds implemented

* Laurent Pinchart review comments incorporated dsi lanes property removed and it is dynamically picked from the dsi ports
VESA/JEIDA format picked from panel-lvds dts

---
 .../display/bridge/toshiba,tc358775.yaml      | 204 ++++++++++++++++++
 1 file changed, 204 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/toshiba,tc358775.yaml
Documentation/devicetree/bindings/display/bridge/toshiba,tc358775.yaml new file +204 -0
new file mode 100644
index 000000000000..ec53d62d408b
@@ -0,0 +1,204 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/bridge/toshiba,tc358775.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Toshiba TC358775 DSI to LVDS bridge bindings
+
+maintainers:
+ - Vinay Simha BN <[email protected]>
+
+description: |
+ This binding supports DSI to LVDS bridge TC358775
+
+properties:
+  compatible:
+    const: toshiba,tc358775
+
+  reg:
+    maxItems: 1
+    description: i2c address of the bridge, 0x0f
+
+  vdd-supply:
+    maxItems: 1
+    description:  1.2V LVDS Power Supply
+
+  vddio-supply:
+    maxItems: 1
+    description: 1.8V IO Power Supply
+
+  stby-gpios:
+    maxItems: 1
+    description: Standby pin, Low active
+
+  reset-gpios:
+    maxItems: 1
+    description: Hardware reset, Low active
+
+  ports:
+    type: object
+    description:
+      A node containing input and output port nodes with endpoint definitions
+      as documented in
+      Documentation/devicetree/bindings/media/video-interfaces.txt
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
+        const: 0
+
+      port@0:
+        type: object
+        description: |
+          DSI Input. The remote endpoint phandle should be a
+          reference to a valid mipi_dsi_host device node.
+
+      port@1:
+        type: object
+        description: |
+          Video port for LVDS output (panel or connector).
+
+      port@2:
+        type: object
+        description: |
+          Video port for Dual link LVDS output (panel or connector).
+
+    required:
+      - port@0
+      - port@1
+
+required:
+ - compatible
+ - reg
+ - vdd-supply
+ - vddio-supply
+ - stby-gpios
+ - reset-gpios
+ - ports
+
+examples:
+ - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c@78b8000 {
+        /* On High speed expansion */
+        label = "HS-I2C2";
+        reg = <0x078b8000 0x500>;
+        clock-frequency = <400000>; /* fastmode operation */
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        tc_bridge: bridge@f {
+            compatible = "toshiba,tc358775";
+            reg = <0x0f>;
+
+            vdd-supply = <&pm8916_l2>;
+            vddio-supply = <&pm8916_l6>;
+
+            stby-gpios = <&msmgpio 99 GPIO_ACTIVE_LOW>;
+            reset-gpios = <&msmgpio 72 GPIO_ACTIVE_LOW>;
+
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                port@0 {
+                    reg = <0>;
+                    d2l_in_test: endpoint {
+                        remote-endpoint = <&dsi0_out>;
+                    };
+                };
+
+                port@1 {
+                    reg = <1>;
+                    lvds_out: endpoint {
+                        remote-endpoint = <&panel_in>;
+                    };
+                };
+            };
+        };
+    };
+
+    dsi@1a98000 {
+        reg = <0x1a98000 0x25c>;
+        reg-names = "dsi_ctrl";
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            port@1 {
+                reg = <1>;
+                dsi0_out: endpoint {
+                    remote-endpoint = <&d2l_in_test>;
+                        data-lanes = <0 1 2 3>;
+                };
+             };
+         };
+     };
+
+ - |
+    i2c@78b8000 {
+        /* On High speed expansion */
+        label = "HS-I2C2";
+        reg = <0x078b8000 0x500>;
+        clock-frequency = <400000>; /* fastmode operation */
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        tc_bridge_dual: bridge@f {
+            compatible = "toshiba,tc358775";
+            reg = <0x0f>;
+
+            vdd-supply = <&pm8916_l2>;
+            vddio-supply = <&pm8916_l6>;
+
+            stby-gpios = <&msmgpio 99 GPIO_ACTIVE_LOW>;
+            reset-gpios = <&msmgpio 72 GPIO_ACTIVE_LOW>;
+
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                port@0 {
+                    reg = <0>;
+                    d2l_in_dual: endpoint {
+                        remote-endpoint = <&dsi0_out_dual>;
+                    };
+                };
+
+                port@1 {
+                    reg = <1>;
+                    lvds0_out: endpoint {
+                        remote-endpoint = <&panel_in0>;
+                    };
+                };
+
+                port@2 {
+                    reg = <2>;
+                    lvds1_out: endpoint {
+                        remote-endpoint = <&panel_in1>;
+                    };
+                };
+            };
+        };
+    };
+
+    dsi@1a98000 {
+        reg = <0x1a98000 0x25c>;
+        reg-names = "dsi_ctrl";
+
+        ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            port@1 {
+                reg = <1>;
+                dsi0_out_dual: endpoint {
+                    remote-endpoint = <&d2l_in_dual>;
+                        data-lanes = <0 1 2 3>;
+                };
+             };
+         };
+     };
+...
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 2/2 display/drm/bridge: TC358775 DSI/LVDS driver

---
v1:
Initial version

v2:
* Andrzej Hajda review comments incorporated SPDX identifier
development debug removed
alphabetic order headers
u32 instead of unit32_t
magic numbers to macros for CLRSI and mux registers ignored return value

* Laurent Pinchart review comments incorporated
mdelay to usleep_range
bus_formats added

v3:
* Andrzej Hajda review comments incorporated drm_connector_status removed
u32 rev removed and local variabl is used regulator enable disable with proper orders and delays as per the spec
devm_drm_panel_bridge_add method used instead of panel description modified
dual port implemented

---
 drivers/gpu/drm/bridge/Kconfig    |  10 +
 drivers/gpu/drm/bridge/Makefile   |   1 +
 drivers/gpu/drm/bridge/tc358775.c | 725 ++++++++++++++++++++++++++++++
 3 files changed, 736 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/tc358775.c
drivers/gpu/drm/bridge/Kconfig +10 -0
index 43271c21d3fc..084e9853944a 100644
@@ -181,6 +181,16 @@ config DRM_TOSHIBA_TC358768
 	help
 	  Toshiba TC358768AXBG/TC358778XBG DSI bridge chip driver.
 
+config DRM_TOSHIBA_TC358775
+        tristate "Toshiba TC358775 LVDS bridge"
+        depends on OF
+        select DRM_KMS_HELPER
+        select REGMAP_I2C
+        select DRM_PANEL
+	select DRM_MIPI_DSI
+        ---help---
+          Toshiba TC358775 LVDS bridge chip driver.
+
 config DRM_TI_TFP410
 	tristate "TI TFP410 DVI/HDMI bridge"
 	depends on OF
drivers/gpu/drm/bridge/Makefile +1 -0
index d63d4b7e4347..23c770b3bfe4 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358768) += tc358768.o
+obj-$(CONFIG_DRM_TOSHIBA_TC358775) += tc358775.o
 obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
 obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
 obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
drivers/gpu/drm/bridge/tc358775.c new file +725 -0

725 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v3 2/2] display/drm/bridge: TC358775 DSI/LVDS driver

Thank you for the patch! Perhaps something to improve:

Hi Vinay,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.8-rc1 next-20200618]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Vinay-Simha-BN/dt-binding-Add-DSI-LVDS-TC358775-bridge-bindings/20200618-202234
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1b5044021070efa3259f3e9548dc35d1eb6aa844
config: x86_64-randconfig-r034-20200619 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 487ca07fcc75d52755c9fe2ee05bcb3b6eeeec44)

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
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

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

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/gpu/drm/bridge/tc358775.c:505:5: warning: no previous prototype for function 'tc358775_parse_dt' [-Wmissing-prototypes]

int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)
^
drivers/gpu/drm/bridge/tc358775.c:505:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)
^
static

>> drivers/gpu/drm/bridge/tc358775.c:523:8: warning: variable 'len' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

if (endpoint) {
^~~~~~~~
drivers/gpu/drm/bridge/tc358775.c:536:22: note: uninitialized use occurs here
tc->num_dsi_lanes = len / sizeof(u32);
^~~
drivers/gpu/drm/bridge/tc358775.c:523:4: note: remove the 'if' if its condition is always true
if (endpoint) {
^~~~~~~~~~~~~~
drivers/gpu/drm/bridge/tc358775.c:519:7: warning: variable 'len' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (parent) {
^~~~~~
drivers/gpu/drm/bridge/tc358775.c:536:22: note: uninitialized use occurs here
tc->num_dsi_lanes = len / sizeof(u32);
^~~
drivers/gpu/drm/bridge/tc358775.c:519:3: note: remove the 'if' if its condition is always true
if (parent) {
^~~~~~~~~~~~
drivers/gpu/drm/bridge/tc358775.c:515:6: warning: variable 'len' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (endpoint) {
^~~~~~~~
drivers/gpu/drm/bridge/tc358775.c:536:22: note: uninitialized use occurs here
tc->num_dsi_lanes = len / sizeof(u32);
^~~
drivers/gpu/drm/bridge/tc358775.c:515:2: note: remove the 'if' if its condition is always true
if (endpoint) {
^~~~~~~~~~~~~~
drivers/gpu/drm/bridge/tc358775.c:511:9: note: initialize the variable 'len' to silence this warning
int len;
^
= 0
4 warnings generated.

vim +/tc358775_parse_dt +505 drivers/gpu/drm/bridge/tc358775.c

504

 > 505	int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)
   506	{
   507		struct device_node *endpoint;
   508		struct device_node *parent;
   509		struct device_node *remote;
   510		struct property *prop;
   511		int len;
   512	
   513		endpoint = of_graph_get_endpoint_by_regs(tc->dev->of_node,
   514							 TC358775_DSI_IN, -1);
   515		if (endpoint) {
   516			/* dsi0_out node */
   517			parent = of_graph_get_remote_port_parent(endpoint);
   518			of_node_put(endpoint);
   519			if (parent) {
   520				/* dsi0 port 1 */
   521				endpoint = of_graph_get_endpoint_by_regs(parent, 1, -1);
   522				of_node_put(parent);
 > 523				if (endpoint) {

524 prop = of_find_property(endpoint, "data-lanes",
525 &len);
526 of_node_put(endpoint);
527 if (!prop) {
528 dev_err(tc->dev,
529 "failed to find data lane\n");
530 return -EPROBE_DEFER;
531 }
532 }
533 }
534 }
535
536 tc->num_dsi_lanes = len / sizeof(u32);
537
538 if (tc->num_dsi_lanes < 1 || tc->num_dsi_lanes > 4)
539 return -EINVAL;
540
541 tc->host_node = of_graph_get_remote_node(np, 0, 0);
542 if (!tc->host_node)
543 return -ENODEV;
544
545 of_node_put(tc->host_node);
546
547 endpoint = of_graph_get_endpoint_by_regs(tc->dev->of_node,
548 TC358775_LVDS_OUT1, -1);
549 if (endpoint) {
550 remote = of_graph_get_remote_port_parent(endpoint);
551 of_node_put(endpoint);
552
553 if (remote) {
554 if (of_device_is_available(remote))
555 tc->dual_link = true;
556 of_node_put(remote);
557 }
558 }
559
560 dev_dbg(tc->dev, "no.of dsi lanes: %d\n", tc->num_dsi_lanes);
561 dev_dbg(tc->dev, "operating in %s-link mode\n",
562 tc->dual_link ? "dual" : "single");
563
564 return 0;
565 }
566

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

#3 lore raw

Re: [PATCH v3 2/2] display/drm/bridge: TC358775 DSI/LVDS driver

In reply to Vinay Simha BN
Thank you for the patch! Perhaps something to improve:

Hi Vinay,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.8-rc1 next-20200618]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Vinay-Simha-BN/dt-binding-Add-DSI-LVDS-TC358775-bridge-bindings/20200618-202234
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1b5044021070efa3259f3e9548dc35d1eb6aa844
config: nds32-randconfig-r002-20200619 (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.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
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32

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

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/gpu/drm/bridge/tc358775.c:505:5: warning: no previous prototype for 'tc358775_parse_dt' [-Wmissing-prototypes]

505 | int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)
| ^~~~~~~~~~~~~~~~~

vim +/tc358775_parse_dt +505 drivers/gpu/drm/bridge/tc358775.c

504

 > 505	int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)

506 {
507 struct device_node *endpoint;
508 struct device_node *parent;
509 struct device_node *remote;
510 struct property *prop;
511 int len;
512
513 endpoint = of_graph_get_endpoint_by_regs(tc->dev->of_node,
514 TC358775_DSI_IN, -1);
515 if (endpoint) {
516 /* dsi0_out node */
517 parent = of_graph_get_remote_port_parent(endpoint);
518 of_node_put(endpoint);
519 if (parent) {
520 /* dsi0 port 1 */
521 endpoint = of_graph_get_endpoint_by_regs(parent, 1, -1);
522 of_node_put(parent);
523 if (endpoint) {
524 prop = of_find_property(endpoint, "data-lanes",
525 &len);
526 of_node_put(endpoint);
527 if (!prop) {
528 dev_err(tc->dev,
529 "failed to find data lane\n");
530 return -EPROBE_DEFER;
531 }
532 }
533 }
534 }
535
536 tc->num_dsi_lanes = len / sizeof(u32);
537
538 if (tc->num_dsi_lanes < 1 || tc->num_dsi_lanes > 4)
539 return -EINVAL;
540
541 tc->host_node = of_graph_get_remote_node(np, 0, 0);
542 if (!tc->host_node)
543 return -ENODEV;
544
545 of_node_put(tc->host_node);
546
547 endpoint = of_graph_get_endpoint_by_regs(tc->dev->of_node,
548 TC358775_LVDS_OUT1, -1);
549 if (endpoint) {
550 remote = of_graph_get_remote_port_parent(endpoint);
551 of_node_put(endpoint);
552
553 if (remote) {
554 if (of_device_is_available(remote))
555 tc->dual_link = true;
556 of_node_put(remote);
557 }
558 }
559
560 dev_dbg(tc->dev, "no.of dsi lanes: %d\n", tc->num_dsi_lanes);
561 dev_dbg(tc->dev, "operating in %s-link mode\n",
562 tc->dual_link ? "dual" : "single");
563
564 return 0;
565 }
566

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

#4 lore raw

[RFC PATCH] display/drm/bridge: tc358775_parse_dt() can be static

In reply to Vinay Simha BN
Signed-off-by: kernel test robot <[email protected]>
---
 tc358775.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/tc358775.c +1 -1
index 87af3271b63521..88a45e86eae334 100644
@@ -502,7 +502,7 @@ static int tc_mode_valid(struct drm_bridge *bridge,
 	return MODE_OK;
 }
 
-int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)
+static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)
 {
 	struct device_node *endpoint;
 	struct device_node *parent;
#5 lore raw

Re: [PATCH v3 2/2] display/drm/bridge: TC358775 DSI/LVDS driver

In reply to Vinay Simha BN

Hi Vinay.

Quoted 13 lines
drivers/gpu/drm/bridge/tc358775.c new file +13 -0
+
+static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	struct device *dev = &client->dev;
+	struct drm_panel *panel;
+	struct tc_data *tc;
+	int ret;
+
+	tc = devm_kzalloc(dev, sizeof(*tc), GFP_KERNEL);
+	if (!tc)
+		return -ENOMEM;
+
+	tc->dev = dev;

drivers/gpu/drm/bridge/tc358775.c line 644

Quoted 10 lines
drivers/gpu/drm/bridge/tc358775.c new file +10 -0
+	tc->i2c = client;
+
+	ret = drm_of_find_panel_or_bridge(dev->of_node, TC358775_LVDS_OUT0,
+					  0, &panel, NULL);
+	if (ret < 0)
+		return ret;
+	if (!panel)
+		return -ENODEV;
+
+	panel->connector_type = DRM_MODE_CONNECTOR_LVDS;

The panel is responsible for specifying the connector_type. It is wrong to let users of panel set it.

Fix the panel and not the bridge driver.

Quoted 36 lines
drivers/gpu/drm/bridge/tc358775.c new file +36 -0
+
+	tc->panel_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (IS_ERR(tc->panel_bridge))
+		return PTR_ERR(tc->panel_bridge);
+
+	ret = tc358775_parse_dt(dev->of_node, tc);
+	if (ret)
+		return ret;
+
+	tc->vddio = devm_regulator_get(dev, "vddio-supply");
+	if (IS_ERR(tc->vddio)) {
+		ret = PTR_ERR(tc->vddio);
+		dev_err(dev, "vddio-supply not found\n");
+		return ret;
+	}
+
+	tc->vdd = devm_regulator_get(dev, "vdd-supply");
+	if (IS_ERR(tc->vdd)) {
+		ret = PTR_ERR(tc->vddio);
+		dev_err(dev, "vdd-supply not found\n");
+		return ret;
+	}
+
+	tc->stby_gpio = devm_gpiod_get(dev, "stby", GPIOD_OUT_HIGH);
+	if (IS_ERR(tc->stby_gpio)) {
+		ret = PTR_ERR(tc->stby_gpio);
+		dev_err(dev, "cannot get stby-gpio %d\n", ret);
+		return ret;
+	}
+
+	tc->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(tc->reset_gpio)) {
+		ret = PTR_ERR(tc->reset_gpio);
+		dev_err(dev, "cannot get reset-gpios %d\n", ret);
+		return ret;
+	}

drivers/gpu/drm/bridge/tc358775.c line 690

Quoted 10 lines
drivers/gpu/drm/bridge/tc358775.c new file +10 -0
+
+	tc->bridge.funcs = &tc_bridge_funcs;
+	tc->bridge.of_node = dev->of_node;
+	drm_bridge_add(&tc->bridge);
+
+	i2c_set_clientdata(client, tc);
+
+	return 0;
+}
+

Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel