1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 2 /* 3 * Interface the pinctrl subsystem 4 * 5 * Copyright (C) 2011 ST-Ericsson SA 6 * Written on behalf of Linaro for ST-Ericsson 7 * This interface is used in the core to keep 8 * 9 * Author: Linus Walleij <linus.walleij@linaro 10 */ 11 #ifndef __LINUX_PINCTRL_PINCTRL_H 12 #define __LINUX_PINCTRL_PINCTRL_H 13 14 #include <linux/types.h> 15 16 struct device; 17 struct device_node; 18 struct gpio_chip; 19 struct module; 20 struct seq_file; 21 22 struct pin_config_item; 23 struct pinconf_generic_params; 24 struct pinconf_ops; 25 struct pinctrl_dev; 26 struct pinctrl_map; 27 struct pinmux_ops; 28 29 /** 30 * struct pingroup - provides information on p 31 * @name: a name for pingroup 32 * @pins: an array of pins in the pingroup 33 * @npins: number of pins in the pingroup 34 */ 35 struct pingroup { 36 const char *name; 37 const unsigned int *pins; 38 size_t npins; 39 }; 40 41 /* Convenience macro to define a single named 42 #define PINCTRL_PINGROUP(_name, _pins, _npins) 43 (struct pingroup) { 44 .name = _name, 45 .pins = _pins, 46 .npins = _npins, 47 } 48 49 /** 50 * struct pinctrl_pin_desc - boards/machines p 51 * pins, pads or other muxable units in this s 52 * @number: unique pin number from the global 53 * @name: a name for this pin 54 * @drv_data: driver-defined per-pin data. pin 55 */ 56 struct pinctrl_pin_desc { 57 unsigned int number; 58 const char *name; 59 void *drv_data; 60 }; 61 62 /* Convenience macro to define a single named 63 #define PINCTRL_PIN(a, b) { .number = a, .name 64 #define PINCTRL_PIN_ANON(a) { .number = a } 65 66 /** 67 * struct pinctrl_gpio_range - each pin contro 68 * the GPIO number space to be handled by the 69 * @node: list node for internal use 70 * @name: a name for the chip in this range 71 * @id: an ID number for the chip in this rang 72 * @base: base offset of the GPIO range 73 * @pin_base: base pin number of the GPIO rang 74 * @npins: number of pins in the GPIO range, i 75 * @pins: enumeration of pins in GPIO range or 76 * @gc: an optional pointer to a gpio_chip 77 */ 78 struct pinctrl_gpio_range { 79 struct list_head node; 80 const char *name; 81 unsigned int id; 82 unsigned int base; 83 unsigned int pin_base; 84 unsigned int npins; 85 unsigned int const *pins; 86 struct gpio_chip *gc; 87 }; 88 89 /** 90 * struct pinctrl_ops - global pin control ope 91 * pin controller drivers. 92 * @get_groups_count: Returns the count of tot 93 * @get_group_name: return the group name of t 94 * @get_group_pins: return an array of pins co 95 * group selector @pins, and the size of 96 * @pin_dbg_show: optional debugfs display hoo 97 * info for a certain pin in debugfs 98 * @dt_node_to_map: parse a device tree "pin c 99 * mapping table entries for it. These ar 100 * @num_maps output parameters. This func 101 * omitted for pinctrl drivers that do no 102 * @dt_free_map: free mapping table entries cr 103 * top-level @map pointer must be freed, 104 * allocated members of the mapping table 105 * function is optional, and may be omitt 106 * not support device tree. 107 */ 108 struct pinctrl_ops { 109 int (*get_groups_count) (struct pinctr 110 const char *(*get_group_name) (struct 111 unsigne 112 int (*get_group_pins) (struct pinctrl_ 113 unsigned int se 114 const unsigned 115 unsigned int *n 116 void (*pin_dbg_show) (struct pinctrl_d 117 unsigned int off 118 int (*dt_node_to_map) (struct pinctrl_ 119 struct device_n 120 struct pinctrl_ 121 void (*dt_free_map) (struct pinctrl_de 122 struct pinctrl_ma 123 }; 124 125 /** 126 * struct pinctrl_desc - pin controller descri 127 * control subsystem 128 * @name: name for the pin controller 129 * @pins: an array of pin descriptors describi 130 * this pin controller 131 * @npins: number of descriptors in the array, 132 * of the pins field above 133 * @pctlops: pin control operation vtable, to 134 * grouping of pins, this is optional. 135 * @pmxops: pinmux operations vtable, if you s 136 * @confops: pin config operations vtable, if 137 * your driver 138 * @owner: module providing the pin controller 139 * @num_custom_params: Number of driver-specif 140 * from the hardware description 141 * @custom_params: List of driver_specific cus 142 * the hardware description 143 * @custom_conf_items: Information how to prin 144 * the same size as the @custom_params, i 145 * @link_consumers: If true create a device li 146 * consumers (i.e. the devices requesting 147 * sometimes necessary to ascertain the r 148 * example. 149 */ 150 struct pinctrl_desc { 151 const char *name; 152 const struct pinctrl_pin_desc *pins; 153 unsigned int npins; 154 const struct pinctrl_ops *pctlops; 155 const struct pinmux_ops *pmxops; 156 const struct pinconf_ops *confops; 157 struct module *owner; 158 #ifdef CONFIG_GENERIC_PINCONF 159 unsigned int num_custom_params; 160 const struct pinconf_generic_params *c 161 const struct pin_config_item *custom_c 162 #endif 163 bool link_consumers; 164 }; 165 166 /* External interface to pin controller */ 167 168 extern int pinctrl_register_and_init(struct pi 169 struct de 170 struct pi 171 extern int pinctrl_enable(struct pinctrl_dev * 172 173 /* Please use pinctrl_register_and_init() and 174 extern struct pinctrl_dev *pinctrl_register(st 175 struct device 176 177 extern void pinctrl_unregister(struct pinctrl_ 178 179 extern int devm_pinctrl_register_and_init(stru 180 struct pinctrl 181 void *driver_d 182 struct pinctrl 183 184 /* Please use devm_pinctrl_register_and_init() 185 extern struct pinctrl_dev *devm_pinctrl_regist 186 struct pinctrl 187 void *driver_d 188 189 extern void devm_pinctrl_unregister(struct dev 190 struct pinctrl 191 192 extern void pinctrl_add_gpio_range(struct pinc 193 struct pinctrl 194 extern void pinctrl_add_gpio_ranges(struct pin 195 struct pinctrl 196 unsigned int n 197 extern void pinctrl_remove_gpio_range(struct p 198 struct pinctrl 199 200 extern struct pinctrl_dev *pinctrl_find_and_ad 201 struct pinctrl_gpio_range *ran 202 extern struct pinctrl_gpio_range * 203 pinctrl_find_gpio_range_from_pin(struct pinctr 204 unsigned int 205 extern int pinctrl_get_group_pins(struct pinct 206 const char * 207 unsigned int 208 209 /** 210 * struct pinfunction - Description about a fu 211 * @name: Name of the function 212 * @groups: An array of groups for this functi 213 * @ngroups: Number of groups in @groups 214 */ 215 struct pinfunction { 216 const char *name; 217 const char * const *groups; 218 size_t ngroups; 219 }; 220 221 /* Convenience macro to define a single named 222 #define PINCTRL_PINFUNCTION(_name, _groups, _n 223 (struct pinfunction) { 224 .name = (_name), 225 .groups = (_groups), 226 .ngroups = (_ngroups), 227 } 228 229 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG 230 extern struct pinctrl_dev *of_pinctrl_get(stru 231 #else 232 static inline 233 struct pinctrl_dev *of_pinctrl_get(struct devi 234 { 235 return NULL; 236 } 237 #endif /* CONFIG_OF */ 238 239 extern const char *pinctrl_dev_get_name(struct 240 extern const char *pinctrl_dev_get_devname(str 241 extern void *pinctrl_dev_get_drvdata(struct pi 242 243 #endif /* __LINUX_PINCTRL_PINCTRL_H */ 244
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.