3 #include <asm/arch/imx-regs.h>
5 #define IMX_GPIO_ALLOC_MODE_NORMAL 0
6 #define IMX_GPIO_ALLOC_MODE_NO_ALLOC 1
7 #define IMX_GPIO_ALLOC_MODE_TRY_ALLOC 2
8 #define IMX_GPIO_ALLOC_MODE_ALLOC_ONLY 4
9 #define IMX_GPIO_ALLOC_MODE_RELEASE 8
11 extern int imx_gpio_request(unsigned gpio
, const char *label
);
13 extern void imx_gpio_free(unsigned gpio
);
15 extern int imx_gpio_setup_multiple_pins(const int *pin_list
, unsigned count
,
16 int alloc_mode
, const char *label
);
18 extern int imx_gpio_direction_input(unsigned gpio
);
20 extern int imx_gpio_direction_output(unsigned gpio
, int value
);
22 extern void __imx_gpio_set_value(unsigned gpio
, int value
);
24 static inline int imx_gpio_get_value(unsigned gpio
)
26 return SSR(gpio
>> GPIO_PORT_SHIFT
) & (1 << (gpio
& GPIO_PIN_MASK
));
29 static inline void imx_gpio_set_value_inline(unsigned gpio
, int value
)
33 raw_local_irq_save(flags
);
35 DR(gpio
>> GPIO_PORT_SHIFT
) |= (1 << (gpio
& GPIO_PIN_MASK
));
37 DR(gpio
>> GPIO_PORT_SHIFT
) &= ~(1 << (gpio
& GPIO_PIN_MASK
));
38 raw_local_irq_restore(flags
);
41 static inline void imx_gpio_set_value(unsigned gpio
, int value
)
43 if(__builtin_constant_p(gpio
))
44 imx_gpio_set_value_inline(gpio
, value
);
46 __imx_gpio_set_value(gpio
, value
);
49 extern int imx_gpio_to_irq(unsigned gpio
);
51 extern int imx_irq_to_gpio(unsigned irq
);
53 /*-------------------------------------------------------------------------*/
55 /* Wrappers for "new style" GPIO calls. These calls i.MX specific versions
56 * to allow future extension of GPIO logic.
59 static inline int gpio_request(unsigned gpio
, const char *label
)
61 return imx_gpio_request(gpio
, label
);
64 static inline void gpio_free(unsigned gpio
)
69 static inline int gpio_direction_input(unsigned gpio
)
71 return imx_gpio_direction_input(gpio
);
74 static inline int gpio_direction_output(unsigned gpio
, int value
)
76 return imx_gpio_direction_output(gpio
, value
);
79 static inline int gpio_get_value(unsigned gpio
)
81 return imx_gpio_get_value(gpio
);
84 static inline void gpio_set_value(unsigned gpio
, int value
)
86 imx_gpio_set_value(gpio
, value
);
89 #include <asm-generic/gpio.h> /* cansleep wrappers */
91 static inline int gpio_to_irq(unsigned gpio
)
93 return imx_gpio_to_irq(gpio
);
96 static inline int irq_to_gpio(unsigned irq
)
98 return imx_irq_to_gpio(irq
);