]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/msm/dsi: Don't get DSI index from DT
authorArchit Taneja <architt@codeaurora.org>
Thu, 23 Jun 2016 09:56:04 +0000 (15:26 +0530)
committerRob Clark <robdclark@gmail.com>
Sat, 16 Jul 2016 14:09:02 +0000 (10:09 -0400)
The DSI host and PHY driver currently expects the DT bindings to provide
custom properties "qcom,dsi-host-index" and "qcom,dsi-phy-index" so that
the driver can identify which DSI instance it is.

The binding isn't acceptable, but the driver still needs to figure out
what its instance id. This is now done by storing the mmio starting
addresses for each DSI instance in every SoC version in the driver. The
driver then identifies the index number by trying to match the stored
address with comparing the resource start address we get from DT.

We don't have compatible strings for DSI PHY on each SoC, but only the
DSI PHY type. We only support one SoC version for each PHY type, so we
get away doing the same thing above for the PHY driver. We can revisit
this when we support two SoCs with the same DSI PHY.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/dsi/dsi_cfg.c
drivers/gpu/drm/msm/dsi/dsi_cfg.h
drivers/gpu/drm/msm/dsi/dsi_host.c
drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c
drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c

index 93c1ee094eac867074c3da9be5b38970703c657f..63436d8ee470ea1ca98728ac7707d8ee141ecb9c 100644 (file)
@@ -29,6 +29,8 @@ static const struct msm_dsi_config apq8064_dsi_cfg = {
        },
        .bus_clk_names = dsi_v2_bus_clk_names,
        .num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names),
+       .io_start = { 0x4700000, 0x5800000 },
+       .num_dsi = 2,
 };
 
 static const char * const dsi_6g_bus_clk_names[] = {
@@ -48,6 +50,8 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
        },
        .bus_clk_names = dsi_6g_bus_clk_names,
        .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
+       .io_start = { 0xfd922800, 0xfd922b00 },
+       .num_dsi = 2,
 };
 
 static const char * const dsi_8916_bus_clk_names[] = {
@@ -66,6 +70,8 @@ static const struct msm_dsi_config msm8916_dsi_cfg = {
        },
        .bus_clk_names = dsi_8916_bus_clk_names,
        .num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
+       .io_start = { 0x1a98000 },
+       .num_dsi = 1,
 };
 
 static const struct msm_dsi_config msm8994_dsi_cfg = {
@@ -84,6 +90,8 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
        },
        .bus_clk_names = dsi_6g_bus_clk_names,
        .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
+       .io_start = { 0xfd998000, 0xfd9a0000 },
+       .num_dsi = 2,
 };
 
 static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
index a68c836744a3d1f223447905b380b5299d5f4d1d..eeacc323249481c14fc75d477824420fdd56637e 100644 (file)
@@ -34,6 +34,8 @@ struct msm_dsi_config {
        struct dsi_reg_config reg_cfg;
        const char * const *bus_clk_names;
        const int num_bus_clks;
+       const resource_size_t io_start[DSI_MAX];
+       const int num_dsi;
 };
 
 struct msm_dsi_cfg_handler {
index e6a8cd1b6462e3a506be3758bbfb6ec870a774b3..80d8594c68ba6ecd54c1db96ca622a341cfee735 100644 (file)
@@ -1605,13 +1605,6 @@ static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
        struct device_node *endpoint, *device_node;
        int ret;
 
-       ret = of_property_read_u32(np, "qcom,dsi-host-index", &msm_host->id);
-       if (ret) {
-               dev_err(dev, "%s: host index not specified, ret=%d\n",
-                       __func__, ret);
-               return ret;
-       }
-
        /*
         * Get the endpoint of the output port of the DSI host. In our case,
         * this is mapped to port number with reg = 1. Don't return an error if
@@ -1659,6 +1652,25 @@ err:
        return ret;
 }
 
+static int dsi_host_get_id(struct msm_dsi_host *msm_host)
+{
+       struct platform_device *pdev = msm_host->pdev;
+       const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg;
+       struct resource *res;
+       int i;
+
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_ctrl");
+       if (!res)
+               return -EINVAL;
+
+       for (i = 0; i < cfg->num_dsi; i++) {
+               if (cfg->io_start[i] == res->start)
+                       return i;
+       }
+
+       return -EINVAL;
+}
+
 int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 {
        struct msm_dsi_host *msm_host = NULL;
@@ -1695,6 +1707,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
                goto fail;
        }
 
+       msm_host->id = dsi_host_get_id(msm_host);
+       if (msm_host->id < 0) {
+               ret = msm_host->id;
+               pr_err("%s: unable to identify DSI host index\n", __func__);
+               goto fail;
+       }
+
        /* fixup base address by io offset */
        msm_host->ctrl_base += msm_host->cfg_hnd->cfg->io_offset;
 
index e2f42d8ea29412e415577f33367d9494bd726ab0..f39386ed75e47d69827d1f62d6f20acecc9e7a75 100644 (file)
@@ -271,6 +271,30 @@ static const struct of_device_id dsi_phy_dt_match[] = {
        {}
 };
 
+/*
+ * Currently, we only support one SoC for each PHY type. When we have multiple
+ * SoCs for the same PHY, we can try to make the index searching a bit more
+ * clever.
+ */
+static int dsi_phy_get_id(struct msm_dsi_phy *phy)
+{
+       struct platform_device *pdev = phy->pdev;
+       const struct msm_dsi_phy_cfg *cfg = phy->cfg;
+       struct resource *res;
+       int i;
+
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_phy");
+       if (!res)
+               return -EINVAL;
+
+       for (i = 0; i < cfg->num_dsi_phy; i++) {
+               if (cfg->io_start[i] == res->start)
+                       return i;
+       }
+
+       return -EINVAL;
+}
+
 static int dsi_phy_driver_probe(struct platform_device *pdev)
 {
        struct msm_dsi_phy *phy;
@@ -289,10 +313,10 @@ static int dsi_phy_driver_probe(struct platform_device *pdev)
        phy->cfg = match->data;
        phy->pdev = pdev;
 
-       ret = of_property_read_u32(dev->of_node,
-                               "qcom,dsi-phy-index", &phy->id);
-       if (ret) {
-               dev_err(dev, "%s: PHY index not specified, %d\n",
+       phy->id = dsi_phy_get_id(phy);
+       if (phy->id < 0) {
+               ret = phy->id;
+               dev_err(dev, "%s: couldn't identify PHY index, %d\n",
                        __func__, ret);
                goto fail;
        }
index 0d54ed00386dee2a1e58e2237c3d8384d33e65a6..f24a85439b942e08b051f018379873fad5581261 100644 (file)
@@ -38,6 +38,8 @@ struct msm_dsi_phy_cfg {
         * Fill default H/W values in illegal cells, eg. cell {0, 1}.
         */
        bool src_pll_truthtable[DSI_MAX][DSI_MAX];
+       const resource_size_t io_start[DSI_MAX];
+       const int num_dsi_phy;
 };
 
 extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
index f4bc11af849a5ea23272c7f5e64ec58f70900815..c757e2070cac7f104b0e1aaf5037bf6c2d95e73c 100644 (file)
@@ -145,6 +145,8 @@ const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs = {
        .ops = {
                .enable = dsi_20nm_phy_enable,
                .disable = dsi_20nm_phy_disable,
-       }
+       },
+       .io_start = { 0xfd998300, 0xfd9a0300 },
+       .num_dsi_phy = 2,
 };
 
index 96d1852af41868a79d0eceeffa66e44eb34e9f5f..63d7fba31380e4091487f7d0e4ecfdaf5910ce38 100644 (file)
@@ -145,6 +145,8 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs = {
                .enable = dsi_28nm_phy_enable,
                .disable = dsi_28nm_phy_disable,
        },
+       .io_start = { 0xfd922b00, 0xfd923100 },
+       .num_dsi_phy = 2,
 };
 
 const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs = {
@@ -160,5 +162,7 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs = {
                .enable = dsi_28nm_phy_enable,
                .disable = dsi_28nm_phy_disable,
        },
+       .io_start = { 0x1a98500 },
+       .num_dsi_phy = 1,
 };
 
index 213355a3e767a54d19498679cae2bb908992d7da..7bdb9de549680d3a11f704ec242f0fbaf0da6273 100644 (file)
@@ -192,4 +192,6 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs = {
                .enable = dsi_28nm_phy_enable,
                .disable = dsi_28nm_phy_disable,
        },
+       .io_start = { 0x4700300, 0x5800300 },
+       .num_dsi_phy = 2,
 };