14 #include <linux/module.h>
17 #include <linux/errno.h>
18 #include <linux/kernel.h>
25 #include <mach/hardware.h>
29 #define DRIVER_NAME "sa11x0-mcp"
39 #define MCCR0(m) ((m)->base0 + 0x00)
40 #define MCDR0(m) ((m)->base0 + 0x08)
41 #define MCDR1(m) ((m)->base0 + 0x0c)
42 #define MCDR2(m) ((m)->base0 + 0x10)
43 #define MCSR(m) ((m)->base0 + 0x18)
44 #define MCCR1(m) ((m)->base1 + 0x00)
46 #define priv(mcp) ((struct mcp_sa11x0 *)mcp_priv(mcp))
49 mcp_sa11x0_set_telecom_divisor(
struct mcp *
mcp,
unsigned int divisor)
55 m->
mccr0 &= ~0x00007f00;
56 m->
mccr0 |= divisor << 8;
61 mcp_sa11x0_set_audio_divisor(
struct mcp *
mcp,
unsigned int divisor)
67 m->
mccr0 &= ~0x0000007f;
79 mcp_sa11x0_write(
struct mcp *mcp,
unsigned int reg,
unsigned int val)
85 writel_relaxed(reg << 17 |
MCDR2_Wr | (val & 0xffff),
MCDR2(m));
87 for (i = 0; i < 2; i++) {
106 mcp_sa11x0_read(
struct mcp *mcp,
unsigned int reg)
114 for (i = 0; i < 2; i++) {
128 static void mcp_sa11x0_enable(
struct mcp *mcp)
137 static void mcp_sa11x0_disable(
struct mcp *mcp)
149 .set_telecom_divisor = mcp_sa11x0_set_telecom_divisor,
150 .set_audio_divisor = mcp_sa11x0_set_audio_divisor,
151 .reg_write = mcp_sa11x0_write,
152 .reg_read = mcp_sa11x0_read,
153 .enable = mcp_sa11x0_enable,
154 .disable = mcp_sa11x0_disable,
161 struct mcp_sa11x0 *
m;
192 mcp->
ops = &mcp_sa11x0;
206 platform_set_drvdata(dev, mcp);
212 writel_relaxed(-1,
MCSR(m));
228 platform_set_drvdata(dev,
NULL);
244 struct mcp *mcp = platform_get_drvdata(dev);
245 struct mcp_sa11x0 *m =
priv(mcp);
250 "device left active (missing disable call?)\n");
255 platform_set_drvdata(dev,
NULL);
266 #ifdef CONFIG_PM_SLEEP
267 static int mcp_sa11x0_suspend(
struct device *dev)
272 dev_warn(dev,
"device left active (missing disable call?)\n");
279 static int mcp_sa11x0_resume(
struct device *dev)
290 static const struct dev_pm_ops mcp_sa11x0_pm_ops = {
291 #ifdef CONFIG_PM_SLEEP
292 .suspend = mcp_sa11x0_suspend,
293 .freeze = mcp_sa11x0_suspend,
294 .poweroff = mcp_sa11x0_suspend,
295 .resume_noirq = mcp_sa11x0_resume,
296 .thaw_noirq = mcp_sa11x0_resume,
297 .restore_noirq = mcp_sa11x0_resume,
302 .probe = mcp_sa11x0_probe,
303 .remove = mcp_sa11x0_remove,
307 .pm = &mcp_sa11x0_pm_ops,