1d90a5a30SMasahiro Yamada /* 2d90a5a30SMasahiro Yamada * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com> 3d90a5a30SMasahiro Yamada * 4d90a5a30SMasahiro Yamada * SPDX-License-Identifier: GPL-2.0+ 5d90a5a30SMasahiro Yamada */ 6d90a5a30SMasahiro Yamada 7d90a5a30SMasahiro Yamada #ifndef __PINCTRL_H 8d90a5a30SMasahiro Yamada #define __PINCTRL_H 9d90a5a30SMasahiro Yamada 10d90a5a30SMasahiro Yamada /** 11d90a5a30SMasahiro Yamada * struct pinconf_param - pin config parameters 12d90a5a30SMasahiro Yamada * 13d90a5a30SMasahiro Yamada * @property: property name in DT nodes 14d90a5a30SMasahiro Yamada * @param: ID for this config parameter 15d90a5a30SMasahiro Yamada * @default_value: default value for this config parameter used in case 16d90a5a30SMasahiro Yamada * no value is specified in DT nodes 17d90a5a30SMasahiro Yamada */ 18d90a5a30SMasahiro Yamada struct pinconf_param { 19d90a5a30SMasahiro Yamada const char * const property; 20d90a5a30SMasahiro Yamada unsigned int param; 21d90a5a30SMasahiro Yamada u32 default_value; 22d90a5a30SMasahiro Yamada }; 23d90a5a30SMasahiro Yamada 24d90a5a30SMasahiro Yamada /** 25d90a5a30SMasahiro Yamada * struct pinctrl_ops - pin control operations, to be implemented by 26d90a5a30SMasahiro Yamada * pin controller drivers. 27d90a5a30SMasahiro Yamada * 28d90a5a30SMasahiro Yamada * The @set_state is the only mandatory operation. You can implement your 29d90a5a30SMasahiro Yamada * pinctrl driver with its own @set_state. In this case, the other callbacks 30d90a5a30SMasahiro Yamada * are not required. Otherwise, generic pinctrl framework is also available; 31d90a5a30SMasahiro Yamada * use pinctrl_generic_set_state for @set_state, and implement other operations 32d90a5a30SMasahiro Yamada * depending on your necessity. 33d90a5a30SMasahiro Yamada * 34d90a5a30SMasahiro Yamada * @get_pins_count: return number of selectable named pins available 35d90a5a30SMasahiro Yamada * in this driver. (necessary to parse "pins" property in DTS) 36d90a5a30SMasahiro Yamada * @get_pin_name: return the pin name of the pin selector, 37d90a5a30SMasahiro Yamada * called by the core to figure out which pin it shall do 38d90a5a30SMasahiro Yamada * operations to. (necessary to parse "pins" property in DTS) 39d90a5a30SMasahiro Yamada * @get_groups_count: return number of selectable named groups available 40d90a5a30SMasahiro Yamada * in this driver. (necessary to parse "groups" property in DTS) 41d90a5a30SMasahiro Yamada * @get_group_name: return the group name of the group selector, 42d90a5a30SMasahiro Yamada * called by the core to figure out which pin group it shall do 43d90a5a30SMasahiro Yamada * operations to. (necessary to parse "groups" property in DTS) 44d90a5a30SMasahiro Yamada * @get_functions_count: return number of selectable named functions available 45d90a5a30SMasahiro Yamada * in this driver. (necessary for pin-muxing) 46d90a5a30SMasahiro Yamada * @get_function_name: return the function name of the muxing selector, 47d90a5a30SMasahiro Yamada * called by the core to figure out which mux setting it shall map a 48d90a5a30SMasahiro Yamada * certain device to. (necessary for pin-muxing) 49d90a5a30SMasahiro Yamada * @pinmux_set: enable a certain muxing function with a certain pin. 50d90a5a30SMasahiro Yamada * The @func_selector selects a certain function whereas @pin_selector 51d90a5a30SMasahiro Yamada * selects a certain pin to be used. On simple controllers one of them 52d90a5a30SMasahiro Yamada * may be ignored. (necessary for pin-muxing against a single pin) 53d90a5a30SMasahiro Yamada * @pinmux_group_set: enable a certain muxing function with a certain pin 54d90a5a30SMasahiro Yamada * group. The @func_selector selects a certain function whereas 55d90a5a30SMasahiro Yamada * @group_selector selects a certain set of pins to be used. On simple 56d90a5a30SMasahiro Yamada * controllers one of them may be ignored. 57d90a5a30SMasahiro Yamada * (necessary for pin-muxing against a pin group) 58d90a5a30SMasahiro Yamada * @pinconf_num_params: number of driver-specific parameters to be parsed 59d90a5a30SMasahiro Yamada * from device trees (necessary for pin-configuration) 60d90a5a30SMasahiro Yamada * @pinconf_params: list of driver_specific parameters to be parsed from 61d90a5a30SMasahiro Yamada * device trees (necessary for pin-configuration) 62d90a5a30SMasahiro Yamada * @pinconf_set: configure an individual pin with a given parameter. 63d90a5a30SMasahiro Yamada * (necessary for pin-configuration against a single pin) 64d90a5a30SMasahiro Yamada * @pinconf_group_set: configure all pins in a group with a given parameter. 65d90a5a30SMasahiro Yamada * (necessary for pin-configuration against a pin group) 66d90a5a30SMasahiro Yamada * @set_state: do pinctrl operations specified by @config, a pseudo device 67d90a5a30SMasahiro Yamada * pointing a config node. (necessary for pinctrl_full) 68d90a5a30SMasahiro Yamada * @set_state_simple: do needed pinctrl operations for a peripherl @periph. 69d90a5a30SMasahiro Yamada * (necessary for pinctrl_simple) 70*6b9191d0SPatrice Chotard * @get_pin_muxing: display the muxing of a given pin. 71d90a5a30SMasahiro Yamada */ 72d90a5a30SMasahiro Yamada struct pinctrl_ops { 73d90a5a30SMasahiro Yamada int (*get_pins_count)(struct udevice *dev); 74d90a5a30SMasahiro Yamada const char *(*get_pin_name)(struct udevice *dev, unsigned selector); 75d90a5a30SMasahiro Yamada int (*get_groups_count)(struct udevice *dev); 76d90a5a30SMasahiro Yamada const char *(*get_group_name)(struct udevice *dev, unsigned selector); 77d90a5a30SMasahiro Yamada int (*get_functions_count)(struct udevice *dev); 78d90a5a30SMasahiro Yamada const char *(*get_function_name)(struct udevice *dev, 79d90a5a30SMasahiro Yamada unsigned selector); 80d90a5a30SMasahiro Yamada int (*pinmux_set)(struct udevice *dev, unsigned pin_selector, 81d90a5a30SMasahiro Yamada unsigned func_selector); 82d90a5a30SMasahiro Yamada int (*pinmux_group_set)(struct udevice *dev, unsigned group_selector, 83d90a5a30SMasahiro Yamada unsigned func_selector); 84d90a5a30SMasahiro Yamada unsigned int pinconf_num_params; 85d90a5a30SMasahiro Yamada const struct pinconf_param *pinconf_params; 86d90a5a30SMasahiro Yamada int (*pinconf_set)(struct udevice *dev, unsigned pin_selector, 87d90a5a30SMasahiro Yamada unsigned param, unsigned argument); 88d90a5a30SMasahiro Yamada int (*pinconf_group_set)(struct udevice *dev, unsigned group_selector, 89d90a5a30SMasahiro Yamada unsigned param, unsigned argument); 90d90a5a30SMasahiro Yamada int (*set_state)(struct udevice *dev, struct udevice *config); 91c5acf4a2SSimon Glass 92c5acf4a2SSimon Glass /* for pinctrl-simple */ 93d90a5a30SMasahiro Yamada int (*set_state_simple)(struct udevice *dev, struct udevice *periph); 94c5acf4a2SSimon Glass /** 95c5acf4a2SSimon Glass * request() - Request a particular pinctrl function 96c5acf4a2SSimon Glass * 97c5acf4a2SSimon Glass * This activates the selected function. 98c5acf4a2SSimon Glass * 99c5acf4a2SSimon Glass * @dev: Device to adjust (UCLASS_PINCTRL) 100c5acf4a2SSimon Glass * @func: Function number (driver-specific) 101c5acf4a2SSimon Glass * @return 0 if OK, -ve on error 102c5acf4a2SSimon Glass */ 103c5acf4a2SSimon Glass int (*request)(struct udevice *dev, int func, int flags); 104c5acf4a2SSimon Glass 105c5acf4a2SSimon Glass /** 106c5acf4a2SSimon Glass * get_periph_id() - get the peripheral ID for a device 107c5acf4a2SSimon Glass * 108c5acf4a2SSimon Glass * This generally looks at the peripheral's device tree node to work 109c5acf4a2SSimon Glass * out the peripheral ID. The return value is normally interpreted as 110c5acf4a2SSimon Glass * enum periph_id. so long as this is defined by the platform (which it 111c5acf4a2SSimon Glass * should be). 112c5acf4a2SSimon Glass * 113c5acf4a2SSimon Glass * @dev: Pinctrl device to use for decoding 114c5acf4a2SSimon Glass * @periph: Device to check 115c5acf4a2SSimon Glass * @return peripheral ID of @periph, or -ENOENT on error 116c5acf4a2SSimon Glass */ 117c5acf4a2SSimon Glass int (*get_periph_id)(struct udevice *dev, struct udevice *periph); 11877eaa19eSSimon Glass 11977eaa19eSSimon Glass /** 12077eaa19eSSimon Glass * get_gpio_mux() - get the mux value for a particular GPIO 12177eaa19eSSimon Glass * 12277eaa19eSSimon Glass * This allows the raw mux value for a GPIO to be obtained. It is 12377eaa19eSSimon Glass * useful for displaying the function being used by that GPIO, such 12477eaa19eSSimon Glass * as with the 'gpio' command. This function is internal to the GPIO 12577eaa19eSSimon Glass * subsystem and should not be used by generic code. Typically it is 12677eaa19eSSimon Glass * used by a GPIO driver with knowledge of the SoC pinctrl setup. 12777eaa19eSSimon Glass * 12877eaa19eSSimon Glass * @dev: Pinctrl device to use 12977eaa19eSSimon Glass * @banknum: GPIO bank number 13077eaa19eSSimon Glass * @index: GPIO index within the bank 13177eaa19eSSimon Glass * @return mux value (SoC-specific, e.g. 0 for input, 1 for output) 13277eaa19eSSimon Glass */ 13377eaa19eSSimon Glass int (*get_gpio_mux)(struct udevice *dev, int banknum, int index); 134*6b9191d0SPatrice Chotard 135*6b9191d0SPatrice Chotard /** 136*6b9191d0SPatrice Chotard * get_pin_muxing() - show pin muxing 137*6b9191d0SPatrice Chotard * 138*6b9191d0SPatrice Chotard * This allows to display the muxing of a given pin. It's useful for 139*6b9191d0SPatrice Chotard * debug purpose to know if a pin is configured as GPIO or as an 140*6b9191d0SPatrice Chotard * alternate function and which one. 141*6b9191d0SPatrice Chotard * Typically it is used by a PINCTRL driver with knowledge of the SoC 142*6b9191d0SPatrice Chotard * pinctrl setup. 143*6b9191d0SPatrice Chotard * 144*6b9191d0SPatrice Chotard * @dev: Pinctrl device to use 145*6b9191d0SPatrice Chotard * @selector: Pin selector 146*6b9191d0SPatrice Chotard * @buf Pin's muxing description 147*6b9191d0SPatrice Chotard * @size Pin's muxing description length 148*6b9191d0SPatrice Chotard * return 0 if OK, -ve on error 149*6b9191d0SPatrice Chotard */ 150*6b9191d0SPatrice Chotard int (*get_pin_muxing)(struct udevice *dev, unsigned int selector, 151*6b9191d0SPatrice Chotard char *buf, int size); 152d90a5a30SMasahiro Yamada }; 153d90a5a30SMasahiro Yamada 154d90a5a30SMasahiro Yamada #define pinctrl_get_ops(dev) ((struct pinctrl_ops *)(dev)->driver->ops) 155d90a5a30SMasahiro Yamada 156d90a5a30SMasahiro Yamada /** 157d90a5a30SMasahiro Yamada * Generic pin configuration paramters 158d90a5a30SMasahiro Yamada * 159d90a5a30SMasahiro Yamada * @PIN_CONFIG_BIAS_DISABLE: disable any pin bias on the pin, a 160d90a5a30SMasahiro Yamada * transition from say pull-up to pull-down implies that you disable 161d90a5a30SMasahiro Yamada * pull-up in the process, this setting disables all biasing. 162d90a5a30SMasahiro Yamada * @PIN_CONFIG_BIAS_HIGH_IMPEDANCE: the pin will be set to a high impedance 163d90a5a30SMasahiro Yamada * mode, also know as "third-state" (tristate) or "high-Z" or "floating". 164d90a5a30SMasahiro Yamada * On output pins this effectively disconnects the pin, which is useful 165d90a5a30SMasahiro Yamada * if for example some other pin is going to drive the signal connected 166d90a5a30SMasahiro Yamada * to it for a while. Pins used for input are usually always high 167d90a5a30SMasahiro Yamada * impedance. 168d90a5a30SMasahiro Yamada * @PIN_CONFIG_BIAS_BUS_HOLD: the pin will be set to weakly latch so that it 169d90a5a30SMasahiro Yamada * weakly drives the last value on a tristate bus, also known as a "bus 170d90a5a30SMasahiro Yamada * holder", "bus keeper" or "repeater". This allows another device on the 171d90a5a30SMasahiro Yamada * bus to change the value by driving the bus high or low and switching to 172d90a5a30SMasahiro Yamada * tristate. The argument is ignored. 173d90a5a30SMasahiro Yamada * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high 174d90a5a30SMasahiro Yamada * impedance to VDD). If the argument is != 0 pull-up is enabled, 175d90a5a30SMasahiro Yamada * if it is 0, pull-up is total, i.e. the pin is connected to VDD. 176d90a5a30SMasahiro Yamada * @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high 177d90a5a30SMasahiro Yamada * impedance to GROUND). If the argument is != 0 pull-down is enabled, 178d90a5a30SMasahiro Yamada * if it is 0, pull-down is total, i.e. the pin is connected to GROUND. 179d90a5a30SMasahiro Yamada * @PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: the pin will be pulled up or down based 180d90a5a30SMasahiro Yamada * on embedded knowledge of the controller hardware, like current mux 181d90a5a30SMasahiro Yamada * function. The pull direction and possibly strength too will normally 182d90a5a30SMasahiro Yamada * be decided completely inside the hardware block and not be readable 183d90a5a30SMasahiro Yamada * from the kernel side. 184d90a5a30SMasahiro Yamada * If the argument is != 0 pull up/down is enabled, if it is 0, the 185d90a5a30SMasahiro Yamada * configuration is ignored. The proper way to disable it is to use 186d90a5a30SMasahiro Yamada * @PIN_CONFIG_BIAS_DISABLE. 187d90a5a30SMasahiro Yamada * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and 188d90a5a30SMasahiro Yamada * low, this is the most typical case and is typically achieved with two 189d90a5a30SMasahiro Yamada * active transistors on the output. Setting this config will enable 190d90a5a30SMasahiro Yamada * push-pull mode, the argument is ignored. 191d90a5a30SMasahiro Yamada * @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open 192d90a5a30SMasahiro Yamada * collector) which means it is usually wired with other output ports 193d90a5a30SMasahiro Yamada * which are then pulled up with an external resistor. Setting this 194d90a5a30SMasahiro Yamada * config will enable open drain mode, the argument is ignored. 195d90a5a30SMasahiro Yamada * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source 196d90a5a30SMasahiro Yamada * (open emitter). Setting this config will enable open source mode, the 197d90a5a30SMasahiro Yamada * argument is ignored. 198d90a5a30SMasahiro Yamada * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current 199d90a5a30SMasahiro Yamada * passed as argument. The argument is in mA. 200d90a5a30SMasahiro Yamada * @PIN_CONFIG_INPUT_ENABLE: enable the pin's input. Note that this does not 201d90a5a30SMasahiro Yamada * affect the pin's ability to drive output. 1 enables input, 0 disables 202d90a5a30SMasahiro Yamada * input. 203d90a5a30SMasahiro Yamada * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin. 204d90a5a30SMasahiro Yamada * If the argument != 0, schmitt-trigger mode is enabled. If it's 0, 205d90a5a30SMasahiro Yamada * schmitt-trigger mode is disabled. 206d90a5a30SMasahiro Yamada * @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in 207d90a5a30SMasahiro Yamada * schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis, 208d90a5a30SMasahiro Yamada * the threshold value is given on a custom format as argument when 209d90a5a30SMasahiro Yamada * setting pins to this mode. 210d90a5a30SMasahiro Yamada * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode, 211d90a5a30SMasahiro Yamada * which means it will wait for signals to settle when reading inputs. The 212d90a5a30SMasahiro Yamada * argument gives the debounce time in usecs. Setting the 213d90a5a30SMasahiro Yamada * argument to zero turns debouncing off. 214d90a5a30SMasahiro Yamada * @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power 215d90a5a30SMasahiro Yamada * supplies, the argument to this parameter (on a custom format) tells 216d90a5a30SMasahiro Yamada * the driver which alternative power source to use. 217d90a5a30SMasahiro Yamada * @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to 218d90a5a30SMasahiro Yamada * this parameter (on a custom format) tells the driver which alternative 219d90a5a30SMasahiro Yamada * slew rate to use. 220d90a5a30SMasahiro Yamada * @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power 221d90a5a30SMasahiro Yamada * operation, if several modes of operation are supported these can be 222d90a5a30SMasahiro Yamada * passed in the argument on a custom form, else just use argument 1 223d90a5a30SMasahiro Yamada * to indicate low power mode, argument 0 turns low power mode off. 224d90a5a30SMasahiro Yamada * @PIN_CONFIG_OUTPUT: this will configure the pin as an output. Use argument 225d90a5a30SMasahiro Yamada * 1 to indicate high level, argument 0 to indicate low level. (Please 226d90a5a30SMasahiro Yamada * see Documentation/pinctrl.txt, section "GPIO mode pitfalls" for a 227d90a5a30SMasahiro Yamada * discussion around this parameter.) 228d90a5a30SMasahiro Yamada * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if 229d90a5a30SMasahiro Yamada * you need to pass in custom configurations to the pin controller, use 230d90a5a30SMasahiro Yamada * PIN_CONFIG_END+1 as the base offset. 231d90a5a30SMasahiro Yamada */ 232d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_DISABLE 0 233d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_HIGH_IMPEDANCE 1 234d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_BUS_HOLD 2 235d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_PULL_UP 3 236d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_PULL_DOWN 4 237d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_PULL_PIN_DEFAULT 5 238d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_PUSH_PULL 6 239d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_OPEN_DRAIN 7 240d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_OPEN_SOURCE 8 241d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_STRENGTH 9 242d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_ENABLE 10 243d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_SCHMITT_ENABLE 11 244d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_SCHMITT 12 245d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_DEBOUNCE 13 246d90a5a30SMasahiro Yamada #define PIN_CONFIG_POWER_SOURCE 14 247d90a5a30SMasahiro Yamada #define PIN_CONFIG_SLEW_RATE 15 248d90a5a30SMasahiro Yamada #define PIN_CONFIG_LOW_POWER_MODE 16 249d90a5a30SMasahiro Yamada #define PIN_CONFIG_OUTPUT 17 250d90a5a30SMasahiro Yamada #define PIN_CONFIG_END 0x7FFF 251d90a5a30SMasahiro Yamada 252d90a5a30SMasahiro Yamada #if CONFIG_IS_ENABLED(PINCTRL_GENERIC) 253d90a5a30SMasahiro Yamada /** 254d90a5a30SMasahiro Yamada * pinctrl_generic_set_state() - generic set_state operation 255d90a5a30SMasahiro Yamada * Parse the DT node of @config and its children and handle generic properties 256d90a5a30SMasahiro Yamada * such as "pins", "groups", "functions", and pin configuration parameters. 257d90a5a30SMasahiro Yamada * 258d90a5a30SMasahiro Yamada * @pctldev: pinctrl device 259d90a5a30SMasahiro Yamada * @config: config device (pseudo device), pointing a config node in DTS 260d90a5a30SMasahiro Yamada * @return: 0 on success, or negative error code on failure 261d90a5a30SMasahiro Yamada */ 262d90a5a30SMasahiro Yamada int pinctrl_generic_set_state(struct udevice *pctldev, struct udevice *config); 263d90a5a30SMasahiro Yamada #else 264d90a5a30SMasahiro Yamada static inline int pinctrl_generic_set_state(struct udevice *pctldev, 265d90a5a30SMasahiro Yamada struct udevice *config) 266d90a5a30SMasahiro Yamada { 267d90a5a30SMasahiro Yamada return -EINVAL; 268d90a5a30SMasahiro Yamada } 269d90a5a30SMasahiro Yamada #endif 270d90a5a30SMasahiro Yamada 271d90a5a30SMasahiro Yamada #if CONFIG_IS_ENABLED(PINCTRL) 272d90a5a30SMasahiro Yamada /** 273d90a5a30SMasahiro Yamada * pinctrl_select_state() - set a device to a given state 274d90a5a30SMasahiro Yamada * 275d90a5a30SMasahiro Yamada * @dev: peripheral device 276d90a5a30SMasahiro Yamada * @statename: state name, like "default" 277d90a5a30SMasahiro Yamada * @return: 0 on success, or negative error code on failure 278d90a5a30SMasahiro Yamada */ 279d90a5a30SMasahiro Yamada int pinctrl_select_state(struct udevice *dev, const char *statename); 280d90a5a30SMasahiro Yamada 281c5acf4a2SSimon Glass /** 282c5acf4a2SSimon Glass * pinctrl_request() - Request a particular pinctrl function 283c5acf4a2SSimon Glass * 284c5acf4a2SSimon Glass * @dev: Device to check (UCLASS_PINCTRL) 285c5acf4a2SSimon Glass * @func: Function number (driver-specific) 286c5acf4a2SSimon Glass * @flags: Flags (driver-specific) 287c5acf4a2SSimon Glass * @return 0 if OK, -ve on error 288c5acf4a2SSimon Glass */ 289c5acf4a2SSimon Glass int pinctrl_request(struct udevice *dev, int func, int flags); 290c5acf4a2SSimon Glass 291c5acf4a2SSimon Glass /** 292c5acf4a2SSimon Glass * pinctrl_request_noflags() - Request a particular pinctrl function 293c5acf4a2SSimon Glass * 294c5acf4a2SSimon Glass * This is similar to pinctrl_request() but uses 0 for @flags. 295c5acf4a2SSimon Glass * 296c5acf4a2SSimon Glass * @dev: Device to check (UCLASS_PINCTRL) 297c5acf4a2SSimon Glass * @func: Function number (driver-specific) 298c5acf4a2SSimon Glass * @return 0 if OK, -ve on error 299c5acf4a2SSimon Glass */ 300c5acf4a2SSimon Glass int pinctrl_request_noflags(struct udevice *dev, int func); 301c5acf4a2SSimon Glass 302c5acf4a2SSimon Glass /** 303c5acf4a2SSimon Glass * pinctrl_get_periph_id() - get the peripheral ID for a device 304c5acf4a2SSimon Glass * 305c5acf4a2SSimon Glass * This generally looks at the peripheral's device tree node to work out the 306c5acf4a2SSimon Glass * peripheral ID. The return value is normally interpreted as enum periph_id. 307c5acf4a2SSimon Glass * so long as this is defined by the platform (which it should be). 308c5acf4a2SSimon Glass * 309c5acf4a2SSimon Glass * @dev: Pinctrl device to use for decoding 310c5acf4a2SSimon Glass * @periph: Device to check 311c5acf4a2SSimon Glass * @return peripheral ID of @periph, or -ENOENT on error 312c5acf4a2SSimon Glass */ 313c5acf4a2SSimon Glass int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph); 314c5acf4a2SSimon Glass 31552db39a2SSimon Glass /** 31652db39a2SSimon Glass * pinctrl_decode_pin_config() - decode pin configuration flags 31752db39a2SSimon Glass * 31852db39a2SSimon Glass * This decodes some of the PIN_CONFIG values into flags, with each value 31952db39a2SSimon Glass * being (1 << pin_cfg). This does not support things with values like the 32052db39a2SSimon Glass * slew rate. 32152db39a2SSimon Glass * 32252db39a2SSimon Glass * @blob: Device tree blob 32352db39a2SSimon Glass * @node: Node containing the PIN_CONFIG values 32452db39a2SSimon Glass * @return decoded flag value, or -ve on error 32552db39a2SSimon Glass */ 32652db39a2SSimon Glass int pinctrl_decode_pin_config(const void *blob, int node); 32752db39a2SSimon Glass 32877eaa19eSSimon Glass /** 32977eaa19eSSimon Glass * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO 33077eaa19eSSimon Glass * 33177eaa19eSSimon Glass * This allows the raw mux value for a GPIO to be obtained. It is 33277eaa19eSSimon Glass * useful for displaying the function being used by that GPIO, such 33377eaa19eSSimon Glass * as with the 'gpio' command. This function is internal to the GPIO 33477eaa19eSSimon Glass * subsystem and should not be used by generic code. Typically it is 33577eaa19eSSimon Glass * used by a GPIO driver with knowledge of the SoC pinctrl setup. 33677eaa19eSSimon Glass * 33777eaa19eSSimon Glass * @dev: Pinctrl device to use 33877eaa19eSSimon Glass * @banknum: GPIO bank number 33977eaa19eSSimon Glass * @index: GPIO index within the bank 34077eaa19eSSimon Glass * @return mux value (SoC-specific, e.g. 0 for input, 1 for output) 34177eaa19eSSimon Glass */ 34277eaa19eSSimon Glass int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index); 34377eaa19eSSimon Glass 34433f8d8a6SJianqun Xu /** 34533f8d8a6SJianqun Xu * pinctrl_get_pins_count() - get the total pins count for all GPIOs 34633f8d8a6SJianqun Xu * 34733f8d8a6SJianqun Xu * This allows the total pins count for all GPIO to be obtained. 34833f8d8a6SJianqun Xu * 34933f8d8a6SJianqun Xu * @dev: Pinctrl device to use 35033f8d8a6SJianqun Xu * @return pins count 35133f8d8a6SJianqun Xu */ 35233f8d8a6SJianqun Xu int pinctrl_get_pins_count(struct udevice *dev); 353942638a9SPatrice Chotard 354942638a9SPatrice Chotard /** 355942638a9SPatrice Chotard * pinctrl_get_pin_name() - Returns the pin's name 356942638a9SPatrice Chotard * 357942638a9SPatrice Chotard * This allows to display the pin's name for debug purpose 358942638a9SPatrice Chotard * 359942638a9SPatrice Chotard * @dev: Pinctrl device to use 360942638a9SPatrice Chotard * @selector Pin index within pin-controller 361942638a9SPatrice Chotard * @buf Pin's name 362942638a9SPatrice Chotard * @return 0 if OK, -ve on error 363942638a9SPatrice Chotard */ 364942638a9SPatrice Chotard int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf, 365942638a9SPatrice Chotard int size); 366942638a9SPatrice Chotard 367*6b9191d0SPatrice Chotard /** 368*6b9191d0SPatrice Chotard * pinctrl_get_pin_muxing() - Returns the muxing description 369*6b9191d0SPatrice Chotard * 370*6b9191d0SPatrice Chotard * This allows to display the muxing description of the given pin for 371*6b9191d0SPatrice Chotard * debug purpose 372*6b9191d0SPatrice Chotard * 373*6b9191d0SPatrice Chotard * @dev: Pinctrl device to use 374*6b9191d0SPatrice Chotard * @selector Pin index within pin-controller 375*6b9191d0SPatrice Chotard * @buf Pin's muxing description 376*6b9191d0SPatrice Chotard * @size Pin's muxing description length 377*6b9191d0SPatrice Chotard * @return 0 if OK, -ve on error 378*6b9191d0SPatrice Chotard */ 379*6b9191d0SPatrice Chotard int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf, 380*6b9191d0SPatrice Chotard int size); 381*6b9191d0SPatrice Chotard 382d3acdc96SJianqun Xu #else 383d3acdc96SJianqun Xu static inline int pinctrl_select_state(struct udevice *dev, 384d3acdc96SJianqun Xu const char *statename) 385d3acdc96SJianqun Xu { 386d3acdc96SJianqun Xu return -EINVAL; 387d3acdc96SJianqun Xu } 388d3acdc96SJianqun Xu 389d3acdc96SJianqun Xu static inline int pinctrl_request(struct udevice *dev, int func, int flags) 390d3acdc96SJianqun Xu { 391d3acdc96SJianqun Xu return -EINVAL; 392d3acdc96SJianqun Xu } 393d3acdc96SJianqun Xu 394d3acdc96SJianqun Xu static inline int pinctrl_request_noflags(struct udevice *dev, int func) 395d3acdc96SJianqun Xu { 396d3acdc96SJianqun Xu return -EINVAL; 397d3acdc96SJianqun Xu } 398d3acdc96SJianqun Xu 399d3acdc96SJianqun Xu static inline int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph) 400d3acdc96SJianqun Xu { 401d3acdc96SJianqun Xu return -EINVAL; 402d3acdc96SJianqun Xu } 403d3acdc96SJianqun Xu 404d3acdc96SJianqun Xu static inline int pinctrl_decode_pin_config(const void *blob, int node) 405d3acdc96SJianqun Xu { 406d3acdc96SJianqun Xu return -EINVAL; 407d3acdc96SJianqun Xu } 408d3acdc96SJianqun Xu 409d3acdc96SJianqun Xu static inline int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index) 410d3acdc96SJianqun Xu { 411d3acdc96SJianqun Xu return -EINVAL; 412d3acdc96SJianqun Xu } 413d3acdc96SJianqun Xu 414d3acdc96SJianqun Xu static inline int pinctrl_get_pins_count(struct udevice *dev) 415d3acdc96SJianqun Xu { 416d3acdc96SJianqun Xu return -EINVAL; 417d3acdc96SJianqun Xu } 418942638a9SPatrice Chotard 419942638a9SPatrice Chotard static inline int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf, 420942638a9SPatrice Chotard int size) 421942638a9SPatrice Chotard { 422942638a9SPatrice Chotard return -EINVAL; 423942638a9SPatrice Chotard } 424942638a9SPatrice Chotard 425*6b9191d0SPatrice Chotard static inline int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf, 426*6b9191d0SPatrice Chotard int size) 427*6b9191d0SPatrice Chotard { 428*6b9191d0SPatrice Chotard return -EINVAL; 429*6b9191d0SPatrice Chotard } 430*6b9191d0SPatrice Chotard 431d3acdc96SJianqun Xu #endif 43233f8d8a6SJianqun Xu 433d90a5a30SMasahiro Yamada #endif /* __PINCTRL_H */ 434