diff options
Diffstat (limited to 'arch/arm/mach-w90x900/mfp-w90p910.c')
-rw-r--r-- | arch/arm/mach-w90x900/mfp-w90p910.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/arch/arm/mach-w90x900/mfp-w90p910.c b/arch/arm/mach-w90x900/mfp-w90p910.c new file mode 100644 index 000000000000..a3520fefb5e7 --- /dev/null +++ b/arch/arm/mach-w90x900/mfp-w90p910.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-w90x900/mfp-w90p910.c | ||
3 | * | ||
4 | * Copyright (c) 2008 Nuvoton technology corporation | ||
5 | * | ||
6 | * Wan ZongShun <mcuos.com@gmail.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation;version 2 of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/err.h> | ||
19 | #include <linux/string.h> | ||
20 | #include <linux/clk.h> | ||
21 | #include <linux/mutex.h> | ||
22 | #include <linux/io.h> | ||
23 | |||
24 | #include <mach/hardware.h> | ||
25 | |||
26 | #define REG_MFSEL (W90X900_VA_GCR + 0xC) | ||
27 | |||
28 | #define GPSELF (0x01 << 1) | ||
29 | |||
30 | #define GPSELC (0x03 << 2) | ||
31 | #define ENKPI (0x02 << 2) | ||
32 | #define ENNAND (0x01 << 2) | ||
33 | |||
34 | #define GPSELEI0 (0x01 << 26) | ||
35 | #define GPSELEI1 (0x01 << 27) | ||
36 | |||
37 | static DECLARE_MUTEX(mfp_sem); | ||
38 | |||
39 | void mfp_set_groupf(struct device *dev) | ||
40 | { | ||
41 | unsigned long mfpen; | ||
42 | const char *dev_id; | ||
43 | |||
44 | BUG_ON(!dev); | ||
45 | |||
46 | down(&mfp_sem); | ||
47 | |||
48 | dev_id = dev_name(dev); | ||
49 | |||
50 | mfpen = __raw_readl(REG_MFSEL); | ||
51 | |||
52 | if (strcmp(dev_id, "w90p910-emc") == 0) | ||
53 | mfpen |= GPSELF;/*enable mac*/ | ||
54 | else | ||
55 | mfpen &= ~GPSELF;/*GPIOF[9:0]*/ | ||
56 | |||
57 | __raw_writel(mfpen, REG_MFSEL); | ||
58 | |||
59 | up(&mfp_sem); | ||
60 | } | ||
61 | EXPORT_SYMBOL(mfp_set_groupf); | ||
62 | |||
63 | void mfp_set_groupc(struct device *dev) | ||
64 | { | ||
65 | unsigned long mfpen; | ||
66 | const char *dev_id; | ||
67 | |||
68 | BUG_ON(!dev); | ||
69 | |||
70 | down(&mfp_sem); | ||
71 | |||
72 | dev_id = dev_name(dev); | ||
73 | |||
74 | mfpen = __raw_readl(REG_MFSEL); | ||
75 | |||
76 | if (strcmp(dev_id, "w90p910-lcd") == 0) | ||
77 | mfpen |= GPSELC;/*enable lcd*/ | ||
78 | else if (strcmp(dev_id, "w90p910-kpi") == 0) { | ||
79 | mfpen &= (~GPSELC);/*enable kpi*/ | ||
80 | mfpen |= ENKPI; | ||
81 | } else if (strcmp(dev_id, "w90p910-nand") == 0) { | ||
82 | mfpen &= (~GPSELC);/*enable nand*/ | ||
83 | mfpen |= ENNAND; | ||
84 | } else | ||
85 | mfpen &= (~GPSELC);/*GPIOC[14:0]*/ | ||
86 | |||
87 | __raw_writel(mfpen, REG_MFSEL); | ||
88 | |||
89 | up(&mfp_sem); | ||
90 | } | ||
91 | EXPORT_SYMBOL(mfp_set_groupc); | ||
92 | |||
93 | void mfp_set_groupi(struct device *dev, int gpio) | ||
94 | { | ||
95 | unsigned long mfpen; | ||
96 | const char *dev_id; | ||
97 | |||
98 | BUG_ON(!dev); | ||
99 | |||
100 | down(&mfp_sem); | ||
101 | |||
102 | dev_id = dev_name(dev); | ||
103 | |||
104 | mfpen = __raw_readl(REG_MFSEL); | ||
105 | |||
106 | if (strcmp(dev_id, "w90p910-wdog") == 0) | ||
107 | mfpen |= GPSELEI1;/*enable wdog*/ | ||
108 | else if (strcmp(dev_id, "w90p910-atapi") == 0) | ||
109 | mfpen |= GPSELEI0;/*enable atapi*/ | ||
110 | |||
111 | __raw_writel(mfpen, REG_MFSEL); | ||
112 | |||
113 | up(&mfp_sem); | ||
114 | } | ||
115 | EXPORT_SYMBOL(mfp_set_groupi); | ||
116 | |||