![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * Interface the generic pinconfig portions of the pinctrl subsystem 0004 * 0005 * Copyright (C) 2011 ST-Ericsson SA 0006 * Written on behalf of Linaro for ST-Ericsson 0007 * This interface is used in the core to keep track of pins. 0008 * 0009 * Author: Linus Walleij <linus.walleij@linaro.org> 0010 */ 0011 #ifndef __LINUX_PINCTRL_PINCONF_GENERIC_H 0012 #define __LINUX_PINCTRL_PINCONF_GENERIC_H 0013 0014 #include <linux/device.h> 0015 #include <linux/pinctrl/machine.h> 0016 0017 struct pinctrl_dev; 0018 struct pinctrl_map; 0019 0020 /** 0021 * enum pin_config_param - possible pin configuration parameters 0022 * @PIN_CONFIG_BIAS_BUS_HOLD: the pin will be set to weakly latch so that it 0023 * weakly drives the last value on a tristate bus, also known as a "bus 0024 * holder", "bus keeper" or "repeater". This allows another device on the 0025 * bus to change the value by driving the bus high or low and switching to 0026 * tristate. The argument is ignored. 0027 * @PIN_CONFIG_BIAS_DISABLE: disable any pin bias on the pin, a 0028 * transition from say pull-up to pull-down implies that you disable 0029 * pull-up in the process, this setting disables all biasing. 0030 * @PIN_CONFIG_BIAS_HIGH_IMPEDANCE: the pin will be set to a high impedance 0031 * mode, also know as "third-state" (tristate) or "high-Z" or "floating". 0032 * On output pins this effectively disconnects the pin, which is useful 0033 * if for example some other pin is going to drive the signal connected 0034 * to it for a while. Pins used for input are usually always high 0035 * impedance. 0036 * @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high 0037 * impedance to GROUND). If the argument is != 0 pull-down is enabled, 0038 * if it is 0, pull-down is total, i.e. the pin is connected to GROUND. 0039 * @PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: the pin will be pulled up or down based 0040 * on embedded knowledge of the controller hardware, like current mux 0041 * function. The pull direction and possibly strength too will normally 0042 * be decided completely inside the hardware block and not be readable 0043 * from the kernel side. 0044 * If the argument is != 0 pull up/down is enabled, if it is 0, the 0045 * configuration is ignored. The proper way to disable it is to use 0046 * @PIN_CONFIG_BIAS_DISABLE. 0047 * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high 0048 * impedance to VDD). If the argument is != 0 pull-up is enabled, 0049 * if it is 0, pull-up is total, i.e. the pin is connected to VDD. 0050 * @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open 0051 * collector) which means it is usually wired with other output ports 0052 * which are then pulled up with an external resistor. Setting this 0053 * config will enable open drain mode, the argument is ignored. 0054 * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source 0055 * (open emitter). Setting this config will enable open source mode, the 0056 * argument is ignored. 0057 * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and 0058 * low, this is the most typical case and is typically achieved with two 0059 * active transistors on the output. Setting this config will enable 0060 * push-pull mode, the argument is ignored. 0061 * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current 0062 * passed as argument. The argument is in mA. 0063 * @PIN_CONFIG_DRIVE_STRENGTH_UA: the pin will sink or source at most the current 0064 * passed as argument. The argument is in uA. 0065 * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode, 0066 * which means it will wait for signals to settle when reading inputs. The 0067 * argument gives the debounce time in usecs. Setting the 0068 * argument to zero turns debouncing off. 0069 * @PIN_CONFIG_INPUT_ENABLE: enable the pin's input. Note that this does not 0070 * affect the pin's ability to drive output. 1 enables input, 0 disables 0071 * input. 0072 * @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in 0073 * schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis, 0074 * the threshold value is given on a custom format as argument when 0075 * setting pins to this mode. 0076 * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin. 0077 * If the argument != 0, schmitt-trigger mode is enabled. If it's 0, 0078 * schmitt-trigger mode is disabled. 0079 * @PIN_CONFIG_MODE_LOW_POWER: this will configure the pin for low power 0080 * operation, if several modes of operation are supported these can be 0081 * passed in the argument on a custom form, else just use argument 1 0082 * to indicate low power mode, argument 0 turns low power mode off. 0083 * @PIN_CONFIG_MODE_PWM: this will configure the pin for PWM 0084 * @PIN_CONFIG_OUTPUT: this will configure the pin as an output and drive a 0085 * value on the line. Use argument 1 to indicate high level, argument 0 to 0086 * indicate low level. (Please see Documentation/driver-api/pin-control.rst, 0087 * section "GPIO mode pitfalls" for a discussion around this parameter.) 0088 * @PIN_CONFIG_OUTPUT_ENABLE: this will enable the pin's output mode 0089 * without driving a value there. For most platforms this reduces to 0090 * enable the output buffers and then let the pin controller current 0091 * configuration (eg. the currently selected mux function) drive values on 0092 * the line. Use argument 1 to enable output mode, argument 0 to disable 0093 * it. 0094 * @PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS: this will configure the output impedance 0095 * of the pin with the value passed as argument. The argument is in ohms. 0096 * @PIN_CONFIG_PERSIST_STATE: retain pin state across sleep or controller reset 0097 * @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power 0098 * supplies, the argument to this parameter (on a custom format) tells 0099 * the driver which alternative power source to use. 0100 * @PIN_CONFIG_SKEW_DELAY: if the pin has programmable skew rate (on inputs) 0101 * or latch delay (on outputs) this parameter (in a custom format) 0102 * specifies the clock skew or latch delay. It typically controls how 0103 * many double inverters are put in front of the line. 0104 * @PIN_CONFIG_SLEEP_HARDWARE_STATE: indicate this is sleep related state. 0105 * @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to 0106 * this parameter (on a custom format) tells the driver which alternative 0107 * slew rate to use. 0108 * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if 0109 * you need to pass in custom configurations to the pin controller, use 0110 * PIN_CONFIG_END+1 as the base offset. 0111 * @PIN_CONFIG_MAX: this is the maximum configuration value that can be 0112 * presented using the packed format. 0113 */ 0114 enum pin_config_param { 0115 PIN_CONFIG_BIAS_BUS_HOLD, 0116 PIN_CONFIG_BIAS_DISABLE, 0117 PIN_CONFIG_BIAS_HIGH_IMPEDANCE, 0118 PIN_CONFIG_BIAS_PULL_DOWN, 0119 PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, 0120 PIN_CONFIG_BIAS_PULL_UP, 0121 PIN_CONFIG_DRIVE_OPEN_DRAIN, 0122 PIN_CONFIG_DRIVE_OPEN_SOURCE, 0123 PIN_CONFIG_DRIVE_PUSH_PULL, 0124 PIN_CONFIG_DRIVE_STRENGTH, 0125 PIN_CONFIG_DRIVE_STRENGTH_UA, 0126 PIN_CONFIG_INPUT_DEBOUNCE, 0127 PIN_CONFIG_INPUT_ENABLE, 0128 PIN_CONFIG_INPUT_SCHMITT, 0129 PIN_CONFIG_INPUT_SCHMITT_ENABLE, 0130 PIN_CONFIG_MODE_LOW_POWER, 0131 PIN_CONFIG_MODE_PWM, 0132 PIN_CONFIG_OUTPUT, 0133 PIN_CONFIG_OUTPUT_ENABLE, 0134 PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS, 0135 PIN_CONFIG_PERSIST_STATE, 0136 PIN_CONFIG_POWER_SOURCE, 0137 PIN_CONFIG_SKEW_DELAY, 0138 PIN_CONFIG_SLEEP_HARDWARE_STATE, 0139 PIN_CONFIG_SLEW_RATE, 0140 PIN_CONFIG_END = 0x7F, 0141 PIN_CONFIG_MAX = 0xFF, 0142 }; 0143 0144 /* 0145 * Helpful configuration macro to be used in tables etc. 0146 */ 0147 #define PIN_CONF_PACKED(p, a) ((a << 8) | ((unsigned long) p & 0xffUL)) 0148 0149 /* 0150 * The following inlines stuffs a configuration parameter and data value 0151 * into and out of an unsigned long argument, as used by the generic pin config 0152 * system. We put the parameter in the lower 8 bits and the argument in the 0153 * upper 24 bits. 0154 */ 0155 0156 static inline enum pin_config_param pinconf_to_config_param(unsigned long config) 0157 { 0158 return (enum pin_config_param) (config & 0xffUL); 0159 } 0160 0161 static inline u32 pinconf_to_config_argument(unsigned long config) 0162 { 0163 return (u32) ((config >> 8) & 0xffffffUL); 0164 } 0165 0166 static inline unsigned long pinconf_to_config_packed(enum pin_config_param param, 0167 u32 argument) 0168 { 0169 return PIN_CONF_PACKED(param, argument); 0170 } 0171 0172 #define PCONFDUMP(a, b, c, d) { \ 0173 .param = a, .display = b, .format = c, .has_arg = d \ 0174 } 0175 0176 struct pin_config_item { 0177 const enum pin_config_param param; 0178 const char * const display; 0179 const char * const format; 0180 bool has_arg; 0181 }; 0182 0183 struct pinconf_generic_params { 0184 const char * const property; 0185 enum pin_config_param param; 0186 u32 default_value; 0187 }; 0188 0189 int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, 0190 struct device_node *np, struct pinctrl_map **map, 0191 unsigned *reserved_maps, unsigned *num_maps, 0192 enum pinctrl_map_type type); 0193 int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, 0194 struct device_node *np_config, struct pinctrl_map **map, 0195 unsigned *num_maps, enum pinctrl_map_type type); 0196 void pinconf_generic_dt_free_map(struct pinctrl_dev *pctldev, 0197 struct pinctrl_map *map, unsigned num_maps); 0198 0199 static inline int pinconf_generic_dt_node_to_map_group( 0200 struct pinctrl_dev *pctldev, struct device_node *np_config, 0201 struct pinctrl_map **map, unsigned *num_maps) 0202 { 0203 return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps, 0204 PIN_MAP_TYPE_CONFIGS_GROUP); 0205 } 0206 0207 static inline int pinconf_generic_dt_node_to_map_pin( 0208 struct pinctrl_dev *pctldev, struct device_node *np_config, 0209 struct pinctrl_map **map, unsigned *num_maps) 0210 { 0211 return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps, 0212 PIN_MAP_TYPE_CONFIGS_PIN); 0213 } 0214 0215 static inline int pinconf_generic_dt_node_to_map_all( 0216 struct pinctrl_dev *pctldev, struct device_node *np_config, 0217 struct pinctrl_map **map, unsigned *num_maps) 0218 { 0219 /* 0220 * passing the type as PIN_MAP_TYPE_INVALID causes the underlying parser 0221 * to infer the map type from the DT properties used. 0222 */ 0223 return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps, 0224 PIN_MAP_TYPE_INVALID); 0225 } 0226 0227 #endif /* __LINUX_PINCTRL_PINCONF_GENERIC_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |