Commit 0ff03fd1 authored by Hyungwon Hwang's avatar Hyungwon Hwang Committed by Inki Dae

drm/exynos: dsi: make use of array for clock access

This patch make the driver to use an array for clock access. The number
of clocks are different from the existing MIPI DSI driver and Exynos5433
MIPI DSI driver. So this patch is needed before adding support for
Exynos5433 MIPI DSI driver.
Signed-off-by: default avatarHyungwon Hwang <human.hwang@samsung.com>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent d668e8bf
...@@ -211,6 +211,8 @@ ...@@ -211,6 +211,8 @@
REG_ADDR((dsi), (reg_idx))) REG_ADDR((dsi), (reg_idx)))
#define DSI_READ(dsi, reg_idx) readl(REG_ADDR((dsi), (reg_idx))) #define DSI_READ(dsi, reg_idx) readl(REG_ADDR((dsi), (reg_idx)))
static char *clk_names[2] = { "bus_clk", "sclk_mipi" };
enum exynos_dsi_transfer_type { enum exynos_dsi_transfer_type {
EXYNOS_DSI_TX, EXYNOS_DSI_TX,
EXYNOS_DSI_RX, EXYNOS_DSI_RX,
...@@ -260,8 +262,7 @@ struct exynos_dsi { ...@@ -260,8 +262,7 @@ struct exynos_dsi {
void __iomem *reg_base; void __iomem *reg_base;
struct phy *phy; struct phy *phy;
struct clk *sclk_clk; struct clk **clks;
struct clk *bus_clk;
struct regulator_bulk_data supplies[2]; struct regulator_bulk_data supplies[2];
int irq; int irq;
int te_gpio; int te_gpio;
...@@ -1390,7 +1391,8 @@ static const struct mipi_dsi_host_ops exynos_dsi_ops = { ...@@ -1390,7 +1391,8 @@ static const struct mipi_dsi_host_ops exynos_dsi_ops = {
static int exynos_dsi_poweron(struct exynos_dsi *dsi) static int exynos_dsi_poweron(struct exynos_dsi *dsi)
{ {
int ret; struct exynos_dsi_driver_data *driver_data = dsi->driver_data;
int ret, i;
ret = regulator_bulk_enable(ARRAY_SIZE(dsi->supplies), dsi->supplies); ret = regulator_bulk_enable(ARRAY_SIZE(dsi->supplies), dsi->supplies);
if (ret < 0) { if (ret < 0) {
...@@ -1398,31 +1400,23 @@ static int exynos_dsi_poweron(struct exynos_dsi *dsi) ...@@ -1398,31 +1400,23 @@ static int exynos_dsi_poweron(struct exynos_dsi *dsi)
return ret; return ret;
} }
ret = clk_prepare_enable(dsi->bus_clk); for (i = 0; i < driver_data->num_clks; i++) {
if (ret < 0) { ret = clk_prepare_enable(dsi->clks[i]);
dev_err(dsi->dev, "cannot enable bus clock %d\n", ret); if (ret < 0)
goto err_bus_clk; goto err_clk;
}
ret = clk_prepare_enable(dsi->sclk_clk);
if (ret < 0) {
dev_err(dsi->dev, "cannot enable pll clock %d\n", ret);
goto err_sclk_clk;
} }
ret = phy_power_on(dsi->phy); ret = phy_power_on(dsi->phy);
if (ret < 0) { if (ret < 0) {
dev_err(dsi->dev, "cannot enable phy %d\n", ret); dev_err(dsi->dev, "cannot enable phy %d\n", ret);
goto err_phy; goto err_clk;
} }
return 0; return 0;
err_phy: err_clk:
clk_disable_unprepare(dsi->sclk_clk); while (--i > -1)
err_sclk_clk: clk_disable_unprepare(dsi->clks[i]);
clk_disable_unprepare(dsi->bus_clk);
err_bus_clk:
regulator_bulk_disable(ARRAY_SIZE(dsi->supplies), dsi->supplies); regulator_bulk_disable(ARRAY_SIZE(dsi->supplies), dsi->supplies);
return ret; return ret;
...@@ -1430,7 +1424,8 @@ static int exynos_dsi_poweron(struct exynos_dsi *dsi) ...@@ -1430,7 +1424,8 @@ static int exynos_dsi_poweron(struct exynos_dsi *dsi)
static void exynos_dsi_poweroff(struct exynos_dsi *dsi) static void exynos_dsi_poweroff(struct exynos_dsi *dsi)
{ {
int ret; struct exynos_dsi_driver_data *driver_data = dsi->driver_data;
int ret, i;
usleep_range(10000, 20000); usleep_range(10000, 20000);
...@@ -1446,8 +1441,8 @@ static void exynos_dsi_poweroff(struct exynos_dsi *dsi) ...@@ -1446,8 +1441,8 @@ static void exynos_dsi_poweroff(struct exynos_dsi *dsi)
phy_power_off(dsi->phy); phy_power_off(dsi->phy);
clk_disable_unprepare(dsi->sclk_clk); for (i = driver_data->num_clks - 1; i > -1; i--)
clk_disable_unprepare(dsi->bus_clk); clk_disable_unprepare(dsi->clks[i]);
ret = regulator_bulk_disable(ARRAY_SIZE(dsi->supplies), dsi->supplies); ret = regulator_bulk_disable(ARRAY_SIZE(dsi->supplies), dsi->supplies);
if (ret < 0) if (ret < 0)
...@@ -1778,7 +1773,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) ...@@ -1778,7 +1773,7 @@ static int exynos_dsi_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *res; struct resource *res;
struct exynos_dsi *dsi; struct exynos_dsi *dsi;
int ret; int ret, i;
dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
if (!dsi) if (!dsi)
...@@ -1813,19 +1808,22 @@ static int exynos_dsi_probe(struct platform_device *pdev) ...@@ -1813,19 +1808,22 @@ static int exynos_dsi_probe(struct platform_device *pdev)
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
dsi->sclk_clk = devm_clk_get(dev, "sclk_mipi"); dsi->clks = devm_kzalloc(dev,
if (IS_ERR(dsi->sclk_clk)) { sizeof(*dsi->clks) * dsi->driver_data->num_clks,
dsi->sclk_clk = devm_clk_get(dev, OLD_SCLK_MIPI_CLK_NAME); GFP_KERNEL);
if (IS_ERR(dsi->sclk_clk)) { for (i = 0; i < dsi->driver_data->num_clks; i++) {
dev_info(dev, "failed to get dsi sclk clock\n"); dsi->clks[i] = devm_clk_get(dev, clk_names[i]);
eturn PTR_ERR(dsi->sclk_clk); if (IS_ERR(dsi->clks[i])) {
} if (strcmp(clk_names[i], "sclk_mipi") == 0) {
} strcpy(clk_names[i], OLD_SCLK_MIPI_CLK_NAME);
i--;
continue;
}
dsi->bus_clk = devm_clk_get(dev, "bus_clk"); dev_info(dev, "failed to get the clock: %s\n",
if (IS_ERR(dsi->bus_clk)) { clk_names[i]);
dev_info(dev, "failed to get dsi bus clock\n"); return PTR_ERR(dsi->clks[i]);
return PTR_ERR(dsi->bus_clk); }
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment