aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorArchit Taneja <architt@codeaurora.org>2016-06-23 05:56:04 -0400
committerRob Clark <robdclark@gmail.com>2016-07-16 10:09:02 -0400
commit32280d66fd44de231b1d1a015e4ef41cac2d295c (patch)
treebb1826ef885f53d7a60273fedf3ba3f41ce94f55 /drivers/gpu
parent96a611b54f7f0564886d64c43485402fa2530bf4 (diff)
drm/msm/dsi: Don't get DSI index from DT
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>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_cfg.c8
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_cfg.h2
-rw-r--r--drivers/gpu/drm/msm/dsi/dsi_host.c33
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy.c32
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy.h2
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c4
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c4
-rw-r--r--drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c2
8 files changed, 75 insertions, 12 deletions
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 93c1ee094eac..63436d8ee470 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -29,6 +29,8 @@ static const struct msm_dsi_config apq8064_dsi_cfg = {
29 }, 29 },
30 .bus_clk_names = dsi_v2_bus_clk_names, 30 .bus_clk_names = dsi_v2_bus_clk_names,
31 .num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names), 31 .num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names),
32 .io_start = { 0x4700000, 0x5800000 },
33 .num_dsi = 2,
32}; 34};
33 35
34static const char * const dsi_6g_bus_clk_names[] = { 36static const char * const dsi_6g_bus_clk_names[] = {
@@ -48,6 +50,8 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
48 }, 50 },
49 .bus_clk_names = dsi_6g_bus_clk_names, 51 .bus_clk_names = dsi_6g_bus_clk_names,
50 .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names), 52 .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
53 .io_start = { 0xfd922800, 0xfd922b00 },
54 .num_dsi = 2,
51}; 55};
52 56
53static const char * const dsi_8916_bus_clk_names[] = { 57static const char * const dsi_8916_bus_clk_names[] = {
@@ -66,6 +70,8 @@ static const struct msm_dsi_config msm8916_dsi_cfg = {
66 }, 70 },
67 .bus_clk_names = dsi_8916_bus_clk_names, 71 .bus_clk_names = dsi_8916_bus_clk_names,
68 .num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names), 72 .num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
73 .io_start = { 0x1a98000 },
74 .num_dsi = 1,
69}; 75};
70 76
71static const struct msm_dsi_config msm8994_dsi_cfg = { 77static const struct msm_dsi_config msm8994_dsi_cfg = {
@@ -84,6 +90,8 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
84 }, 90 },
85 .bus_clk_names = dsi_6g_bus_clk_names, 91 .bus_clk_names = dsi_6g_bus_clk_names,
86 .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names), 92 .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
93 .io_start = { 0xfd998000, 0xfd9a0000 },
94 .num_dsi = 2,
87}; 95};
88 96
89static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = { 97static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
index a68c836744a3..eeacc3232494 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
@@ -34,6 +34,8 @@ struct msm_dsi_config {
34 struct dsi_reg_config reg_cfg; 34 struct dsi_reg_config reg_cfg;
35 const char * const *bus_clk_names; 35 const char * const *bus_clk_names;
36 const int num_bus_clks; 36 const int num_bus_clks;
37 const resource_size_t io_start[DSI_MAX];
38 const int num_dsi;
37}; 39};
38 40
39struct msm_dsi_cfg_handler { 41struct msm_dsi_cfg_handler {
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index e6a8cd1b6462..80d8594c68ba 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1605,13 +1605,6 @@ static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
1605 struct device_node *endpoint, *device_node; 1605 struct device_node *endpoint, *device_node;
1606 int ret; 1606 int ret;
1607 1607
1608 ret = of_property_read_u32(np, "qcom,dsi-host-index", &msm_host->id);
1609 if (ret) {
1610 dev_err(dev, "%s: host index not specified, ret=%d\n",
1611 __func__, ret);
1612 return ret;
1613 }
1614
1615 /* 1608 /*
1616 * Get the endpoint of the output port of the DSI host. In our case, 1609 * Get the endpoint of the output port of the DSI host. In our case,
1617 * this is mapped to port number with reg = 1. Don't return an error if 1610 * this is mapped to port number with reg = 1. Don't return an error if
@@ -1659,6 +1652,25 @@ err:
1659 return ret; 1652 return ret;
1660} 1653}
1661 1654
1655static int dsi_host_get_id(struct msm_dsi_host *msm_host)
1656{
1657 struct platform_device *pdev = msm_host->pdev;
1658 const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg;
1659 struct resource *res;
1660 int i;
1661
1662 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_ctrl");
1663 if (!res)
1664 return -EINVAL;
1665
1666 for (i = 0; i < cfg->num_dsi; i++) {
1667 if (cfg->io_start[i] == res->start)
1668 return i;
1669 }
1670
1671 return -EINVAL;
1672}
1673
1662int msm_dsi_host_init(struct msm_dsi *msm_dsi) 1674int msm_dsi_host_init(struct msm_dsi *msm_dsi)
1663{ 1675{
1664 struct msm_dsi_host *msm_host = NULL; 1676 struct msm_dsi_host *msm_host = NULL;
@@ -1695,6 +1707,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
1695 goto fail; 1707 goto fail;
1696 } 1708 }
1697 1709
1710 msm_host->id = dsi_host_get_id(msm_host);
1711 if (msm_host->id < 0) {
1712 ret = msm_host->id;
1713 pr_err("%s: unable to identify DSI host index\n", __func__);
1714 goto fail;
1715 }
1716
1698 /* fixup base address by io offset */ 1717 /* fixup base address by io offset */
1699 msm_host->ctrl_base += msm_host->cfg_hnd->cfg->io_offset; 1718 msm_host->ctrl_base += msm_host->cfg_hnd->cfg->io_offset;
1700 1719
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index e2f42d8ea294..f39386ed75e4 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -271,6 +271,30 @@ static const struct of_device_id dsi_phy_dt_match[] = {
271 {} 271 {}
272}; 272};
273 273
274/*
275 * Currently, we only support one SoC for each PHY type. When we have multiple
276 * SoCs for the same PHY, we can try to make the index searching a bit more
277 * clever.
278 */
279static int dsi_phy_get_id(struct msm_dsi_phy *phy)
280{
281 struct platform_device *pdev = phy->pdev;
282 const struct msm_dsi_phy_cfg *cfg = phy->cfg;
283 struct resource *res;
284 int i;
285
286 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_phy");
287 if (!res)
288 return -EINVAL;
289
290 for (i = 0; i < cfg->num_dsi_phy; i++) {
291 if (cfg->io_start[i] == res->start)
292 return i;
293 }
294
295 return -EINVAL;
296}
297
274static int dsi_phy_driver_probe(struct platform_device *pdev) 298static int dsi_phy_driver_probe(struct platform_device *pdev)
275{ 299{
276 struct msm_dsi_phy *phy; 300 struct msm_dsi_phy *phy;
@@ -289,10 +313,10 @@ static int dsi_phy_driver_probe(struct platform_device *pdev)
289 phy->cfg = match->data; 313 phy->cfg = match->data;
290 phy->pdev = pdev; 314 phy->pdev = pdev;
291 315
292 ret = of_property_read_u32(dev->of_node, 316 phy->id = dsi_phy_get_id(phy);
293 "qcom,dsi-phy-index", &phy->id); 317 if (phy->id < 0) {
294 if (ret) { 318 ret = phy->id;
295 dev_err(dev, "%s: PHY index not specified, %d\n", 319 dev_err(dev, "%s: couldn't identify PHY index, %d\n",
296 __func__, ret); 320 __func__, ret);
297 goto fail; 321 goto fail;
298 } 322 }
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
index 0d54ed00386d..f24a85439b94 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
@@ -38,6 +38,8 @@ struct msm_dsi_phy_cfg {
38 * Fill default H/W values in illegal cells, eg. cell {0, 1}. 38 * Fill default H/W values in illegal cells, eg. cell {0, 1}.
39 */ 39 */
40 bool src_pll_truthtable[DSI_MAX][DSI_MAX]; 40 bool src_pll_truthtable[DSI_MAX][DSI_MAX];
41 const resource_size_t io_start[DSI_MAX];
42 const int num_dsi_phy;
41}; 43};
42 44
43extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs; 45extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c
index f4bc11af849a..c757e2070cac 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c
@@ -145,6 +145,8 @@ const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs = {
145 .ops = { 145 .ops = {
146 .enable = dsi_20nm_phy_enable, 146 .enable = dsi_20nm_phy_enable,
147 .disable = dsi_20nm_phy_disable, 147 .disable = dsi_20nm_phy_disable,
148 } 148 },
149 .io_start = { 0xfd998300, 0xfd9a0300 },
150 .num_dsi_phy = 2,
149}; 151};
150 152
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
index 96d1852af418..63d7fba31380 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
@@ -145,6 +145,8 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs = {
145 .enable = dsi_28nm_phy_enable, 145 .enable = dsi_28nm_phy_enable,
146 .disable = dsi_28nm_phy_disable, 146 .disable = dsi_28nm_phy_disable,
147 }, 147 },
148 .io_start = { 0xfd922b00, 0xfd923100 },
149 .num_dsi_phy = 2,
148}; 150};
149 151
150const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs = { 152const 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 = {
160 .enable = dsi_28nm_phy_enable, 162 .enable = dsi_28nm_phy_enable,
161 .disable = dsi_28nm_phy_disable, 163 .disable = dsi_28nm_phy_disable,
162 }, 164 },
165 .io_start = { 0x1a98500 },
166 .num_dsi_phy = 1,
163}; 167};
164 168
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
index 213355a3e767..7bdb9de54968 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
@@ -192,4 +192,6 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs = {
192 .enable = dsi_28nm_phy_enable, 192 .enable = dsi_28nm_phy_enable,
193 .disable = dsi_28nm_phy_disable, 193 .disable = dsi_28nm_phy_disable,
194 }, 194 },
195 .io_start = { 0x4700300, 0x5800300 },
196 .num_dsi_phy = 2,
195}; 197};