staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / arch / arm / mach-w90x900 / mfp.c
blob05f3779a36189cd70baebdfe9a42233a6f10dfeb
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * linux/arch/arm/mach-w90x900/mfp.c
5 * Copyright (c) 2008 Nuvoton technology corporation
7 * Wan ZongShun <mcuos.com@gmail.com>
8 */
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/device.h>
13 #include <linux/list.h>
14 #include <linux/errno.h>
15 #include <linux/err.h>
16 #include <linux/string.h>
17 #include <linux/clk.h>
18 #include <linux/mutex.h>
19 #include <linux/io.h>
21 #include <mach/hardware.h>
23 #define REG_MFSEL (W90X900_VA_GCR + 0xC)
25 #define GPSELF (0x01 << 1)
26 #define GPSELC (0x03 << 2)
27 #define GPSELD (0x0f << 4)
29 #define GPSELEI0 (0x01 << 26)
30 #define GPSELEI1 (0x01 << 27)
32 #define GPIOG0TO1 (0x03 << 14)
33 #define GPIOG2TO3 (0x03 << 16)
34 #define GPIOG22TO23 (0x03 << 22)
35 #define GPIOG18TO20 (0x07 << 18)
37 #define ENSPI (0x0a << 14)
38 #define ENI2C0 (0x01 << 14)
39 #define ENI2C1 (0x01 << 16)
40 #define ENAC97 (0x02 << 22)
41 #define ENSD1 (0x02 << 18)
42 #define ENSD0 (0x0a << 4)
43 #define ENKPI (0x02 << 2)
44 #define ENNAND (0x01 << 2)
46 static DEFINE_MUTEX(mfp_mutex);
48 void mfp_set_groupf(struct device *dev)
50 unsigned long mfpen;
51 const char *dev_id;
53 BUG_ON(!dev);
55 mutex_lock(&mfp_mutex);
57 dev_id = dev_name(dev);
59 mfpen = __raw_readl(REG_MFSEL);
61 if (strcmp(dev_id, "nuc900-emc") == 0)
62 mfpen |= GPSELF;/*enable mac*/
63 else
64 mfpen &= ~GPSELF;/*GPIOF[9:0]*/
66 __raw_writel(mfpen, REG_MFSEL);
68 mutex_unlock(&mfp_mutex);
70 EXPORT_SYMBOL(mfp_set_groupf);
72 void mfp_set_groupc(struct device *dev)
74 unsigned long mfpen;
75 const char *dev_id;
77 BUG_ON(!dev);
79 mutex_lock(&mfp_mutex);
81 dev_id = dev_name(dev);
83 mfpen = __raw_readl(REG_MFSEL);
85 if (strcmp(dev_id, "nuc900-lcd") == 0)
86 mfpen |= GPSELC;/*enable lcd*/
87 else if (strcmp(dev_id, "nuc900-kpi") == 0) {
88 mfpen &= (~GPSELC);/*enable kpi*/
89 mfpen |= ENKPI;
90 } else if (strcmp(dev_id, "nuc900-nand") == 0) {
91 mfpen &= (~GPSELC);/*enable nand*/
92 mfpen |= ENNAND;
93 } else
94 mfpen &= (~GPSELC);/*GPIOC[14:0]*/
96 __raw_writel(mfpen, REG_MFSEL);
98 mutex_unlock(&mfp_mutex);
100 EXPORT_SYMBOL(mfp_set_groupc);
102 void mfp_set_groupi(struct device *dev)
104 unsigned long mfpen;
105 const char *dev_id;
107 BUG_ON(!dev);
109 mutex_lock(&mfp_mutex);
111 dev_id = dev_name(dev);
113 mfpen = __raw_readl(REG_MFSEL);
115 mfpen &= ~GPSELEI1;/*default gpio16*/
117 if (strcmp(dev_id, "nuc900-wdog") == 0)
118 mfpen |= GPSELEI1;/*enable wdog*/
119 else if (strcmp(dev_id, "nuc900-atapi") == 0)
120 mfpen |= GPSELEI0;/*enable atapi*/
121 else if (strcmp(dev_id, "nuc900-keypad") == 0)
122 mfpen &= ~GPSELEI0;/*enable keypad*/
124 __raw_writel(mfpen, REG_MFSEL);
126 mutex_unlock(&mfp_mutex);
128 EXPORT_SYMBOL(mfp_set_groupi);
130 void mfp_set_groupg(struct device *dev, const char *subname)
132 unsigned long mfpen;
133 const char *dev_id;
135 BUG_ON((!dev) && (!subname));
137 mutex_lock(&mfp_mutex);
139 if (subname != NULL)
140 dev_id = subname;
141 else
142 dev_id = dev_name(dev);
144 mfpen = __raw_readl(REG_MFSEL);
146 if (strcmp(dev_id, "nuc900-spi") == 0) {
147 mfpen &= ~(GPIOG0TO1 | GPIOG2TO3);
148 mfpen |= ENSPI;/*enable spi*/
149 } else if (strcmp(dev_id, "nuc900-i2c0") == 0) {
150 mfpen &= ~(GPIOG0TO1);
151 mfpen |= ENI2C0;/*enable i2c0*/
152 } else if (strcmp(dev_id, "nuc900-i2c1") == 0) {
153 mfpen &= ~(GPIOG2TO3);
154 mfpen |= ENI2C1;/*enable i2c1*/
155 } else if (strcmp(dev_id, "nuc900-ac97") == 0) {
156 mfpen &= ~(GPIOG22TO23);
157 mfpen |= ENAC97;/*enable AC97*/
158 } else if (strcmp(dev_id, "nuc900-mmc-port1") == 0) {
159 mfpen &= ~(GPIOG18TO20);
160 mfpen |= (ENSD1 | 0x01);/*enable sd1*/
161 } else {
162 mfpen &= ~(GPIOG0TO1 | GPIOG2TO3);/*GPIOG[3:0]*/
165 __raw_writel(mfpen, REG_MFSEL);
167 mutex_unlock(&mfp_mutex);
169 EXPORT_SYMBOL(mfp_set_groupg);
171 void mfp_set_groupd(struct device *dev, const char *subname)
173 unsigned long mfpen;
174 const char *dev_id;
176 BUG_ON((!dev) && (!subname));
178 mutex_lock(&mfp_mutex);
180 if (subname != NULL)
181 dev_id = subname;
182 else
183 dev_id = dev_name(dev);
185 mfpen = __raw_readl(REG_MFSEL);
187 if (strcmp(dev_id, "nuc900-mmc-port0") == 0) {
188 mfpen &= ~GPSELD;/*enable sd0*/
189 mfpen |= ENSD0;
190 } else
191 mfpen &= (~GPSELD);
193 __raw_writel(mfpen, REG_MFSEL);
195 mutex_unlock(&mfp_mutex);
197 EXPORT_SYMBOL(mfp_set_groupd);