blob: 7a270eecd4808a64f60a7bc1dc97395a47c23b51 [file] [log] [blame]
eric miao2c8086a2007-09-11 19:13:17 -07001/*
2 * linux/arch/arm/mach-pxa/mfp.c
3 *
4 * PXA3xx Multi-Function Pin Support
5 *
6 * Copyright (C) 2007 Marvell Internation Ltd.
7 *
eric miaoe9bba8e2007-10-30 08:01:38 +01008 * 2007-08-21: eric miao <eric.miao@marvell.com>
eric miao2c8086a2007-09-11 19:13:17 -07009 * initial version
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/io.h>
Russell Kingd4fc8582008-01-08 15:12:22 +000020#include <linux/sysdev.h>
eric miao2c8086a2007-09-11 19:13:17 -070021
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/hardware.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/mfp-pxa3xx.h>
24#include <mach/pxa3xx-regs.h>
eric miao2c8086a2007-09-11 19:13:17 -070025
Russell Kingd4fc8582008-01-08 15:12:22 +000026#ifdef CONFIG_PM
27/*
28 * Configure the MFPs appropriately for suspend/resume.
29 * FIXME: this should probably depend on which system state we're
30 * entering - for instance, we might not want to place MFP pins in
31 * a pull-down mode if they're an active low chip select, and we're
32 * just entering standby.
33 */
34static int pxa3xx_mfp_suspend(struct sys_device *d, pm_message_t state)
35{
Eric Miaof8dec042009-01-15 16:42:56 +080036 mfp_config_lpm();
Russell Kingd4fc8582008-01-08 15:12:22 +000037 return 0;
38}
39
40static int pxa3xx_mfp_resume(struct sys_device *d)
41{
Eric Miaof8dec042009-01-15 16:42:56 +080042 mfp_config_run();
eric miaoc4d1fb62008-01-28 23:00:02 +000043
44 /* clear RDH bit when MFP settings are restored
45 *
46 * NOTE: the last 3 bits DxS are write-1-to-clear so carefully
47 * preserve them here in case they will be referenced later
48 */
49 ASCR &= ~(ASCR_RDH | ASCR_D1S | ASCR_D2S | ASCR_D3S);
Russell Kingd4fc8582008-01-08 15:12:22 +000050 return 0;
51}
eric miao4be35e22008-02-04 10:07:09 +080052#else
53#define pxa3xx_mfp_suspend NULL
54#define pxa3xx_mfp_resume NULL
55#endif
Russell Kingd4fc8582008-01-08 15:12:22 +000056
eric miao4be35e22008-02-04 10:07:09 +080057struct sysdev_class pxa3xx_mfp_sysclass = {
eric miao14271a72008-01-29 08:57:45 +080058 .name = "mfp",
Russell Kingd4fc8582008-01-08 15:12:22 +000059 .suspend = pxa3xx_mfp_suspend,
60 .resume = pxa3xx_mfp_resume,
61};
62
Russell Kingd4fc8582008-01-08 15:12:22 +000063static int __init mfp_init_devicefs(void)
64{
eric miao4be35e22008-02-04 10:07:09 +080065 if (cpu_is_pxa3xx())
66 return sysdev_class_register(&pxa3xx_mfp_sysclass);
67
68 return 0;
Russell Kingd4fc8582008-01-08 15:12:22 +000069}
eric miao4be35e22008-02-04 10:07:09 +080070postcore_initcall(mfp_init_devicefs);