Lines Matching +full:pin +full:- +full:settings
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Core driver for the pin config portions of the pin control subsystem
5 * Copyright (C) 2011 ST-Ericsson SA
6 * Written on behalf of Linaro for ST-Ericsson
29 const struct pinconf_ops *ops = pctldev->desc->confops; in pinconf_check_ops()
32 if (!ops->pin_config_set && !ops->pin_config_group_set) { in pinconf_check_ops()
33 dev_err(pctldev->dev, in pinconf_check_ops()
35 return -EINVAL; in pinconf_check_ops()
42 if (!map->data.configs.group_or_pin) { in pinconf_validate_map()
43 pr_err("failed to register map %s (%d): no group/pin given\n", in pinconf_validate_map()
44 map->name, i); in pinconf_validate_map()
45 return -EINVAL; in pinconf_validate_map()
48 if (!map->data.configs.num_configs || in pinconf_validate_map()
49 !map->data.configs.configs) { in pinconf_validate_map()
51 map->name, i); in pinconf_validate_map()
52 return -EINVAL; in pinconf_validate_map()
58 int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned int pin, in pin_config_get_for_pin() argument
61 const struct pinconf_ops *ops = pctldev->desc->confops; in pin_config_get_for_pin()
63 if (!ops || !ops->pin_config_get) { in pin_config_get_for_pin()
64 dev_dbg(pctldev->dev, in pin_config_get_for_pin()
65 "cannot get pin configuration, .pin_config_get missing in driver\n"); in pin_config_get_for_pin()
66 return -ENOTSUPP; in pin_config_get_for_pin()
69 return ops->pin_config_get(pctldev, pin, config); in pin_config_get_for_pin()
81 ret = -EINVAL; in pin_config_group_get()
85 mutex_lock(&pctldev->mutex); in pin_config_group_get()
87 ops = pctldev->desc->confops; in pin_config_group_get()
89 if (!ops || !ops->pin_config_group_get) { in pin_config_group_get()
90 dev_dbg(pctldev->dev, in pin_config_group_get()
91 "cannot get configuration for pin group, missing group config get function in driver\n"); in pin_config_group_get()
92 ret = -ENOTSUPP; in pin_config_group_get()
102 ret = ops->pin_config_group_get(pctldev, selector, config); in pin_config_group_get()
105 mutex_unlock(&pctldev->mutex); in pin_config_group_get()
112 struct pinctrl_dev *pctldev = setting->pctldev; in pinconf_map_to_setting()
113 int pin; in pinconf_map_to_setting() local
115 switch (setting->type) { in pinconf_map_to_setting()
117 pin = pin_get_from_name(pctldev, in pinconf_map_to_setting()
118 map->data.configs.group_or_pin); in pinconf_map_to_setting()
119 if (pin < 0) { in pinconf_map_to_setting()
120 dev_err(pctldev->dev, "could not map pin config for \"%s\"", in pinconf_map_to_setting()
121 map->data.configs.group_or_pin); in pinconf_map_to_setting()
122 return pin; in pinconf_map_to_setting()
124 setting->data.configs.group_or_pin = pin; in pinconf_map_to_setting()
127 pin = pinctrl_get_group_selector(pctldev, in pinconf_map_to_setting()
128 map->data.configs.group_or_pin); in pinconf_map_to_setting()
129 if (pin < 0) { in pinconf_map_to_setting()
130 dev_err(pctldev->dev, "could not map group config for \"%s\"", in pinconf_map_to_setting()
131 map->data.configs.group_or_pin); in pinconf_map_to_setting()
132 return pin; in pinconf_map_to_setting()
134 setting->data.configs.group_or_pin = pin; in pinconf_map_to_setting()
137 return -EINVAL; in pinconf_map_to_setting()
140 setting->data.configs.num_configs = map->data.configs.num_configs; in pinconf_map_to_setting()
141 setting->data.configs.configs = map->data.configs.configs; in pinconf_map_to_setting()
152 struct pinctrl_dev *pctldev = setting->pctldev; in pinconf_apply_setting()
153 const struct pinconf_ops *ops = pctldev->desc->confops; in pinconf_apply_setting()
157 dev_err(pctldev->dev, "missing confops\n"); in pinconf_apply_setting()
158 return -EINVAL; in pinconf_apply_setting()
161 switch (setting->type) { in pinconf_apply_setting()
163 if (!ops->pin_config_set) { in pinconf_apply_setting()
164 dev_err(pctldev->dev, "missing pin_config_set op\n"); in pinconf_apply_setting()
165 return -EINVAL; in pinconf_apply_setting()
167 ret = ops->pin_config_set(pctldev, in pinconf_apply_setting()
168 setting->data.configs.group_or_pin, in pinconf_apply_setting()
169 setting->data.configs.configs, in pinconf_apply_setting()
170 setting->data.configs.num_configs); in pinconf_apply_setting()
172 dev_err(pctldev->dev, in pinconf_apply_setting()
173 "pin_config_set op failed for pin %d\n", in pinconf_apply_setting()
174 setting->data.configs.group_or_pin); in pinconf_apply_setting()
179 if (!ops->pin_config_group_set) { in pinconf_apply_setting()
180 dev_err(pctldev->dev, in pinconf_apply_setting()
182 return -EINVAL; in pinconf_apply_setting()
184 ret = ops->pin_config_group_set(pctldev, in pinconf_apply_setting()
185 setting->data.configs.group_or_pin, in pinconf_apply_setting()
186 setting->data.configs.configs, in pinconf_apply_setting()
187 setting->data.configs.num_configs); in pinconf_apply_setting()
189 dev_err(pctldev->dev, in pinconf_apply_setting()
191 setting->data.configs.group_or_pin); in pinconf_apply_setting()
196 return -EINVAL; in pinconf_apply_setting()
202 int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned int pin, in pinconf_set_config() argument
207 ops = pctldev->desc->confops; in pinconf_set_config()
208 if (!ops || !ops->pin_config_set) in pinconf_set_config()
209 return -ENOTSUPP; in pinconf_set_config()
211 return ops->pin_config_set(pctldev, pin, configs, nconfigs); in pinconf_set_config()
223 confops = pctldev->desc->confops; in pinconf_show_config()
229 if (confops && confops->pin_config_config_dbg_show) in pinconf_show_config()
230 confops->pin_config_config_dbg_show(pctldev, s, in pinconf_show_config()
242 pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name); in pinconf_show_map()
244 switch (map->type) { in pinconf_show_map()
246 seq_puts(s, "pin "); in pinconf_show_map()
255 seq_printf(s, "%s\n", map->data.configs.group_or_pin); in pinconf_show_map()
257 pinconf_show_config(s, pctldev, map->data.configs.configs, in pinconf_show_map()
258 map->data.configs.num_configs); in pinconf_show_map()
264 struct pinctrl_dev *pctldev = setting->pctldev; in pinconf_show_setting()
265 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; in pinconf_show_setting()
268 switch (setting->type) { in pinconf_show_setting()
270 desc = pin_desc_get(setting->pctldev, in pinconf_show_setting()
271 setting->data.configs.group_or_pin); in pinconf_show_setting()
272 seq_printf(s, "pin %s (%d)", desc->name, in pinconf_show_setting()
273 setting->data.configs.group_or_pin); in pinconf_show_setting()
277 pctlops->get_group_name(pctldev, in pinconf_show_setting()
278 setting->data.configs.group_or_pin), in pinconf_show_setting()
279 setting->data.configs.group_or_pin); in pinconf_show_setting()
286 * FIXME: We should really get the pin controller to dump the config in pinconf_show_setting()
289 pinconf_show_config(s, pctldev, setting->data.configs.configs, in pinconf_show_setting()
290 setting->data.configs.num_configs); in pinconf_show_setting()
294 struct seq_file *s, int pin) in pinconf_dump_pin() argument
296 const struct pinconf_ops *ops = pctldev->desc->confops; in pinconf_dump_pin()
298 /* no-op when not using generic pin config */ in pinconf_dump_pin()
299 pinconf_generic_dump_pins(pctldev, s, NULL, pin); in pinconf_dump_pin()
300 if (ops && ops->pin_config_dbg_show) in pinconf_dump_pin()
301 ops->pin_config_dbg_show(pctldev, s, pin); in pinconf_dump_pin()
306 struct pinctrl_dev *pctldev = s->private; in pinconf_pins_show()
307 unsigned int i, pin; in pinconf_pins_show() local
309 seq_puts(s, "Pin config settings per pin\n"); in pinconf_pins_show()
310 seq_puts(s, "Format: pin (name): configs\n"); in pinconf_pins_show()
312 mutex_lock(&pctldev->mutex); in pinconf_pins_show()
314 /* The pin number can be retrived from the pin controller descriptor */ in pinconf_pins_show()
315 for (i = 0; i < pctldev->desc->npins; i++) { in pinconf_pins_show()
318 pin = pctldev->desc->pins[i].number; in pinconf_pins_show()
319 desc = pin_desc_get(pctldev, pin); in pinconf_pins_show()
320 /* Skip if we cannot search the pin */ in pinconf_pins_show()
324 seq_printf(s, "pin %d (%s): ", pin, desc->name); in pinconf_pins_show()
326 pinconf_dump_pin(pctldev, s, pin); in pinconf_pins_show()
330 mutex_unlock(&pctldev->mutex); in pinconf_pins_show()
339 const struct pinconf_ops *ops = pctldev->desc->confops; in pinconf_dump_group()
341 /* no-op when not using generic pin config */ in pinconf_dump_group()
343 if (ops && ops->pin_config_group_dbg_show) in pinconf_dump_group()
344 ops->pin_config_group_dbg_show(pctldev, s, selector); in pinconf_dump_group()
349 struct pinctrl_dev *pctldev = s->private; in pinconf_groups_show()
350 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; in pinconf_groups_show()
351 unsigned int ngroups = pctlops->get_groups_count(pctldev); in pinconf_groups_show()
354 seq_puts(s, "Pin config settings per pin group\n"); in pinconf_groups_show()
358 const char *gname = pctlops->get_group_name(pctldev, selector); in pinconf_groups_show()
375 debugfs_create_file("pinconf-pins", 0444, in pinconf_init_device_debugfs()
377 debugfs_create_file("pinconf-groups", 0444, in pinconf_init_device_debugfs()