diff options
| author | Stephen Warren <swarren@nvidia.com> | 2012-03-02 15:05:48 -0500 |
|---|---|---|
| committer | Linus Walleij <linus.walleij@linaro.org> | 2012-03-05 05:25:11 -0500 |
| commit | 1e2082b520721734c358f776d34a069867214c8e (patch) | |
| tree | 4d11e15a4127ad69faf7555864480a6fafe5422c /include/linux/pinctrl | |
| parent | 6e5e959dde0d92d177f035652aeaa77f9330c9c6 (diff) | |
pinctrl: enhance mapping table to support pin config operations
The pinctrl mapping table can now contain entries to:
* Set the mux function of a pin group
* Apply a set of pin config options to a pin or a group
This allows pinctrl_select_state() to apply pin configs settings as well
as mux settings.
v3: Fix find_pinctrl() to iterate over the correct list.
s/_MUX_CONFIGS_/_CONFIGS_/ in mapping table macros.
Fix documentation to use correct mapping table macro.
v2: Added numerous extra PIN_MAP_*() special-case macros.
Fixed kerneldoc typo. Delete pinctrl_get_pin_id() and
replace it with pin_get_from_name(). Various minor fixes.
Updates due to rebase.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/pinctrl')
| -rw-r--r-- | include/linux/pinctrl/machine.h | 145 |
1 files changed, 115 insertions, 30 deletions
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h index 05d25c8adbaf..3fd2f9dfc645 100644 --- a/include/linux/pinctrl/machine.h +++ b/include/linux/pinctrl/machine.h | |||
| @@ -14,6 +14,41 @@ | |||
| 14 | 14 | ||
| 15 | #include "pinctrl.h" | 15 | #include "pinctrl.h" |
| 16 | 16 | ||
| 17 | enum pinctrl_map_type { | ||
| 18 | PIN_MAP_TYPE_INVALID, | ||
| 19 | PIN_MAP_TYPE_DUMMY_STATE, | ||
| 20 | PIN_MAP_TYPE_MUX_GROUP, | ||
| 21 | PIN_MAP_TYPE_CONFIGS_PIN, | ||
| 22 | PIN_MAP_TYPE_CONFIGS_GROUP, | ||
| 23 | }; | ||
| 24 | |||
| 25 | /** | ||
| 26 | * struct pinctrl_map_mux - mapping table content for MAP_TYPE_MUX_GROUP | ||
| 27 | * @group: the name of the group whose mux function is to be configured. This | ||
| 28 | * field may be left NULL, and the first applicable group for the function | ||
| 29 | * will be used. | ||
| 30 | * @function: the mux function to select for the group | ||
| 31 | */ | ||
| 32 | struct pinctrl_map_mux { | ||
| 33 | const char *group; | ||
| 34 | const char *function; | ||
| 35 | }; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * struct pinctrl_map_configs - mapping table content for MAP_TYPE_CONFIGS_* | ||
| 39 | * @group_or_pin: the name of the pin or group whose configuration parameters | ||
| 40 | * are to be configured. | ||
| 41 | * @configs: a pointer to an array of config parameters/values to program into | ||
| 42 | * hardware. Each individual pin controller defines the format and meaning | ||
| 43 | * of config parameters. | ||
| 44 | * @num_configs: the number of entries in array @configs | ||
| 45 | */ | ||
| 46 | struct pinctrl_map_configs { | ||
| 47 | const char *group_or_pin; | ||
| 48 | unsigned long *configs; | ||
| 49 | unsigned num_configs; | ||
| 50 | }; | ||
| 51 | |||
| 17 | /** | 52 | /** |
| 18 | * struct pinctrl_map - boards/machines shall provide this map for devices | 53 | * struct pinctrl_map - boards/machines shall provide this map for devices |
| 19 | * @dev_name: the name of the device using this specific mapping, the name | 54 | * @dev_name: the name of the device using this specific mapping, the name |
| @@ -22,46 +57,96 @@ | |||
| 22 | * hogged by the driver itself upon registration | 57 | * hogged by the driver itself upon registration |
| 23 | * @name: the name of this specific map entry for the particular machine. | 58 | * @name: the name of this specific map entry for the particular machine. |
| 24 | * This is the parameter passed to pinmux_lookup_state() | 59 | * This is the parameter passed to pinmux_lookup_state() |
| 60 | * @type: the type of mapping table entry | ||
| 25 | * @ctrl_dev_name: the name of the device controlling this specific mapping, | 61 | * @ctrl_dev_name: the name of the device controlling this specific mapping, |
| 26 | * the name must be the same as in your struct device* | 62 | * the name must be the same as in your struct device*. This field is not |
| 27 | * @group: sometimes a function can map to different pin groups, so this | 63 | * used for PIN_MAP_TYPE_DUMMY_STATE |
| 28 | * selects a certain specific pin group to activate for the function, if | 64 | * @data: Data specific to the mapping type |
| 29 | * left as NULL, the first applicable group will be used | ||
| 30 | * @function: a function in the driver to use for this mapping, the driver | ||
| 31 | * will lookup the function referenced by this ID on the specified | ||
| 32 | * pin control device | ||
| 33 | */ | 65 | */ |
| 34 | struct pinctrl_map { | 66 | struct pinctrl_map { |
| 35 | const char *dev_name; | 67 | const char *dev_name; |
| 36 | const char *name; | 68 | const char *name; |
| 69 | enum pinctrl_map_type type; | ||
| 37 | const char *ctrl_dev_name; | 70 | const char *ctrl_dev_name; |
| 38 | const char *group; | 71 | union { |
| 39 | const char *function; | 72 | struct pinctrl_map_mux mux; |
| 73 | struct pinctrl_map_configs configs; | ||
| 74 | } data; | ||
| 40 | }; | 75 | }; |
| 41 | 76 | ||
| 42 | /* | 77 | /* Convenience macros to create mapping table entries */ |
| 43 | * Convenience macro to set a simple map from a certain pin controller and a | ||
| 44 | * certain function to a named device | ||
| 45 | */ | ||
| 46 | #define PIN_MAP(a, b, c, d) \ | ||
| 47 | { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d } | ||
| 48 | 78 | ||
| 49 | /* | 79 | #define PIN_MAP_DUMMY_STATE(dev, state) \ |
| 50 | * Convenience macro to map a system function onto a certain pinctrl device, | 80 | { \ |
| 51 | * to be hogged by the pin control core until the system shuts down. | 81 | .dev_name = dev, \ |
| 52 | */ | 82 | .name = state, \ |
| 53 | #define PIN_MAP_SYS_HOG(a, b) \ | 83 | .type = PIN_MAP_TYPE_DUMMY_STATE, \ |
| 54 | { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ | 84 | } |
| 55 | .function = b, } | ||
| 56 | 85 | ||
| 57 | /* | 86 | #define PIN_MAP_MUX_GROUP(dev, state, pinctrl, grp, func) \ |
| 58 | * Convenience macro to map a system function onto a certain pinctrl device | 87 | { \ |
| 59 | * using a specified group, to be hogged by the pin control core until the | 88 | .dev_name = dev, \ |
| 60 | * system shuts down. | 89 | .name = state, \ |
| 61 | */ | 90 | .type = PIN_MAP_TYPE_MUX_GROUP, \ |
| 62 | #define PIN_MAP_SYS_HOG_GROUP(a, b, c) \ | 91 | .ctrl_dev_name = pinctrl, \ |
| 63 | { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ | 92 | .data.mux = { \ |
| 64 | .function = b, .group = c, } | 93 | .group = grp, \ |
| 94 | .function = func, \ | ||
| 95 | }, \ | ||
| 96 | } | ||
| 97 | |||
| 98 | #define PIN_MAP_MUX_GROUP_DEFAULT(dev, pinctrl, grp, func) \ | ||
| 99 | PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, func) | ||
| 100 | |||
| 101 | #define PIN_MAP_MUX_GROUP_HOG(dev, state, grp, func) \ | ||
| 102 | PIN_MAP_MUX_GROUP(dev, state, dev, grp, func) | ||
| 103 | |||
| 104 | #define PIN_MAP_MUX_GROUP_HOG_DEFAULT(dev, grp, func) \ | ||
| 105 | PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, func) | ||
| 106 | |||
| 107 | #define PIN_MAP_CONFIGS_PIN(dev, state, pinctrl, pin, cfgs) \ | ||
| 108 | { \ | ||
| 109 | .dev_name = dev, \ | ||
| 110 | .name = state, \ | ||
| 111 | .type = PIN_MAP_TYPE_CONFIGS_PIN, \ | ||
| 112 | .ctrl_dev_name = pinctrl, \ | ||
| 113 | .data.configs = { \ | ||
| 114 | .group_or_pin = pin, \ | ||
| 115 | .configs = cfgs, \ | ||
| 116 | .num_configs = ARRAY_SIZE(cfgs), \ | ||
| 117 | }, \ | ||
| 118 | } | ||
| 119 | |||
| 120 | #define PIN_MAP_CONFIGS_PIN_DEFAULT(dev, pinctrl, pin, cfgs) \ | ||
| 121 | PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, pinctrl, pin, cfgs) | ||
| 122 | |||
| 123 | #define PIN_MAP_CONFIGS_PIN_HOG(dev, state, pin, cfgs) \ | ||
| 124 | PIN_MAP_CONFIGS_PIN(dev, state, dev, pin, cfgs) | ||
| 125 | |||
| 126 | #define PIN_MAP_CONFIGS_PIN_HOG_DEFAULT(dev, pin, cfgs) \ | ||
| 127 | PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, dev, pin, cfgs) | ||
| 128 | |||
| 129 | #define PIN_MAP_CONFIGS_GROUP(dev, state, pinctrl, grp, cfgs) \ | ||
| 130 | { \ | ||
| 131 | .dev_name = dev, \ | ||
| 132 | .name = state, \ | ||
| 133 | .type = PIN_MAP_TYPE_CONFIGS_GROUP, \ | ||
| 134 | .ctrl_dev_name = pinctrl, \ | ||
| 135 | .data.configs = { \ | ||
| 136 | .group_or_pin = grp, \ | ||
| 137 | .configs = cfgs, \ | ||
| 138 | .num_configs = ARRAY_SIZE(cfgs), \ | ||
| 139 | }, \ | ||
| 140 | } | ||
| 141 | |||
| 142 | #define PIN_MAP_CONFIGS_GROUP_DEFAULT(dev, pinctrl, grp, cfgs) \ | ||
| 143 | PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, cfgs) | ||
| 144 | |||
| 145 | #define PIN_MAP_CONFIGS_GROUP_HOG(dev, state, grp, cfgs) \ | ||
| 146 | PIN_MAP_CONFIGS_GROUP(dev, state, dev, grp, cfgs) | ||
| 147 | |||
| 148 | #define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs) \ | ||
| 149 | PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs) | ||
| 65 | 150 | ||
| 66 | #ifdef CONFIG_PINMUX | 151 | #ifdef CONFIG_PINMUX |
| 67 | 152 | ||
