Commit b51339ff authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

sh: sh_mobile lcdc clock framework support

Add clock framework support to the lcdc driver and
adjust the board specific code accordingly.
Signed-off-by: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 765786e0
...@@ -345,7 +345,6 @@ static int __init ap325rxa_devices_setup(void) ...@@ -345,7 +345,6 @@ static int __init ap325rxa_devices_setup(void)
gpio_export(GPIO_PTF7, 0); gpio_export(GPIO_PTF7, 0);
/* LCDC */ /* LCDC */
clk_always_enable("mstp200");
gpio_request(GPIO_FN_LCDD15, NULL); gpio_request(GPIO_FN_LCDD15, NULL);
gpio_request(GPIO_FN_LCDD14, NULL); gpio_request(GPIO_FN_LCDD14, NULL);
gpio_request(GPIO_FN_LCDD13, NULL); gpio_request(GPIO_FN_LCDD13, NULL);
......
...@@ -502,7 +502,6 @@ static int __init migor_devices_setup(void) ...@@ -502,7 +502,6 @@ static int __init migor_devices_setup(void)
gpio_request(GPIO_FN_IRQ6, NULL); gpio_request(GPIO_FN_IRQ6, NULL);
/* LCD Panel */ /* LCD Panel */
clk_always_enable("mstp200"); /* LCDC */
#ifdef CONFIG_SH_MIGOR_QVGA /* LCDC - QVGA - Enable SYS Interface signals */ #ifdef CONFIG_SH_MIGOR_QVGA /* LCDC - QVGA - Enable SYS Interface signals */
gpio_request(GPIO_FN_LCDD17, NULL); gpio_request(GPIO_FN_LCDD17, NULL);
gpio_request(GPIO_FN_LCDD16, NULL); gpio_request(GPIO_FN_LCDD16, NULL);
......
...@@ -35,6 +35,7 @@ struct sh_mobile_lcdc_chan { ...@@ -35,6 +35,7 @@ struct sh_mobile_lcdc_chan {
struct sh_mobile_lcdc_priv { struct sh_mobile_lcdc_priv {
void __iomem *base; void __iomem *base;
#ifdef CONFIG_HAVE_CLK #ifdef CONFIG_HAVE_CLK
struct clk *dot_clk;
struct clk *clk; struct clk *clk;
#endif #endif
unsigned long lddckr; unsigned long lddckr;
...@@ -207,6 +208,11 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -207,6 +208,11 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
int k, m; int k, m;
int ret = 0; int ret = 0;
#ifdef CONFIG_HAVE_CLK
clk_enable(priv->clk);
if (priv->dot_clk)
clk_enable(priv->dot_clk);
#endif
/* reset */ /* reset */
lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET); lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET);
lcdc_wait_bit(priv, _LDCNT2R, LCDC_RESET, 0); lcdc_wait_bit(priv, _LDCNT2R, LCDC_RESET, 0);
...@@ -371,6 +377,12 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) ...@@ -371,6 +377,12 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
/* stop the lcdc */ /* stop the lcdc */
sh_mobile_lcdc_start_stop(priv, 0); sh_mobile_lcdc_start_stop(priv, 0);
#ifdef CONFIG_HAVE_CLK
if (priv->dot_clk)
clk_disable(priv->dot_clk);
clk_disable(priv->clk);
#endif
} }
static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch) static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch)
...@@ -413,9 +425,13 @@ static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch) ...@@ -413,9 +425,13 @@ static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch)
return -EINVAL; return -EINVAL;
} }
static int sh_mobile_lcdc_setup_clocks(struct device *dev, int clock_source, static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev,
int clock_source,
struct sh_mobile_lcdc_priv *priv) struct sh_mobile_lcdc_priv *priv)
{ {
#ifdef CONFIG_HAVE_CLK
char clk_name[8];
#endif
char *str; char *str;
int icksel; int icksel;
...@@ -430,14 +446,20 @@ static int sh_mobile_lcdc_setup_clocks(struct device *dev, int clock_source, ...@@ -430,14 +446,20 @@ static int sh_mobile_lcdc_setup_clocks(struct device *dev, int clock_source,
priv->lddckr = icksel << 16; priv->lddckr = icksel << 16;
#ifdef CONFIG_HAVE_CLK #ifdef CONFIG_HAVE_CLK
snprintf(clk_name, sizeof(clk_name), "lcdc%d", pdev->id);
priv->clk = clk_get(&pdev->dev, clk_name);
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
return PTR_ERR(priv->clk);
}
if (str) { if (str) {
priv->clk = clk_get(dev, str); priv->dot_clk = clk_get(&pdev->dev, str);
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->dot_clk)) {
dev_err(dev, "cannot get clock %s\n", str); dev_err(&pdev->dev, "cannot get dot clock %s\n", str);
return PTR_ERR(priv->clk); clk_put(priv->clk);
return PTR_ERR(priv->dot_clk);
} }
clk_enable(priv->clk);
} }
#endif #endif
...@@ -587,8 +609,7 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) ...@@ -587,8 +609,7 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
goto err1; goto err1;
} }
error = sh_mobile_lcdc_setup_clocks(&pdev->dev, error = sh_mobile_lcdc_setup_clocks(pdev, pdata->clock_source, priv);
pdata->clock_source, priv);
if (error) { if (error) {
dev_err(&pdev->dev, "unable to setup clocks\n"); dev_err(&pdev->dev, "unable to setup clocks\n");
goto err1; goto err1;
...@@ -697,10 +718,9 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev) ...@@ -697,10 +718,9 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev)
} }
#ifdef CONFIG_HAVE_CLK #ifdef CONFIG_HAVE_CLK
if (priv->clk) { if (priv->dot_clk)
clk_disable(priv->clk); clk_put(priv->dot_clk);
clk_put(priv->clk); clk_put(priv->clk);
}
#endif #endif
if (priv->base) if (priv->base)
......
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