2 * Core driver for the pin control subsystem
4 * Copyright (C) 2011-2012 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson
6 * Based on bits of regulator core, gpio core and clk core
8 * Author: Linus Walleij <linus.walleij@linaro.org>
10 * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
12 * License terms: GNU General Public License (GPL) version 2
14 #define pr_fmt(fmt) "pinctrl core: " fmt
16 #include <linux/kernel.h>
17 #include <linux/kref.h>
18 #include <linux/export.h>
19 #include <linux/init.h>
20 #include <linux/device.h>
21 #include <linux/slab.h>
22 #include <linux/err.h>
23 #include <linux/list.h>
24 #include <linux/sysfs.h>
25 #include <linux/debugfs.h>
26 #include <linux/seq_file.h>
27 #include <linux/pinctrl/consumer.h>
28 #include <linux/pinctrl/pinctrl.h>
29 #include <linux/pinctrl/machine.h>
32 #include <asm-generic/gpio.h>
36 #include "devicetree.h"
41 static bool pinctrl_dummy_state
;
43 /* Mutex taken by all entry points */
44 DEFINE_MUTEX(pinctrl_mutex
);
46 /* Global list of pin control devices (struct pinctrl_dev) */
47 LIST_HEAD(pinctrldev_list
);
49 /* List of pin controller handles (struct pinctrl) */
50 static LIST_HEAD(pinctrl_list
);
52 /* List of pinctrl maps (struct pinctrl_maps) */
53 LIST_HEAD(pinctrl_maps
);
57 * pinctrl_provide_dummies() - indicate if pinctrl provides dummy state support
59 * Usually this function is called by platforms without pinctrl driver support
60 * but run with some shared drivers using pinctrl APIs.
61 * After calling this function, the pinctrl core will return successfully
62 * with creating a dummy state for the driver to keep going smoothly.
64 void pinctrl_provide_dummies(void)
66 pinctrl_dummy_state
= true;
69 const char *pinctrl_dev_get_name(struct pinctrl_dev
*pctldev
)
71 /* We're not allowed to register devices without name */
72 return pctldev
->desc
->name
;
74 EXPORT_SYMBOL_GPL(pinctrl_dev_get_name
);
76 const char *pinctrl_dev_get_devname(struct pinctrl_dev
*pctldev
)
78 return dev_name(pctldev
->dev
);
80 EXPORT_SYMBOL_GPL(pinctrl_dev_get_devname
);
82 void *pinctrl_dev_get_drvdata(struct pinctrl_dev
*pctldev
)
84 return pctldev
->driver_data
;
86 EXPORT_SYMBOL_GPL(pinctrl_dev_get_drvdata
);
89 * get_pinctrl_dev_from_devname() - look up pin controller device
90 * @devname: the name of a device instance, as returned by dev_name()
92 * Looks up a pin control device matching a certain device name or pure device
93 * pointer, the pure device pointer will take precedence.
95 struct pinctrl_dev
*get_pinctrl_dev_from_devname(const char *devname
)
97 struct pinctrl_dev
*pctldev
= NULL
;
103 list_for_each_entry(pctldev
, &pinctrldev_list
, node
) {
104 if (!strcmp(dev_name(pctldev
->dev
), devname
)) {
105 /* Matched on device name */
111 return found
? pctldev
: NULL
;
115 * pin_get_from_name() - look up a pin number from a name
116 * @pctldev: the pin control device to lookup the pin on
117 * @name: the name of the pin to look up
119 int pin_get_from_name(struct pinctrl_dev
*pctldev
, const char *name
)
123 /* The pin number can be retrived from the pin controller descriptor */
124 for (i
= 0; i
< pctldev
->desc
->npins
; i
++) {
125 struct pin_desc
*desc
;
127 pin
= pctldev
->desc
->pins
[i
].number
;
128 desc
= pin_desc_get(pctldev
, pin
);
129 /* Pin space may be sparse */
132 if (desc
->name
&& !strcmp(name
, desc
->name
))
140 * pin_get_name_from_id() - look up a pin name from a pin id
141 * @pctldev: the pin control device to lookup the pin on
142 * @name: the name of the pin to look up
144 const char *pin_get_name(struct pinctrl_dev
*pctldev
, const unsigned pin
)
146 const struct pin_desc
*desc
;
148 desc
= pin_desc_get(pctldev
, pin
);
150 dev_err(pctldev
->dev
, "failed to get pin(%d) name\n",
159 * pin_is_valid() - check if pin exists on controller
160 * @pctldev: the pin control device to check the pin on
161 * @pin: pin to check, use the local pin controller index number
163 * This tells us whether a certain pin exist on a certain pin controller or
164 * not. Pin lists may be sparse, so some pins may not exist.
166 bool pin_is_valid(struct pinctrl_dev
*pctldev
, int pin
)
168 struct pin_desc
*pindesc
;
173 mutex_lock(&pinctrl_mutex
);
174 pindesc
= pin_desc_get(pctldev
, pin
);
175 mutex_unlock(&pinctrl_mutex
);
177 return pindesc
!= NULL
;
179 EXPORT_SYMBOL_GPL(pin_is_valid
);
181 /* Deletes a range of pin descriptors */
182 static void pinctrl_free_pindescs(struct pinctrl_dev
*pctldev
,
183 const struct pinctrl_pin_desc
*pins
,
188 for (i
= 0; i
< num_pins
; i
++) {
189 struct pin_desc
*pindesc
;
191 pindesc
= radix_tree_lookup(&pctldev
->pin_desc_tree
,
193 if (pindesc
!= NULL
) {
194 radix_tree_delete(&pctldev
->pin_desc_tree
,
196 if (pindesc
->dynamic_name
)
197 kfree(pindesc
->name
);
203 static int pinctrl_register_one_pin(struct pinctrl_dev
*pctldev
,
204 unsigned number
, const char *name
)
206 struct pin_desc
*pindesc
;
208 pindesc
= pin_desc_get(pctldev
, number
);
209 if (pindesc
!= NULL
) {
210 pr_err("pin %d already registered on %s\n", number
,
211 pctldev
->desc
->name
);
215 pindesc
= kzalloc(sizeof(*pindesc
), GFP_KERNEL
);
216 if (pindesc
== NULL
) {
217 dev_err(pctldev
->dev
, "failed to alloc struct pin_desc\n");
222 pindesc
->pctldev
= pctldev
;
224 /* Copy basic pin info */
226 pindesc
->name
= name
;
228 pindesc
->name
= kasprintf(GFP_KERNEL
, "PIN%u", number
);
229 if (pindesc
->name
== NULL
) {
233 pindesc
->dynamic_name
= true;
236 radix_tree_insert(&pctldev
->pin_desc_tree
, number
, pindesc
);
237 pr_debug("registered pin %d (%s) on %s\n",
238 number
, pindesc
->name
, pctldev
->desc
->name
);
242 static int pinctrl_register_pins(struct pinctrl_dev
*pctldev
,
243 struct pinctrl_pin_desc
const *pins
,
249 for (i
= 0; i
< num_descs
; i
++) {
250 ret
= pinctrl_register_one_pin(pctldev
,
251 pins
[i
].number
, pins
[i
].name
);
260 * pinctrl_match_gpio_range() - check if a certain GPIO pin is in range
261 * @pctldev: pin controller device to check
262 * @gpio: gpio pin to check taken from the global GPIO pin space
264 * Tries to match a GPIO pin number to the ranges handled by a certain pin
265 * controller, return the range or NULL
267 static struct pinctrl_gpio_range
*
268 pinctrl_match_gpio_range(struct pinctrl_dev
*pctldev
, unsigned gpio
)
270 struct pinctrl_gpio_range
*range
= NULL
;
272 /* Loop over the ranges */
273 list_for_each_entry(range
, &pctldev
->gpio_ranges
, node
) {
274 /* Check if we're in the valid range */
275 if (gpio
>= range
->base
&&
276 gpio
< range
->base
+ range
->npins
) {
285 * pinctrl_ready_for_gpio_range() - check if other GPIO pins of
286 * the same GPIO chip are in range
287 * @gpio: gpio pin to check taken from the global GPIO pin space
289 * This function is complement of pinctrl_match_gpio_range(). If the return
290 * value of pinctrl_match_gpio_range() is NULL, this function could be used
291 * to check whether pinctrl device is ready or not. Maybe some GPIO pins
292 * of the same GPIO chip don't have back-end pinctrl interface.
293 * If the return value is true, it means that pinctrl device is ready & the
294 * certain GPIO pin doesn't have back-end pinctrl device. If the return value
295 * is false, it means that pinctrl device may not be ready.
297 #ifdef CONFIG_GPIOLIB
298 static bool pinctrl_ready_for_gpio_range(unsigned gpio
)
300 struct pinctrl_dev
*pctldev
;
301 struct pinctrl_gpio_range
*range
= NULL
;
302 struct gpio_chip
*chip
= gpio_to_chip(gpio
);
304 /* Loop over the pin controllers */
305 list_for_each_entry(pctldev
, &pinctrldev_list
, node
) {
306 /* Loop over the ranges */
307 list_for_each_entry(range
, &pctldev
->gpio_ranges
, node
) {
308 /* Check if any gpio range overlapped with gpio chip */
309 if (range
->base
+ range
->npins
- 1 < chip
->base
||
310 range
->base
> chip
->base
+ chip
->ngpio
- 1)
318 static bool pinctrl_ready_for_gpio_range(unsigned gpio
) { return true; }
322 * pinctrl_get_device_gpio_range() - find device for GPIO range
323 * @gpio: the pin to locate the pin controller for
324 * @outdev: the pin control device if found
325 * @outrange: the GPIO range if found
327 * Find the pin controller handling a certain GPIO pin from the pinspace of
328 * the GPIO subsystem, return the device and the matching GPIO range. Returns
329 * -EPROBE_DEFER if the GPIO range could not be found in any device since it
330 * may still have not been registered.
332 static int pinctrl_get_device_gpio_range(unsigned gpio
,
333 struct pinctrl_dev
**outdev
,
334 struct pinctrl_gpio_range
**outrange
)
336 struct pinctrl_dev
*pctldev
= NULL
;
338 /* Loop over the pin controllers */
339 list_for_each_entry(pctldev
, &pinctrldev_list
, node
) {
340 struct pinctrl_gpio_range
*range
;
342 range
= pinctrl_match_gpio_range(pctldev
, gpio
);
350 return -EPROBE_DEFER
;
354 * pinctrl_add_gpio_range() - register a GPIO range for a controller
355 * @pctldev: pin controller device to add the range to
356 * @range: the GPIO range to add
358 * This adds a range of GPIOs to be handled by a certain pin controller. Call
359 * this to register handled ranges after registering your pin controller.
361 void pinctrl_add_gpio_range(struct pinctrl_dev
*pctldev
,
362 struct pinctrl_gpio_range
*range
)
364 mutex_lock(&pinctrl_mutex
);
365 list_add_tail(&range
->node
, &pctldev
->gpio_ranges
);
366 mutex_unlock(&pinctrl_mutex
);
368 EXPORT_SYMBOL_GPL(pinctrl_add_gpio_range
);
370 void pinctrl_add_gpio_ranges(struct pinctrl_dev
*pctldev
,
371 struct pinctrl_gpio_range
*ranges
,
376 for (i
= 0; i
< nranges
; i
++)
377 pinctrl_add_gpio_range(pctldev
, &ranges
[i
]);
379 EXPORT_SYMBOL_GPL(pinctrl_add_gpio_ranges
);
381 struct pinctrl_dev
*pinctrl_find_and_add_gpio_range(const char *devname
,
382 struct pinctrl_gpio_range
*range
)
384 struct pinctrl_dev
*pctldev
= get_pinctrl_dev_from_devname(devname
);
387 * If we can't find this device, let's assume that is because
388 * it has not probed yet, so the driver trying to register this
389 * range need to defer probing.
392 return ERR_PTR(-EPROBE_DEFER
);
394 pinctrl_add_gpio_range(pctldev
, range
);
397 EXPORT_SYMBOL_GPL(pinctrl_find_and_add_gpio_range
);
400 * pinctrl_find_gpio_range_from_pin() - locate the GPIO range for a pin
401 * @pctldev: the pin controller device to look in
402 * @pin: a controller-local number to find the range for
404 struct pinctrl_gpio_range
*
405 pinctrl_find_gpio_range_from_pin(struct pinctrl_dev
*pctldev
,
408 struct pinctrl_gpio_range
*range
= NULL
;
410 /* Loop over the ranges */
411 list_for_each_entry(range
, &pctldev
->gpio_ranges
, node
) {
412 /* Check if we're in the valid range */
413 if (pin
>= range
->pin_base
&&
414 pin
< range
->pin_base
+ range
->npins
) {
421 EXPORT_SYMBOL_GPL(pinctrl_find_gpio_range_from_pin
);
424 * pinctrl_remove_gpio_range() - remove a range of GPIOs fro a pin controller
425 * @pctldev: pin controller device to remove the range from
426 * @range: the GPIO range to remove
428 void pinctrl_remove_gpio_range(struct pinctrl_dev
*pctldev
,
429 struct pinctrl_gpio_range
*range
)
431 mutex_lock(&pinctrl_mutex
);
432 list_del(&range
->node
);
433 mutex_unlock(&pinctrl_mutex
);
435 EXPORT_SYMBOL_GPL(pinctrl_remove_gpio_range
);
438 * pinctrl_get_group_selector() - returns the group selector for a group
439 * @pctldev: the pin controller handling the group
440 * @pin_group: the pin group to look up
442 int pinctrl_get_group_selector(struct pinctrl_dev
*pctldev
,
443 const char *pin_group
)
445 const struct pinctrl_ops
*pctlops
= pctldev
->desc
->pctlops
;
446 unsigned ngroups
= pctlops
->get_groups_count(pctldev
);
447 unsigned group_selector
= 0;
449 while (group_selector
< ngroups
) {
450 const char *gname
= pctlops
->get_group_name(pctldev
,
452 if (!strcmp(gname
, pin_group
)) {
453 dev_dbg(pctldev
->dev
,
454 "found group selector %u for %s\n",
457 return group_selector
;
463 dev_err(pctldev
->dev
, "does not have pin group %s\n",
470 * pinctrl_request_gpio() - request a single pin to be used in as GPIO
471 * @gpio: the GPIO pin number from the GPIO subsystem number space
473 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
474 * as part of their gpio_request() semantics, platforms and individual drivers
475 * shall *NOT* request GPIO pins to be muxed in.
477 int pinctrl_request_gpio(unsigned gpio
)
479 struct pinctrl_dev
*pctldev
;
480 struct pinctrl_gpio_range
*range
;
484 mutex_lock(&pinctrl_mutex
);
486 ret
= pinctrl_get_device_gpio_range(gpio
, &pctldev
, &range
);
488 if (pinctrl_ready_for_gpio_range(gpio
))
490 mutex_unlock(&pinctrl_mutex
);
494 /* Convert to the pin controllers number space */
495 pin
= gpio
- range
->base
+ range
->pin_base
;
497 ret
= pinmux_request_gpio(pctldev
, range
, pin
, gpio
);
499 mutex_unlock(&pinctrl_mutex
);
502 EXPORT_SYMBOL_GPL(pinctrl_request_gpio
);
505 * pinctrl_free_gpio() - free control on a single pin, currently used as GPIO
506 * @gpio: the GPIO pin number from the GPIO subsystem number space
508 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
509 * as part of their gpio_free() semantics, platforms and individual drivers
510 * shall *NOT* request GPIO pins to be muxed out.
512 void pinctrl_free_gpio(unsigned gpio
)
514 struct pinctrl_dev
*pctldev
;
515 struct pinctrl_gpio_range
*range
;
519 mutex_lock(&pinctrl_mutex
);
521 ret
= pinctrl_get_device_gpio_range(gpio
, &pctldev
, &range
);
523 mutex_unlock(&pinctrl_mutex
);
527 /* Convert to the pin controllers number space */
528 pin
= gpio
- range
->base
+ range
->pin_base
;
530 pinmux_free_gpio(pctldev
, pin
, range
);
532 mutex_unlock(&pinctrl_mutex
);
534 EXPORT_SYMBOL_GPL(pinctrl_free_gpio
);
536 static int pinctrl_gpio_direction(unsigned gpio
, bool input
)
538 struct pinctrl_dev
*pctldev
;
539 struct pinctrl_gpio_range
*range
;
543 ret
= pinctrl_get_device_gpio_range(gpio
, &pctldev
, &range
);
547 /* Convert to the pin controllers number space */
548 pin
= gpio
- range
->base
+ range
->pin_base
;
550 return pinmux_gpio_direction(pctldev
, range
, pin
, input
);
554 * pinctrl_gpio_direction_input() - request a GPIO pin to go into input mode
555 * @gpio: the GPIO pin number from the GPIO subsystem number space
557 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
558 * as part of their gpio_direction_input() semantics, platforms and individual
559 * drivers shall *NOT* touch pin control GPIO calls.
561 int pinctrl_gpio_direction_input(unsigned gpio
)
564 mutex_lock(&pinctrl_mutex
);
565 ret
= pinctrl_gpio_direction(gpio
, true);
566 mutex_unlock(&pinctrl_mutex
);
569 EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_input
);
572 * pinctrl_gpio_direction_output() - request a GPIO pin to go into output mode
573 * @gpio: the GPIO pin number from the GPIO subsystem number space
575 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
576 * as part of their gpio_direction_output() semantics, platforms and individual
577 * drivers shall *NOT* touch pin control GPIO calls.
579 int pinctrl_gpio_direction_output(unsigned gpio
)
582 mutex_lock(&pinctrl_mutex
);
583 ret
= pinctrl_gpio_direction(gpio
, false);
584 mutex_unlock(&pinctrl_mutex
);
587 EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output
);
589 static struct pinctrl_state
*find_state(struct pinctrl
*p
,
592 struct pinctrl_state
*state
;
594 list_for_each_entry(state
, &p
->states
, node
)
595 if (!strcmp(state
->name
, name
))
601 static struct pinctrl_state
*create_state(struct pinctrl
*p
,
604 struct pinctrl_state
*state
;
606 state
= kzalloc(sizeof(*state
), GFP_KERNEL
);
609 "failed to alloc struct pinctrl_state\n");
610 return ERR_PTR(-ENOMEM
);
614 INIT_LIST_HEAD(&state
->settings
);
616 list_add_tail(&state
->node
, &p
->states
);
621 static int add_setting(struct pinctrl
*p
, struct pinctrl_map
const *map
)
623 struct pinctrl_state
*state
;
624 struct pinctrl_setting
*setting
;
627 state
= find_state(p
, map
->name
);
629 state
= create_state(p
, map
->name
);
631 return PTR_ERR(state
);
633 if (map
->type
== PIN_MAP_TYPE_DUMMY_STATE
)
636 setting
= kzalloc(sizeof(*setting
), GFP_KERNEL
);
637 if (setting
== NULL
) {
639 "failed to alloc struct pinctrl_setting\n");
643 setting
->type
= map
->type
;
645 setting
->pctldev
= get_pinctrl_dev_from_devname(map
->ctrl_dev_name
);
646 if (setting
->pctldev
== NULL
) {
648 /* Do not defer probing of hogs (circular loop) */
649 if (!strcmp(map
->ctrl_dev_name
, map
->dev_name
))
652 * OK let us guess that the driver is not there yet, and
653 * let's defer obtaining this pinctrl handle to later...
655 dev_info(p
->dev
, "unknown pinctrl device %s in map entry, deferring probe",
657 return -EPROBE_DEFER
;
660 setting
->dev_name
= map
->dev_name
;
663 case PIN_MAP_TYPE_MUX_GROUP
:
664 ret
= pinmux_map_to_setting(map
, setting
);
666 case PIN_MAP_TYPE_CONFIGS_PIN
:
667 case PIN_MAP_TYPE_CONFIGS_GROUP
:
668 ret
= pinconf_map_to_setting(map
, setting
);
679 list_add_tail(&setting
->node
, &state
->settings
);
684 static struct pinctrl
*find_pinctrl(struct device
*dev
)
688 list_for_each_entry(p
, &pinctrl_list
, node
)
695 static void pinctrl_put_locked(struct pinctrl
*p
, bool inlist
);
697 static struct pinctrl
*create_pinctrl(struct device
*dev
)
701 struct pinctrl_maps
*maps_node
;
703 struct pinctrl_map
const *map
;
707 * create the state cookie holder struct pinctrl for each
708 * mapping, this is what consumers will get when requesting
709 * a pin control handle with pinctrl_get()
711 p
= kzalloc(sizeof(*p
), GFP_KERNEL
);
713 dev_err(dev
, "failed to alloc struct pinctrl\n");
714 return ERR_PTR(-ENOMEM
);
717 INIT_LIST_HEAD(&p
->states
);
718 INIT_LIST_HEAD(&p
->dt_maps
);
720 ret
= pinctrl_dt_to_map(p
);
726 devname
= dev_name(dev
);
728 /* Iterate over the pin control maps to locate the right ones */
729 for_each_maps(maps_node
, i
, map
) {
730 /* Map must be for this device */
731 if (strcmp(map
->dev_name
, devname
))
734 ret
= add_setting(p
, map
);
736 * At this point the adding of a setting may:
738 * - Defer, if the pinctrl device is not yet available
739 * - Fail, if the pinctrl device is not yet available,
740 * AND the setting is a hog. We cannot defer that, since
741 * the hog will kick in immediately after the device
744 * If the error returned was not -EPROBE_DEFER then we
745 * accumulate the errors to see if we end up with
746 * an -EPROBE_DEFER later, as that is the worst case.
748 if (ret
== -EPROBE_DEFER
) {
749 pinctrl_put_locked(p
, false);
754 /* If some other error than deferral occured, return here */
755 pinctrl_put_locked(p
, false);
759 kref_init(&p
->users
);
761 /* Add the pinctrl handle to the global list */
762 list_add_tail(&p
->node
, &pinctrl_list
);
767 static struct pinctrl
*pinctrl_get_locked(struct device
*dev
)
772 return ERR_PTR(-EINVAL
);
775 * See if somebody else (such as the device core) has already
776 * obtained a handle to the pinctrl for this device. In that case,
777 * return another pointer to it.
779 p
= find_pinctrl(dev
);
781 dev_dbg(dev
, "obtain a copy of previously claimed pinctrl\n");
786 return create_pinctrl(dev
);
790 * pinctrl_get() - retrieves the pinctrl handle for a device
791 * @dev: the device to obtain the handle for
793 struct pinctrl
*pinctrl_get(struct device
*dev
)
797 mutex_lock(&pinctrl_mutex
);
798 p
= pinctrl_get_locked(dev
);
799 mutex_unlock(&pinctrl_mutex
);
803 EXPORT_SYMBOL_GPL(pinctrl_get
);
805 static void pinctrl_free_setting(bool disable_setting
,
806 struct pinctrl_setting
*setting
)
808 switch (setting
->type
) {
809 case PIN_MAP_TYPE_MUX_GROUP
:
811 pinmux_disable_setting(setting
);
812 pinmux_free_setting(setting
);
814 case PIN_MAP_TYPE_CONFIGS_PIN
:
815 case PIN_MAP_TYPE_CONFIGS_GROUP
:
816 pinconf_free_setting(setting
);
823 static void pinctrl_put_locked(struct pinctrl
*p
, bool inlist
)
825 struct pinctrl_state
*state
, *n1
;
826 struct pinctrl_setting
*setting
, *n2
;
828 list_for_each_entry_safe(state
, n1
, &p
->states
, node
) {
829 list_for_each_entry_safe(setting
, n2
, &state
->settings
, node
) {
830 pinctrl_free_setting(state
== p
->state
, setting
);
831 list_del(&setting
->node
);
834 list_del(&state
->node
);
838 pinctrl_dt_free_maps(p
);
846 * pinctrl_release() - release the pinctrl handle
847 * @kref: the kref in the pinctrl being released
849 static void pinctrl_release(struct kref
*kref
)
851 struct pinctrl
*p
= container_of(kref
, struct pinctrl
, users
);
853 pinctrl_put_locked(p
, true);
857 * pinctrl_put() - decrease use count on a previously claimed pinctrl handle
858 * @p: the pinctrl handle to release
860 void pinctrl_put(struct pinctrl
*p
)
862 mutex_lock(&pinctrl_mutex
);
863 kref_put(&p
->users
, pinctrl_release
);
864 mutex_unlock(&pinctrl_mutex
);
866 EXPORT_SYMBOL_GPL(pinctrl_put
);
868 static struct pinctrl_state
*pinctrl_lookup_state_locked(struct pinctrl
*p
,
871 struct pinctrl_state
*state
;
873 state
= find_state(p
, name
);
875 if (pinctrl_dummy_state
) {
876 /* create dummy state */
877 dev_dbg(p
->dev
, "using pinctrl dummy state (%s)\n",
879 state
= create_state(p
, name
);
881 state
= ERR_PTR(-ENODEV
);
888 * pinctrl_lookup_state() - retrieves a state handle from a pinctrl handle
889 * @p: the pinctrl handle to retrieve the state from
890 * @name: the state name to retrieve
892 struct pinctrl_state
*pinctrl_lookup_state(struct pinctrl
*p
, const char *name
)
894 struct pinctrl_state
*s
;
896 mutex_lock(&pinctrl_mutex
);
897 s
= pinctrl_lookup_state_locked(p
, name
);
898 mutex_unlock(&pinctrl_mutex
);
902 EXPORT_SYMBOL_GPL(pinctrl_lookup_state
);
904 static int pinctrl_select_state_locked(struct pinctrl
*p
,
905 struct pinctrl_state
*state
)
907 struct pinctrl_setting
*setting
, *setting2
;
908 struct pinctrl_state
*old_state
= p
->state
;
911 if (p
->state
== state
)
916 * The set of groups with a mux configuration in the old state
917 * may not be identical to the set of groups with a mux setting
918 * in the new state. While this might be unusual, it's entirely
919 * possible for the "user"-supplied mapping table to be written
920 * that way. For each group that was configured in the old state
921 * but not in the new state, this code puts that group into a
922 * safe/disabled state.
924 list_for_each_entry(setting
, &p
->state
->settings
, node
) {
926 if (setting
->type
!= PIN_MAP_TYPE_MUX_GROUP
)
928 list_for_each_entry(setting2
, &state
->settings
, node
) {
929 if (setting2
->type
!= PIN_MAP_TYPE_MUX_GROUP
)
931 if (setting2
->data
.mux
.group
==
932 setting
->data
.mux
.group
) {
938 pinmux_disable_setting(setting
);
944 /* Apply all the settings for the new state */
945 list_for_each_entry(setting
, &state
->settings
, node
) {
946 switch (setting
->type
) {
947 case PIN_MAP_TYPE_MUX_GROUP
:
948 ret
= pinmux_enable_setting(setting
);
950 case PIN_MAP_TYPE_CONFIGS_PIN
:
951 case PIN_MAP_TYPE_CONFIGS_GROUP
:
952 ret
= pinconf_apply_setting(setting
);
960 goto unapply_new_state
;
968 dev_err(p
->dev
, "Error applying setting, reverse things back\n");
970 list_for_each_entry(setting2
, &state
->settings
, node
) {
971 if (&setting2
->node
== &setting
->node
)
973 pinctrl_free_setting(true, setting2
);
977 list_for_each_entry(setting
, &old_state
->settings
, node
) {
979 if (setting
->type
!= PIN_MAP_TYPE_MUX_GROUP
)
981 list_for_each_entry(setting2
, &state
->settings
, node
) {
982 if (setting2
->type
!= PIN_MAP_TYPE_MUX_GROUP
)
984 if (setting2
->data
.mux
.group
==
985 setting
->data
.mux
.group
) {
991 pinmux_enable_setting(setting
);
998 * pinctrl_select() - select/activate/program a pinctrl state to HW
999 * @p: the pinctrl handle for the device that requests configuratio
1000 * @state: the state handle to select/activate/program
1002 int pinctrl_select_state(struct pinctrl
*p
, struct pinctrl_state
*state
)
1006 mutex_lock(&pinctrl_mutex
);
1007 ret
= pinctrl_select_state_locked(p
, state
);
1008 mutex_unlock(&pinctrl_mutex
);
1012 EXPORT_SYMBOL_GPL(pinctrl_select_state
);
1014 static void devm_pinctrl_release(struct device
*dev
, void *res
)
1016 pinctrl_put(*(struct pinctrl
**)res
);
1020 * struct devm_pinctrl_get() - Resource managed pinctrl_get()
1021 * @dev: the device to obtain the handle for
1023 * If there is a need to explicitly destroy the returned struct pinctrl,
1024 * devm_pinctrl_put() should be used, rather than plain pinctrl_put().
1026 struct pinctrl
*devm_pinctrl_get(struct device
*dev
)
1028 struct pinctrl
**ptr
, *p
;
1030 ptr
= devres_alloc(devm_pinctrl_release
, sizeof(*ptr
), GFP_KERNEL
);
1032 return ERR_PTR(-ENOMEM
);
1034 p
= pinctrl_get(dev
);
1037 devres_add(dev
, ptr
);
1044 EXPORT_SYMBOL_GPL(devm_pinctrl_get
);
1046 static int devm_pinctrl_match(struct device
*dev
, void *res
, void *data
)
1048 struct pinctrl
**p
= res
;
1054 * devm_pinctrl_put() - Resource managed pinctrl_put()
1055 * @p: the pinctrl handle to release
1057 * Deallocate a struct pinctrl obtained via devm_pinctrl_get(). Normally
1058 * this function will not need to be called and the resource management
1059 * code will ensure that the resource is freed.
1061 void devm_pinctrl_put(struct pinctrl
*p
)
1063 WARN_ON(devres_release(p
->dev
, devm_pinctrl_release
,
1064 devm_pinctrl_match
, p
));
1066 EXPORT_SYMBOL_GPL(devm_pinctrl_put
);
1068 int pinctrl_register_map(struct pinctrl_map
const *maps
, unsigned num_maps
,
1069 bool dup
, bool locked
)
1072 struct pinctrl_maps
*maps_node
;
1074 pr_debug("add %d pinmux maps\n", num_maps
);
1076 /* First sanity check the new mapping */
1077 for (i
= 0; i
< num_maps
; i
++) {
1078 if (!maps
[i
].dev_name
) {
1079 pr_err("failed to register map %s (%d): no device given\n",
1084 if (!maps
[i
].name
) {
1085 pr_err("failed to register map %d: no map name given\n",
1090 if (maps
[i
].type
!= PIN_MAP_TYPE_DUMMY_STATE
&&
1091 !maps
[i
].ctrl_dev_name
) {
1092 pr_err("failed to register map %s (%d): no pin control device given\n",
1097 switch (maps
[i
].type
) {
1098 case PIN_MAP_TYPE_DUMMY_STATE
:
1100 case PIN_MAP_TYPE_MUX_GROUP
:
1101 ret
= pinmux_validate_map(&maps
[i
], i
);
1105 case PIN_MAP_TYPE_CONFIGS_PIN
:
1106 case PIN_MAP_TYPE_CONFIGS_GROUP
:
1107 ret
= pinconf_validate_map(&maps
[i
], i
);
1112 pr_err("failed to register map %s (%d): invalid type given\n",
1118 maps_node
= kzalloc(sizeof(*maps_node
), GFP_KERNEL
);
1120 pr_err("failed to alloc struct pinctrl_maps\n");
1124 maps_node
->num_maps
= num_maps
;
1126 maps_node
->maps
= kmemdup(maps
, sizeof(*maps
) * num_maps
,
1128 if (!maps_node
->maps
) {
1129 pr_err("failed to duplicate mapping table\n");
1134 maps_node
->maps
= maps
;
1138 mutex_lock(&pinctrl_mutex
);
1139 list_add_tail(&maps_node
->node
, &pinctrl_maps
);
1141 mutex_unlock(&pinctrl_mutex
);
1147 * pinctrl_register_mappings() - register a set of pin controller mappings
1148 * @maps: the pincontrol mappings table to register. This should probably be
1149 * marked with __initdata so it can be discarded after boot. This
1150 * function will perform a shallow copy for the mapping entries.
1151 * @num_maps: the number of maps in the mapping table
1153 int pinctrl_register_mappings(struct pinctrl_map
const *maps
,
1156 return pinctrl_register_map(maps
, num_maps
, true, false);
1159 void pinctrl_unregister_map(struct pinctrl_map
const *map
)
1161 struct pinctrl_maps
*maps_node
;
1163 list_for_each_entry(maps_node
, &pinctrl_maps
, node
) {
1164 if (maps_node
->maps
== map
) {
1165 list_del(&maps_node
->node
);
1172 * pinctrl_force_sleep() - turn a given controller device into sleep state
1173 * @pctldev: pin controller device
1175 int pinctrl_force_sleep(struct pinctrl_dev
*pctldev
)
1177 if (!IS_ERR(pctldev
->p
) && !IS_ERR(pctldev
->hog_sleep
))
1178 return pinctrl_select_state(pctldev
->p
, pctldev
->hog_sleep
);
1181 EXPORT_SYMBOL_GPL(pinctrl_force_sleep
);
1184 * pinctrl_force_default() - turn a given controller device into default state
1185 * @pctldev: pin controller device
1187 int pinctrl_force_default(struct pinctrl_dev
*pctldev
)
1189 if (!IS_ERR(pctldev
->p
) && !IS_ERR(pctldev
->hog_default
))
1190 return pinctrl_select_state(pctldev
->p
, pctldev
->hog_default
);
1193 EXPORT_SYMBOL_GPL(pinctrl_force_default
);
1195 #ifdef CONFIG_DEBUG_FS
1197 static int pinctrl_pins_show(struct seq_file
*s
, void *what
)
1199 struct pinctrl_dev
*pctldev
= s
->private;
1200 const struct pinctrl_ops
*ops
= pctldev
->desc
->pctlops
;
1203 seq_printf(s
, "registered pins: %d\n", pctldev
->desc
->npins
);
1205 mutex_lock(&pinctrl_mutex
);
1207 /* The pin number can be retrived from the pin controller descriptor */
1208 for (i
= 0; i
< pctldev
->desc
->npins
; i
++) {
1209 struct pin_desc
*desc
;
1211 pin
= pctldev
->desc
->pins
[i
].number
;
1212 desc
= pin_desc_get(pctldev
, pin
);
1213 /* Pin space may be sparse */
1217 seq_printf(s
, "pin %d (%s) ", pin
,
1218 desc
->name
? desc
->name
: "unnamed");
1220 /* Driver-specific info per pin */
1221 if (ops
->pin_dbg_show
)
1222 ops
->pin_dbg_show(pctldev
, s
, pin
);
1227 mutex_unlock(&pinctrl_mutex
);
1232 static int pinctrl_groups_show(struct seq_file
*s
, void *what
)
1234 struct pinctrl_dev
*pctldev
= s
->private;
1235 const struct pinctrl_ops
*ops
= pctldev
->desc
->pctlops
;
1236 unsigned ngroups
, selector
= 0;
1238 ngroups
= ops
->get_groups_count(pctldev
);
1239 mutex_lock(&pinctrl_mutex
);
1241 seq_puts(s
, "registered pin groups:\n");
1242 while (selector
< ngroups
) {
1243 const unsigned *pins
;
1245 const char *gname
= ops
->get_group_name(pctldev
, selector
);
1250 ret
= ops
->get_group_pins(pctldev
, selector
,
1253 seq_printf(s
, "%s [ERROR GETTING PINS]\n",
1256 seq_printf(s
, "group: %s\n", gname
);
1257 for (i
= 0; i
< num_pins
; i
++) {
1258 pname
= pin_get_name(pctldev
, pins
[i
]);
1259 if (WARN_ON(!pname
)) {
1260 mutex_unlock(&pinctrl_mutex
);
1263 seq_printf(s
, "pin %d (%s)\n", pins
[i
], pname
);
1270 mutex_unlock(&pinctrl_mutex
);
1275 static int pinctrl_gpioranges_show(struct seq_file
*s
, void *what
)
1277 struct pinctrl_dev
*pctldev
= s
->private;
1278 struct pinctrl_gpio_range
*range
= NULL
;
1280 seq_puts(s
, "GPIO ranges handled:\n");
1282 mutex_lock(&pinctrl_mutex
);
1284 /* Loop over the ranges */
1285 list_for_each_entry(range
, &pctldev
->gpio_ranges
, node
) {
1286 seq_printf(s
, "%u: %s GPIOS [%u - %u] PINS [%u - %u]\n",
1287 range
->id
, range
->name
,
1288 range
->base
, (range
->base
+ range
->npins
- 1),
1290 (range
->pin_base
+ range
->npins
- 1));
1293 mutex_unlock(&pinctrl_mutex
);
1298 static int pinctrl_devices_show(struct seq_file
*s
, void *what
)
1300 struct pinctrl_dev
*pctldev
;
1302 seq_puts(s
, "name [pinmux] [pinconf]\n");
1304 mutex_lock(&pinctrl_mutex
);
1306 list_for_each_entry(pctldev
, &pinctrldev_list
, node
) {
1307 seq_printf(s
, "%s ", pctldev
->desc
->name
);
1308 if (pctldev
->desc
->pmxops
)
1309 seq_puts(s
, "yes ");
1312 if (pctldev
->desc
->confops
)
1319 mutex_unlock(&pinctrl_mutex
);
1324 static inline const char *map_type(enum pinctrl_map_type type
)
1326 static const char * const names
[] = {
1334 if (type
>= ARRAY_SIZE(names
))
1340 static int pinctrl_maps_show(struct seq_file
*s
, void *what
)
1342 struct pinctrl_maps
*maps_node
;
1344 struct pinctrl_map
const *map
;
1346 seq_puts(s
, "Pinctrl maps:\n");
1348 mutex_lock(&pinctrl_mutex
);
1350 for_each_maps(maps_node
, i
, map
) {
1351 seq_printf(s
, "device %s\nstate %s\ntype %s (%d)\n",
1352 map
->dev_name
, map
->name
, map_type(map
->type
),
1355 if (map
->type
!= PIN_MAP_TYPE_DUMMY_STATE
)
1356 seq_printf(s
, "controlling device %s\n",
1357 map
->ctrl_dev_name
);
1359 switch (map
->type
) {
1360 case PIN_MAP_TYPE_MUX_GROUP
:
1361 pinmux_show_map(s
, map
);
1363 case PIN_MAP_TYPE_CONFIGS_PIN
:
1364 case PIN_MAP_TYPE_CONFIGS_GROUP
:
1365 pinconf_show_map(s
, map
);
1371 seq_printf(s
, "\n");
1374 mutex_unlock(&pinctrl_mutex
);
1379 static int pinctrl_show(struct seq_file
*s
, void *what
)
1382 struct pinctrl_state
*state
;
1383 struct pinctrl_setting
*setting
;
1385 seq_puts(s
, "Requested pin control handlers their pinmux maps:\n");
1387 mutex_lock(&pinctrl_mutex
);
1389 list_for_each_entry(p
, &pinctrl_list
, node
) {
1390 seq_printf(s
, "device: %s current state: %s\n",
1392 p
->state
? p
->state
->name
: "none");
1394 list_for_each_entry(state
, &p
->states
, node
) {
1395 seq_printf(s
, " state: %s\n", state
->name
);
1397 list_for_each_entry(setting
, &state
->settings
, node
) {
1398 struct pinctrl_dev
*pctldev
= setting
->pctldev
;
1400 seq_printf(s
, " type: %s controller %s ",
1401 map_type(setting
->type
),
1402 pinctrl_dev_get_name(pctldev
));
1404 switch (setting
->type
) {
1405 case PIN_MAP_TYPE_MUX_GROUP
:
1406 pinmux_show_setting(s
, setting
);
1408 case PIN_MAP_TYPE_CONFIGS_PIN
:
1409 case PIN_MAP_TYPE_CONFIGS_GROUP
:
1410 pinconf_show_setting(s
, setting
);
1419 mutex_unlock(&pinctrl_mutex
);
1424 static int pinctrl_pins_open(struct inode
*inode
, struct file
*file
)
1426 return single_open(file
, pinctrl_pins_show
, inode
->i_private
);
1429 static int pinctrl_groups_open(struct inode
*inode
, struct file
*file
)
1431 return single_open(file
, pinctrl_groups_show
, inode
->i_private
);
1434 static int pinctrl_gpioranges_open(struct inode
*inode
, struct file
*file
)
1436 return single_open(file
, pinctrl_gpioranges_show
, inode
->i_private
);
1439 static int pinctrl_devices_open(struct inode
*inode
, struct file
*file
)
1441 return single_open(file
, pinctrl_devices_show
, NULL
);
1444 static int pinctrl_maps_open(struct inode
*inode
, struct file
*file
)
1446 return single_open(file
, pinctrl_maps_show
, NULL
);
1449 static int pinctrl_open(struct inode
*inode
, struct file
*file
)
1451 return single_open(file
, pinctrl_show
, NULL
);
1454 static const struct file_operations pinctrl_pins_ops
= {
1455 .open
= pinctrl_pins_open
,
1457 .llseek
= seq_lseek
,
1458 .release
= single_release
,
1461 static const struct file_operations pinctrl_groups_ops
= {
1462 .open
= pinctrl_groups_open
,
1464 .llseek
= seq_lseek
,
1465 .release
= single_release
,
1468 static const struct file_operations pinctrl_gpioranges_ops
= {
1469 .open
= pinctrl_gpioranges_open
,
1471 .llseek
= seq_lseek
,
1472 .release
= single_release
,
1475 static const struct file_operations pinctrl_devices_ops
= {
1476 .open
= pinctrl_devices_open
,
1478 .llseek
= seq_lseek
,
1479 .release
= single_release
,
1482 static const struct file_operations pinctrl_maps_ops
= {
1483 .open
= pinctrl_maps_open
,
1485 .llseek
= seq_lseek
,
1486 .release
= single_release
,
1489 static const struct file_operations pinctrl_ops
= {
1490 .open
= pinctrl_open
,
1492 .llseek
= seq_lseek
,
1493 .release
= single_release
,
1496 static struct dentry
*debugfs_root
;
1498 static void pinctrl_init_device_debugfs(struct pinctrl_dev
*pctldev
)
1500 struct dentry
*device_root
;
1502 device_root
= debugfs_create_dir(dev_name(pctldev
->dev
),
1504 pctldev
->device_root
= device_root
;
1506 if (IS_ERR(device_root
) || !device_root
) {
1507 pr_warn("failed to create debugfs directory for %s\n",
1508 dev_name(pctldev
->dev
));
1511 debugfs_create_file("pins", S_IFREG
| S_IRUGO
,
1512 device_root
, pctldev
, &pinctrl_pins_ops
);
1513 debugfs_create_file("pingroups", S_IFREG
| S_IRUGO
,
1514 device_root
, pctldev
, &pinctrl_groups_ops
);
1515 debugfs_create_file("gpio-ranges", S_IFREG
| S_IRUGO
,
1516 device_root
, pctldev
, &pinctrl_gpioranges_ops
);
1517 pinmux_init_device_debugfs(device_root
, pctldev
);
1518 pinconf_init_device_debugfs(device_root
, pctldev
);
1521 static void pinctrl_remove_device_debugfs(struct pinctrl_dev
*pctldev
)
1523 debugfs_remove_recursive(pctldev
->device_root
);
1526 static void pinctrl_init_debugfs(void)
1528 debugfs_root
= debugfs_create_dir("pinctrl", NULL
);
1529 if (IS_ERR(debugfs_root
) || !debugfs_root
) {
1530 pr_warn("failed to create debugfs directory\n");
1531 debugfs_root
= NULL
;
1535 debugfs_create_file("pinctrl-devices", S_IFREG
| S_IRUGO
,
1536 debugfs_root
, NULL
, &pinctrl_devices_ops
);
1537 debugfs_create_file("pinctrl-maps", S_IFREG
| S_IRUGO
,
1538 debugfs_root
, NULL
, &pinctrl_maps_ops
);
1539 debugfs_create_file("pinctrl-handles", S_IFREG
| S_IRUGO
,
1540 debugfs_root
, NULL
, &pinctrl_ops
);
1543 #else /* CONFIG_DEBUG_FS */
1545 static void pinctrl_init_device_debugfs(struct pinctrl_dev
*pctldev
)
1549 static void pinctrl_init_debugfs(void)
1553 static void pinctrl_remove_device_debugfs(struct pinctrl_dev
*pctldev
)
1559 static int pinctrl_check_ops(struct pinctrl_dev
*pctldev
)
1561 const struct pinctrl_ops
*ops
= pctldev
->desc
->pctlops
;
1564 !ops
->get_groups_count
||
1565 !ops
->get_group_name
||
1566 !ops
->get_group_pins
)
1569 if (ops
->dt_node_to_map
&& !ops
->dt_free_map
)
1576 * pinctrl_register() - register a pin controller device
1577 * @pctldesc: descriptor for this pin controller
1578 * @dev: parent device for this pin controller
1579 * @driver_data: private pin controller data for this pin controller
1581 struct pinctrl_dev
*pinctrl_register(struct pinctrl_desc
*pctldesc
,
1582 struct device
*dev
, void *driver_data
)
1584 struct pinctrl_dev
*pctldev
;
1589 if (!pctldesc
->name
)
1592 pctldev
= kzalloc(sizeof(*pctldev
), GFP_KERNEL
);
1593 if (pctldev
== NULL
) {
1594 dev_err(dev
, "failed to alloc struct pinctrl_dev\n");
1598 /* Initialize pin control device struct */
1599 pctldev
->owner
= pctldesc
->owner
;
1600 pctldev
->desc
= pctldesc
;
1601 pctldev
->driver_data
= driver_data
;
1602 INIT_RADIX_TREE(&pctldev
->pin_desc_tree
, GFP_KERNEL
);
1603 INIT_LIST_HEAD(&pctldev
->gpio_ranges
);
1606 /* check core ops for sanity */
1607 if (pinctrl_check_ops(pctldev
)) {
1608 dev_err(dev
, "pinctrl ops lacks necessary functions\n");
1612 /* If we're implementing pinmuxing, check the ops for sanity */
1613 if (pctldesc
->pmxops
) {
1614 if (pinmux_check_ops(pctldev
))
1618 /* If we're implementing pinconfig, check the ops for sanity */
1619 if (pctldesc
->confops
) {
1620 if (pinconf_check_ops(pctldev
))
1624 /* Register all the pins */
1625 dev_dbg(dev
, "try to register %d pins ...\n", pctldesc
->npins
);
1626 ret
= pinctrl_register_pins(pctldev
, pctldesc
->pins
, pctldesc
->npins
);
1628 dev_err(dev
, "error during pin registration\n");
1629 pinctrl_free_pindescs(pctldev
, pctldesc
->pins
,
1634 mutex_lock(&pinctrl_mutex
);
1636 list_add_tail(&pctldev
->node
, &pinctrldev_list
);
1638 pctldev
->p
= pinctrl_get_locked(pctldev
->dev
);
1639 if (!IS_ERR(pctldev
->p
)) {
1640 pctldev
->hog_default
=
1641 pinctrl_lookup_state_locked(pctldev
->p
,
1642 PINCTRL_STATE_DEFAULT
);
1643 if (IS_ERR(pctldev
->hog_default
)) {
1644 dev_dbg(dev
, "failed to lookup the default state\n");
1646 if (pinctrl_select_state_locked(pctldev
->p
,
1647 pctldev
->hog_default
))
1649 "failed to select default state\n");
1652 pctldev
->hog_sleep
=
1653 pinctrl_lookup_state_locked(pctldev
->p
,
1654 PINCTRL_STATE_SLEEP
);
1655 if (IS_ERR(pctldev
->hog_sleep
))
1656 dev_dbg(dev
, "failed to lookup the sleep state\n");
1659 mutex_unlock(&pinctrl_mutex
);
1661 pinctrl_init_device_debugfs(pctldev
);
1669 EXPORT_SYMBOL_GPL(pinctrl_register
);
1672 * pinctrl_unregister() - unregister pinmux
1673 * @pctldev: pin controller to unregister
1675 * Called by pinmux drivers to unregister a pinmux.
1677 void pinctrl_unregister(struct pinctrl_dev
*pctldev
)
1679 struct pinctrl_gpio_range
*range
, *n
;
1680 if (pctldev
== NULL
)
1683 pinctrl_remove_device_debugfs(pctldev
);
1685 mutex_lock(&pinctrl_mutex
);
1687 if (!IS_ERR(pctldev
->p
))
1688 pinctrl_put_locked(pctldev
->p
, true);
1690 /* TODO: check that no pinmuxes are still active? */
1691 list_del(&pctldev
->node
);
1692 /* Destroy descriptor tree */
1693 pinctrl_free_pindescs(pctldev
, pctldev
->desc
->pins
,
1694 pctldev
->desc
->npins
);
1695 /* remove gpio ranges map */
1696 list_for_each_entry_safe(range
, n
, &pctldev
->gpio_ranges
, node
)
1697 list_del(&range
->node
);
1701 mutex_unlock(&pinctrl_mutex
);
1703 EXPORT_SYMBOL_GPL(pinctrl_unregister
);
1705 static int __init
pinctrl_init(void)
1707 pr_info("initialized pinctrl subsystem\n");
1708 pinctrl_init_debugfs();
1712 /* init early since many drivers really need to initialized pinmux early */
1713 core_initcall(pinctrl_init
);