diff options
| -rw-r--r-- | drivers/pinctrl/aspeed/pinctrl-aspeed.h | 498 |
1 files changed, 0 insertions, 498 deletions
diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed.h b/drivers/pinctrl/aspeed/pinctrl-aspeed.h index b7790395aead..7fcfc5004b44 100644 --- a/drivers/pinctrl/aspeed/pinctrl-aspeed.h +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed.h | |||
| @@ -18,504 +18,6 @@ | |||
| 18 | 18 | ||
| 19 | #include "pinmux-aspeed.h" | 19 | #include "pinmux-aspeed.h" |
| 20 | 20 | ||
| 21 | /* | ||
| 22 | * The ASPEED SoCs provide typically more than 200 pins for GPIO and other | ||
| 23 | * functions. The SoC function enabled on a pin is determined on a priority | ||
| 24 | * basis where a given pin can provide a number of different signal types. | ||
| 25 | * | ||
| 26 | * The signal active on a pin is described by both a priority level and | ||
| 27 | * compound logical expressions involving multiple operators, registers and | ||
| 28 | * bits. Some difficulty arises as the pin's function bit masks for each | ||
| 29 | * priority level are frequently not the same (i.e. cannot just flip a bit to | ||
| 30 | * change from a high to low priority signal), or even in the same register. | ||
| 31 | * Further, not all signals can be unmuxed, as some expressions depend on | ||
| 32 | * values in the hardware strapping register (which is treated as read-only). | ||
| 33 | * | ||
| 34 | * SoC Multi-function Pin Expression Examples | ||
| 35 | * ------------------------------------------ | ||
| 36 | * | ||
| 37 | * Here are some sample mux configurations from the AST2400 and AST2500 | ||
| 38 | * datasheets to illustrate the corner cases, roughly in order of least to most | ||
| 39 | * corner. The signal priorities are in decending order from P0 (highest). | ||
| 40 | * | ||
| 41 | * D6 is a pin with a single function (beside GPIO); a high priority signal | ||
| 42 | * that participates in one function: | ||
| 43 | * | ||
| 44 | * Ball | Default | P0 Signal | P0 Expression | P1 Signal | P1 Expression | Other | ||
| 45 | * -----+---------+-----------+-----------------------------+-----------+---------------+---------- | ||
| 46 | * D6 GPIOA0 MAC1LINK SCU80[0]=1 GPIOA0 | ||
| 47 | * -----+---------+-----------+-----------------------------+-----------+---------------+---------- | ||
| 48 | * | ||
| 49 | * C5 is a multi-signal pin (high and low priority signals). Here we touch | ||
| 50 | * different registers for the different functions that enable each signal: | ||
| 51 | * | ||
| 52 | * -----+---------+-----------+-----------------------------+-----------+---------------+---------- | ||
| 53 | * C5 GPIOA4 SCL9 SCU90[22]=1 TIMER5 SCU80[4]=1 GPIOA4 | ||
| 54 | * -----+---------+-----------+-----------------------------+-----------+---------------+---------- | ||
| 55 | * | ||
| 56 | * E19 is a single-signal pin with two functions that influence the active | ||
| 57 | * signal. In this case both bits have the same meaning - enable a dedicated | ||
| 58 | * LPC reset pin. However it's not always the case that the bits in the | ||
| 59 | * OR-relationship have the same meaning. | ||
| 60 | * | ||
| 61 | * -----+---------+-----------+-----------------------------+-----------+---------------+---------- | ||
| 62 | * E19 GPIOB4 LPCRST# SCU80[12]=1 | Strap[14]=1 GPIOB4 | ||
| 63 | * -----+---------+-----------+-----------------------------+-----------+---------------+---------- | ||
| 64 | * | ||
| 65 | * For example, pin B19 has a low-priority signal that's enabled by two | ||
| 66 | * distinct SoC functions: A specific SIOPBI bit in register SCUA4, and an ACPI | ||
| 67 | * bit in the STRAP register. The ACPI bit configures signals on pins in | ||
| 68 | * addition to B19. Both of the low priority functions as well as the high | ||
| 69 | * priority function must be disabled for GPIOF1 to be used. | ||
| 70 | * | ||
| 71 | * Ball | Default | P0 Signal | P0 Expression | P1 Signal | P1 Expression | Other | ||
| 72 | * -----+---------+-----------+-----------------------------------------+-----------+----------------------------------------+---------- | ||
| 73 | * B19 GPIOF1 NDCD4 SCU80[25]=1 SIOPBI# SCUA4[12]=1 | Strap[19]=0 GPIOF1 | ||
| 74 | * -----+---------+-----------+-----------------------------------------+-----------+----------------------------------------+---------- | ||
| 75 | * | ||
| 76 | * For pin E18, the SoC ANDs the expected state of three bits to determine the | ||
| 77 | * pin's active signal: | ||
| 78 | * | ||
| 79 | * * SCU3C[3]: Enable external SOC reset function | ||
| 80 | * * SCU80[15]: Enable SPICS1# or EXTRST# function pin | ||
| 81 | * * SCU90[31]: Select SPI interface CS# output | ||
| 82 | * | ||
| 83 | * -----+---------+-----------+-----------------------------------------+-----------+----------------------------------------+---------- | ||
| 84 | * E18 GPIOB7 EXTRST# SCU3C[3]=1 & SCU80[15]=1 & SCU90[31]=0 SPICS1# SCU3C[3]=1 & SCU80[15]=1 & SCU90[31]=1 GPIOB7 | ||
| 85 | * -----+---------+-----------+-----------------------------------------+-----------+----------------------------------------+---------- | ||
| 86 | * | ||
| 87 | * (Bits SCU3C[3] and SCU80[15] appear to only be used in the expressions for | ||
| 88 | * selecting the signals on pin E18) | ||
| 89 | * | ||
| 90 | * Pin T5 is a multi-signal pin with a more complex configuration: | ||
| 91 | * | ||
| 92 | * Ball | Default | P0 Signal | P0 Expression | P1 Signal | P1 Expression | Other | ||
| 93 | * -----+---------+-----------+------------------------------+-----------+---------------+---------- | ||
| 94 | * T5 GPIOL1 VPIDE SCU90[5:4]!=0 & SCU84[17]=1 NDCD1 SCU84[17]=1 GPIOL1 | ||
| 95 | * -----+---------+-----------+------------------------------+-----------+---------------+---------- | ||
| 96 | * | ||
| 97 | * The high priority signal configuration is best thought of in terms of its | ||
| 98 | * exploded form, with reference to the SCU90[5:4] bits: | ||
| 99 | * | ||
| 100 | * * SCU90[5:4]=00: disable | ||
| 101 | * * SCU90[5:4]=01: 18 bits (R6/G6/B6) video mode. | ||
| 102 | * * SCU90[5:4]=10: 24 bits (R8/G8/B8) video mode. | ||
| 103 | * * SCU90[5:4]=11: 30 bits (R10/G10/B10) video mode. | ||
| 104 | * | ||
| 105 | * Re-writing: | ||
| 106 | * | ||
| 107 | * -----+---------+-----------+------------------------------+-----------+---------------+---------- | ||
| 108 | * T5 GPIOL1 VPIDE (SCU90[5:4]=1 & SCU84[17]=1) NDCD1 SCU84[17]=1 GPIOL1 | ||
| 109 | * | (SCU90[5:4]=2 & SCU84[17]=1) | ||
| 110 | * | (SCU90[5:4]=3 & SCU84[17]=1) | ||
| 111 | * -----+---------+-----------+------------------------------+-----------+---------------+---------- | ||
| 112 | * | ||
| 113 | * For reference the SCU84[17] bit configure the "UART1 NDCD1 or Video VPIDE | ||
| 114 | * function pin", where the signal itself is determined by whether SCU94[5:4] | ||
| 115 | * is disabled or in one of the 18, 24 or 30bit video modes. | ||
| 116 | * | ||
| 117 | * Other video-input-related pins require an explicit state in SCU90[5:4], e.g. | ||
| 118 | * W1 and U5: | ||
| 119 | * | ||
| 120 | * -----+---------+-----------+------------------------------+-----------+---------------+---------- | ||
| 121 | * W1 GPIOL6 VPIB0 SCU90[5:4]=3 & SCU84[22]=1 TXD1 SCU84[22]=1 GPIOL6 | ||
| 122 | * U5 GPIOL7 VPIB1 SCU90[5:4]=3 & SCU84[23]=1 RXD1 SCU84[23]=1 GPIOL7 | ||
| 123 | * -----+---------+-----------+------------------------------+-----------+---------------+---------- | ||
| 124 | * | ||
| 125 | * The examples of T5 and W1 are particularly fertile, as they also demonstrate | ||
| 126 | * that despite operating as part of the video input bus each signal needs to | ||
| 127 | * be enabled individually via it's own SCU84 (in the cases of T5 and W1) | ||
| 128 | * register bit. This is a little crazy if the bus doesn't have optional | ||
| 129 | * signals, but is used to decent effect with some of the UARTs where not all | ||
| 130 | * signals are required. However, this isn't done consistently - UART1 is | ||
| 131 | * enabled on a per-pin basis, and by contrast, all signals for UART6 are | ||
| 132 | * enabled by a single bit. | ||
| 133 | * | ||
| 134 | * Further, the high and low priority signals listed in the table above share | ||
| 135 | * a configuration bit. The VPI signals should operate in concert in a single | ||
| 136 | * function, but the UART signals should retain the ability to be configured | ||
| 137 | * independently. This pushes the implementation down the path of tagging a | ||
| 138 | * signal's expressions with the function they participate in, rather than | ||
| 139 | * defining masks affecting multiple signals per function. The latter approach | ||
| 140 | * fails in this instance where applying the configuration for the UART pin of | ||
| 141 | * interest will stomp on the state of other UART signals when disabling the | ||
| 142 | * VPI functions on the current pin. | ||
| 143 | * | ||
| 144 | * Ball | Default | P0 Signal | P0 Expression | P1 Signal | P1 Expression | Other | ||
| 145 | * -----+------------+-----------+---------------------------+-----------+---------------+------------ | ||
| 146 | * A12 RGMII1TXCK GPIOT0 SCUA0[0]=1 RMII1TXEN Strap[6]=0 RGMII1TXCK | ||
| 147 | * B12 RGMII1TXCTL GPIOT1 SCUA0[1]=1 – Strap[6]=0 RGMII1TXCTL | ||
| 148 | * -----+------------+-----------+---------------------------+-----------+---------------+------------ | ||
| 149 | * | ||
| 150 | * A12 demonstrates that the "Other" signal isn't always GPIO - in this case | ||
| 151 | * GPIOT0 is a high-priority signal and RGMII1TXCK is Other. Thus, GPIO | ||
| 152 | * should be treated like any other signal type with full function expression | ||
| 153 | * requirements, and not assumed to be the default case. Separately, GPIOT0 and | ||
| 154 | * GPIOT1's signal descriptor bits are distinct, therefore we must iterate all | ||
| 155 | * pins in the function's group to disable the higher-priority signals such | ||
| 156 | * that the signal for the function of interest is correctly enabled. | ||
| 157 | * | ||
| 158 | * Finally, three priority levels aren't always enough; the AST2500 brings with | ||
| 159 | * it 18 pins of five priority levels, however the 18 pins only use three of | ||
| 160 | * the five priority levels. | ||
| 161 | * | ||
| 162 | * Ultimately the requirement to control pins in the examples above drive the | ||
| 163 | * design: | ||
| 164 | * | ||
| 165 | * * Pins provide signals according to functions activated in the mux | ||
| 166 | * configuration | ||
| 167 | * | ||
| 168 | * * Pins provide up to five signal types in a priority order | ||
| 169 | * | ||
| 170 | * * For priorities levels defined on a pin, each priority provides one signal | ||
| 171 | * | ||
| 172 | * * Enabling lower priority signals requires higher priority signals be | ||
| 173 | * disabled | ||
| 174 | * | ||
| 175 | * * A function represents a set of signals; functions are distinct if their | ||
| 176 | * sets of signals are not equal | ||
| 177 | * | ||
| 178 | * * Signals participate in one or more functions | ||
| 179 | * | ||
| 180 | * * A function is described by an expression of one or more signal | ||
| 181 | * descriptors, which compare bit values in a register | ||
| 182 | * | ||
| 183 | * * A signal expression is the smallest set of signal descriptors whose | ||
| 184 | * comparisons must evaluate 'true' for a signal to be enabled on a pin. | ||
| 185 | * | ||
| 186 | * * A function's signal is active on a pin if evaluating all signal | ||
| 187 | * descriptors in the pin's signal expression for the function yields a 'true' | ||
| 188 | * result | ||
| 189 | * | ||
| 190 | * * A signal at a given priority on a given pin is active if any of the | ||
| 191 | * functions in which the signal participates are active, and no higher | ||
| 192 | * priority signal on the pin is active | ||
| 193 | * | ||
| 194 | * * GPIO is configured per-pin | ||
| 195 | * | ||
| 196 | * And so: | ||
| 197 | * | ||
| 198 | * * To disable a signal, any function(s) activating the signal must be | ||
| 199 | * disabled | ||
| 200 | * | ||
| 201 | * * Each pin must know the signal expressions of functions in which it | ||
| 202 | * participates, for the purpose of enabling the Other function. This is done | ||
| 203 | * by deactivating all functions that activate higher priority signals on the | ||
| 204 | * pin. | ||
| 205 | * | ||
| 206 | * As a concrete example: | ||
| 207 | * | ||
| 208 | * * T5 provides three signals types: VPIDE, NDCD1 and GPIO | ||
| 209 | * | ||
| 210 | * * The VPIDE signal participates in 3 functions: VPI18, VPI24 and VPI30 | ||
| 211 | * | ||
| 212 | * * The NDCD1 signal participates in just its own NDCD1 function | ||
| 213 | * | ||
| 214 | * * VPIDE is high priority, NDCD1 is low priority, and GPIOL1 is the least | ||
| 215 | * prioritised | ||
| 216 | * | ||
| 217 | * * The prerequisit for activating the NDCD1 signal is that the VPI18, VPI24 | ||
| 218 | * and VPI30 functions all be disabled | ||
| 219 | * | ||
| 220 | * * Similarly, all of VPI18, VPI24, VPI30 and NDCD1 functions must be disabled | ||
| 221 | * to provide GPIOL6 | ||
| 222 | * | ||
| 223 | * Considerations | ||
| 224 | * -------------- | ||
| 225 | * | ||
| 226 | * If pinctrl allows us to allocate a pin we can configure a function without | ||
| 227 | * concern for the function of already allocated pins, if pin groups are | ||
| 228 | * created with respect to the SoC functions in which they participate. This is | ||
| 229 | * intuitive, but it did not feel obvious from the bit/pin relationships. | ||
| 230 | * | ||
| 231 | * Conversely, failing to allocate all pins in a group indicates some bits (as | ||
| 232 | * well as pins) required for the group's configuration will already be in use, | ||
| 233 | * likely in a way that's inconsistent with the requirements of the failed | ||
| 234 | * group. | ||
| 235 | */ | ||
| 236 | |||
| 237 | #define ASPEED_IP_SCU 0 | ||
| 238 | #define ASPEED_IP_GFX 1 | ||
| 239 | #define ASPEED_IP_LPC 2 | ||
| 240 | #define ASPEED_NR_PINMUX_IPS 3 | ||
| 241 | |||
| 242 | /* | ||
| 243 | * The "Multi-function Pins Mapping and Control" table in the SoC datasheet | ||
| 244 | * references registers by the device/offset mnemonic. The register macros | ||
| 245 | * below are named the same way to ease transcription and verification (as | ||
| 246 | * opposed to naming them e.g. PINMUX_CTRL_[0-9]). Further, signal expressions | ||
| 247 | * reference registers beyond those dedicated to pinmux, such as the system | ||
| 248 | * reset control and MAC clock configuration registers. The AST2500 goes a step | ||
| 249 | * further and references registers in the graphics IP block. | ||
| 250 | */ | ||
| 251 | #define SCU2C 0x2C /* Misc. Control Register */ | ||
| 252 | #define SCU3C 0x3C /* System Reset Control/Status Register */ | ||
| 253 | #define SCU48 0x48 /* MAC Interface Clock Delay Setting */ | ||
| 254 | #define HW_STRAP1 0x70 /* AST2400 strapping is 33 bits, is split */ | ||
| 255 | #define HW_REVISION_ID 0x7C /* Silicon revision ID register */ | ||
| 256 | #define SCU80 0x80 /* Multi-function Pin Control #1 */ | ||
| 257 | #define SCU84 0x84 /* Multi-function Pin Control #2 */ | ||
| 258 | #define SCU88 0x88 /* Multi-function Pin Control #3 */ | ||
| 259 | #define SCU8C 0x8C /* Multi-function Pin Control #4 */ | ||
| 260 | #define SCU90 0x90 /* Multi-function Pin Control #5 */ | ||
| 261 | #define SCU94 0x94 /* Multi-function Pin Control #6 */ | ||
| 262 | #define SCUA0 0xA0 /* Multi-function Pin Control #7 */ | ||
| 263 | #define SCUA4 0xA4 /* Multi-function Pin Control #8 */ | ||
| 264 | #define SCUA8 0xA8 /* Multi-function Pin Control #9 */ | ||
| 265 | #define SCUAC 0xAC /* Multi-function Pin Control #10 */ | ||
| 266 | #define HW_STRAP2 0xD0 /* Strapping */ | ||
| 267 | |||
| 268 | /** | ||
| 269 | * A signal descriptor, which describes the register, bits and the | ||
| 270 | * enable/disable values that should be compared or written. | ||
| 271 | * | ||
| 272 | * @ip: The IP block identifier, used as an index into the regmap array in | ||
| 273 | * struct aspeed_pinctrl_data | ||
| 274 | * @reg: The register offset with respect to the base address of the IP block | ||
| 275 | * @mask: The mask to apply to the register. The lowest set bit of the mask is | ||
| 276 | * used to derive the shift value. | ||
| 277 | * @enable: The value that enables the function. Value should be in the LSBs, | ||
| 278 | * not at the position of the mask. | ||
| 279 | * @disable: The value that disables the function. Value should be in the | ||
| 280 | * LSBs, not at the position of the mask. | ||
| 281 | */ | ||
| 282 | struct aspeed_sig_desc { | ||
| 283 | unsigned int ip; | ||
| 284 | unsigned int reg; | ||
| 285 | u32 mask; | ||
| 286 | u32 enable; | ||
| 287 | u32 disable; | ||
| 288 | }; | ||
| 289 | |||
| 290 | /** | ||
| 291 | * Describes a signal expression. The expression is evaluated by ANDing the | ||
| 292 | * evaluation of the descriptors. | ||
| 293 | * | ||
| 294 | * @signal: The signal name for the priority level on the pin. If the signal | ||
| 295 | * type is GPIO, then the signal name must begin with the string | ||
| 296 | * "GPIO", e.g. GPIOA0, GPIOT4 etc. | ||
| 297 | * @function: The name of the function the signal participates in for the | ||
| 298 | * associated expression | ||
| 299 | * @ndescs: The number of signal descriptors in the expression | ||
| 300 | * @descs: Pointer to an array of signal descriptors that comprise the | ||
| 301 | * function expression | ||
| 302 | */ | ||
| 303 | struct aspeed_sig_expr { | ||
| 304 | const char *signal; | ||
| 305 | const char *function; | ||
| 306 | int ndescs; | ||
| 307 | const struct aspeed_sig_desc *descs; | ||
| 308 | }; | ||
| 309 | |||
| 310 | /** | ||
| 311 | * A struct capturing the list of expressions enabling signals at each priority | ||
| 312 | * for a given pin. The signal configuration for a priority level is evaluated | ||
| 313 | * by ORing the evaluation of the signal expressions in the respective | ||
| 314 | * priority's list. | ||
| 315 | * | ||
| 316 | * @name: A name for the pin | ||
| 317 | * @prios: A pointer to an array of expression list pointers | ||
| 318 | * | ||
| 319 | */ | ||
| 320 | struct aspeed_pin_desc { | ||
| 321 | const char *name; | ||
| 322 | const struct aspeed_sig_expr ***prios; | ||
| 323 | }; | ||
| 324 | |||
| 325 | /* Macro hell */ | ||
| 326 | |||
| 327 | #define SIG_DESC_IP_BIT(ip, reg, idx, val) \ | ||
| 328 | { ip, reg, BIT_MASK(idx), val, (((val) + 1) & 1) } | ||
| 329 | |||
| 330 | /** | ||
| 331 | * Short-hand macro for describing an SCU descriptor enabled by the state of | ||
| 332 | * one bit. The disable value is derived. | ||
| 333 | * | ||
| 334 | * @reg: The signal's associated register, offset from base | ||
| 335 | * @idx: The signal's bit index in the register | ||
| 336 | * @val: The value (0 or 1) that enables the function | ||
| 337 | */ | ||
| 338 | #define SIG_DESC_BIT(reg, idx, val) \ | ||
| 339 | SIG_DESC_IP_BIT(ASPEED_IP_SCU, reg, idx, val) | ||
| 340 | |||
| 341 | #define SIG_DESC_IP_SET(ip, reg, idx) SIG_DESC_IP_BIT(ip, reg, idx, 1) | ||
| 342 | |||
| 343 | /** | ||
| 344 | * A further short-hand macro expanding to an SCU descriptor enabled by a set | ||
| 345 | * bit. | ||
| 346 | * | ||
| 347 | * @reg: The register, offset from base | ||
| 348 | * @idx: The bit index in the register | ||
| 349 | */ | ||
| 350 | #define SIG_DESC_SET(reg, idx) SIG_DESC_IP_BIT(ASPEED_IP_SCU, reg, idx, 1) | ||
| 351 | |||
| 352 | #define SIG_DESC_LIST_SYM(sig, func) sig_descs_ ## sig ## _ ## func | ||
| 353 | #define SIG_DESC_LIST_DECL(sig, func, ...) \ | ||
| 354 | static const struct aspeed_sig_desc SIG_DESC_LIST_SYM(sig, func)[] = \ | ||
| 355 | { __VA_ARGS__ } | ||
| 356 | |||
| 357 | #define SIG_EXPR_SYM(sig, func) sig_expr_ ## sig ## _ ## func | ||
| 358 | #define SIG_EXPR_DECL_(sig, func) \ | ||
| 359 | static const struct aspeed_sig_expr SIG_EXPR_SYM(sig, func) = \ | ||
| 360 | { \ | ||
| 361 | .signal = #sig, \ | ||
| 362 | .function = #func, \ | ||
| 363 | .ndescs = ARRAY_SIZE(SIG_DESC_LIST_SYM(sig, func)), \ | ||
| 364 | .descs = &(SIG_DESC_LIST_SYM(sig, func))[0], \ | ||
| 365 | } | ||
| 366 | |||
| 367 | /** | ||
| 368 | * Declare a signal expression. | ||
| 369 | * | ||
| 370 | * @sig: A macro symbol name for the signal (is subjected to stringification | ||
| 371 | * and token pasting) | ||
| 372 | * @func: The function in which the signal is participating | ||
| 373 | * @...: Signal descriptors that define the signal expression | ||
| 374 | * | ||
| 375 | * For example, the following declares the ROMD8 signal for the ROM16 function: | ||
| 376 | * | ||
| 377 | * SIG_EXPR_DECL(ROMD8, ROM16, SIG_DESC_SET(SCU90, 6)); | ||
| 378 | * | ||
| 379 | * And with multiple signal descriptors: | ||
| 380 | * | ||
| 381 | * SIG_EXPR_DECL(ROMD8, ROM16S, SIG_DESC_SET(HW_STRAP1, 4), | ||
| 382 | * { HW_STRAP1, GENMASK(1, 0), 0, 0 }); | ||
| 383 | */ | ||
| 384 | #define SIG_EXPR_DECL(sig, func, ...) \ | ||
| 385 | SIG_DESC_LIST_DECL(sig, func, __VA_ARGS__); \ | ||
| 386 | SIG_EXPR_DECL_(sig, func) | ||
| 387 | |||
| 388 | /** | ||
| 389 | * Declare a pointer to a signal expression | ||
| 390 | * | ||
| 391 | * @sig: The macro symbol name for the signal (subjected to token pasting) | ||
| 392 | * @func: The macro symbol name for the function (subjected to token pasting) | ||
| 393 | */ | ||
| 394 | #define SIG_EXPR_PTR(sig, func) (&SIG_EXPR_SYM(sig, func)) | ||
| 395 | |||
| 396 | #define SIG_EXPR_LIST_SYM(sig) sig_exprs_ ## sig | ||
| 397 | |||
| 398 | /** | ||
| 399 | * Declare a signal expression list for reference in a struct aspeed_pin_prio. | ||
| 400 | * | ||
| 401 | * @sig: A macro symbol name for the signal (is subjected to token pasting) | ||
| 402 | * @...: Signal expression structure pointers (use SIG_EXPR_PTR()) | ||
| 403 | * | ||
| 404 | * For example, the 16-bit ROM bus can be enabled by one of two possible signal | ||
| 405 | * expressions: | ||
| 406 | * | ||
| 407 | * SIG_EXPR_DECL(ROMD8, ROM16, SIG_DESC_SET(SCU90, 6)); | ||
| 408 | * SIG_EXPR_DECL(ROMD8, ROM16S, SIG_DESC_SET(HW_STRAP1, 4), | ||
| 409 | * { HW_STRAP1, GENMASK(1, 0), 0, 0 }); | ||
| 410 | * SIG_EXPR_LIST_DECL(ROMD8, SIG_EXPR_PTR(ROMD8, ROM16), | ||
| 411 | * SIG_EXPR_PTR(ROMD8, ROM16S)); | ||
| 412 | */ | ||
| 413 | #define SIG_EXPR_LIST_DECL(sig, ...) \ | ||
| 414 | static const struct aspeed_sig_expr *SIG_EXPR_LIST_SYM(sig)[] = \ | ||
| 415 | { __VA_ARGS__, NULL } | ||
| 416 | |||
| 417 | /** | ||
| 418 | * A short-hand macro for declaring a function expression and an expression | ||
| 419 | * list with a single function. | ||
| 420 | * | ||
| 421 | * @func: A macro symbol name for the function (is subjected to token pasting) | ||
| 422 | * @...: Function descriptors that define the function expression | ||
| 423 | * | ||
| 424 | * For example, signal NCTS6 participates in its own function with one group: | ||
| 425 | * | ||
| 426 | * SIG_EXPR_LIST_DECL_SINGLE(NCTS6, NCTS6, SIG_DESC_SET(SCU90, 7)); | ||
| 427 | */ | ||
| 428 | #define SIG_EXPR_LIST_DECL_SINGLE(sig, func, ...) \ | ||
| 429 | SIG_DESC_LIST_DECL(sig, func, __VA_ARGS__); \ | ||
| 430 | SIG_EXPR_DECL_(sig, func); \ | ||
| 431 | SIG_EXPR_LIST_DECL(sig, SIG_EXPR_PTR(sig, func)) | ||
| 432 | |||
| 433 | #define SIG_EXPR_LIST_DECL_DUAL(sig, f0, f1) \ | ||
| 434 | SIG_EXPR_LIST_DECL(sig, SIG_EXPR_PTR(sig, f0), SIG_EXPR_PTR(sig, f1)) | ||
| 435 | |||
| 436 | #define SIG_EXPR_LIST_PTR(sig) (&SIG_EXPR_LIST_SYM(sig)[0]) | ||
| 437 | |||
| 438 | #define PIN_EXPRS_SYM(pin) pin_exprs_ ## pin | ||
| 439 | #define PIN_EXPRS_PTR(pin) (&PIN_EXPRS_SYM(pin)[0]) | ||
| 440 | #define PIN_SYM(pin) pin_ ## pin | ||
| 441 | |||
| 442 | #define MS_PIN_DECL_(pin, ...) \ | ||
| 443 | static const struct aspeed_sig_expr **PIN_EXPRS_SYM(pin)[] = \ | ||
| 444 | { __VA_ARGS__, NULL }; \ | ||
| 445 | static const struct aspeed_pin_desc PIN_SYM(pin) = \ | ||
| 446 | { #pin, PIN_EXPRS_PTR(pin) } | ||
| 447 | |||
| 448 | /** | ||
| 449 | * Declare a multi-signal pin | ||
| 450 | * | ||
| 451 | * @pin: The pin number | ||
| 452 | * @other: Macro name for "other" functionality (subjected to stringification) | ||
| 453 | * @high: Macro name for the highest priority signal functions | ||
| 454 | * @low: Macro name for the low signal functions | ||
| 455 | * | ||
| 456 | * For example: | ||
| 457 | * | ||
| 458 | * #define A8 56 | ||
| 459 | * SIG_EXPR_DECL(ROMD8, ROM16, SIG_DESC_SET(SCU90, 6)); | ||
| 460 | * SIG_EXPR_DECL(ROMD8, ROM16S, SIG_DESC_SET(HW_STRAP1, 4), | ||
| 461 | * { HW_STRAP1, GENMASK(1, 0), 0, 0 }); | ||
| 462 | * SIG_EXPR_LIST_DECL(ROMD8, SIG_EXPR_PTR(ROMD8, ROM16), | ||
| 463 | * SIG_EXPR_PTR(ROMD8, ROM16S)); | ||
| 464 | * SIG_EXPR_LIST_DECL_SINGLE(NCTS6, NCTS6, SIG_DESC_SET(SCU90, 7)); | ||
| 465 | * MS_PIN_DECL(A8, GPIOH0, ROMD8, NCTS6); | ||
| 466 | */ | ||
| 467 | #define MS_PIN_DECL(pin, other, high, low) \ | ||
| 468 | SIG_EXPR_LIST_DECL_SINGLE(other, other); \ | ||
| 469 | MS_PIN_DECL_(pin, \ | ||
| 470 | SIG_EXPR_LIST_PTR(high), \ | ||
| 471 | SIG_EXPR_LIST_PTR(low), \ | ||
| 472 | SIG_EXPR_LIST_PTR(other)) | ||
| 473 | |||
| 474 | #define PIN_GROUP_SYM(func) pins_ ## func | ||
| 475 | #define FUNC_GROUP_SYM(func) groups_ ## func | ||
| 476 | #define FUNC_GROUP_DECL(func, ...) \ | ||
| 477 | static const int PIN_GROUP_SYM(func)[] = { __VA_ARGS__ }; \ | ||
| 478 | static const char *FUNC_GROUP_SYM(func)[] = { #func } | ||
| 479 | |||
| 480 | /** | ||
| 481 | * Declare a single signal pin | ||
| 482 | * | ||
| 483 | * @pin: The pin number | ||
| 484 | * @other: Macro name for "other" functionality (subjected to stringification) | ||
| 485 | * @sig: Macro name for the signal (subjected to stringification) | ||
| 486 | * | ||
| 487 | * For example: | ||
| 488 | * | ||
| 489 | * #define E3 80 | ||
| 490 | * SIG_EXPR_LIST_DECL_SINGLE(SCL5, I2C5, I2C5_DESC); | ||
| 491 | * SS_PIN_DECL(E3, GPIOK0, SCL5); | ||
| 492 | */ | ||
| 493 | #define SS_PIN_DECL(pin, other, sig) \ | ||
| 494 | SIG_EXPR_LIST_DECL_SINGLE(other, other); \ | ||
| 495 | MS_PIN_DECL_(pin, SIG_EXPR_LIST_PTR(sig), SIG_EXPR_LIST_PTR(other)) | ||
| 496 | |||
| 497 | /** | ||
| 498 | * Single signal, single function pin declaration | ||
| 499 | * | ||
| 500 | * @pin: The pin number | ||
| 501 | * @other: Macro name for "other" functionality (subjected to stringification) | ||
| 502 | * @sig: Macro name for the signal (subjected to stringification) | ||
| 503 | * @...: Signal descriptors that define the function expression | ||
| 504 | * | ||
| 505 | * For example: | ||
| 506 | * | ||
| 507 | * SSSF_PIN_DECL(A4, GPIOA2, TIMER3, SIG_DESC_SET(SCU80, 2)); | ||
| 508 | */ | ||
| 509 | #define SSSF_PIN_DECL(pin, other, sig, ...) \ | ||
| 510 | SIG_EXPR_LIST_DECL_SINGLE(sig, sig, __VA_ARGS__); \ | ||
| 511 | SIG_EXPR_LIST_DECL_SINGLE(other, other); \ | ||
| 512 | MS_PIN_DECL_(pin, SIG_EXPR_LIST_PTR(sig), SIG_EXPR_LIST_PTR(other)); \ | ||
| 513 | FUNC_GROUP_DECL(sig, pin) | ||
| 514 | |||
| 515 | #define GPIO_PIN_DECL(pin, gpio) \ | ||
| 516 | SIG_EXPR_LIST_DECL_SINGLE(gpio, gpio); \ | ||
| 517 | MS_PIN_DECL_(pin, SIG_EXPR_LIST_PTR(gpio)) | ||
| 518 | |||
| 519 | /** | 21 | /** |
| 520 | * @param The pinconf parameter type | 22 | * @param The pinconf parameter type |
| 521 | * @pins The pin range this config struct covers, [low, high] | 23 | * @pins The pin range this config struct covers, [low, high] |
