blob: 6c722505f89365ba58069c4d6f0976355f16dbd2 [file] [log] [blame]
Linus Walleijae6b4d82011-10-19 18:14:33 +02001/*
2 * Internal interface between the core pin control system and the
3 * pin config 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
14#ifdef CONFIG_PINCONF
15
Tony Lindgrenb9130b72012-01-24 16:28:08 -080016int pinconf_check_ops(struct pinctrl_dev *pctldev);
Masahiro Yamada3f713b72017-08-04 11:22:31 +090017int pinconf_validate_map(const struct pinctrl_map *map, int i);
18int pinconf_map_to_setting(const struct pinctrl_map *map,
Stephen Warren1e2082b2012-03-02 13:05:48 -070019 struct pinctrl_setting *setting);
Masahiro Yamada3f713b72017-08-04 11:22:31 +090020void pinconf_free_setting(const struct pinctrl_setting *setting);
21int pinconf_apply_setting(const struct pinctrl_setting *setting);
Linus Walleijae6b4d82011-10-19 18:14:33 +020022
Mika Westerberg15381bc2017-01-23 15:34:33 +030023int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
24 unsigned long *configs, size_t nconfigs);
25
Linus Walleij394349f2011-11-24 18:27:15 +010026/*
27 * You will only be interested in these if you're using PINCONF
28 * so don't supply any stubs for these.
29 */
30int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
31 unsigned long *config);
32int pin_config_group_get(const char *dev_name, const char *pin_group,
33 unsigned long *config);
34
Linus Walleijae6b4d82011-10-19 18:14:33 +020035#else
36
Tony Lindgrenb9130b72012-01-24 16:28:08 -080037static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
Linus Walleijae6b4d82011-10-19 18:14:33 +020038{
39 return 0;
40}
41
Masahiro Yamada3f713b72017-08-04 11:22:31 +090042static inline int pinconf_validate_map(const struct pinctrl_map *map, int i)
Stephen Warren1e2082b2012-03-02 13:05:48 -070043{
44 return 0;
45}
46
Masahiro Yamada3f713b72017-08-04 11:22:31 +090047static inline int pinconf_map_to_setting(const struct pinctrl_map *map,
Stephen Warren1e2082b2012-03-02 13:05:48 -070048 struct pinctrl_setting *setting)
49{
50 return 0;
51}
52
Masahiro Yamada3f713b72017-08-04 11:22:31 +090053static inline void pinconf_free_setting(const struct pinctrl_setting *setting)
Stephen Warren1e2082b2012-03-02 13:05:48 -070054{
55}
56
Masahiro Yamada3f713b72017-08-04 11:22:31 +090057static inline int pinconf_apply_setting(const struct pinctrl_setting *setting)
Stephen Warren1e2082b2012-03-02 13:05:48 -070058{
59 return 0;
60}
61
Mika Westerberg15381bc2017-01-23 15:34:33 +030062static inline int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
63 unsigned long *configs, size_t nconfigs)
64{
65 return -ENOTSUPP;
66}
67
Stephen Warrenc736d732012-04-11 16:45:45 -060068#endif
69
Viresh Kumar96593af2012-04-16 14:22:34 +053070#if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS)
Stephen Warrenc736d732012-04-11 16:45:45 -060071
Masahiro Yamada3f713b72017-08-04 11:22:31 +090072void pinconf_show_map(struct seq_file *s, const struct pinctrl_map *map);
Stephen Warrenc736d732012-04-11 16:45:45 -060073void pinconf_show_setting(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +090074 const struct pinctrl_setting *setting);
Stephen Warrenc736d732012-04-11 16:45:45 -060075void pinconf_init_device_debugfs(struct dentry *devroot,
76 struct pinctrl_dev *pctldev);
77
78#else
79
Stephen Warren1e2082b2012-03-02 13:05:48 -070080static inline void pinconf_show_map(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +090081 const struct pinctrl_map *map)
Stephen Warren1e2082b2012-03-02 13:05:48 -070082{
83}
84
85static inline void pinconf_show_setting(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +090086 const struct pinctrl_setting *setting)
Stephen Warren1e2082b2012-03-02 13:05:48 -070087{
88}
89
Linus Walleijae6b4d82011-10-19 18:14:33 +020090static inline void pinconf_init_device_debugfs(struct dentry *devroot,
91 struct pinctrl_dev *pctldev)
92{
93}
94
95#endif
Linus Walleij394349f2011-11-24 18:27:15 +010096
97/*
98 * The following functions are available if the driver uses the generic
99 * pin config.
100 */
101
Sachin Kamatbf4d7be2013-03-13 17:13:46 +0530102#if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_DEBUG_FS)
Linus Walleij394349f2011-11-24 18:27:15 +0100103
Soren Brinkmanndd4d01f2015-01-09 07:43:46 -0800104void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
105 struct seq_file *s, const char *gname,
106 unsigned pin);
Linus Walleij394349f2011-11-24 18:27:15 +0100107
Haojian Zhuang9cfd1722013-02-17 19:42:53 +0800108void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
109 struct seq_file *s, unsigned long config);
Linus Walleij394349f2011-11-24 18:27:15 +0100110#else
111
Soren Brinkmanndd4d01f2015-01-09 07:43:46 -0800112static inline void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
113 struct seq_file *s,
114 const char *gname, unsigned pin)
Linus Walleij394349f2011-11-24 18:27:15 +0100115{
116 return;
117}
118
Haojian Zhuang9cfd1722013-02-17 19:42:53 +0800119static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
120 struct seq_file *s,
121 unsigned long config)
122{
123 return;
124}
Linus Walleij394349f2011-11-24 18:27:15 +0100125#endif
Heiko Stübner7db9af42013-06-10 21:40:29 +0200126
127#if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_OF)
128int pinconf_generic_parse_dt_config(struct device_node *np,
Soren Brinkmanndd4d01f2015-01-09 07:43:46 -0800129 struct pinctrl_dev *pctldev,
Heiko Stübner7db9af42013-06-10 21:40:29 +0200130 unsigned long **configs,
131 unsigned int *nconfigs);
132#endif