sh: gpio: Include asm-generic/gpio.h for non-gpiolib stubs.
[linux-2.6/verdex.git] / arch / sh / include / asm / gpio.h
bloba6ec3e430380e0b4854da5a8d29f32e38c3e78a7
1 /*
2 * include/asm-sh/gpio.h
4 * Generic GPIO API and pinmux table support for SuperH.
6 * Copyright (c) 2008 Magnus Damm
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
12 #ifndef __ASM_SH_GPIO_H
13 #define __ASM_SH_GPIO_H
15 #if defined(CONFIG_CPU_SH3)
16 #include <cpu/gpio.h>
17 #endif
19 typedef unsigned short pinmux_enum_t;
20 typedef unsigned char pinmux_flag_t;
22 #define PINMUX_TYPE_NONE 0
23 #define PINMUX_TYPE_FUNCTION 1
24 #define PINMUX_TYPE_GPIO 2
25 #define PINMUX_TYPE_OUTPUT 3
26 #define PINMUX_TYPE_INPUT 4
27 #define PINMUX_TYPE_INPUT_PULLUP 5
28 #define PINMUX_TYPE_INPUT_PULLDOWN 6
30 #define PINMUX_FLAG_TYPE (0x7)
31 #define PINMUX_FLAG_WANT_PULLUP (1 << 3)
32 #define PINMUX_FLAG_WANT_PULLDOWN (1 << 4)
34 struct pinmux_gpio {
35 pinmux_enum_t enum_id;
36 pinmux_flag_t flags;
39 #define PINMUX_GPIO(gpio, data_or_mark) [gpio] = { data_or_mark }
40 #define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0
42 struct pinmux_cfg_reg {
43 unsigned long reg, reg_width, field_width;
44 unsigned long *cnt;
45 pinmux_enum_t *enum_ids;
48 #define PINMUX_CFG_REG(name, r, r_width, f_width) \
49 .reg = r, .reg_width = r_width, .field_width = f_width, \
50 .cnt = (unsigned long [r_width / f_width]) {}, \
51 .enum_ids = (pinmux_enum_t [(r_width / f_width) * (1 << f_width)]) \
53 struct pinmux_data_reg {
54 unsigned long reg, reg_width;
55 pinmux_enum_t *enum_ids;
58 #define PINMUX_DATA_REG(name, r, r_width) \
59 .reg = r, .reg_width = r_width, \
60 .enum_ids = (pinmux_enum_t [r_width]) \
62 struct pinmux_range {
63 pinmux_enum_t begin;
64 pinmux_enum_t end;
67 struct pinmux_info {
68 char *name;
69 pinmux_enum_t reserved_id;
70 struct pinmux_range data;
71 struct pinmux_range input;
72 struct pinmux_range input_pd;
73 struct pinmux_range input_pu;
74 struct pinmux_range output;
75 struct pinmux_range mark;
76 struct pinmux_range function;
78 unsigned first_gpio, last_gpio;
80 struct pinmux_gpio *gpios;
81 struct pinmux_cfg_reg *cfg_regs;
82 struct pinmux_data_reg *data_regs;
84 pinmux_enum_t *gpio_data;
85 unsigned int gpio_data_size;
87 unsigned long *gpio_in_use;
90 int register_pinmux(struct pinmux_info *pip);
92 int __gpio_request(unsigned gpio);
93 static inline int gpio_request(unsigned gpio, const char *label)
95 return __gpio_request(gpio);
97 void gpio_free(unsigned gpio);
98 int gpio_direction_input(unsigned gpio);
99 int gpio_direction_output(unsigned gpio, int value);
100 int gpio_get_value(unsigned gpio);
101 void gpio_set_value(unsigned gpio, int value);
103 #include <asm-generic/gpio.h>
105 #endif /* __ASM_SH_GPIO_H */