blob: 160fb5aae591c6219380a4d57847ceb0ddbe94c0 [file] [log] [blame]
Linus Walleij2744e8a2011-05-02 20:50:54 +02001/*
2 * Core driver for the pin control subsystem
3 *
4 * Copyright (C) 2011 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson
6 * Based on bits of regulator core, gpio core and clk core
7 *
8 * Author: Linus Walleij <linus.walleij@linaro.org>
9 *
10 * License terms: GNU General Public License (GPL) version 2
11 */
12#define pr_fmt(fmt) "pinctrl core: " fmt
13
14#include <linux/kernel.h>
Stephen Rothwella5a697c2011-09-30 14:39:04 +100015#include <linux/export.h>
Linus Walleij2744e8a2011-05-02 20:50:54 +020016#include <linux/init.h>
17#include <linux/device.h>
18#include <linux/slab.h>
19#include <linux/radix-tree.h>
20#include <linux/err.h>
21#include <linux/list.h>
22#include <linux/mutex.h>
23#include <linux/spinlock.h>
24#include <linux/sysfs.h>
25#include <linux/debugfs.h>
26#include <linux/seq_file.h>
27#include <linux/pinctrl/pinctrl.h>
28#include <linux/pinctrl/machine.h>
29#include "core.h"
30#include "pinmux.h"
Linus Walleijae6b4d82011-10-19 18:14:33 +020031#include "pinconf.h"
Linus Walleij2744e8a2011-05-02 20:50:54 +020032
33/* Global list of pin control devices */
34static DEFINE_MUTEX(pinctrldev_list_mutex);
35static LIST_HEAD(pinctrldev_list);
36
Linus Walleij2744e8a2011-05-02 20:50:54 +020037const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev)
38{
39 /* We're not allowed to register devices without name */
40 return pctldev->desc->name;
41}
42EXPORT_SYMBOL_GPL(pinctrl_dev_get_name);
43
44void *pinctrl_dev_get_drvdata(struct pinctrl_dev *pctldev)
45{
46 return pctldev->driver_data;
47}
48EXPORT_SYMBOL_GPL(pinctrl_dev_get_drvdata);
49
50/**
51 * get_pinctrl_dev_from_dev() - look up pin controller device
52 * @dev: a device pointer, this may be NULL but then devname needs to be
53 * defined instead
54 * @devname: the name of a device instance, as returned by dev_name(), this
55 * may be NULL but then dev needs to be defined instead
56 *
57 * Looks up a pin control device matching a certain device name or pure device
58 * pointer, the pure device pointer will take precedence.
59 */
60struct pinctrl_dev *get_pinctrl_dev_from_dev(struct device *dev,
61 const char *devname)
62{
63 struct pinctrl_dev *pctldev = NULL;
64 bool found = false;
65
66 mutex_lock(&pinctrldev_list_mutex);
67 list_for_each_entry(pctldev, &pinctrldev_list, node) {
Stephen Warren51cd24e2011-12-09 16:59:05 -070068 if (dev && pctldev->dev == dev) {
Linus Walleij2744e8a2011-05-02 20:50:54 +020069 /* Matched on device pointer */
70 found = true;
71 break;
72 }
73
74 if (devname &&
Stephen Warren51cd24e2011-12-09 16:59:05 -070075 !strcmp(dev_name(pctldev->dev), devname)) {
Linus Walleij2744e8a2011-05-02 20:50:54 +020076 /* Matched on device name */
77 found = true;
78 break;
79 }
80 }
81 mutex_unlock(&pinctrldev_list_mutex);
82
83 return found ? pctldev : NULL;
84}
85
Marek Belisko33d58942011-10-31 21:27:52 +010086struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin)
Linus Walleij2744e8a2011-05-02 20:50:54 +020087{
88 struct pin_desc *pindesc;
89 unsigned long flags;
90
91 spin_lock_irqsave(&pctldev->pin_desc_tree_lock, flags);
92 pindesc = radix_tree_lookup(&pctldev->pin_desc_tree, pin);
93 spin_unlock_irqrestore(&pctldev->pin_desc_tree_lock, flags);
94
95 return pindesc;
96}
97
98/**
Linus Walleijae6b4d82011-10-19 18:14:33 +020099 * pin_get_from_name() - look up a pin number from a name
100 * @pctldev: the pin control device to lookup the pin on
101 * @name: the name of the pin to look up
102 */
103int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name)
104{
105 unsigned pin;
106
107 /* The highest pin number need to be included in the loop, thus <= */
108 for (pin = 0; pin <= pctldev->desc->maxpin; pin++) {
109 struct pin_desc *desc;
110
111 desc = pin_desc_get(pctldev, pin);
112 /* Pin space may be sparse */
113 if (desc == NULL)
114 continue;
115 if (desc->name && !strcmp(name, desc->name))
116 return pin;
117 }
118
119 return -EINVAL;
120}
121
122/**
Linus Walleij2744e8a2011-05-02 20:50:54 +0200123 * pin_is_valid() - check if pin exists on controller
124 * @pctldev: the pin control device to check the pin on
125 * @pin: pin to check, use the local pin controller index number
126 *
127 * This tells us whether a certain pin exist on a certain pin controller or
128 * not. Pin lists may be sparse, so some pins may not exist.
129 */
130bool pin_is_valid(struct pinctrl_dev *pctldev, int pin)
131{
132 struct pin_desc *pindesc;
133
134 if (pin < 0)
135 return false;
136
137 pindesc = pin_desc_get(pctldev, pin);
138 if (pindesc == NULL)
139 return false;
140
141 return true;
142}
143EXPORT_SYMBOL_GPL(pin_is_valid);
144
145/* Deletes a range of pin descriptors */
146static void pinctrl_free_pindescs(struct pinctrl_dev *pctldev,
147 const struct pinctrl_pin_desc *pins,
148 unsigned num_pins)
149{
150 int i;
151
152 spin_lock(&pctldev->pin_desc_tree_lock);
153 for (i = 0; i < num_pins; i++) {
154 struct pin_desc *pindesc;
155
156 pindesc = radix_tree_lookup(&pctldev->pin_desc_tree,
157 pins[i].number);
158 if (pindesc != NULL) {
159 radix_tree_delete(&pctldev->pin_desc_tree,
160 pins[i].number);
161 }
162 kfree(pindesc);
163 }
164 spin_unlock(&pctldev->pin_desc_tree_lock);
165}
166
167static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
168 unsigned number, const char *name)
169{
170 struct pin_desc *pindesc;
171
172 pindesc = pin_desc_get(pctldev, number);
173 if (pindesc != NULL) {
174 pr_err("pin %d already registered on %s\n", number,
175 pctldev->desc->name);
176 return -EINVAL;
177 }
178
179 pindesc = kzalloc(sizeof(*pindesc), GFP_KERNEL);
180 if (pindesc == NULL)
181 return -ENOMEM;
Linus Walleijae6b4d82011-10-19 18:14:33 +0200182
Linus Walleij2744e8a2011-05-02 20:50:54 +0200183 spin_lock_init(&pindesc->lock);
184
185 /* Set owner */
186 pindesc->pctldev = pctldev;
187
Stephen Warren9af1e442011-10-19 16:19:27 -0600188 /* Copy basic pin info */
189 pindesc->name = name;
Linus Walleij2744e8a2011-05-02 20:50:54 +0200190
191 spin_lock(&pctldev->pin_desc_tree_lock);
192 radix_tree_insert(&pctldev->pin_desc_tree, number, pindesc);
193 spin_unlock(&pctldev->pin_desc_tree_lock);
194 pr_debug("registered pin %d (%s) on %s\n",
195 number, name ? name : "(unnamed)", pctldev->desc->name);
196 return 0;
197}
198
199static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
200 struct pinctrl_pin_desc const *pins,
201 unsigned num_descs)
202{
203 unsigned i;
204 int ret = 0;
205
206 for (i = 0; i < num_descs; i++) {
207 ret = pinctrl_register_one_pin(pctldev,
208 pins[i].number, pins[i].name);
209 if (ret)
210 return ret;
211 }
212
213 return 0;
214}
215
216/**
217 * pinctrl_match_gpio_range() - check if a certain GPIO pin is in range
218 * @pctldev: pin controller device to check
219 * @gpio: gpio pin to check taken from the global GPIO pin space
220 *
221 * Tries to match a GPIO pin number to the ranges handled by a certain pin
222 * controller, return the range or NULL
223 */
224static struct pinctrl_gpio_range *
225pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
226{
227 struct pinctrl_gpio_range *range = NULL;
228
229 /* Loop over the ranges */
230 mutex_lock(&pctldev->gpio_ranges_lock);
231 list_for_each_entry(range, &pctldev->gpio_ranges, node) {
232 /* Check if we're in the valid range */
233 if (gpio >= range->base &&
234 gpio < range->base + range->npins) {
235 mutex_unlock(&pctldev->gpio_ranges_lock);
236 return range;
237 }
238 }
239 mutex_unlock(&pctldev->gpio_ranges_lock);
240
241 return NULL;
242}
243
244/**
245 * pinctrl_get_device_gpio_range() - find device for GPIO range
246 * @gpio: the pin to locate the pin controller for
247 * @outdev: the pin control device if found
248 * @outrange: the GPIO range if found
249 *
250 * Find the pin controller handling a certain GPIO pin from the pinspace of
251 * the GPIO subsystem, return the device and the matching GPIO range. Returns
252 * negative if the GPIO range could not be found in any device.
253 */
254int pinctrl_get_device_gpio_range(unsigned gpio,
255 struct pinctrl_dev **outdev,
256 struct pinctrl_gpio_range **outrange)
257{
258 struct pinctrl_dev *pctldev = NULL;
259
260 /* Loop over the pin controllers */
261 mutex_lock(&pinctrldev_list_mutex);
262 list_for_each_entry(pctldev, &pinctrldev_list, node) {
263 struct pinctrl_gpio_range *range;
264
265 range = pinctrl_match_gpio_range(pctldev, gpio);
266 if (range != NULL) {
267 *outdev = pctldev;
268 *outrange = range;
269 mutex_unlock(&pinctrldev_list_mutex);
270 return 0;
271 }
272 }
273 mutex_unlock(&pinctrldev_list_mutex);
274
275 return -EINVAL;
276}
277
278/**
279 * pinctrl_add_gpio_range() - register a GPIO range for a controller
280 * @pctldev: pin controller device to add the range to
281 * @range: the GPIO range to add
282 *
283 * This adds a range of GPIOs to be handled by a certain pin controller. Call
284 * this to register handled ranges after registering your pin controller.
285 */
286void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev,
287 struct pinctrl_gpio_range *range)
288{
289 mutex_lock(&pctldev->gpio_ranges_lock);
290 list_add(&range->node, &pctldev->gpio_ranges);
291 mutex_unlock(&pctldev->gpio_ranges_lock);
292}
293
294/**
295 * pinctrl_remove_gpio_range() - remove a range of GPIOs fro a pin controller
296 * @pctldev: pin controller device to remove the range from
297 * @range: the GPIO range to remove
298 */
299void pinctrl_remove_gpio_range(struct pinctrl_dev *pctldev,
300 struct pinctrl_gpio_range *range)
301{
302 mutex_lock(&pctldev->gpio_ranges_lock);
303 list_del(&range->node);
304 mutex_unlock(&pctldev->gpio_ranges_lock);
305}
306
Linus Walleij7afde8b2011-10-19 17:07:16 +0200307/**
308 * pinctrl_get_group_selector() - returns the group selector for a group
309 * @pctldev: the pin controller handling the group
310 * @pin_group: the pin group to look up
311 */
312int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
313 const char *pin_group)
314{
315 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
316 unsigned group_selector = 0;
317
318 while (pctlops->list_groups(pctldev, group_selector) >= 0) {
319 const char *gname = pctlops->get_group_name(pctldev,
320 group_selector);
321 if (!strcmp(gname, pin_group)) {
Stephen Warren51cd24e2011-12-09 16:59:05 -0700322 dev_dbg(pctldev->dev,
Linus Walleij7afde8b2011-10-19 17:07:16 +0200323 "found group selector %u for %s\n",
324 group_selector,
325 pin_group);
326 return group_selector;
327 }
328
329 group_selector++;
330 }
331
Stephen Warren51cd24e2011-12-09 16:59:05 -0700332 dev_err(pctldev->dev, "does not have pin group %s\n",
Linus Walleij7afde8b2011-10-19 17:07:16 +0200333 pin_group);
334
335 return -EINVAL;
336}
337
Linus Walleij2744e8a2011-05-02 20:50:54 +0200338#ifdef CONFIG_DEBUG_FS
339
340static int pinctrl_pins_show(struct seq_file *s, void *what)
341{
342 struct pinctrl_dev *pctldev = s->private;
343 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
344 unsigned pin;
345
346 seq_printf(s, "registered pins: %d\n", pctldev->desc->npins);
347 seq_printf(s, "max pin number: %d\n", pctldev->desc->maxpin);
348
349 /* The highest pin number need to be included in the loop, thus <= */
350 for (pin = 0; pin <= pctldev->desc->maxpin; pin++) {
351 struct pin_desc *desc;
352
353 desc = pin_desc_get(pctldev, pin);
354 /* Pin space may be sparse */
355 if (desc == NULL)
356 continue;
357
358 seq_printf(s, "pin %d (%s) ", pin,
359 desc->name ? desc->name : "unnamed");
360
361 /* Driver-specific info per pin */
362 if (ops->pin_dbg_show)
363 ops->pin_dbg_show(pctldev, s, pin);
364
365 seq_puts(s, "\n");
366 }
367
368 return 0;
369}
370
371static int pinctrl_groups_show(struct seq_file *s, void *what)
372{
373 struct pinctrl_dev *pctldev = s->private;
374 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
375 unsigned selector = 0;
376
377 /* No grouping */
378 if (!ops)
379 return 0;
380
381 seq_puts(s, "registered pin groups:\n");
382 while (ops->list_groups(pctldev, selector) >= 0) {
Stephen Warrena5818a82011-10-19 16:19:25 -0600383 const unsigned *pins;
Linus Walleij2744e8a2011-05-02 20:50:54 +0200384 unsigned num_pins;
385 const char *gname = ops->get_group_name(pctldev, selector);
386 int ret;
387 int i;
388
389 ret = ops->get_group_pins(pctldev, selector,
390 &pins, &num_pins);
391 if (ret)
392 seq_printf(s, "%s [ERROR GETTING PINS]\n",
393 gname);
394 else {
395 seq_printf(s, "group: %s, pins = [ ", gname);
396 for (i = 0; i < num_pins; i++)
397 seq_printf(s, "%d ", pins[i]);
398 seq_puts(s, "]\n");
399 }
400 selector++;
401 }
402
403
404 return 0;
405}
406
407static int pinctrl_gpioranges_show(struct seq_file *s, void *what)
408{
409 struct pinctrl_dev *pctldev = s->private;
410 struct pinctrl_gpio_range *range = NULL;
411
412 seq_puts(s, "GPIO ranges handled:\n");
413
414 /* Loop over the ranges */
415 mutex_lock(&pctldev->gpio_ranges_lock);
416 list_for_each_entry(range, &pctldev->gpio_ranges, node) {
Linus Walleij75d66422011-11-16 09:58:51 +0100417 seq_printf(s, "%u: %s GPIOS [%u - %u] PINS [%u - %u]\n",
418 range->id, range->name,
419 range->base, (range->base + range->npins - 1),
420 range->pin_base,
421 (range->pin_base + range->npins - 1));
Linus Walleij2744e8a2011-05-02 20:50:54 +0200422 }
423 mutex_unlock(&pctldev->gpio_ranges_lock);
424
425 return 0;
426}
427
428static int pinctrl_devices_show(struct seq_file *s, void *what)
429{
430 struct pinctrl_dev *pctldev;
431
Linus Walleijae6b4d82011-10-19 18:14:33 +0200432 seq_puts(s, "name [pinmux] [pinconf]\n");
Linus Walleij2744e8a2011-05-02 20:50:54 +0200433 mutex_lock(&pinctrldev_list_mutex);
434 list_for_each_entry(pctldev, &pinctrldev_list, node) {
435 seq_printf(s, "%s ", pctldev->desc->name);
436 if (pctldev->desc->pmxops)
Linus Walleijae6b4d82011-10-19 18:14:33 +0200437 seq_puts(s, "yes ");
438 else
439 seq_puts(s, "no ");
440 if (pctldev->desc->confops)
Linus Walleij2744e8a2011-05-02 20:50:54 +0200441 seq_puts(s, "yes");
442 else
443 seq_puts(s, "no");
444 seq_puts(s, "\n");
445 }
446 mutex_unlock(&pinctrldev_list_mutex);
447
448 return 0;
449}
450
451static int pinctrl_pins_open(struct inode *inode, struct file *file)
452{
453 return single_open(file, pinctrl_pins_show, inode->i_private);
454}
455
456static int pinctrl_groups_open(struct inode *inode, struct file *file)
457{
458 return single_open(file, pinctrl_groups_show, inode->i_private);
459}
460
461static int pinctrl_gpioranges_open(struct inode *inode, struct file *file)
462{
463 return single_open(file, pinctrl_gpioranges_show, inode->i_private);
464}
465
466static int pinctrl_devices_open(struct inode *inode, struct file *file)
467{
468 return single_open(file, pinctrl_devices_show, NULL);
469}
470
471static const struct file_operations pinctrl_pins_ops = {
472 .open = pinctrl_pins_open,
473 .read = seq_read,
474 .llseek = seq_lseek,
475 .release = single_release,
476};
477
478static const struct file_operations pinctrl_groups_ops = {
479 .open = pinctrl_groups_open,
480 .read = seq_read,
481 .llseek = seq_lseek,
482 .release = single_release,
483};
484
485static const struct file_operations pinctrl_gpioranges_ops = {
486 .open = pinctrl_gpioranges_open,
487 .read = seq_read,
488 .llseek = seq_lseek,
489 .release = single_release,
490};
491
492static const struct file_operations pinctrl_devices_ops = {
493 .open = pinctrl_devices_open,
494 .read = seq_read,
495 .llseek = seq_lseek,
496 .release = single_release,
497};
498
499static struct dentry *debugfs_root;
500
501static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
502{
503 static struct dentry *device_root;
504
Stephen Warren51cd24e2011-12-09 16:59:05 -0700505 device_root = debugfs_create_dir(dev_name(pctldev->dev),
Linus Walleij2744e8a2011-05-02 20:50:54 +0200506 debugfs_root);
507 if (IS_ERR(device_root) || !device_root) {
508 pr_warn("failed to create debugfs directory for %s\n",
Stephen Warren51cd24e2011-12-09 16:59:05 -0700509 dev_name(pctldev->dev));
Linus Walleij2744e8a2011-05-02 20:50:54 +0200510 return;
511 }
512 debugfs_create_file("pins", S_IFREG | S_IRUGO,
513 device_root, pctldev, &pinctrl_pins_ops);
514 debugfs_create_file("pingroups", S_IFREG | S_IRUGO,
515 device_root, pctldev, &pinctrl_groups_ops);
516 debugfs_create_file("gpio-ranges", S_IFREG | S_IRUGO,
517 device_root, pctldev, &pinctrl_gpioranges_ops);
518 pinmux_init_device_debugfs(device_root, pctldev);
Linus Walleijae6b4d82011-10-19 18:14:33 +0200519 pinconf_init_device_debugfs(device_root, pctldev);
Linus Walleij2744e8a2011-05-02 20:50:54 +0200520}
521
522static void pinctrl_init_debugfs(void)
523{
524 debugfs_root = debugfs_create_dir("pinctrl", NULL);
525 if (IS_ERR(debugfs_root) || !debugfs_root) {
526 pr_warn("failed to create debugfs directory\n");
527 debugfs_root = NULL;
528 return;
529 }
530
531 debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO,
532 debugfs_root, NULL, &pinctrl_devices_ops);
533 pinmux_init_debugfs(debugfs_root);
534}
535
536#else /* CONFIG_DEBUG_FS */
537
538static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
539{
540}
541
542static void pinctrl_init_debugfs(void)
543{
544}
545
546#endif
547
548/**
549 * pinctrl_register() - register a pin controller device
550 * @pctldesc: descriptor for this pin controller
551 * @dev: parent device for this pin controller
552 * @driver_data: private pin controller data for this pin controller
553 */
554struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
555 struct device *dev, void *driver_data)
556{
Linus Walleij2744e8a2011-05-02 20:50:54 +0200557 struct pinctrl_dev *pctldev;
558 int ret;
559
560 if (pctldesc == NULL)
561 return NULL;
562 if (pctldesc->name == NULL)
563 return NULL;
564
565 /* If we're implementing pinmuxing, check the ops for sanity */
566 if (pctldesc->pmxops) {
567 ret = pinmux_check_ops(pctldesc->pmxops);
568 if (ret) {
569 pr_err("%s pinmux ops lacks necessary functions\n",
570 pctldesc->name);
571 return NULL;
572 }
573 }
574
Linus Walleijae6b4d82011-10-19 18:14:33 +0200575 /* If we're implementing pinconfig, check the ops for sanity */
576 if (pctldesc->confops) {
577 ret = pinconf_check_ops(pctldesc->confops);
578 if (ret) {
579 pr_err("%s pin config ops lacks necessary functions\n",
580 pctldesc->name);
581 return NULL;
582 }
583 }
584
Linus Walleij2744e8a2011-05-02 20:50:54 +0200585 pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
586 if (pctldev == NULL)
587 return NULL;
588
589 /* Initialize pin control device struct */
590 pctldev->owner = pctldesc->owner;
591 pctldev->desc = pctldesc;
592 pctldev->driver_data = driver_data;
593 INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
594 spin_lock_init(&pctldev->pin_desc_tree_lock);
595 INIT_LIST_HEAD(&pctldev->gpio_ranges);
596 mutex_init(&pctldev->gpio_ranges_lock);
Stephen Warren51cd24e2011-12-09 16:59:05 -0700597 pctldev->dev = dev;
Linus Walleij2744e8a2011-05-02 20:50:54 +0200598
599 /* Register all the pins */
600 pr_debug("try to register %d pins on %s...\n",
601 pctldesc->npins, pctldesc->name);
602 ret = pinctrl_register_pins(pctldev, pctldesc->pins, pctldesc->npins);
603 if (ret) {
604 pr_err("error during pin registration\n");
605 pinctrl_free_pindescs(pctldev, pctldesc->pins,
606 pctldesc->npins);
Stephen Warren51cd24e2011-12-09 16:59:05 -0700607 goto out_err;
Linus Walleij2744e8a2011-05-02 20:50:54 +0200608 }
609
610 pinctrl_init_device_debugfs(pctldev);
611 mutex_lock(&pinctrldev_list_mutex);
612 list_add(&pctldev->node, &pinctrldev_list);
613 mutex_unlock(&pinctrldev_list_mutex);
614 pinmux_hog_maps(pctldev);
615 return pctldev;
616
Stephen Warren51cd24e2011-12-09 16:59:05 -0700617out_err:
618 kfree(pctldev);
Linus Walleij2744e8a2011-05-02 20:50:54 +0200619 return NULL;
620}
621EXPORT_SYMBOL_GPL(pinctrl_register);
622
623/**
624 * pinctrl_unregister() - unregister pinmux
625 * @pctldev: pin controller to unregister
626 *
627 * Called by pinmux drivers to unregister a pinmux.
628 */
629void pinctrl_unregister(struct pinctrl_dev *pctldev)
630{
631 if (pctldev == NULL)
632 return;
633
634 pinmux_unhog_maps(pctldev);
635 /* TODO: check that no pinmuxes are still active? */
636 mutex_lock(&pinctrldev_list_mutex);
637 list_del(&pctldev->node);
638 mutex_unlock(&pinctrldev_list_mutex);
639 /* Destroy descriptor tree */
640 pinctrl_free_pindescs(pctldev, pctldev->desc->pins,
641 pctldev->desc->npins);
Stephen Warren51cd24e2011-12-09 16:59:05 -0700642 kfree(pctldev);
Linus Walleij2744e8a2011-05-02 20:50:54 +0200643}
644EXPORT_SYMBOL_GPL(pinctrl_unregister);
645
646static int __init pinctrl_init(void)
647{
648 pr_info("initialized pinctrl subsystem\n");
649 pinctrl_init_debugfs();
650 return 0;
651}
652
653/* init early since many drivers really need to initialized pinmux early */
654core_initcall(pinctrl_init);