Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SuperH Pin Function Controller 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 | |
| 11 | #ifndef __SH_PFC_H |
| 12 | #define __SH_PFC_H |
| 13 | |
Laurent Pinchart | bf9f067 | 2013-04-09 14:06:01 +0000 | [diff] [blame] | 14 | #include <linux/bug.h> |
Paul Mundt | 72c7afa | 2012-07-10 11:59:29 +0900 | [diff] [blame] | 15 | #include <linux/stringify.h> |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 16 | |
Paul Mundt | 06d5631 | 2012-06-21 00:03:41 +0900 | [diff] [blame] | 17 | enum { |
| 18 | PINMUX_TYPE_NONE, |
Paul Mundt | 06d5631 | 2012-06-21 00:03:41 +0900 | [diff] [blame] | 19 | PINMUX_TYPE_FUNCTION, |
| 20 | PINMUX_TYPE_GPIO, |
| 21 | PINMUX_TYPE_OUTPUT, |
| 22 | PINMUX_TYPE_INPUT, |
Paul Mundt | 06d5631 | 2012-06-21 00:03:41 +0900 | [diff] [blame] | 23 | }; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 24 | |
Laurent Pinchart | c58d9c1 | 2013-03-10 16:44:02 +0100 | [diff] [blame] | 25 | #define SH_PFC_PIN_CFG_INPUT (1 << 0) |
| 26 | #define SH_PFC_PIN_CFG_OUTPUT (1 << 1) |
| 27 | #define SH_PFC_PIN_CFG_PULL_UP (1 << 2) |
| 28 | #define SH_PFC_PIN_CFG_PULL_DOWN (1 << 3) |
| 29 | |
Laurent Pinchart | a3db40a | 2013-01-02 14:53:37 +0100 | [diff] [blame] | 30 | struct sh_pfc_pin { |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 31 | u16 enum_id; |
Paul Mundt | 72c7afa | 2012-07-10 11:59:29 +0900 | [diff] [blame] | 32 | const char *name; |
Laurent Pinchart | c58d9c1 | 2013-03-10 16:44:02 +0100 | [diff] [blame] | 33 | unsigned int configs; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
Laurent Pinchart | 3d8d9f1 | 2013-01-03 14:33:13 +0100 | [diff] [blame] | 36 | #define SH_PFC_PIN_GROUP(n) \ |
| 37 | { \ |
| 38 | .name = #n, \ |
| 39 | .pins = n##_pins, \ |
| 40 | .mux = n##_mux, \ |
| 41 | .nr_pins = ARRAY_SIZE(n##_pins), \ |
| 42 | } |
| 43 | |
| 44 | struct sh_pfc_pin_group { |
| 45 | const char *name; |
| 46 | const unsigned int *pins; |
| 47 | const unsigned int *mux; |
| 48 | unsigned int nr_pins; |
| 49 | }; |
| 50 | |
| 51 | #define SH_PFC_FUNCTION(n) \ |
| 52 | { \ |
| 53 | .name = #n, \ |
| 54 | .groups = n##_groups, \ |
| 55 | .nr_groups = ARRAY_SIZE(n##_groups), \ |
| 56 | } |
| 57 | |
| 58 | struct sh_pfc_function { |
| 59 | const char *name; |
| 60 | const char * const *groups; |
| 61 | unsigned int nr_groups; |
| 62 | }; |
| 63 | |
Laurent Pinchart | a373ed0 | 2012-11-29 13:24:07 +0100 | [diff] [blame] | 64 | struct pinmux_func { |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 65 | u16 enum_id; |
Laurent Pinchart | a373ed0 | 2012-11-29 13:24:07 +0100 | [diff] [blame] | 66 | const char *name; |
| 67 | }; |
| 68 | |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 69 | struct pinmux_cfg_reg { |
| 70 | unsigned long reg, reg_width, field_width; |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 71 | const u16 *enum_ids; |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 72 | const unsigned long *var_field_width; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | #define PINMUX_CFG_REG(name, r, r_width, f_width) \ |
| 76 | .reg = r, .reg_width = r_width, .field_width = f_width, \ |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 77 | .enum_ids = (u16 [(r_width / f_width) * (1 << f_width)]) |
Magnus Damm | f78a26f | 2011-12-14 01:01:05 +0900 | [diff] [blame] | 78 | |
| 79 | #define PINMUX_CFG_REG_VAR(name, r, r_width, var_fw0, var_fwn...) \ |
| 80 | .reg = r, .reg_width = r_width, \ |
Magnus Damm | f78a26f | 2011-12-14 01:01:05 +0900 | [diff] [blame] | 81 | .var_field_width = (unsigned long [r_width]) { var_fw0, var_fwn, 0 }, \ |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 82 | .enum_ids = (u16 []) |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 83 | |
| 84 | struct pinmux_data_reg { |
Laurent Pinchart | 51cb226 | 2013-02-16 18:34:32 +0100 | [diff] [blame] | 85 | unsigned long reg, reg_width; |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 86 | const u16 *enum_ids; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | #define PINMUX_DATA_REG(name, r, r_width) \ |
| 90 | .reg = r, .reg_width = r_width, \ |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 91 | .enum_ids = (u16 [r_width]) \ |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 92 | |
Magnus Damm | ad2a8e7 | 2011-09-28 16:50:58 +0900 | [diff] [blame] | 93 | struct pinmux_irq { |
| 94 | int irq; |
Laurent Pinchart | c07f54f | 2013-01-03 14:12:14 +0100 | [diff] [blame] | 95 | unsigned short *gpios; |
Magnus Damm | ad2a8e7 | 2011-09-28 16:50:58 +0900 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | #define PINMUX_IRQ(irq_nr, ids...) \ |
Laurent Pinchart | c07f54f | 2013-01-03 14:12:14 +0100 | [diff] [blame] | 99 | { .irq = irq_nr, .gpios = (unsigned short []) { ids, 0 } } \ |
Magnus Damm | ad2a8e7 | 2011-09-28 16:50:58 +0900 | [diff] [blame] | 100 | |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 101 | struct pinmux_range { |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 102 | u16 begin; |
| 103 | u16 end; |
| 104 | u16 force; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
Laurent Pinchart | c58d9c1 | 2013-03-10 16:44:02 +0100 | [diff] [blame] | 107 | struct sh_pfc; |
| 108 | |
| 109 | struct sh_pfc_soc_operations { |
Laurent Pinchart | 0c15106 | 2013-04-21 20:21:57 +0200 | [diff] [blame] | 110 | int (*init)(struct sh_pfc *pfc); |
| 111 | void (*exit)(struct sh_pfc *pfc); |
Laurent Pinchart | c58d9c1 | 2013-03-10 16:44:02 +0100 | [diff] [blame] | 112 | unsigned int (*get_bias)(struct sh_pfc *pfc, unsigned int pin); |
| 113 | void (*set_bias)(struct sh_pfc *pfc, unsigned int pin, |
| 114 | unsigned int bias); |
| 115 | }; |
| 116 | |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 117 | struct sh_pfc_soc_info { |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 118 | const char *name; |
Laurent Pinchart | c58d9c1 | 2013-03-10 16:44:02 +0100 | [diff] [blame] | 119 | const struct sh_pfc_soc_operations *ops; |
| 120 | |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 121 | struct pinmux_range input; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 122 | struct pinmux_range output; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 123 | struct pinmux_range function; |
| 124 | |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 125 | const struct sh_pfc_pin *pins; |
Laurent Pinchart | caa5bac | 2012-11-29 12:24:51 +0100 | [diff] [blame] | 126 | unsigned int nr_pins; |
Laurent Pinchart | 63d5738 | 2013-02-15 01:33:38 +0100 | [diff] [blame] | 127 | const struct pinmux_range *ranges; |
| 128 | unsigned int nr_ranges; |
Laurent Pinchart | 3d8d9f1 | 2013-01-03 14:33:13 +0100 | [diff] [blame] | 129 | const struct sh_pfc_pin_group *groups; |
| 130 | unsigned int nr_groups; |
| 131 | const struct sh_pfc_function *functions; |
| 132 | unsigned int nr_functions; |
| 133 | |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 134 | const struct pinmux_func *func_gpios; |
Laurent Pinchart | a373ed0 | 2012-11-29 13:24:07 +0100 | [diff] [blame] | 135 | unsigned int nr_func_gpios; |
Laurent Pinchart | d7a7ca5 | 2012-11-28 17:51:00 +0100 | [diff] [blame] | 136 | |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 137 | const struct pinmux_cfg_reg *cfg_regs; |
| 138 | const struct pinmux_data_reg *data_regs; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 139 | |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 140 | const u16 *gpio_data; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 141 | unsigned int gpio_data_size; |
| 142 | |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 143 | const struct pinmux_irq *gpio_irq; |
Magnus Damm | ad2a8e7 | 2011-09-28 16:50:58 +0900 | [diff] [blame] | 144 | unsigned int gpio_irq_size; |
| 145 | |
Magnus Damm | e499ada | 2011-12-14 01:01:14 +0900 | [diff] [blame] | 146 | unsigned long unlock_reg; |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 147 | }; |
| 148 | |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 149 | /* ----------------------------------------------------------------------------- |
| 150 | * Helper macros to create pin and port lists |
| 151 | */ |
| 152 | |
| 153 | /* |
| 154 | * sh_pfc_soc_info gpio_data array macros |
| 155 | */ |
| 156 | |
| 157 | #define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0 |
| 158 | |
| 159 | #define PINMUX_IPSR_NOGP(ispr, fn) \ |
| 160 | PINMUX_DATA(fn##_MARK, FN_##fn) |
| 161 | #define PINMUX_IPSR_DATA(ipsr, fn) \ |
| 162 | PINMUX_DATA(fn##_MARK, FN_##fn, FN_##ipsr) |
| 163 | #define PINMUX_IPSR_NOGM(ispr, fn, ms) \ |
| 164 | PINMUX_DATA(fn##_MARK, FN_##fn, FN_##ms) |
| 165 | #define PINMUX_IPSR_MSEL(ipsr, fn, ms) \ |
| 166 | PINMUX_DATA(fn##_MARK, FN_##fn, FN_##ipsr, FN_##ms) |
| 167 | #define PINMUX_IPSR_MODSEL_DATA(ipsr, fn, ms) \ |
| 168 | PINMUX_DATA(fn##_MARK, FN_##ms, FN_##ipsr, FN_##fn) |
| 169 | |
| 170 | /* |
| 171 | * GP port style (32 ports banks) |
| 172 | */ |
| 173 | |
| 174 | #define PORT_GP_1(bank, pin, fn, sfx) fn(bank, pin, GP_##bank##_##pin, sfx) |
| 175 | |
| 176 | #define PORT_GP_32(bank, fn, sfx) \ |
| 177 | PORT_GP_1(bank, 0, fn, sfx), PORT_GP_1(bank, 1, fn, sfx), \ |
| 178 | PORT_GP_1(bank, 2, fn, sfx), PORT_GP_1(bank, 3, fn, sfx), \ |
| 179 | PORT_GP_1(bank, 4, fn, sfx), PORT_GP_1(bank, 5, fn, sfx), \ |
| 180 | PORT_GP_1(bank, 6, fn, sfx), PORT_GP_1(bank, 7, fn, sfx), \ |
| 181 | PORT_GP_1(bank, 8, fn, sfx), PORT_GP_1(bank, 9, fn, sfx), \ |
| 182 | PORT_GP_1(bank, 10, fn, sfx), PORT_GP_1(bank, 11, fn, sfx), \ |
| 183 | PORT_GP_1(bank, 12, fn, sfx), PORT_GP_1(bank, 13, fn, sfx), \ |
| 184 | PORT_GP_1(bank, 14, fn, sfx), PORT_GP_1(bank, 15, fn, sfx), \ |
| 185 | PORT_GP_1(bank, 16, fn, sfx), PORT_GP_1(bank, 17, fn, sfx), \ |
| 186 | PORT_GP_1(bank, 18, fn, sfx), PORT_GP_1(bank, 19, fn, sfx), \ |
| 187 | PORT_GP_1(bank, 20, fn, sfx), PORT_GP_1(bank, 21, fn, sfx), \ |
| 188 | PORT_GP_1(bank, 22, fn, sfx), PORT_GP_1(bank, 23, fn, sfx), \ |
| 189 | PORT_GP_1(bank, 24, fn, sfx), PORT_GP_1(bank, 25, fn, sfx), \ |
| 190 | PORT_GP_1(bank, 26, fn, sfx), PORT_GP_1(bank, 27, fn, sfx), \ |
| 191 | PORT_GP_1(bank, 28, fn, sfx), PORT_GP_1(bank, 29, fn, sfx), \ |
| 192 | PORT_GP_1(bank, 30, fn, sfx), PORT_GP_1(bank, 31, fn, sfx) |
| 193 | |
| 194 | #define PORT_GP_32_REV(bank, fn, sfx) \ |
| 195 | PORT_GP_1(bank, 31, fn, sfx), PORT_GP_1(bank, 30, fn, sfx), \ |
| 196 | PORT_GP_1(bank, 29, fn, sfx), PORT_GP_1(bank, 28, fn, sfx), \ |
| 197 | PORT_GP_1(bank, 27, fn, sfx), PORT_GP_1(bank, 26, fn, sfx), \ |
| 198 | PORT_GP_1(bank, 25, fn, sfx), PORT_GP_1(bank, 24, fn, sfx), \ |
| 199 | PORT_GP_1(bank, 23, fn, sfx), PORT_GP_1(bank, 22, fn, sfx), \ |
| 200 | PORT_GP_1(bank, 21, fn, sfx), PORT_GP_1(bank, 20, fn, sfx), \ |
| 201 | PORT_GP_1(bank, 19, fn, sfx), PORT_GP_1(bank, 18, fn, sfx), \ |
| 202 | PORT_GP_1(bank, 17, fn, sfx), PORT_GP_1(bank, 16, fn, sfx), \ |
| 203 | PORT_GP_1(bank, 15, fn, sfx), PORT_GP_1(bank, 14, fn, sfx), \ |
| 204 | PORT_GP_1(bank, 13, fn, sfx), PORT_GP_1(bank, 12, fn, sfx), \ |
| 205 | PORT_GP_1(bank, 11, fn, sfx), PORT_GP_1(bank, 10, fn, sfx), \ |
| 206 | PORT_GP_1(bank, 9, fn, sfx), PORT_GP_1(bank, 8, fn, sfx), \ |
| 207 | PORT_GP_1(bank, 7, fn, sfx), PORT_GP_1(bank, 6, fn, sfx), \ |
| 208 | PORT_GP_1(bank, 5, fn, sfx), PORT_GP_1(bank, 4, fn, sfx), \ |
| 209 | PORT_GP_1(bank, 3, fn, sfx), PORT_GP_1(bank, 2, fn, sfx), \ |
| 210 | PORT_GP_1(bank, 1, fn, sfx), PORT_GP_1(bank, 0, fn, sfx) |
| 211 | |
| 212 | /* GP_ALL(suffix) - Expand to a list of GP_#_#_suffix */ |
| 213 | #define _GP_ALL(bank, pin, name, sfx) name##_##sfx |
| 214 | #define GP_ALL(str) CPU_ALL_PORT(_GP_ALL, str) |
| 215 | |
| 216 | /* PINMUX_GPIO_GP_ALL - Expand to a list of sh_pfc_pin entries */ |
| 217 | #define _GP_GPIO(bank, pin, _name, sfx) \ |
| 218 | [(bank * 32) + pin] = { \ |
| 219 | .name = __stringify(_name), \ |
| 220 | .enum_id = _name##_DATA, \ |
| 221 | } |
| 222 | #define PINMUX_GPIO_GP_ALL() CPU_ALL_PORT(_GP_GPIO, unused) |
| 223 | |
| 224 | /* PINMUX_DATA_GP_ALL - Expand to a list of name_DATA, name_FN marks */ |
| 225 | #define _GP_DATA(bank, pin, name, sfx) PINMUX_DATA(name##_DATA, name##_FN) |
| 226 | #define PINMUX_DATA_GP_ALL() CPU_ALL_PORT(_GP_DATA, unused) |
| 227 | |
| 228 | /* |
| 229 | * PORT style (linear pin space) |
| 230 | */ |
| 231 | |
Kuninori Morimoto | 972c3fb | 2011-11-10 18:45:33 -0800 | [diff] [blame] | 232 | #define PORT_1(fn, pfx, sfx) fn(pfx, sfx) |
| 233 | |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 234 | #define PORT_10(fn, pfx, sfx) \ |
| 235 | PORT_1(fn, pfx##0, sfx), PORT_1(fn, pfx##1, sfx), \ |
| 236 | PORT_1(fn, pfx##2, sfx), PORT_1(fn, pfx##3, sfx), \ |
| 237 | PORT_1(fn, pfx##4, sfx), PORT_1(fn, pfx##5, sfx), \ |
| 238 | PORT_1(fn, pfx##6, sfx), PORT_1(fn, pfx##7, sfx), \ |
Kuninori Morimoto | 972c3fb | 2011-11-10 18:45:33 -0800 | [diff] [blame] | 239 | PORT_1(fn, pfx##8, sfx), PORT_1(fn, pfx##9, sfx) |
| 240 | |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 241 | #define PORT_10_REV(fn, pfx, sfx) \ |
| 242 | PORT_1(fn, pfx##9, sfx), PORT_1(fn, pfx##8, sfx), \ |
| 243 | PORT_1(fn, pfx##7, sfx), PORT_1(fn, pfx##6, sfx), \ |
| 244 | PORT_1(fn, pfx##5, sfx), PORT_1(fn, pfx##4, sfx), \ |
| 245 | PORT_1(fn, pfx##3, sfx), PORT_1(fn, pfx##2, sfx), \ |
Laurent Pinchart | 17dffe4 | 2013-02-13 22:09:27 +0100 | [diff] [blame] | 246 | PORT_1(fn, pfx##1, sfx), PORT_1(fn, pfx##0, sfx) |
| 247 | |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 248 | #define PORT_32(fn, pfx, sfx) \ |
| 249 | PORT_10(fn, pfx, sfx), PORT_10(fn, pfx##1, sfx), \ |
| 250 | PORT_10(fn, pfx##2, sfx), PORT_1(fn, pfx##30, sfx), \ |
Laurent Pinchart | 17dffe4 | 2013-02-13 22:09:27 +0100 | [diff] [blame] | 251 | PORT_1(fn, pfx##31, sfx) |
| 252 | |
| 253 | #define PORT_32_REV(fn, pfx, sfx) \ |
| 254 | PORT_1(fn, pfx##31, sfx), PORT_1(fn, pfx##30, sfx), \ |
| 255 | PORT_10_REV(fn, pfx##2, sfx), PORT_10_REV(fn, pfx##1, sfx), \ |
| 256 | PORT_10_REV(fn, pfx, sfx) |
| 257 | |
Kuninori Morimoto | 972c3fb | 2011-11-10 18:45:33 -0800 | [diff] [blame] | 258 | #define PORT_90(fn, pfx, sfx) \ |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 259 | PORT_10(fn, pfx##1, sfx), PORT_10(fn, pfx##2, sfx), \ |
| 260 | PORT_10(fn, pfx##3, sfx), PORT_10(fn, pfx##4, sfx), \ |
| 261 | PORT_10(fn, pfx##5, sfx), PORT_10(fn, pfx##6, sfx), \ |
| 262 | PORT_10(fn, pfx##7, sfx), PORT_10(fn, pfx##8, sfx), \ |
Kuninori Morimoto | 972c3fb | 2011-11-10 18:45:33 -0800 | [diff] [blame] | 263 | PORT_10(fn, pfx##9, sfx) |
| 264 | |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 265 | /* PORT_ALL(suffix) - Expand to a list of PORT_#_suffix */ |
| 266 | #define _PORT_ALL(pfx, sfx) pfx##_##sfx |
| 267 | #define PORT_ALL(str) CPU_ALL_PORT(_PORT_ALL, PORT, str) |
Kuninori Morimoto | 972c3fb | 2011-11-10 18:45:33 -0800 | [diff] [blame] | 268 | |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 269 | /* PINMUX_GPIO - Expand to a sh_pfc_pin entry */ |
| 270 | #define PINMUX_GPIO(gpio, data_or_mark) \ |
| 271 | [gpio] = { \ |
| 272 | .name = __stringify(gpio), \ |
| 273 | .enum_id = data_or_mark, \ |
| 274 | } |
Kuninori Morimoto | bd8d0cba | 2011-11-10 18:45:23 -0800 | [diff] [blame] | 275 | |
Laurent Pinchart | e3d93b4 | 2013-07-15 15:14:22 +0200 | [diff] [blame^] | 276 | /* PINMUX_DATA_ALL - Expand to a list of PORT_name_DATA, PORT_name_FN0, |
| 277 | * PORT_name_OUT, PORT_name_IN marks |
| 278 | */ |
| 279 | #define _PORT_DATA(pfx, sfx) \ |
| 280 | PINMUX_DATA(PORT##pfx##_DATA, PORT##pfx##_FN0, \ |
| 281 | PORT##pfx##_OUT, PORT##pfx##_IN) |
| 282 | #define PINMUX_DATA_ALL() CPU_ALL_PORT(_PORT_DATA, , unused) |
| 283 | |
| 284 | /* GPIO_FN(name) - Expand to a sh_pfc_pin entry for a function GPIO */ |
| 285 | #define PINMUX_GPIO_FN(gpio, base, data_or_mark) \ |
| 286 | [gpio - (base)] = { \ |
| 287 | .name = __stringify(gpio), \ |
| 288 | .enum_id = data_or_mark, \ |
| 289 | } |
| 290 | #define GPIO_FN(str) \ |
| 291 | PINMUX_GPIO_FN(GPIO_FN_##str, PINMUX_FN_BASE, str##_MARK) |
| 292 | |
| 293 | /* |
| 294 | * PORTnCR macro |
| 295 | */ |
Kuninori Morimoto | 9b49139 | 2011-11-10 18:45:43 -0800 | [diff] [blame] | 296 | #define _PCRH(in, in_pd, in_pu, out) \ |
| 297 | 0, (out), (in), 0, \ |
| 298 | 0, 0, 0, 0, \ |
| 299 | 0, 0, (in_pd), 0, \ |
| 300 | 0, 0, (in_pu), 0 |
| 301 | |
| 302 | #define PORTCR(nr, reg) \ |
| 303 | { \ |
| 304 | PINMUX_CFG_REG("PORT" nr "CR", reg, 8, 4) { \ |
| 305 | _PCRH(PORT##nr##_IN, PORT##nr##_IN_PD, \ |
| 306 | PORT##nr##_IN_PU, PORT##nr##_OUT), \ |
| 307 | PORT##nr##_FN0, PORT##nr##_FN1, \ |
| 308 | PORT##nr##_FN2, PORT##nr##_FN3, \ |
| 309 | PORT##nr##_FN4, PORT##nr##_FN5, \ |
| 310 | PORT##nr##_FN6, PORT##nr##_FN7 } \ |
| 311 | } |
Kuninori Morimoto | bd8d0cba | 2011-11-10 18:45:23 -0800 | [diff] [blame] | 312 | |
Magnus Damm | fae4339 | 2009-11-27 07:38:01 +0000 | [diff] [blame] | 313 | #endif /* __SH_PFC_H */ |