diff options
Diffstat (limited to 'include/linux/pinctrl')
| -rw-r--r-- | include/linux/pinctrl/machine.h | 30 | ||||
| -rw-r--r-- | include/linux/pinctrl/pinconf.h | 97 | ||||
| -rw-r--r-- | include/linux/pinctrl/pinctrl.h | 15 | ||||
| -rw-r--r-- | include/linux/pinctrl/pinmux.h | 29 |
4 files changed, 143 insertions, 28 deletions
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h index 88863531d862..d0aecb7f6fb9 100644 --- a/include/linux/pinctrl/machine.h +++ b/include/linux/pinctrl/machine.h | |||
| @@ -48,7 +48,7 @@ struct pinmux_map { | |||
| 48 | const char *group; | 48 | const char *group; |
| 49 | struct device *dev; | 49 | struct device *dev; |
| 50 | const char *dev_name; | 50 | const char *dev_name; |
| 51 | const bool hog_on_boot; | 51 | bool hog_on_boot; |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | /* | 54 | /* |
| @@ -66,30 +66,22 @@ struct pinmux_map { | |||
| 66 | { .name = a, .ctrl_dev_name = b, .function = c } | 66 | { .name = a, .ctrl_dev_name = b, .function = c } |
| 67 | 67 | ||
| 68 | /* | 68 | /* |
| 69 | * Convenience macro to map a function onto the primary device pinctrl device | 69 | * Convenience macro to map a system function onto a certain pinctrl device, |
| 70 | * this is especially helpful on systems that have only one pin controller | 70 | * to be hogged by the pinmux core until the system shuts down. |
| 71 | * or need to set up a lot of mappings on the primary controller. | ||
| 72 | */ | ||
| 73 | #define PINMUX_MAP_PRIMARY(a, b, c) \ | ||
| 74 | { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \ | ||
| 75 | .dev_name = c } | ||
| 76 | |||
| 77 | /* | ||
| 78 | * Convenience macro to map a system function onto the primary pinctrl device. | ||
| 79 | * System functions are not assigned to a particular device. | ||
| 80 | */ | 71 | */ |
| 81 | #define PINMUX_MAP_PRIMARY_SYS(a, b) \ | 72 | #define PINMUX_MAP_SYS_HOG(a, b, c) \ |
| 82 | { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b } | 73 | { .name = a, .ctrl_dev_name = b, .function = c, \ |
| 74 | .hog_on_boot = true } | ||
| 83 | 75 | ||
| 84 | /* | 76 | /* |
| 85 | * Convenience macro to map a system function onto the primary pinctrl device, | 77 | * Convenience macro to map a system function onto a certain pinctrl device |
| 86 | * to be hogged by the pinmux core until the system shuts down. | 78 | * using a specified group, to be hogged by the pinmux core until the system |
| 79 | * shuts down. | ||
| 87 | */ | 80 | */ |
| 88 | #define PINMUX_MAP_PRIMARY_SYS_HOG(a, b) \ | 81 | #define PINMUX_MAP_SYS_HOG_GROUP(a, b, c, d) \ |
| 89 | { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \ | 82 | { .name = a, .ctrl_dev_name = b, .function = c, .group = d, \ |
| 90 | .hog_on_boot = true } | 83 | .hog_on_boot = true } |
| 91 | 84 | ||
| 92 | |||
| 93 | #ifdef CONFIG_PINMUX | 85 | #ifdef CONFIG_PINMUX |
| 94 | 86 | ||
| 95 | extern int pinmux_register_mappings(struct pinmux_map const *map, | 87 | extern int pinmux_register_mappings(struct pinmux_map const *map, |
diff --git a/include/linux/pinctrl/pinconf.h b/include/linux/pinctrl/pinconf.h new file mode 100644 index 000000000000..477922cf043a --- /dev/null +++ b/include/linux/pinctrl/pinconf.h | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | /* | ||
| 2 | * Interface the pinconfig portions of the pinctrl subsystem | ||
| 3 | * | ||
| 4 | * Copyright (C) 2011 ST-Ericsson SA | ||
| 5 | * Written on behalf of Linaro for ST-Ericsson | ||
| 6 | * This interface is used in the core to keep track of pins. | ||
| 7 | * | ||
| 8 | * Author: Linus Walleij <linus.walleij@linaro.org> | ||
| 9 | * | ||
| 10 | * License terms: GNU General Public License (GPL) version 2 | ||
| 11 | */ | ||
| 12 | #ifndef __LINUX_PINCTRL_PINCONF_H | ||
| 13 | #define __LINUX_PINCTRL_PINCONF_H | ||
| 14 | |||
| 15 | #ifdef CONFIG_PINCONF | ||
| 16 | |||
| 17 | struct pinctrl_dev; | ||
| 18 | struct seq_file; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * struct pinconf_ops - pin config operations, to be implemented by | ||
| 22 | * pin configuration capable drivers. | ||
| 23 | * @pin_config_get: get the config of a certain pin, if the requested config | ||
| 24 | * is not available on this controller this should return -ENOTSUPP | ||
| 25 | * and if it is available but disabled it should return -EINVAL | ||
| 26 | * @pin_config_get: get the config of a certain pin | ||
| 27 | * @pin_config_set: configure an individual pin | ||
| 28 | * @pin_config_group_get: get configurations for an entire pin group | ||
| 29 | * @pin_config_group_set: configure all pins in a group | ||
| 30 | * @pin_config_dbg_show: optional debugfs display hook that will provide | ||
| 31 | * per-device info for a certain pin in debugfs | ||
| 32 | * @pin_config_group_dbg_show: optional debugfs display hook that will provide | ||
| 33 | * per-device info for a certain group in debugfs | ||
| 34 | */ | ||
| 35 | struct pinconf_ops { | ||
| 36 | int (*pin_config_get) (struct pinctrl_dev *pctldev, | ||
| 37 | unsigned pin, | ||
| 38 | unsigned long *config); | ||
| 39 | int (*pin_config_set) (struct pinctrl_dev *pctldev, | ||
| 40 | unsigned pin, | ||
| 41 | unsigned long config); | ||
| 42 | int (*pin_config_group_get) (struct pinctrl_dev *pctldev, | ||
| 43 | unsigned selector, | ||
| 44 | unsigned long *config); | ||
| 45 | int (*pin_config_group_set) (struct pinctrl_dev *pctldev, | ||
| 46 | unsigned selector, | ||
| 47 | unsigned long config); | ||
| 48 | void (*pin_config_dbg_show) (struct pinctrl_dev *pctldev, | ||
| 49 | struct seq_file *s, | ||
| 50 | unsigned offset); | ||
| 51 | void (*pin_config_group_dbg_show) (struct pinctrl_dev *pctldev, | ||
| 52 | struct seq_file *s, | ||
| 53 | unsigned selector); | ||
| 54 | }; | ||
| 55 | |||
| 56 | extern int pin_config_get(const char *dev_name, const char *name, | ||
| 57 | unsigned long *config); | ||
| 58 | extern int pin_config_set(const char *dev_name, const char *name, | ||
| 59 | unsigned long config); | ||
| 60 | extern int pin_config_group_get(const char *dev_name, | ||
| 61 | const char *pin_group, | ||
| 62 | unsigned long *config); | ||
| 63 | extern int pin_config_group_set(const char *dev_name, | ||
| 64 | const char *pin_group, | ||
| 65 | unsigned long config); | ||
| 66 | |||
| 67 | #else | ||
| 68 | |||
| 69 | static inline int pin_config_get(const char *dev_name, const char *name, | ||
| 70 | unsigned long *config) | ||
| 71 | { | ||
| 72 | return 0; | ||
| 73 | } | ||
| 74 | |||
| 75 | static inline int pin_config_set(const char *dev_name, const char *name, | ||
| 76 | unsigned long config) | ||
| 77 | { | ||
| 78 | return 0; | ||
| 79 | } | ||
| 80 | |||
| 81 | static inline int pin_config_group_get(const char *dev_name, | ||
| 82 | const char *pin_group, | ||
| 83 | unsigned long *config) | ||
| 84 | { | ||
| 85 | return 0; | ||
| 86 | } | ||
| 87 | |||
| 88 | static inline int pin_config_group_set(const char *dev_name, | ||
| 89 | const char *pin_group, | ||
| 90 | unsigned long config) | ||
| 91 | { | ||
| 92 | return 0; | ||
| 93 | } | ||
| 94 | |||
| 95 | #endif | ||
| 96 | |||
| 97 | #endif /* __LINUX_PINCTRL_PINCONF_H */ | ||
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h index 04c011038f32..8bd22ee7aa09 100644 --- a/include/linux/pinctrl/pinctrl.h +++ b/include/linux/pinctrl/pinctrl.h | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | struct pinctrl_dev; | 22 | struct pinctrl_dev; |
| 23 | struct pinmux_ops; | 23 | struct pinmux_ops; |
| 24 | struct pinconf_ops; | ||
| 24 | struct gpio_chip; | 25 | struct gpio_chip; |
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| @@ -45,6 +46,7 @@ struct pinctrl_pin_desc { | |||
| 45 | * @name: a name for the chip in this range | 46 | * @name: a name for the chip in this range |
| 46 | * @id: an ID number for the chip in this range | 47 | * @id: an ID number for the chip in this range |
| 47 | * @base: base offset of the GPIO range | 48 | * @base: base offset of the GPIO range |
| 49 | * @pin_base: base pin number of the GPIO range | ||
| 48 | * @npins: number of pins in the GPIO range, including the base number | 50 | * @npins: number of pins in the GPIO range, including the base number |
| 49 | * @gc: an optional pointer to a gpio_chip | 51 | * @gc: an optional pointer to a gpio_chip |
| 50 | */ | 52 | */ |
| @@ -53,6 +55,7 @@ struct pinctrl_gpio_range { | |||
| 53 | const char *name; | 55 | const char *name; |
| 54 | unsigned int id; | 56 | unsigned int id; |
| 55 | unsigned int base; | 57 | unsigned int base; |
| 58 | unsigned int pin_base; | ||
| 56 | unsigned int npins; | 59 | unsigned int npins; |
| 57 | struct gpio_chip *gc; | 60 | struct gpio_chip *gc; |
| 58 | }; | 61 | }; |
| @@ -89,22 +92,20 @@ struct pinctrl_ops { | |||
| 89 | * this pin controller | 92 | * this pin controller |
| 90 | * @npins: number of descriptors in the array, usually just ARRAY_SIZE() | 93 | * @npins: number of descriptors in the array, usually just ARRAY_SIZE() |
| 91 | * of the pins field above | 94 | * of the pins field above |
| 92 | * @maxpin: since pin spaces may be sparse, there can he "holes" in the | ||
| 93 | * pin range, this attribute gives the maximum pin number in the | ||
| 94 | * total range. This should not be lower than npins for example, | ||
| 95 | * but may be equal to npins if you have no holes in the pin range. | ||
| 96 | * @pctlops: pin control operation vtable, to support global concepts like | 95 | * @pctlops: pin control operation vtable, to support global concepts like |
| 97 | * grouping of pins, this is optional. | 96 | * grouping of pins, this is optional. |
| 98 | * @pmxops: pinmux operation vtable, if you support pinmuxing in your driver | 97 | * @pmxops: pinmux operations vtable, if you support pinmuxing in your driver |
| 98 | * @confops: pin config operations vtable, if you support pin configuration in | ||
| 99 | * your driver | ||
| 99 | * @owner: module providing the pin controller, used for refcounting | 100 | * @owner: module providing the pin controller, used for refcounting |
| 100 | */ | 101 | */ |
| 101 | struct pinctrl_desc { | 102 | struct pinctrl_desc { |
| 102 | const char *name; | 103 | const char *name; |
| 103 | struct pinctrl_pin_desc const *pins; | 104 | struct pinctrl_pin_desc const *pins; |
| 104 | unsigned int npins; | 105 | unsigned int npins; |
| 105 | unsigned int maxpin; | ||
| 106 | struct pinctrl_ops *pctlops; | 106 | struct pinctrl_ops *pctlops; |
| 107 | struct pinmux_ops *pmxops; | 107 | struct pinmux_ops *pmxops; |
| 108 | struct pinconf_ops *confops; | ||
| 108 | struct module *owner; | 109 | struct module *owner; |
| 109 | }; | 110 | }; |
| 110 | 111 | ||
| @@ -123,7 +124,7 @@ extern void *pinctrl_dev_get_drvdata(struct pinctrl_dev *pctldev); | |||
| 123 | 124 | ||
| 124 | struct pinctrl_dev; | 125 | struct pinctrl_dev; |
| 125 | 126 | ||
| 126 | /* Sufficiently stupid default function when pinctrl is not in use */ | 127 | /* Sufficiently stupid default functions when pinctrl is not in use */ |
| 127 | static inline bool pin_is_valid(struct pinctrl_dev *pctldev, int pin) | 128 | static inline bool pin_is_valid(struct pinctrl_dev *pctldev, int pin) |
| 128 | { | 129 | { |
| 129 | return pin >= 0; | 130 | return pin >= 0; |
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h index 3c430e797efc..937b3e2fa36f 100644 --- a/include/linux/pinctrl/pinmux.h +++ b/include/linux/pinctrl/pinmux.h | |||
| @@ -52,9 +52,15 @@ struct pinctrl_dev; | |||
| 52 | * @disable: disable a certain muxing selector with a certain pin group | 52 | * @disable: disable a certain muxing selector with a certain pin group |
| 53 | * @gpio_request_enable: requests and enables GPIO on a certain pin. | 53 | * @gpio_request_enable: requests and enables GPIO on a certain pin. |
| 54 | * Implement this only if you can mux every pin individually as GPIO. The | 54 | * Implement this only if you can mux every pin individually as GPIO. The |
| 55 | * affected GPIO range is passed along with an offset into that | 55 | * affected GPIO range is passed along with an offset(pin number) into that |
| 56 | * specific GPIO range - function selectors and pin groups are orthogonal | 56 | * specific GPIO range - function selectors and pin groups are orthogonal |
| 57 | * to this, the core will however make sure the pins do not collide | 57 | * to this, the core will however make sure the pins do not collide. |
| 58 | * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of | ||
| 59 | * @gpio_request_enable | ||
| 60 | * @gpio_set_direction: Since controllers may need different configurations | ||
| 61 | * depending on whether the GPIO is configured as input or output, | ||
| 62 | * a direction selector function may be implemented as a backing | ||
| 63 | * to the GPIO controllers that need pin muxing. | ||
| 58 | */ | 64 | */ |
| 59 | struct pinmux_ops { | 65 | struct pinmux_ops { |
| 60 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); | 66 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); |
| @@ -73,11 +79,20 @@ struct pinmux_ops { | |||
| 73 | int (*gpio_request_enable) (struct pinctrl_dev *pctldev, | 79 | int (*gpio_request_enable) (struct pinctrl_dev *pctldev, |
| 74 | struct pinctrl_gpio_range *range, | 80 | struct pinctrl_gpio_range *range, |
| 75 | unsigned offset); | 81 | unsigned offset); |
| 82 | void (*gpio_disable_free) (struct pinctrl_dev *pctldev, | ||
| 83 | struct pinctrl_gpio_range *range, | ||
| 84 | unsigned offset); | ||
| 85 | int (*gpio_set_direction) (struct pinctrl_dev *pctldev, | ||
| 86 | struct pinctrl_gpio_range *range, | ||
| 87 | unsigned offset, | ||
| 88 | bool input); | ||
| 76 | }; | 89 | }; |
| 77 | 90 | ||
| 78 | /* External interface to pinmux */ | 91 | /* External interface to pinmux */ |
| 79 | extern int pinmux_request_gpio(unsigned gpio); | 92 | extern int pinmux_request_gpio(unsigned gpio); |
| 80 | extern void pinmux_free_gpio(unsigned gpio); | 93 | extern void pinmux_free_gpio(unsigned gpio); |
| 94 | extern int pinmux_gpio_direction_input(unsigned gpio); | ||
| 95 | extern int pinmux_gpio_direction_output(unsigned gpio); | ||
| 81 | extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name); | 96 | extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name); |
| 82 | extern void pinmux_put(struct pinmux *pmx); | 97 | extern void pinmux_put(struct pinmux *pmx); |
| 83 | extern int pinmux_enable(struct pinmux *pmx); | 98 | extern int pinmux_enable(struct pinmux *pmx); |
| @@ -94,6 +109,16 @@ static inline void pinmux_free_gpio(unsigned gpio) | |||
| 94 | { | 109 | { |
| 95 | } | 110 | } |
| 96 | 111 | ||
| 112 | static inline int pinmux_gpio_direction_input(unsigned gpio) | ||
| 113 | { | ||
| 114 | return 0; | ||
| 115 | } | ||
| 116 | |||
| 117 | static inline int pinmux_gpio_direction_output(unsigned gpio) | ||
| 118 | { | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | |||
| 97 | static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name) | 122 | static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name) |
| 98 | { | 123 | { |
| 99 | return NULL; | 124 | return NULL; |
