Re: [PATCH v10 3/4] drm/lsdc: add drm driver for loongson display controller

From: Sui Jingfeng
Date: Wed Feb 23 2022 - 10:14:29 EST



On 2022/2/23 22:39, Maxime Ripard wrote:
On Tue, Feb 22, 2022 at 10:46:35PM +0800, Sui Jingfeng wrote:
On 2022/2/22 16:27, Maxime Ripard wrote:
+ if (!of_device_is_available(output)) {
+ of_node_put(output);
+ drm_info(ddev, "connector%d is not available\n", index);
+ return NULL;
+ }
+
+ disp_tims_np = of_get_child_by_name(output, "display-timings");
+ if (disp_tims_np) {
+ lsdc_get_display_timings_from_dtb(output, &lconn->disp_tim);
+ lconn->has_disp_tim = true;
+ of_node_put(disp_tims_np);
+ drm_info(ddev, "Found display timings provided by connector%d\n", index);
+ }
+
+ connector_type = lsdc_get_connector_type(ddev, output, index);
+
+ if (output) {
+ of_node_put(output);
+ output = NULL;
+ }
+
+DT_SKIPED:
+
+ /* Only create the i2c channel if display timing is not provided */
+ if (!lconn->has_disp_tim) {
+ const struct lsdc_chip_desc * const desc = ldev->desc;
+
+ if (desc->have_builtin_i2c)
+ lconn->ddc = lsdc_create_i2c_chan(ddev, index);
+ else
+ lconn->ddc = lsdc_get_i2c_adapter(ddev, index);
This looks weird: the connector bindings have a property to store the
i2c controller connected to the DDC lines, so you should use that
instead.

This is not  weird,  ast, mgag200, hibmc do the same thing.
And none of them have DT support.

Maxime

You are wrong, ast driver have dt support. See ast_detect_config_mode() in drm/ast/ast_main.c

static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev)
{
    struct device_node *np = dev->dev->of_node;
    struct ast_private *ast = to_ast_private(dev);
    struct pci_dev *pdev = to_pci_dev(dev->dev);
    uint32_t data, jregd0, jregd1;

    /* Defaults */
    ast->config_mode = ast_use_defaults;
    *scu_rev = 0xffffffff;

    /* Check if we have device-tree properties */
    if (np && !of_property_read_u32(np, "aspeed,scu-revision-id",
                    scu_rev)) {
        /* We do, disable P2A access */
        ast->config_mode = ast_use_dt;
        drm_info(dev, "Using device-tree for configuration\n");
        return;
    }

 ....

}