diff options
Diffstat (limited to 'include/linux/sh_pfc.h')
-rw-r--r-- | include/linux/sh_pfc.h | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index 5c15aed9c4b2..c19a0925829a 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h | |||
@@ -11,22 +11,24 @@ | |||
11 | #ifndef __SH_PFC_H | 11 | #ifndef __SH_PFC_H |
12 | #define __SH_PFC_H | 12 | #define __SH_PFC_H |
13 | 13 | ||
14 | #include <linux/stringify.h> | ||
14 | #include <asm-generic/gpio.h> | 15 | #include <asm-generic/gpio.h> |
15 | 16 | ||
16 | typedef unsigned short pinmux_enum_t; | 17 | typedef unsigned short pinmux_enum_t; |
17 | typedef unsigned short pinmux_flag_t; | 18 | typedef unsigned short pinmux_flag_t; |
18 | 19 | ||
19 | #define PINMUX_TYPE_NONE 0 | 20 | enum { |
20 | #define PINMUX_TYPE_FUNCTION 1 | 21 | PINMUX_TYPE_NONE, |
21 | #define PINMUX_TYPE_GPIO 2 | ||
22 | #define PINMUX_TYPE_OUTPUT 3 | ||
23 | #define PINMUX_TYPE_INPUT 4 | ||
24 | #define PINMUX_TYPE_INPUT_PULLUP 5 | ||
25 | #define PINMUX_TYPE_INPUT_PULLDOWN 6 | ||
26 | 22 | ||
27 | #define PINMUX_FLAG_TYPE (0x7) | 23 | PINMUX_TYPE_FUNCTION, |
28 | #define PINMUX_FLAG_WANT_PULLUP (1 << 3) | 24 | PINMUX_TYPE_GPIO, |
29 | #define PINMUX_FLAG_WANT_PULLDOWN (1 << 4) | 25 | PINMUX_TYPE_OUTPUT, |
26 | PINMUX_TYPE_INPUT, | ||
27 | PINMUX_TYPE_INPUT_PULLUP, | ||
28 | PINMUX_TYPE_INPUT_PULLDOWN, | ||
29 | |||
30 | PINMUX_FLAG_TYPE, /* must be last */ | ||
31 | }; | ||
30 | 32 | ||
31 | #define PINMUX_FLAG_DBIT_SHIFT 5 | 33 | #define PINMUX_FLAG_DBIT_SHIFT 5 |
32 | #define PINMUX_FLAG_DBIT (0x1f << PINMUX_FLAG_DBIT_SHIFT) | 34 | #define PINMUX_FLAG_DBIT (0x1f << PINMUX_FLAG_DBIT_SHIFT) |
@@ -36,9 +38,12 @@ typedef unsigned short pinmux_flag_t; | |||
36 | struct pinmux_gpio { | 38 | struct pinmux_gpio { |
37 | pinmux_enum_t enum_id; | 39 | pinmux_enum_t enum_id; |
38 | pinmux_flag_t flags; | 40 | pinmux_flag_t flags; |
41 | const char *name; | ||
39 | }; | 42 | }; |
40 | 43 | ||
41 | #define PINMUX_GPIO(gpio, data_or_mark) [gpio] = { data_or_mark } | 44 | #define PINMUX_GPIO(gpio, data_or_mark) \ |
45 | [gpio] = { .name = __stringify(gpio), .enum_id = data_or_mark, .flags = PINMUX_TYPE_NONE } | ||
46 | |||
42 | #define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0 | 47 | #define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0 |
43 | 48 | ||
44 | struct pinmux_cfg_reg { | 49 | struct pinmux_cfg_reg { |
@@ -89,7 +94,7 @@ struct pfc_window { | |||
89 | unsigned long size; | 94 | unsigned long size; |
90 | }; | 95 | }; |
91 | 96 | ||
92 | struct pinmux_info { | 97 | struct sh_pfc { |
93 | char *name; | 98 | char *name; |
94 | pinmux_enum_t reserved_id; | 99 | pinmux_enum_t reserved_id; |
95 | struct pinmux_range data; | 100 | struct pinmux_range data; |
@@ -112,17 +117,45 @@ struct pinmux_info { | |||
112 | struct pinmux_irq *gpio_irq; | 117 | struct pinmux_irq *gpio_irq; |
113 | unsigned int gpio_irq_size; | 118 | unsigned int gpio_irq_size; |
114 | 119 | ||
120 | spinlock_t lock; | ||
121 | |||
115 | struct resource *resource; | 122 | struct resource *resource; |
116 | unsigned int num_resources; | 123 | unsigned int num_resources; |
117 | struct pfc_window *window; | 124 | struct pfc_window *window; |
118 | 125 | ||
119 | unsigned long unlock_reg; | 126 | unsigned long unlock_reg; |
120 | |||
121 | struct gpio_chip chip; | ||
122 | }; | 127 | }; |
123 | 128 | ||
124 | int register_pinmux(struct pinmux_info *pip); | 129 | /* XXX compat for now */ |
125 | int unregister_pinmux(struct pinmux_info *pip); | 130 | #define pinmux_info sh_pfc |
131 | |||
132 | /* drivers/sh/pfc/gpio.c */ | ||
133 | int sh_pfc_register_gpiochip(struct sh_pfc *pfc); | ||
134 | |||
135 | /* drivers/sh/pfc/pinctrl.c */ | ||
136 | int sh_pfc_register_pinctrl(struct sh_pfc *pfc); | ||
137 | |||
138 | /* drivers/sh/pfc/core.c */ | ||
139 | int register_sh_pfc(struct sh_pfc *pfc); | ||
140 | |||
141 | int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos); | ||
142 | void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, | ||
143 | unsigned long value); | ||
144 | int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, | ||
145 | struct pinmux_data_reg **drp, int *bitp); | ||
146 | int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, | ||
147 | pinmux_enum_t *enum_idp); | ||
148 | int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, | ||
149 | int cfg_mode); | ||
150 | |||
151 | /* xxx */ | ||
152 | static inline int register_pinmux(struct pinmux_info *pip) | ||
153 | { | ||
154 | struct sh_pfc *pfc = pip; | ||
155 | return register_sh_pfc(pfc); | ||
156 | } | ||
157 | |||
158 | enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; | ||
126 | 159 | ||
127 | /* helper macro for port */ | 160 | /* helper macro for port */ |
128 | #define PORT_1(fn, pfx, sfx) fn(pfx, sfx) | 161 | #define PORT_1(fn, pfx, sfx) fn(pfx, sfx) |