diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/of.h | 51 | ||||
| -rw-r--r-- | include/linux/pinctrl/consumer.h | 44 | ||||
| -rw-r--r-- | include/linux/pinctrl/machine.h | 7 | ||||
| -rw-r--r-- | include/linux/pinctrl/pinconf.h | 6 | ||||
| -rw-r--r-- | include/linux/pinctrl/pinctrl.h | 22 | ||||
| -rw-r--r-- | include/linux/pinctrl/pinmux.h | 9 |
6 files changed, 127 insertions, 12 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index fa7fb1d97458..2ec1083af7ff 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
| @@ -193,6 +193,17 @@ extern struct device_node *of_get_next_child(const struct device_node *node, | |||
| 193 | for (child = of_get_next_child(parent, NULL); child != NULL; \ | 193 | for (child = of_get_next_child(parent, NULL); child != NULL; \ |
| 194 | child = of_get_next_child(parent, child)) | 194 | child = of_get_next_child(parent, child)) |
| 195 | 195 | ||
| 196 | static inline int of_get_child_count(const struct device_node *np) | ||
| 197 | { | ||
| 198 | struct device_node *child; | ||
| 199 | int num = 0; | ||
| 200 | |||
| 201 | for_each_child_of_node(np, child) | ||
| 202 | num++; | ||
| 203 | |||
| 204 | return num; | ||
| 205 | } | ||
| 206 | |||
| 196 | extern struct device_node *of_find_node_with_property( | 207 | extern struct device_node *of_find_node_with_property( |
| 197 | struct device_node *from, const char *prop_name); | 208 | struct device_node *from, const char *prop_name); |
| 198 | #define for_each_node_with_property(dn, prop_name) \ | 209 | #define for_each_node_with_property(dn, prop_name) \ |
| @@ -259,6 +270,37 @@ extern void of_detach_node(struct device_node *); | |||
| 259 | #endif | 270 | #endif |
| 260 | 271 | ||
| 261 | #define of_match_ptr(_ptr) (_ptr) | 272 | #define of_match_ptr(_ptr) (_ptr) |
| 273 | |||
| 274 | /* | ||
| 275 | * struct property *prop; | ||
| 276 | * const __be32 *p; | ||
| 277 | * u32 u; | ||
| 278 | * | ||
| 279 | * of_property_for_each_u32(np, "propname", prop, p, u) | ||
| 280 | * printk("U32 value: %x\n", u); | ||
| 281 | */ | ||
| 282 | const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, | ||
| 283 | u32 *pu); | ||
| 284 | #define of_property_for_each_u32(np, propname, prop, p, u) \ | ||
| 285 | for (prop = of_find_property(np, propname, NULL), \ | ||
| 286 | p = of_prop_next_u32(prop, NULL, &u); \ | ||
| 287 | p; \ | ||
| 288 | p = of_prop_next_u32(prop, p, &u)) | ||
| 289 | |||
| 290 | /* | ||
| 291 | * struct property *prop; | ||
| 292 | * const char *s; | ||
| 293 | * | ||
| 294 | * of_property_for_each_string(np, "propname", prop, s) | ||
| 295 | * printk("String value: %s\n", s); | ||
| 296 | */ | ||
| 297 | const char *of_prop_next_string(struct property *prop, const char *cur); | ||
| 298 | #define of_property_for_each_string(np, propname, prop, s) \ | ||
| 299 | for (prop = of_find_property(np, propname, NULL), \ | ||
| 300 | s = of_prop_next_string(prop, NULL); \ | ||
| 301 | s; \ | ||
| 302 | s = of_prop_next_string(prop, s)) | ||
| 303 | |||
| 262 | #else /* CONFIG_OF */ | 304 | #else /* CONFIG_OF */ |
| 263 | 305 | ||
| 264 | static inline bool of_have_populated_dt(void) | 306 | static inline bool of_have_populated_dt(void) |
| @@ -269,6 +311,11 @@ static inline bool of_have_populated_dt(void) | |||
| 269 | #define for_each_child_of_node(parent, child) \ | 311 | #define for_each_child_of_node(parent, child) \ |
| 270 | while (0) | 312 | while (0) |
| 271 | 313 | ||
| 314 | static inline int of_get_child_count(const struct device_node *np) | ||
| 315 | { | ||
| 316 | return 0; | ||
| 317 | } | ||
| 318 | |||
| 272 | static inline int of_device_is_compatible(const struct device_node *device, | 319 | static inline int of_device_is_compatible(const struct device_node *device, |
| 273 | const char *name) | 320 | const char *name) |
| 274 | { | 321 | { |
| @@ -349,6 +396,10 @@ static inline int of_machine_is_compatible(const char *compat) | |||
| 349 | 396 | ||
| 350 | #define of_match_ptr(_ptr) NULL | 397 | #define of_match_ptr(_ptr) NULL |
| 351 | #define of_match_node(_matches, _node) NULL | 398 | #define of_match_node(_matches, _node) NULL |
| 399 | #define of_property_for_each_u32(np, propname, prop, p, u) \ | ||
| 400 | while (0) | ||
| 401 | #define of_property_for_each_string(np, propname, prop, s) \ | ||
| 402 | while (0) | ||
| 352 | #endif /* CONFIG_OF */ | 403 | #endif /* CONFIG_OF */ |
| 353 | 404 | ||
| 354 | /** | 405 | /** |
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h index 191e72688481..6dd96fb45482 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h | |||
| @@ -36,6 +36,9 @@ extern struct pinctrl_state * __must_check pinctrl_lookup_state( | |||
| 36 | const char *name); | 36 | const char *name); |
| 37 | extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s); | 37 | extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s); |
| 38 | 38 | ||
| 39 | extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev); | ||
| 40 | extern void devm_pinctrl_put(struct pinctrl *p); | ||
| 41 | |||
| 39 | #else /* !CONFIG_PINCTRL */ | 42 | #else /* !CONFIG_PINCTRL */ |
| 40 | 43 | ||
| 41 | static inline int pinctrl_request_gpio(unsigned gpio) | 44 | static inline int pinctrl_request_gpio(unsigned gpio) |
| @@ -79,6 +82,15 @@ static inline int pinctrl_select_state(struct pinctrl *p, | |||
| 79 | return 0; | 82 | return 0; |
| 80 | } | 83 | } |
| 81 | 84 | ||
| 85 | static inline struct pinctrl * __must_check devm_pinctrl_get(struct device *dev) | ||
| 86 | { | ||
| 87 | return NULL; | ||
| 88 | } | ||
| 89 | |||
| 90 | static inline void devm_pinctrl_put(struct pinctrl *p) | ||
| 91 | { | ||
| 92 | } | ||
| 93 | |||
| 82 | #endif /* CONFIG_PINCTRL */ | 94 | #endif /* CONFIG_PINCTRL */ |
| 83 | 95 | ||
| 84 | static inline struct pinctrl * __must_check pinctrl_get_select( | 96 | static inline struct pinctrl * __must_check pinctrl_get_select( |
| @@ -113,6 +125,38 @@ static inline struct pinctrl * __must_check pinctrl_get_select_default( | |||
| 113 | return pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT); | 125 | return pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT); |
| 114 | } | 126 | } |
| 115 | 127 | ||
| 128 | static inline struct pinctrl * __must_check devm_pinctrl_get_select( | ||
| 129 | struct device *dev, const char *name) | ||
| 130 | { | ||
| 131 | struct pinctrl *p; | ||
| 132 | struct pinctrl_state *s; | ||
| 133 | int ret; | ||
| 134 | |||
| 135 | p = devm_pinctrl_get(dev); | ||
| 136 | if (IS_ERR(p)) | ||
| 137 | return p; | ||
| 138 | |||
| 139 | s = pinctrl_lookup_state(p, name); | ||
| 140 | if (IS_ERR(s)) { | ||
| 141 | devm_pinctrl_put(p); | ||
| 142 | return ERR_PTR(PTR_ERR(s)); | ||
| 143 | } | ||
| 144 | |||
| 145 | ret = pinctrl_select_state(p, s); | ||
| 146 | if (ret < 0) { | ||
| 147 | devm_pinctrl_put(p); | ||
| 148 | return ERR_PTR(ret); | ||
| 149 | } | ||
| 150 | |||
| 151 | return p; | ||
| 152 | } | ||
| 153 | |||
| 154 | static inline struct pinctrl * __must_check devm_pinctrl_get_select_default( | ||
| 155 | struct device *dev) | ||
| 156 | { | ||
| 157 | return devm_pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT); | ||
| 158 | } | ||
| 159 | |||
| 116 | #ifdef CONFIG_PINCONF | 160 | #ifdef CONFIG_PINCONF |
| 117 | 161 | ||
| 118 | extern int pin_config_get(const char *dev_name, const char *name, | 162 | extern int pin_config_get(const char *dev_name, const char *name, |
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h index e4d1de742502..7d22ab00343f 100644 --- a/include/linux/pinctrl/machine.h +++ b/include/linux/pinctrl/machine.h | |||
| @@ -154,7 +154,7 @@ struct pinctrl_map { | |||
| 154 | 154 | ||
| 155 | extern int pinctrl_register_mappings(struct pinctrl_map const *map, | 155 | extern int pinctrl_register_mappings(struct pinctrl_map const *map, |
| 156 | unsigned num_maps); | 156 | unsigned num_maps); |
| 157 | 157 | extern void pinctrl_provide_dummies(void); | |
| 158 | #else | 158 | #else |
| 159 | 159 | ||
| 160 | static inline int pinctrl_register_mappings(struct pinctrl_map const *map, | 160 | static inline int pinctrl_register_mappings(struct pinctrl_map const *map, |
| @@ -163,5 +163,8 @@ static inline int pinctrl_register_mappings(struct pinctrl_map const *map, | |||
| 163 | return 0; | 163 | return 0; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | #endif /* !CONFIG_PINMUX */ | 166 | static inline void pinctrl_provide_dummies(void) |
| 167 | { | ||
| 168 | } | ||
| 169 | #endif /* !CONFIG_PINCTRL */ | ||
| 167 | #endif | 170 | #endif |
diff --git a/include/linux/pinctrl/pinconf.h b/include/linux/pinctrl/pinconf.h index ec431f03362d..e7a720104a47 100644 --- a/include/linux/pinctrl/pinconf.h +++ b/include/linux/pinctrl/pinconf.h | |||
| @@ -25,7 +25,6 @@ struct seq_file; | |||
| 25 | * @pin_config_get: get the config of a certain pin, if the requested config | 25 | * @pin_config_get: get the config of a certain pin, if the requested config |
| 26 | * is not available on this controller this should return -ENOTSUPP | 26 | * is not available on this controller this should return -ENOTSUPP |
| 27 | * and if it is available but disabled it should return -EINVAL | 27 | * and if it is available but disabled it should return -EINVAL |
| 28 | * @pin_config_get: get the config of a certain pin | ||
| 29 | * @pin_config_set: configure an individual pin | 28 | * @pin_config_set: configure an individual pin |
| 30 | * @pin_config_group_get: get configurations for an entire pin group | 29 | * @pin_config_group_get: get configurations for an entire pin group |
| 31 | * @pin_config_group_set: configure all pins in a group | 30 | * @pin_config_group_set: configure all pins in a group |
| @@ -33,6 +32,8 @@ struct seq_file; | |||
| 33 | * per-device info for a certain pin in debugfs | 32 | * per-device info for a certain pin in debugfs |
| 34 | * @pin_config_group_dbg_show: optional debugfs display hook that will provide | 33 | * @pin_config_group_dbg_show: optional debugfs display hook that will provide |
| 35 | * per-device info for a certain group in debugfs | 34 | * per-device info for a certain group in debugfs |
| 35 | * @pin_config_config_dbg_show: optional debugfs display hook that will decode | ||
| 36 | * and display a driver's pin configuration parameter | ||
| 36 | */ | 37 | */ |
| 37 | struct pinconf_ops { | 38 | struct pinconf_ops { |
| 38 | #ifdef CONFIG_GENERIC_PINCONF | 39 | #ifdef CONFIG_GENERIC_PINCONF |
| @@ -56,6 +57,9 @@ struct pinconf_ops { | |||
| 56 | void (*pin_config_group_dbg_show) (struct pinctrl_dev *pctldev, | 57 | void (*pin_config_group_dbg_show) (struct pinctrl_dev *pctldev, |
| 57 | struct seq_file *s, | 58 | struct seq_file *s, |
| 58 | unsigned selector); | 59 | unsigned selector); |
| 60 | void (*pin_config_config_dbg_show) (struct pinctrl_dev *pctldev, | ||
| 61 | struct seq_file *s, | ||
| 62 | unsigned long config); | ||
| 59 | }; | 63 | }; |
| 60 | 64 | ||
| 61 | #endif | 65 | #endif |
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h index 4e9f0788c221..3b894a668d32 100644 --- a/include/linux/pinctrl/pinctrl.h +++ b/include/linux/pinctrl/pinctrl.h | |||
| @@ -21,9 +21,11 @@ | |||
| 21 | 21 | ||
| 22 | struct device; | 22 | struct device; |
| 23 | struct pinctrl_dev; | 23 | struct pinctrl_dev; |
| 24 | struct pinctrl_map; | ||
| 24 | struct pinmux_ops; | 25 | struct pinmux_ops; |
| 25 | struct pinconf_ops; | 26 | struct pinconf_ops; |
| 26 | struct gpio_chip; | 27 | struct gpio_chip; |
| 28 | struct device_node; | ||
| 27 | 29 | ||
| 28 | /** | 30 | /** |
| 29 | * struct pinctrl_pin_desc - boards/machines provide information on their | 31 | * struct pinctrl_pin_desc - boards/machines provide information on their |
| @@ -64,17 +66,24 @@ struct pinctrl_gpio_range { | |||
| 64 | /** | 66 | /** |
| 65 | * struct pinctrl_ops - global pin control operations, to be implemented by | 67 | * struct pinctrl_ops - global pin control operations, to be implemented by |
| 66 | * pin controller drivers. | 68 | * pin controller drivers. |
| 67 | * @list_groups: list the number of selectable named groups available | 69 | * @get_groups_count: Returns the count of total number of groups registered. |
| 68 | * in this pinmux driver, the core will begin on 0 and call this | ||
| 69 | * repeatedly as long as it returns >= 0 to enumerate the groups | ||
| 70 | * @get_group_name: return the group name of the pin group | 70 | * @get_group_name: return the group name of the pin group |
| 71 | * @get_group_pins: return an array of pins corresponding to a certain | 71 | * @get_group_pins: return an array of pins corresponding to a certain |
| 72 | * group selector @pins, and the size of the array in @num_pins | 72 | * group selector @pins, and the size of the array in @num_pins |
| 73 | * @pin_dbg_show: optional debugfs display hook that will provide per-device | 73 | * @pin_dbg_show: optional debugfs display hook that will provide per-device |
| 74 | * info for a certain pin in debugfs | 74 | * info for a certain pin in debugfs |
| 75 | * @dt_node_to_map: parse a device tree "pin configuration node", and create | ||
| 76 | * mapping table entries for it. These are returned through the @map and | ||
| 77 | * @num_maps output parameters. This function is optional, and may be | ||
| 78 | * omitted for pinctrl drivers that do not support device tree. | ||
| 79 | * @dt_free_map: free mapping table entries created via @dt_node_to_map. The | ||
| 80 | * top-level @map pointer must be freed, along with any dynamically | ||
| 81 | * allocated members of the mapping table entries themselves. This | ||
| 82 | * function is optional, and may be omitted for pinctrl drivers that do | ||
| 83 | * not support device tree. | ||
| 75 | */ | 84 | */ |
| 76 | struct pinctrl_ops { | 85 | struct pinctrl_ops { |
| 77 | int (*list_groups) (struct pinctrl_dev *pctldev, unsigned selector); | 86 | int (*get_groups_count) (struct pinctrl_dev *pctldev); |
| 78 | const char *(*get_group_name) (struct pinctrl_dev *pctldev, | 87 | const char *(*get_group_name) (struct pinctrl_dev *pctldev, |
| 79 | unsigned selector); | 88 | unsigned selector); |
| 80 | int (*get_group_pins) (struct pinctrl_dev *pctldev, | 89 | int (*get_group_pins) (struct pinctrl_dev *pctldev, |
| @@ -83,6 +92,11 @@ struct pinctrl_ops { | |||
| 83 | unsigned *num_pins); | 92 | unsigned *num_pins); |
| 84 | void (*pin_dbg_show) (struct pinctrl_dev *pctldev, struct seq_file *s, | 93 | void (*pin_dbg_show) (struct pinctrl_dev *pctldev, struct seq_file *s, |
| 85 | unsigned offset); | 94 | unsigned offset); |
| 95 | int (*dt_node_to_map) (struct pinctrl_dev *pctldev, | ||
| 96 | struct device_node *np_config, | ||
| 97 | struct pinctrl_map **map, unsigned *num_maps); | ||
| 98 | void (*dt_free_map) (struct pinctrl_dev *pctldev, | ||
| 99 | struct pinctrl_map *map, unsigned num_maps); | ||
| 86 | }; | 100 | }; |
| 87 | 101 | ||
| 88 | /** | 102 | /** |
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h index 47e9237edd47..1818dcbdd9ab 100644 --- a/include/linux/pinctrl/pinmux.h +++ b/include/linux/pinctrl/pinmux.h | |||
| @@ -23,15 +23,14 @@ struct pinctrl_dev; | |||
| 23 | /** | 23 | /** |
| 24 | * struct pinmux_ops - pinmux operations, to be implemented by pin controller | 24 | * struct pinmux_ops - pinmux operations, to be implemented by pin controller |
| 25 | * drivers that support pinmuxing | 25 | * drivers that support pinmuxing |
| 26 | * @request: called by the core to see if a certain pin can be made available | 26 | * @request: called by the core to see if a certain pin can be made |
| 27 | * available for muxing. This is called by the core to acquire the pins | 27 | * available for muxing. This is called by the core to acquire the pins |
| 28 | * before selecting any actual mux setting across a function. The driver | 28 | * before selecting any actual mux setting across a function. The driver |
| 29 | * is allowed to answer "no" by returning a negative error code | 29 | * is allowed to answer "no" by returning a negative error code |
| 30 | * @free: the reverse function of the request() callback, frees a pin after | 30 | * @free: the reverse function of the request() callback, frees a pin after |
| 31 | * being requested | 31 | * being requested |
| 32 | * @list_functions: list the number of selectable named functions available | 32 | * @get_functions_count: returns number of selectable named functions available |
| 33 | * in this pinmux driver, the core will begin on 0 and call this | 33 | * in this pinmux driver |
| 34 | * repeatedly as long as it returns >= 0 to enumerate mux settings | ||
| 35 | * @get_function_name: return the function name of the muxing selector, | 34 | * @get_function_name: return the function name of the muxing selector, |
| 36 | * called by the core to figure out which mux setting it shall map a | 35 | * called by the core to figure out which mux setting it shall map a |
| 37 | * certain device to | 36 | * certain device to |
| @@ -62,7 +61,7 @@ struct pinctrl_dev; | |||
| 62 | struct pinmux_ops { | 61 | struct pinmux_ops { |
| 63 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); | 62 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); |
| 64 | int (*free) (struct pinctrl_dev *pctldev, unsigned offset); | 63 | int (*free) (struct pinctrl_dev *pctldev, unsigned offset); |
| 65 | int (*list_functions) (struct pinctrl_dev *pctldev, unsigned selector); | 64 | int (*get_functions_count) (struct pinctrl_dev *pctldev); |
| 66 | const char *(*get_function_name) (struct pinctrl_dev *pctldev, | 65 | const char *(*get_function_name) (struct pinctrl_dev *pctldev, |
| 67 | unsigned selector); | 66 | unsigned selector); |
| 68 | int (*get_function_groups) (struct pinctrl_dev *pctldev, | 67 | int (*get_function_groups) (struct pinctrl_dev *pctldev, |
