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>
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
)
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*/
55 mfpen
&= ~GPSELF
;/*GPIOF[9:0]*/
57 __raw_writel(mfpen
, REG_MFSEL
);
61 EXPORT_SYMBOL(mfp_set_groupf
);
63 void mfp_set_groupc(struct device
*dev
)
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*/
81 } else if (strcmp(dev_id
, "w90p910-nand") == 0) {
82 mfpen
&= (~GPSELC
);/*enable nand*/
85 mfpen
&= (~GPSELC
);/*GPIOC[14:0]*/
87 __raw_writel(mfpen
, REG_MFSEL
);
91 EXPORT_SYMBOL(mfp_set_groupc
);
93 void mfp_set_groupi(struct device
*dev
, int gpio
)
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
);
115 EXPORT_SYMBOL(mfp_set_groupi
);