blob: be7311373299f7127cfbd661d8c440dc6ed144f9 [file] [log] [blame]
Thomas Gleixneraf873fc2019-05-28 09:57:21 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Walleijae6b4d82011-10-19 18:14:33 +02002/*
3 * Internal interface between the core pin control system and the
4 * pin config 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 Walleijae6b4d82011-10-19 18:14:33 +020011 */
12
13#ifdef CONFIG_PINCONF
14
Tony Lindgrenb9130b72012-01-24 16:28:08 -080015int pinconf_check_ops(struct pinctrl_dev *pctldev);
Masahiro Yamada3f713b72017-08-04 11:22:31 +090016int pinconf_validate_map(const struct pinctrl_map *map, int i);
17int pinconf_map_to_setting(const struct pinctrl_map *map,
Stephen Warren1e2082b2012-03-02 13:05:48 -070018 struct pinctrl_setting *setting);
Masahiro Yamada3f713b72017-08-04 11:22:31 +090019void pinconf_free_setting(const struct pinctrl_setting *setting);
20int pinconf_apply_setting(const struct pinctrl_setting *setting);
Linus Walleijae6b4d82011-10-19 18:14:33 +020021
Mika Westerberg15381bc2017-01-23 15:34:33 +030022int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
23 unsigned long *configs, size_t nconfigs);
24
Linus Walleij394349f2011-11-24 18:27:15 +010025/*
26 * You will only be interested in these if you're using PINCONF
27 * so don't supply any stubs for these.
28 */
29int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
30 unsigned long *config);
31int pin_config_group_get(const char *dev_name, const char *pin_group,
32 unsigned long *config);
33
Linus Walleijae6b4d82011-10-19 18:14:33 +020034#else
35
Tony Lindgrenb9130b72012-01-24 16:28:08 -080036static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
Linus Walleijae6b4d82011-10-19 18:14:33 +020037{
38 return 0;
39}
40
Masahiro Yamada3f713b72017-08-04 11:22:31 +090041static inline int pinconf_validate_map(const struct pinctrl_map *map, int i)
Stephen Warren1e2082b2012-03-02 13:05:48 -070042{
43 return 0;
44}
45
Masahiro Yamada3f713b72017-08-04 11:22:31 +090046static inline int pinconf_map_to_setting(const struct pinctrl_map *map,
Stephen Warren1e2082b2012-03-02 13:05:48 -070047 struct pinctrl_setting *setting)
48{
49 return 0;
50}
51
Masahiro Yamada3f713b72017-08-04 11:22:31 +090052static inline void pinconf_free_setting(const struct pinctrl_setting *setting)
Stephen Warren1e2082b2012-03-02 13:05:48 -070053{
54}
55
Masahiro Yamada3f713b72017-08-04 11:22:31 +090056static inline int pinconf_apply_setting(const struct pinctrl_setting *setting)
Stephen Warren1e2082b2012-03-02 13:05:48 -070057{
58 return 0;
59}
60
Mika Westerberg15381bc2017-01-23 15:34:33 +030061static inline int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
62 unsigned long *configs, size_t nconfigs)
63{
64 return -ENOTSUPP;
65}
66
Stephen Warrenc736d732012-04-11 16:45:45 -060067#endif
68
Viresh Kumar96593af2012-04-16 14:22:34 +053069#if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS)
Stephen Warrenc736d732012-04-11 16:45:45 -060070
Masahiro Yamada3f713b72017-08-04 11:22:31 +090071void pinconf_show_map(struct seq_file *s, const struct pinctrl_map *map);
Stephen Warrenc736d732012-04-11 16:45:45 -060072void pinconf_show_setting(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +090073 const struct pinctrl_setting *setting);
Stephen Warrenc736d732012-04-11 16:45:45 -060074void pinconf_init_device_debugfs(struct dentry *devroot,
75 struct pinctrl_dev *pctldev);
76
77#else
78
Stephen Warren1e2082b2012-03-02 13:05:48 -070079static inline void pinconf_show_map(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +090080 const struct pinctrl_map *map)
Stephen Warren1e2082b2012-03-02 13:05:48 -070081{
82}
83
84static inline void pinconf_show_setting(struct seq_file *s,
Masahiro Yamada3f713b72017-08-04 11:22:31 +090085 const struct pinctrl_setting *setting)
Stephen Warren1e2082b2012-03-02 13:05:48 -070086{
87}
88
Linus Walleijae6b4d82011-10-19 18:14:33 +020089static inline void pinconf_init_device_debugfs(struct dentry *devroot,
90 struct pinctrl_dev *pctldev)
91{
92}
93
94#endif
Linus Walleij394349f2011-11-24 18:27:15 +010095
96/*
97 * The following functions are available if the driver uses the generic
98 * pin config.
99 */
100
Sachin Kamatbf4d7be2013-03-13 17:13:46 +0530101#if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_DEBUG_FS)
Linus Walleij394349f2011-11-24 18:27:15 +0100102
Soren Brinkmanndd4d01f2015-01-09 07:43:46 -0800103void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
104 struct seq_file *s, const char *gname,
105 unsigned pin);
Linus Walleij394349f2011-11-24 18:27:15 +0100106
Haojian Zhuang9cfd1722013-02-17 19:42:53 +0800107void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
108 struct seq_file *s, unsigned long config);
Linus Walleij394349f2011-11-24 18:27:15 +0100109#else
110
Soren Brinkmanndd4d01f2015-01-09 07:43:46 -0800111static inline void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
112 struct seq_file *s,
113 const char *gname, unsigned pin)
Linus Walleij394349f2011-11-24 18:27:15 +0100114{
115 return;
116}
117
Haojian Zhuang9cfd1722013-02-17 19:42:53 +0800118static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
119 struct seq_file *s,
120 unsigned long config)
121{
122 return;
123}
Linus Walleij394349f2011-11-24 18:27:15 +0100124#endif
Heiko Stübner7db9af42013-06-10 21:40:29 +0200125
126#if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_OF)
127int pinconf_generic_parse_dt_config(struct device_node *np,
Soren Brinkmanndd4d01f2015-01-09 07:43:46 -0800128 struct pinctrl_dev *pctldev,
Heiko Stübner7db9af42013-06-10 21:40:29 +0200129 unsigned long **configs,
130 unsigned int *nconfigs);
131#endif