Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Internal interface between the core pin control system and the
0004  * pinmux portions
0005  *
0006  * Copyright (C) 2011 ST-Ericsson SA
0007  * Written on behalf of Linaro for ST-Ericsson
0008  * Based on bits of regulator core, gpio core and clk core
0009  *
0010  * Author: Linus Walleij <linus.walleij@linaro.org>
0011  */
0012 #ifdef CONFIG_PINMUX
0013 
0014 int pinmux_check_ops(struct pinctrl_dev *pctldev);
0015 
0016 int pinmux_validate_map(const struct pinctrl_map *map, int i);
0017 
0018 bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin);
0019 
0020 int pinmux_request_gpio(struct pinctrl_dev *pctldev,
0021             struct pinctrl_gpio_range *range,
0022             unsigned pin, unsigned gpio);
0023 void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
0024               struct pinctrl_gpio_range *range);
0025 int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
0026               struct pinctrl_gpio_range *range,
0027               unsigned pin, bool input);
0028 
0029 int pinmux_map_to_setting(const struct pinctrl_map *map,
0030               struct pinctrl_setting *setting);
0031 void pinmux_free_setting(const struct pinctrl_setting *setting);
0032 int pinmux_enable_setting(const struct pinctrl_setting *setting);
0033 void pinmux_disable_setting(const struct pinctrl_setting *setting);
0034 
0035 #else
0036 
0037 static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
0038 {
0039     return 0;
0040 }
0041 
0042 static inline int pinmux_validate_map(const struct pinctrl_map *map, int i)
0043 {
0044     return 0;
0045 }
0046 
0047 static inline bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev,
0048                            unsigned pin)
0049 {
0050     return true;
0051 }
0052 
0053 static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
0054             struct pinctrl_gpio_range *range,
0055             unsigned pin, unsigned gpio)
0056 {
0057     return 0;
0058 }
0059 
0060 static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
0061                     unsigned pin,
0062                     struct pinctrl_gpio_range *range)
0063 {
0064 }
0065 
0066 static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
0067                     struct pinctrl_gpio_range *range,
0068                     unsigned pin, bool input)
0069 {
0070     return 0;
0071 }
0072 
0073 static inline int pinmux_map_to_setting(const struct pinctrl_map *map,
0074               struct pinctrl_setting *setting)
0075 {
0076     return 0;
0077 }
0078 
0079 static inline void pinmux_free_setting(const struct pinctrl_setting *setting)
0080 {
0081 }
0082 
0083 static inline int pinmux_enable_setting(const struct pinctrl_setting *setting)
0084 {
0085     return 0;
0086 }
0087 
0088 static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
0089 {
0090 }
0091 
0092 #endif
0093 
0094 #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
0095 
0096 void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map);
0097 void pinmux_show_setting(struct seq_file *s,
0098              const struct pinctrl_setting *setting);
0099 void pinmux_init_device_debugfs(struct dentry *devroot,
0100                 struct pinctrl_dev *pctldev);
0101 
0102 #else
0103 
0104 static inline void pinmux_show_map(struct seq_file *s,
0105                    const struct pinctrl_map *map)
0106 {
0107 }
0108 
0109 static inline void pinmux_show_setting(struct seq_file *s,
0110                        const struct pinctrl_setting *setting)
0111 {
0112 }
0113 
0114 static inline void pinmux_init_device_debugfs(struct dentry *devroot,
0115                           struct pinctrl_dev *pctldev)
0116 {
0117 }
0118 
0119 #endif
0120 
0121 #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
0122 
0123 /**
0124  * struct function_desc - generic function descriptor
0125  * @name: name of the function
0126  * @group_names: array of pin group names
0127  * @num_group_names: number of pin group names
0128  * @data: pin controller driver specific data
0129  */
0130 struct function_desc {
0131     const char *name;
0132     const char * const *group_names;
0133     int num_group_names;
0134     void *data;
0135 };
0136 
0137 int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
0138 
0139 const char *
0140 pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
0141                  unsigned int selector);
0142 
0143 int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
0144                        unsigned int selector,
0145                        const char * const **groups,
0146                        unsigned * const num_groups);
0147 
0148 struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
0149                           unsigned int selector);
0150 
0151 int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
0152                 const char *name,
0153                 const char * const *groups,
0154                 unsigned const num_groups,
0155                 void *data);
0156 
0157 int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
0158                    unsigned int selector);
0159 
0160 void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
0161 
0162 #else
0163 
0164 static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
0165 {
0166 }
0167 
0168 #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */