diff options
| author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2013-05-03 06:42:24 -0400 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2013-06-17 07:00:44 -0400 |
| commit | b2541c40aad3024cd6187f4f93af899654127ccc (patch) | |
| tree | 8e25efbf8a37a8b359e4cdcc105e2bc1b795346f | |
| parent | 51930bba8e9a19401247a4147daa828851d400ce (diff) | |
OMAPDSS: DSI: cleanup regulator init
Separate the regulator initialization code to its own function, removing
duplicate code.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
| -rw-r--r-- | drivers/video/omap2/dss/dsi.c | 93 |
1 files changed, 34 insertions, 59 deletions
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index bdddd0d177b6..7d9e5ccb41e1 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c | |||
| @@ -1114,6 +1114,30 @@ void dsi_runtime_put(struct platform_device *dsidev) | |||
| 1114 | WARN_ON(r < 0 && r != -ENOSYS); | 1114 | WARN_ON(r < 0 && r != -ENOSYS); |
| 1115 | } | 1115 | } |
| 1116 | 1116 | ||
| 1117 | static int dsi_regulator_init(struct platform_device *dsidev) | ||
| 1118 | { | ||
| 1119 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); | ||
| 1120 | struct regulator *vdds_dsi; | ||
| 1121 | |||
| 1122 | if (dsi->vdds_dsi_reg != NULL) | ||
| 1123 | return 0; | ||
| 1124 | |||
| 1125 | vdds_dsi = devm_regulator_get(&dsi->pdev->dev, "vdds_dsi"); | ||
| 1126 | |||
| 1127 | /* DT HACK: try VCXIO to make omapdss work for o4 sdp/panda */ | ||
| 1128 | if (IS_ERR(vdds_dsi)) | ||
| 1129 | vdds_dsi = devm_regulator_get(&dsi->pdev->dev, "VCXIO"); | ||
| 1130 | |||
| 1131 | if (IS_ERR(vdds_dsi)) { | ||
| 1132 | DSSERR("can't get VDDS_DSI regulator\n"); | ||
| 1133 | return PTR_ERR(vdds_dsi); | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | dsi->vdds_dsi_reg = vdds_dsi; | ||
| 1137 | |||
| 1138 | return 0; | ||
| 1139 | } | ||
| 1140 | |||
| 1117 | /* source clock for DSI PLL. this could also be PCLKFREE */ | 1141 | /* source clock for DSI PLL. this could also be PCLKFREE */ |
| 1118 | static inline void dsi_enable_pll_clock(struct platform_device *dsidev, | 1142 | static inline void dsi_enable_pll_clock(struct platform_device *dsidev, |
| 1119 | bool enable) | 1143 | bool enable) |
| @@ -1592,22 +1616,9 @@ int dsi_pll_init(struct platform_device *dsidev, bool enable_hsclk, | |||
| 1592 | */ | 1616 | */ |
| 1593 | enable_hsclk = enable_hsdiv = true; | 1617 | enable_hsclk = enable_hsdiv = true; |
| 1594 | 1618 | ||
| 1595 | if (dsi->vdds_dsi_reg == NULL) { | 1619 | r = dsi_regulator_init(dsidev); |
| 1596 | struct regulator *vdds_dsi; | 1620 | if (r) |
| 1597 | 1621 | return r; | |
| 1598 | vdds_dsi = regulator_get(&dsi->pdev->dev, "vdds_dsi"); | ||
| 1599 | |||
| 1600 | /* DT HACK: try VCXIO to make omapdss work for o4 sdp/panda */ | ||
| 1601 | if (IS_ERR(vdds_dsi)) | ||
| 1602 | vdds_dsi = regulator_get(&dsi->pdev->dev, "VCXIO"); | ||
| 1603 | |||
| 1604 | if (IS_ERR(vdds_dsi)) { | ||
| 1605 | DSSERR("can't get VDDS_DSI regulator\n"); | ||
| 1606 | return PTR_ERR(vdds_dsi); | ||
| 1607 | } | ||
| 1608 | |||
| 1609 | dsi->vdds_dsi_reg = vdds_dsi; | ||
| 1610 | } | ||
| 1611 | 1622 | ||
| 1612 | dsi_enable_pll_clock(dsidev, 1); | 1623 | dsi_enable_pll_clock(dsidev, 1); |
| 1613 | /* | 1624 | /* |
| @@ -5225,34 +5236,6 @@ static enum omap_channel dsi_get_channel(int module_id) | |||
| 5225 | } | 5236 | } |
| 5226 | } | 5237 | } |
| 5227 | 5238 | ||
| 5228 | static int dsi_init_display(struct omap_dss_device *dssdev) | ||
| 5229 | { | ||
| 5230 | struct platform_device *dsidev = | ||
| 5231 | dsi_get_dsidev_from_id(dssdev->phy.dsi.module); | ||
| 5232 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); | ||
| 5233 | |||
| 5234 | DSSDBG("DSI init\n"); | ||
| 5235 | |||
| 5236 | if (dsi->vdds_dsi_reg == NULL) { | ||
| 5237 | struct regulator *vdds_dsi; | ||
| 5238 | |||
| 5239 | vdds_dsi = regulator_get(&dsi->pdev->dev, "vdds_dsi"); | ||
| 5240 | |||
| 5241 | /* DT HACK: try VCXIO to make omapdss work for o4 sdp/panda */ | ||
| 5242 | if (IS_ERR(vdds_dsi)) | ||
| 5243 | vdds_dsi = regulator_get(&dsi->pdev->dev, "VCXIO"); | ||
| 5244 | |||
| 5245 | if (IS_ERR(vdds_dsi)) { | ||
| 5246 | DSSERR("can't get VDDS_DSI regulator\n"); | ||
| 5247 | return PTR_ERR(vdds_dsi); | ||
| 5248 | } | ||
| 5249 | |||
| 5250 | dsi->vdds_dsi_reg = vdds_dsi; | ||
| 5251 | } | ||
| 5252 | |||
| 5253 | return 0; | ||
| 5254 | } | ||
| 5255 | |||
| 5256 | int omap_dsi_request_vc(struct omap_dss_device *dssdev, int *channel) | 5239 | int omap_dsi_request_vc(struct omap_dss_device *dssdev, int *channel) |
| 5257 | { | 5240 | { |
| 5258 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); | 5241 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| @@ -5410,19 +5393,16 @@ static int dsi_probe_pdata(struct platform_device *dsidev) | |||
| 5410 | if (!plat_dssdev) | 5393 | if (!plat_dssdev) |
| 5411 | return 0; | 5394 | return 0; |
| 5412 | 5395 | ||
| 5396 | r = dsi_regulator_init(dsidev); | ||
| 5397 | if (r) | ||
| 5398 | return r; | ||
| 5399 | |||
| 5413 | dssdev = dss_alloc_and_init_device(&dsidev->dev); | 5400 | dssdev = dss_alloc_and_init_device(&dsidev->dev); |
| 5414 | if (!dssdev) | 5401 | if (!dssdev) |
| 5415 | return -ENOMEM; | 5402 | return -ENOMEM; |
| 5416 | 5403 | ||
| 5417 | dss_copy_device_pdata(dssdev, plat_dssdev); | 5404 | dss_copy_device_pdata(dssdev, plat_dssdev); |
| 5418 | 5405 | ||
| 5419 | r = dsi_init_display(dssdev); | ||
| 5420 | if (r) { | ||
| 5421 | DSSERR("device %s init failed: %d\n", dssdev->name, r); | ||
| 5422 | dss_put_device(dssdev); | ||
| 5423 | return r; | ||
| 5424 | } | ||
| 5425 | |||
| 5426 | r = omapdss_output_set_device(&dsi->output, dssdev); | 5406 | r = omapdss_output_set_device(&dsi->output, dssdev); |
| 5427 | if (r) { | 5407 | if (r) { |
| 5428 | DSSERR("failed to connect output to new device: %s\n", | 5408 | DSSERR("failed to connect output to new device: %s\n", |
| @@ -5604,14 +5584,9 @@ static int __exit omap_dsihw_remove(struct platform_device *dsidev) | |||
| 5604 | 5584 | ||
| 5605 | pm_runtime_disable(&dsidev->dev); | 5585 | pm_runtime_disable(&dsidev->dev); |
| 5606 | 5586 | ||
| 5607 | if (dsi->vdds_dsi_reg != NULL) { | 5587 | if (dsi->vdds_dsi_reg != NULL && dsi->vdds_dsi_enabled) { |
| 5608 | if (dsi->vdds_dsi_enabled) { | 5588 | regulator_disable(dsi->vdds_dsi_reg); |
| 5609 | regulator_disable(dsi->vdds_dsi_reg); | 5589 | dsi->vdds_dsi_enabled = false; |
| 5610 | dsi->vdds_dsi_enabled = false; | ||
| 5611 | } | ||
| 5612 | |||
| 5613 | regulator_put(dsi->vdds_dsi_reg); | ||
| 5614 | dsi->vdds_dsi_reg = NULL; | ||
| 5615 | } | 5590 | } |
| 5616 | 5591 | ||
| 5617 | return 0; | 5592 | return 0; |
