提交 7acb706c 编写于 作者: I Ian Molton 提交者: Samuel Ortiz

mfd: update TMIO drivers to use the clock API

This patch updates the remaining two TMIO drivers to use the clock API
rather than callback hooks into platform code.
Signed-off-by: NIan Molton <spyro@f2s.com>
Signed-off-by: NSamuel Ortiz <sameo@openedhand.com>
上级 9297a0e7
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/clk.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/tmio.h> #include <linux/mfd/tmio.h>
...@@ -56,6 +58,8 @@ struct t7l66xb { ...@@ -56,6 +58,8 @@ struct t7l66xb {
spinlock_t lock; spinlock_t lock;
struct resource rscr; struct resource rscr;
struct clk *clk48m;
struct clk *clk32k;
int irq; int irq;
int irq_base; int irq_base;
}; };
...@@ -65,13 +69,11 @@ struct t7l66xb { ...@@ -65,13 +69,11 @@ struct t7l66xb {
static int t7l66xb_mmc_enable(struct platform_device *mmc) static int t7l66xb_mmc_enable(struct platform_device *mmc)
{ {
struct platform_device *dev = to_platform_device(mmc->dev.parent); struct platform_device *dev = to_platform_device(mmc->dev.parent);
struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
struct t7l66xb *t7l66xb = platform_get_drvdata(dev); struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
unsigned long flags; unsigned long flags;
u8 dev_ctl; u8 dev_ctl;
if (pdata->enable_clk32k) clk_enable(t7l66xb->clk32k);
pdata->enable_clk32k(dev);
spin_lock_irqsave(&t7l66xb->lock, flags); spin_lock_irqsave(&t7l66xb->lock, flags);
...@@ -87,7 +89,6 @@ static int t7l66xb_mmc_enable(struct platform_device *mmc) ...@@ -87,7 +89,6 @@ static int t7l66xb_mmc_enable(struct platform_device *mmc)
static int t7l66xb_mmc_disable(struct platform_device *mmc) static int t7l66xb_mmc_disable(struct platform_device *mmc)
{ {
struct platform_device *dev = to_platform_device(mmc->dev.parent); struct platform_device *dev = to_platform_device(mmc->dev.parent);
struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
struct t7l66xb *t7l66xb = platform_get_drvdata(dev); struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
unsigned long flags; unsigned long flags;
u8 dev_ctl; u8 dev_ctl;
...@@ -100,8 +101,7 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc) ...@@ -100,8 +101,7 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc)
spin_unlock_irqrestore(&t7l66xb->lock, flags); spin_unlock_irqrestore(&t7l66xb->lock, flags);
if (pdata->disable_clk32k) clk_disable(t7l66xb->clk32k);
pdata->disable_clk32k(dev);
return 0; return 0;
} }
...@@ -258,18 +258,22 @@ static void t7l66xb_detach_irq(struct platform_device *dev) ...@@ -258,18 +258,22 @@ static void t7l66xb_detach_irq(struct platform_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state) static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state)
{ {
struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
struct t7l66xb_platform_data *pdata = dev->dev.platform_data; struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
if (pdata && pdata->suspend) if (pdata && pdata->suspend)
pdata->suspend(dev); pdata->suspend(dev);
clk_disable(t7l66xb->clk48m);
return 0; return 0;
} }
static int t7l66xb_resume(struct platform_device *dev) static int t7l66xb_resume(struct platform_device *dev)
{ {
struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
struct t7l66xb_platform_data *pdata = dev->dev.platform_data; struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
clk_enable(t7l66xb->clk48m);
if (pdata && pdata->resume) if (pdata && pdata->resume)
pdata->resume(dev); pdata->resume(dev);
...@@ -309,6 +313,19 @@ static int t7l66xb_probe(struct platform_device *dev) ...@@ -309,6 +313,19 @@ static int t7l66xb_probe(struct platform_device *dev)
t7l66xb->irq_base = pdata->irq_base; t7l66xb->irq_base = pdata->irq_base;
t7l66xb->clk32k = clk_get(&dev->dev, "CLK_CK32K");
if (IS_ERR(t7l66xb->clk32k)) {
ret = PTR_ERR(t7l66xb->clk32k);
goto err_clk32k_get;
}
t7l66xb->clk48m = clk_get(&dev->dev, "CLK_CK48M");
if (IS_ERR(t7l66xb->clk48m)) {
ret = PTR_ERR(t7l66xb->clk48m);
clk_put(t7l66xb->clk32k);
goto err_clk48m_get;
}
rscr = &t7l66xb->rscr; rscr = &t7l66xb->rscr;
rscr->name = "t7l66xb-core"; rscr->name = "t7l66xb-core";
rscr->start = iomem->start; rscr->start = iomem->start;
...@@ -325,6 +342,8 @@ static int t7l66xb_probe(struct platform_device *dev) ...@@ -325,6 +342,8 @@ static int t7l66xb_probe(struct platform_device *dev)
goto err_ioremap; goto err_ioremap;
} }
clk_enable(t7l66xb->clk48m);
if (pdata && pdata->enable) if (pdata && pdata->enable)
pdata->enable(dev); pdata->enable(dev);
...@@ -359,9 +378,13 @@ static int t7l66xb_probe(struct platform_device *dev) ...@@ -359,9 +378,13 @@ static int t7l66xb_probe(struct platform_device *dev)
iounmap(t7l66xb->scr); iounmap(t7l66xb->scr);
err_ioremap: err_ioremap:
release_resource(&t7l66xb->rscr); release_resource(&t7l66xb->rscr);
err_noirq:
err_request_scr: err_request_scr:
kfree(t7l66xb); kfree(t7l66xb);
clk_put(t7l66xb->clk48m);
err_clk48m_get:
clk_put(t7l66xb->clk32k);
err_clk32k_get:
err_noirq:
return ret; return ret;
} }
...@@ -372,7 +395,8 @@ static int t7l66xb_remove(struct platform_device *dev) ...@@ -372,7 +395,8 @@ static int t7l66xb_remove(struct platform_device *dev)
int ret; int ret;
ret = pdata->disable(dev); ret = pdata->disable(dev);
clk_disable(t7l66xb->clk48m);
clk_put(t7l66xb->clk48m);
t7l66xb_detach_irq(dev); t7l66xb_detach_irq(dev);
iounmap(t7l66xb->scr); iounmap(t7l66xb->scr);
release_resource(&t7l66xb->rscr); release_resource(&t7l66xb->rscr);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/tmio.h> #include <linux/mfd/tmio.h>
...@@ -24,18 +25,22 @@ enum { ...@@ -24,18 +25,22 @@ enum {
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
{ {
struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev); struct clk *clk32k = platform_get_drvdata(dev);
struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
if (pdata && pdata->suspend) if (pdata && pdata->suspend)
pdata->suspend(dev); pdata->suspend(dev);
clk_disable(clk32k);
return 0; return 0;
} }
static int tc6387xb_resume(struct platform_device *dev) static int tc6387xb_resume(struct platform_device *dev)
{ {
struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev); struct clk *clk32k = platform_get_drvdata(dev);
struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
clk_enable(clk32k);
if (pdata && pdata->resume) if (pdata && pdata->resume)
pdata->resume(dev); pdata->resume(dev);
...@@ -51,10 +56,9 @@ static int tc6387xb_resume(struct platform_device *dev) ...@@ -51,10 +56,9 @@ static int tc6387xb_resume(struct platform_device *dev)
static int tc6387xb_mmc_enable(struct platform_device *mmc) static int tc6387xb_mmc_enable(struct platform_device *mmc)
{ {
struct platform_device *dev = to_platform_device(mmc->dev.parent); struct platform_device *dev = to_platform_device(mmc->dev.parent);
struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data; struct clk *clk32k = platform_get_drvdata(dev);
if (tc6387xb->enable_clk32k) clk_enable(clk32k);
tc6387xb->enable_clk32k(dev);
return 0; return 0;
} }
...@@ -62,10 +66,9 @@ static int tc6387xb_mmc_enable(struct platform_device *mmc) ...@@ -62,10 +66,9 @@ static int tc6387xb_mmc_enable(struct platform_device *mmc)
static int tc6387xb_mmc_disable(struct platform_device *mmc) static int tc6387xb_mmc_disable(struct platform_device *mmc)
{ {
struct platform_device *dev = to_platform_device(mmc->dev.parent); struct platform_device *dev = to_platform_device(mmc->dev.parent);
struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data; struct clk *clk32k = platform_get_drvdata(dev);
if (tc6387xb->disable_clk32k) clk_disable(clk32k);
tc6387xb->disable_clk32k(dev);
return 0; return 0;
} }
...@@ -102,14 +105,14 @@ static struct mfd_cell tc6387xb_cells[] = { ...@@ -102,14 +105,14 @@ static struct mfd_cell tc6387xb_cells[] = {
static int tc6387xb_probe(struct platform_device *dev) static int tc6387xb_probe(struct platform_device *dev)
{ {
struct tc6387xb_platform_data *data = platform_get_drvdata(dev); struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
struct resource *iomem; struct resource *iomem;
struct clk *clk32k;
int irq, ret; int irq, ret;
iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!iomem) { if (!iomem) {
ret = -EINVAL; return -EINVAL;
goto err_resource;
} }
ret = platform_get_irq(dev, 0); ret = platform_get_irq(dev, 0);
...@@ -118,8 +121,15 @@ static int tc6387xb_probe(struct platform_device *dev) ...@@ -118,8 +121,15 @@ static int tc6387xb_probe(struct platform_device *dev)
else else
goto err_resource; goto err_resource;
if (data && data->enable) clk32k = clk_get(&dev->dev, "CLK_CK32K");
data->enable(dev); if (IS_ERR(clk32k)) {
ret = PTR_ERR(clk32k);
goto err_resource;
}
platform_set_drvdata(dev, clk32k);
if (pdata && pdata->enable)
pdata->enable(dev);
printk(KERN_INFO "Toshiba tc6387xb initialised\n"); printk(KERN_INFO "Toshiba tc6387xb initialised\n");
...@@ -134,18 +144,19 @@ static int tc6387xb_probe(struct platform_device *dev) ...@@ -134,18 +144,19 @@ static int tc6387xb_probe(struct platform_device *dev)
if (!ret) if (!ret)
return 0; return 0;
clk_put(clk32k);
err_resource: err_resource:
return ret; return ret;
} }
static int tc6387xb_remove(struct platform_device *dev) static int tc6387xb_remove(struct platform_device *dev)
{ {
struct tc6387xb_platform_data *data = platform_get_drvdata(dev); struct clk *clk32k = platform_get_drvdata(dev);
if (data && data->disable)
data->disable(dev);
/* FIXME - free the resources! */ mfd_remove_devices(&dev->dev);
clk_disable(clk32k);
clk_put(clk32k);
platform_set_drvdata(dev, NULL);
return 0; return 0;
} }
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include <linux/mfd/tmio.h> #include <linux/mfd/tmio.h>
struct t7l66xb_platform_data { struct t7l66xb_platform_data {
int (*enable_clk32k)(struct platform_device *dev);
void (*disable_clk32k)(struct platform_device *dev);
int (*enable)(struct platform_device *dev); int (*enable)(struct platform_device *dev);
int (*disable)(struct platform_device *dev); int (*disable)(struct platform_device *dev);
int (*suspend)(struct platform_device *dev); int (*suspend)(struct platform_device *dev);
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
#define MFD_TC6387XB_H #define MFD_TC6387XB_H
struct tc6387xb_platform_data { struct tc6387xb_platform_data {
int (*enable_clk32k)(struct platform_device *dev);
void (*disable_clk32k)(struct platform_device *dev);
int (*enable)(struct platform_device *dev); int (*enable)(struct platform_device *dev);
int (*disable)(struct platform_device *dev); int (*disable)(struct platform_device *dev);
int (*suspend)(struct platform_device *dev); int (*suspend)(struct platform_device *dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册