eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 1 | /* |
| 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 miao | e9bba8e | 2007-10-30 08:01:38 +0100 | [diff] [blame] | 8 | * 2007-08-21: eric miao <eric.miao@marvell.com> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 9 | * 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 King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 20 | #include <linux/sysdev.h> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 21 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 22 | #include <mach/hardware.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/mfp-pxa3xx.h> |
| 24 | #include <mach/pxa3xx-regs.h> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 25 | |
Russell King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 26 | #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 | */ |
| 34 | static int pxa3xx_mfp_suspend(struct sys_device *d, pm_message_t state) |
| 35 | { |
Eric Miao | f8dec04 | 2009-01-15 16:42:56 +0800 | [diff] [blame] | 36 | mfp_config_lpm(); |
Russell King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | static int pxa3xx_mfp_resume(struct sys_device *d) |
| 41 | { |
Eric Miao | f8dec04 | 2009-01-15 16:42:56 +0800 | [diff] [blame] | 42 | mfp_config_run(); |
eric miao | c4d1fb6 | 2008-01-28 23:00:02 +0000 | [diff] [blame] | 43 | |
| 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 King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 50 | return 0; |
| 51 | } |
eric miao | 4be35e2 | 2008-02-04 10:07:09 +0800 | [diff] [blame] | 52 | #else |
| 53 | #define pxa3xx_mfp_suspend NULL |
| 54 | #define pxa3xx_mfp_resume NULL |
| 55 | #endif |
Russell King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 56 | |
eric miao | 4be35e2 | 2008-02-04 10:07:09 +0800 | [diff] [blame] | 57 | struct sysdev_class pxa3xx_mfp_sysclass = { |
eric miao | 14271a7 | 2008-01-29 08:57:45 +0800 | [diff] [blame] | 58 | .name = "mfp", |
Russell King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 59 | .suspend = pxa3xx_mfp_suspend, |
| 60 | .resume = pxa3xx_mfp_resume, |
| 61 | }; |
| 62 | |
Russell King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 63 | static int __init mfp_init_devicefs(void) |
| 64 | { |
eric miao | 4be35e2 | 2008-02-04 10:07:09 +0800 | [diff] [blame] | 65 | if (cpu_is_pxa3xx()) |
| 66 | return sysdev_class_register(&pxa3xx_mfp_sysclass); |
| 67 | |
| 68 | return 0; |
Russell King | d4fc858 | 2008-01-08 15:12:22 +0000 | [diff] [blame] | 69 | } |
eric miao | 4be35e2 | 2008-02-04 10:07:09 +0800 | [diff] [blame] | 70 | postcore_initcall(mfp_init_devicefs); |