Merge git://1984.lsi.us.es/nf-next
[cascardo/linux.git] / arch / arm / mach-shmobile / include / mach / gpio.h
1 /*
2  * Generic GPIO API and pinmux table support
3  *
4  * Copyright (c) 2008  Magnus Damm
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10 #ifndef __ASM_ARCH_GPIO_H
11 #define __ASM_ARCH_GPIO_H
12
13 #include <linux/kernel.h>
14 #include <linux/errno.h>
15 #include <linux/sh_pfc.h>
16 #include <linux/io.h>
17
18 #ifdef CONFIG_GPIOLIB
19
20 static inline int irq_to_gpio(unsigned int irq)
21 {
22         return -ENOSYS;
23 }
24
25 #else
26
27 #define __ARM_GPIOLIB_COMPLEX
28
29 #endif /* CONFIG_GPIOLIB */
30
31 /*
32  * FIXME !!
33  *
34  * current gpio frame work doesn't have
35  * the method to control only pull up/down/free.
36  * this function should be replaced by correct gpio function
37  */
38 static inline void __init gpio_direction_none(u32 addr)
39 {
40         __raw_writeb(0x00, addr);
41 }
42
43 static inline void __init gpio_request_pullup(u32 addr)
44 {
45         u8 data = __raw_readb(addr);
46
47         data &= 0x0F;
48         data |= 0xC0;
49         __raw_writeb(data, addr);
50 }
51
52 static inline void __init gpio_request_pulldown(u32 addr)
53 {
54         u8 data = __raw_readb(addr);
55
56         data &= 0x0F;
57         data |= 0xA0;
58
59         __raw_writeb(data, addr);
60 }
61
62 #endif /* __ASM_ARCH_GPIO_H */