Sonic Zhang | e9a03ad | 2013-09-03 16:28:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Pinctrl Driver for ADI GPIO2 controller |
| 3 | * |
| 4 | * Copyright 2007-2013 Analog Devices Inc. |
| 5 | * |
| 6 | * Licensed under the GPLv2 or later |
| 7 | */ |
| 8 | |
| 9 | #ifndef PINCTRL_PINCTRL_ADI2_H |
| 10 | #define PINCTRL_PINCTRL_ADI2_H |
| 11 | |
| 12 | #include <linux/pinctrl/pinctrl.h> |
| 13 | |
| 14 | /** |
| 15 | * struct adi_pin_group - describes a pin group |
| 16 | * @name: the name of this pin group |
| 17 | * @pins: an array of pins |
| 18 | * @num: the number of pins in this array |
| 19 | */ |
| 20 | struct adi_pin_group { |
| 21 | const char *name; |
| 22 | const unsigned *pins; |
| 23 | const unsigned num; |
Sonic Zhang | e365374 | 2014-02-14 18:21:06 +0800 | [diff] [blame] | 24 | const unsigned short *mux; |
Sonic Zhang | e9a03ad | 2013-09-03 16:28:59 +0800 | [diff] [blame] | 25 | }; |
| 26 | |
Sonic Zhang | e365374 | 2014-02-14 18:21:06 +0800 | [diff] [blame] | 27 | #define ADI_PIN_GROUP(n, p, m) \ |
Sonic Zhang | e9a03ad | 2013-09-03 16:28:59 +0800 | [diff] [blame] | 28 | { \ |
| 29 | .name = n, \ |
| 30 | .pins = p, \ |
| 31 | .num = ARRAY_SIZE(p), \ |
Sonic Zhang | e365374 | 2014-02-14 18:21:06 +0800 | [diff] [blame] | 32 | .mux = m, \ |
Sonic Zhang | e9a03ad | 2013-09-03 16:28:59 +0800 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | /** |
| 36 | * struct adi_pmx_func - describes function mux setting of pin groups |
| 37 | * @name: the name of this function mux setting |
| 38 | * @groups: an array of pin groups |
| 39 | * @num_groups: the number of pin groups in this array |
| 40 | * @mux: the function mux setting array, end by zero |
| 41 | */ |
| 42 | struct adi_pmx_func { |
| 43 | const char *name; |
| 44 | const char * const *groups; |
| 45 | const unsigned num_groups; |
Sonic Zhang | e9a03ad | 2013-09-03 16:28:59 +0800 | [diff] [blame] | 46 | }; |
| 47 | |
Sonic Zhang | e365374 | 2014-02-14 18:21:06 +0800 | [diff] [blame] | 48 | #define ADI_PMX_FUNCTION(n, g) \ |
Sonic Zhang | e9a03ad | 2013-09-03 16:28:59 +0800 | [diff] [blame] | 49 | { \ |
| 50 | .name = n, \ |
| 51 | .groups = g, \ |
| 52 | .num_groups = ARRAY_SIZE(g), \ |
Sonic Zhang | e9a03ad | 2013-09-03 16:28:59 +0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * struct adi_pinctrl_soc_data - ADI pin controller per-SoC configuration |
| 57 | * @functions: The functions supported on this SoC. |
| 58 | * @nfunction: The number of entries in @functions. |
| 59 | * @groups: An array describing all pin groups the pin SoC supports. |
| 60 | * @ngroups: The number of entries in @groups. |
| 61 | * @pins: An array describing all pins the pin controller affects. |
| 62 | * @npins: The number of entries in @pins. |
| 63 | */ |
| 64 | struct adi_pinctrl_soc_data { |
| 65 | const struct adi_pmx_func *functions; |
| 66 | int nfunctions; |
| 67 | const struct adi_pin_group *groups; |
| 68 | int ngroups; |
| 69 | const struct pinctrl_pin_desc *pins; |
| 70 | int npins; |
| 71 | }; |
| 72 | |
| 73 | void adi_pinctrl_soc_init(const struct adi_pinctrl_soc_data **soc); |
| 74 | |
| 75 | #endif /* PINCTRL_PINCTRL_ADI2_H */ |