blob: 78c3a31be88294d148778f9c81642b555765e03c [file] [log] [blame]
Thomas Gleixneraf873fc2019-05-28 09:57:21 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Walleij2744e8a2011-05-02 20:50:54 +02002/*
3 * Internal interface between the core pin control system and the
4 * pinmux portions
5 *
6 * Copyright (C) 2011 ST-Ericsson SA
7 * Written on behalf of Linaro for ST-Ericsson
8 * Based on bits of regulator core, gpio core and clk core
9 *
10 * Author: Linus Walleij <linus.walleij@linaro.org>
Linus Walleij2744e8a2011-05-02 20:50:54 +020011 */
12#ifdef CONFIG_PINMUX
13
Tony Lindgrenb9130b72012-01-24 16:28:08 -080014int pinmux_check_ops(struct pinctrl_dev *pctldev);
Stephen Warren7ecdb162012-03-02 13:05:45 -070015
Masahiro Yamada3f713b72017-08-04 11:22:31 +090016int pinmux_validate_map(const struct pinctrl_map *map, int i);
Stephen Warren1e2082b2012-03-02 13:05:48 -070017
Stefan Wahren472a61e2019-08-14 14:00:35 +030018bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin);
19
Linus Walleijbefe5bd2012-02-09 19:47:48 +010020int pinmux_request_gpio(struct pinctrl_dev *pctldev,
21 struct pinctrl_gpio_range *range,
22 unsigned pin, unsigned gpio);
23void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
24 struct pinctrl_gpio_range *range);
25int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
26 struct pinctrl_gpio_range *range,
27 unsigned pin, bool input);
Stephen Warren7ecdb162012-03-02 13:05:45 -070028
Masahiro Yamada3f713b72017-08-04 11:22:31 +090029int pinmux_map_to_setting(const struct pinctrl_map *map,
Stephen Warren7ecdb162012-03-02 13:05:45 -070030 struct pinctrl_setting *setting);
Masahiro Yamada3f713b72017-08-04 11:22:31 +090031void pinmux_free_setting(const struct pinctrl_setting *setting);
32int pinmux_enable_setting(const struct pinctrl_setting *setting);
33void pinmux_disable_setting(const struct pinctrl_setting *setting);
Stephen Warren7ecdb162012-03-02 13:05:45 -070034
Linus Walleij2744e8a2011-05-02 20:50:54 +020035#else
36
Tony Lindgrenb9130b72012-01-24 16:28:08 -080037static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
Linus Walleij2744e8a2011-05-02 20:50:54 +020038{
39 return 0;
40}
41
Masahiro Yamada3f713b72017-08-04 11:22:31 +090042static inline int pinmux_validate_map(const struct pinctrl_map *map, int i)
Stephen Warren1e2082b2012-03-02 13:05:48 -070043{
44 return 0;
45}
46
Stefan Wahren472a61e2019-08-14 14:00:35 +030047static inline bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev,
48 unsigned pin)
49{
50 return true;
51}
52
Linus Walleijbefe5bd2012-02-09 19:47:48 +010053static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
54 struct pinctrl_gpio_range *range,
55 unsigned pin, unsigned gpio)
Linus Walleij2744e8a2011-05-02 20:50:54 +020056{
57 return 0;
58}
59
Linus Walleijbefe5bd2012-02-09 19:47:48 +010060static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
61 unsigned pin,
62 struct pinctrl_gpio_range *range)
63{
64}
65
66static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
67 struct pinctrl_gpio_range *range,
68 unsigned pin, bool input)
69{
70 return 0;
71}
72
Masahiro Yamada3f713b72017-08-04 11:22:31 +090073static inline int pinmux_map_to_setting(const struct pinctrl_map *map,
Stephen Warren7ecdb162012-03-02 13:05:45 -070074 struct pinctrl_setting *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010075{
76 return 0;
77}
78
Masahiro Yamada3f713b72017-08-04 11:22:31 +090079static inline void pinmux_free_setting(const struct pinctrl_setting *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010080{
81}
82
Masahiro Yamada3f713b72017-08-04 11:22:31 +090083static inline int pinmux_enable_setting(const struct pinctrl_setting *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010084{
Stephen Warren7ecdb162012-03-02 13:05:45 -070085 return 0;
Linus Walleijbefe5bd2012-02-09 19:47:48 +010086}
87
Masahiro Yamada3f713b72017-08-04 11:22:31 +090088static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010089{
90}
91
Stephen Warrenc736d732012-04-11 16:45:45 -060092#endif
93
94#if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
95
Masahiro Yamada3f713b72017-08-04 11:22:31 +090096void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map);
Stephen Warrenc736d732012-04-11 16:45:45 -060097void pinmux_show_setting(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +090098 const struct pinctrl_setting *setting);
Stephen Warrenc736d732012-04-11 16:45:45 -060099void pinmux_init_device_debugfs(struct dentry *devroot,
100 struct pinctrl_dev *pctldev);
101
102#else
103
Stephen Warren1e2082b2012-03-02 13:05:48 -0700104static inline void pinmux_show_map(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +0900105 const struct pinctrl_map *map)
Stephen Warren03665e02012-02-19 23:45:45 -0700106{
107}
108
Stephen Warren1e2082b2012-03-02 13:05:48 -0700109static inline void pinmux_show_setting(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +0900110 const struct pinctrl_setting *setting)
Stephen Warren1e2082b2012-03-02 13:05:48 -0700111{
112}
113
114static inline void pinmux_init_device_debugfs(struct dentry *devroot,
115 struct pinctrl_dev *pctldev)
Linus Walleij2744e8a2011-05-02 20:50:54 +0200116{
117}
118
119#endif
Tony Lindgrena76edc82016-12-27 09:20:01 -0800120
121#ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
122
123/**
124 * struct function_desc - generic function descriptor
125 * @name: name of the function
126 * @group_names: array of pin group names
127 * @num_group_names: number of pin group names
128 * @data: pin controller driver specific data
129 */
130struct function_desc {
131 const char *name;
132 const char **group_names;
133 int num_group_names;
134 void *data;
135};
136
137int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
138
139const char *
140pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
141 unsigned int selector);
142
143int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
144 unsigned int selector,
145 const char * const **groups,
146 unsigned * const num_groups);
147
148struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
149 unsigned int selector);
150
151int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
152 const char *name,
153 const char **groups,
154 unsigned const num_groups,
155 void *data);
156
157int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
158 unsigned int selector);
159
Tony Lindgrena76edc82016-12-27 09:20:01 -0800160void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
161
162#else
163
164static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
165{
166}
167
168#endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */