blob: 248d8ea30e260b4212d08535104a6043371de858 [file] [log] [blame]
Linus Walleij2744e8a2011-05-02 20:50:54 +02001/*
2 * Internal interface between the core pin control system and the
3 * pinmux portions
4 *
5 * Copyright (C) 2011 ST-Ericsson SA
6 * Written on behalf of Linaro for ST-Ericsson
7 * Based on bits of regulator core, gpio core and clk core
8 *
9 * Author: Linus Walleij <linus.walleij@linaro.org>
10 *
11 * License terms: GNU General Public License (GPL) version 2
12 */
13#ifdef CONFIG_PINMUX
14
Tony Lindgrenb9130b72012-01-24 16:28:08 -080015int pinmux_check_ops(struct pinctrl_dev *pctldev);
Stephen Warren7ecdb162012-03-02 13:05:45 -070016
Stephen Warren1e2082b2012-03-02 13:05:48 -070017int pinmux_validate_map(struct pinctrl_map const *map, int i);
18
Linus Walleijbefe5bd2012-02-09 19:47:48 +010019int pinmux_request_gpio(struct pinctrl_dev *pctldev,
20 struct pinctrl_gpio_range *range,
21 unsigned pin, unsigned gpio);
22void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
23 struct pinctrl_gpio_range *range);
24int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
25 struct pinctrl_gpio_range *range,
26 unsigned pin, bool input);
Stephen Warren7ecdb162012-03-02 13:05:45 -070027
28int pinmux_map_to_setting(struct pinctrl_map const *map,
29 struct pinctrl_setting *setting);
30void pinmux_free_setting(struct pinctrl_setting const *setting);
31int pinmux_enable_setting(struct pinctrl_setting const *setting);
32void pinmux_disable_setting(struct pinctrl_setting const *setting);
33
Linus Walleij2744e8a2011-05-02 20:50:54 +020034#else
35
Tony Lindgrenb9130b72012-01-24 16:28:08 -080036static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
Linus Walleij2744e8a2011-05-02 20:50:54 +020037{
38 return 0;
39}
40
Stephen Warren1e2082b2012-03-02 13:05:48 -070041static inline int pinmux_validate_map(struct pinctrl_map const *map, int i)
42{
43 return 0;
44}
45
Linus Walleijbefe5bd2012-02-09 19:47:48 +010046static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
47 struct pinctrl_gpio_range *range,
48 unsigned pin, unsigned gpio)
Linus Walleij2744e8a2011-05-02 20:50:54 +020049{
50 return 0;
51}
52
Linus Walleijbefe5bd2012-02-09 19:47:48 +010053static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
54 unsigned pin,
55 struct pinctrl_gpio_range *range)
56{
57}
58
59static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
60 struct pinctrl_gpio_range *range,
61 unsigned pin, bool input)
62{
63 return 0;
64}
65
Stephen Warren7ecdb162012-03-02 13:05:45 -070066static inline int pinmux_map_to_setting(struct pinctrl_map const *map,
67 struct pinctrl_setting *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010068{
69 return 0;
70}
71
Stephen Warren7ecdb162012-03-02 13:05:45 -070072static inline void pinmux_free_setting(struct pinctrl_setting const *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010073{
74}
75
Stephen Warren7ecdb162012-03-02 13:05:45 -070076static inline int pinmux_enable_setting(struct pinctrl_setting const *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010077{
Stephen Warren7ecdb162012-03-02 13:05:45 -070078 return 0;
Linus Walleijbefe5bd2012-02-09 19:47:48 +010079}
80
Stephen Warren7ecdb162012-03-02 13:05:45 -070081static inline void pinmux_disable_setting(
82 struct pinctrl_setting const *setting)
Linus Walleijbefe5bd2012-02-09 19:47:48 +010083{
84}
85
Stephen Warrenc736d732012-04-11 16:45:45 -060086#endif
87
88#if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
89
90void pinmux_show_map(struct seq_file *s, struct pinctrl_map const *map);
91void pinmux_show_setting(struct seq_file *s,
92 struct pinctrl_setting const *setting);
93void pinmux_init_device_debugfs(struct dentry *devroot,
94 struct pinctrl_dev *pctldev);
95
96#else
97
Stephen Warren1e2082b2012-03-02 13:05:48 -070098static inline void pinmux_show_map(struct seq_file *s,
99 struct pinctrl_map const *map)
Stephen Warren03665e02012-02-19 23:45:45 -0700100{
101}
102
Stephen Warren1e2082b2012-03-02 13:05:48 -0700103static inline void pinmux_show_setting(struct seq_file *s,
104 struct pinctrl_setting const *setting)
105{
106}
107
108static inline void pinmux_init_device_debugfs(struct dentry *devroot,
109 struct pinctrl_dev *pctldev)
Linus Walleij2744e8a2011-05-02 20:50:54 +0200110{
111}
112
113#endif
Tony Lindgrena76edc82016-12-27 09:20:01 -0800114
115#ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
116
117/**
118 * struct function_desc - generic function descriptor
119 * @name: name of the function
120 * @group_names: array of pin group names
121 * @num_group_names: number of pin group names
122 * @data: pin controller driver specific data
123 */
124struct function_desc {
125 const char *name;
126 const char **group_names;
127 int num_group_names;
128 void *data;
129};
130
131int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
132
133const char *
134pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
135 unsigned int selector);
136
137int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
138 unsigned int selector,
139 const char * const **groups,
140 unsigned * const num_groups);
141
142struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
143 unsigned int selector);
144
145int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
146 const char *name,
147 const char **groups,
148 unsigned const num_groups,
149 void *data);
150
151int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
152 unsigned int selector);
153
154static inline int
155pinmux_generic_remove_last_function(struct pinctrl_dev *pctldev)
156{
157 return pinmux_generic_remove_function(pctldev,
158 pctldev->num_functions - 1);
159}
160
161void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
162
163#else
164
165static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
166{
167}
168
169#endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */