Linux 2.6.31.8
[linux/fpc-iii.git] / arch / arm / mach-w90x900 / mfp-w90p910.c
bloba3520fefb5e732848415179ce5ad5633f1aaf340
1 /*
2 * linux/arch/arm/mach-w90x900/mfp-w90p910.c
4 * Copyright (c) 2008 Nuvoton technology corporation
6 * Wan ZongShun <mcuos.com@gmail.com>
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.
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>
24 #include <mach/hardware.h>
26 #define REG_MFSEL (W90X900_VA_GCR + 0xC)
28 #define GPSELF (0x01 << 1)
30 #define GPSELC (0x03 << 2)
31 #define ENKPI (0x02 << 2)
32 #define ENNAND (0x01 << 2)
34 #define GPSELEI0 (0x01 << 26)
35 #define GPSELEI1 (0x01 << 27)
37 static DECLARE_MUTEX(mfp_sem);
39 void mfp_set_groupf(struct device *dev)
41 unsigned long mfpen;
42 const char *dev_id;
44 BUG_ON(!dev);
46 down(&mfp_sem);
48 dev_id = dev_name(dev);
50 mfpen = __raw_readl(REG_MFSEL);
52 if (strcmp(dev_id, "w90p910-emc") == 0)
53 mfpen |= GPSELF;/*enable mac*/
54 else
55 mfpen &= ~GPSELF;/*GPIOF[9:0]*/
57 __raw_writel(mfpen, REG_MFSEL);
59 up(&mfp_sem);
61 EXPORT_SYMBOL(mfp_set_groupf);
63 void mfp_set_groupc(struct device *dev)
65 unsigned long mfpen;
66 const char *dev_id;
68 BUG_ON(!dev);
70 down(&mfp_sem);
72 dev_id = dev_name(dev);
74 mfpen = __raw_readl(REG_MFSEL);
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]*/
87 __raw_writel(mfpen, REG_MFSEL);
89 up(&mfp_sem);
91 EXPORT_SYMBOL(mfp_set_groupc);
93 void mfp_set_groupi(struct device *dev, int gpio)
95 unsigned long mfpen;
96 const char *dev_id;
98 BUG_ON(!dev);
100 down(&mfp_sem);
102 dev_id = dev_name(dev);
104 mfpen = __raw_readl(REG_MFSEL);
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*/
111 __raw_writel(mfpen, REG_MFSEL);
113 up(&mfp_sem);
115 EXPORT_SYMBOL(mfp_set_groupi);