blob: 7a89888fce9456932da896a7588a0409d3645ead [file] [log] [blame]
Linus Walleij2744e8a2011-05-02 20:50:54 +02001/*
2 * Core private header for the pin control subsystem
3 *
4 * Copyright (C) 2011 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson
6 *
7 * Author: Linus Walleij <linus.walleij@linaro.org>
8 *
9 * License terms: GNU General Public License (GPL) version 2
10 */
11
Linus Walleijae6b4d82011-10-19 18:14:33 +020012#include <linux/pinctrl/pinconf.h>
13
14struct pinctrl_gpio_range;
15
Linus Walleij2744e8a2011-05-02 20:50:54 +020016/**
17 * struct pinctrl_dev - pin control class device
18 * @node: node to include this pin controller in the global pin controller list
19 * @desc: the pin controller descriptor supplied when initializing this pin
20 * controller
21 * @pin_desc_tree: each pin descriptor for this pin controller is stored in
22 * this radix tree
23 * @pin_desc_tree_lock: lock for the descriptor tree
24 * @gpio_ranges: a list of GPIO ranges that is handled by this pin controller,
25 * ranges are added to this list at runtime
26 * @gpio_ranges_lock: lock for the GPIO ranges list
27 * @dev: the device entry for this pin controller
28 * @owner: module providing the pin controller, used for refcounting
29 * @driver_data: driver data for drivers registering to the pin controller
30 * subsystem
Linus Walleije93bcee2012-02-09 07:23:28 +010031 * @pinctrl_hogs_lock: lock for the pin control hog list
32 * @pinctrl_hogs: list of pin control maps hogged by this device
Linus Walleij2744e8a2011-05-02 20:50:54 +020033 */
34struct pinctrl_dev {
35 struct list_head node;
36 struct pinctrl_desc *desc;
37 struct radix_tree_root pin_desc_tree;
38 spinlock_t pin_desc_tree_lock;
39 struct list_head gpio_ranges;
40 struct mutex gpio_ranges_lock;
Stephen Warren51cd24e2011-12-09 16:59:05 -070041 struct device *dev;
Linus Walleij2744e8a2011-05-02 20:50:54 +020042 struct module *owner;
43 void *driver_data;
Tony Lindgren02157162012-01-20 08:17:22 -080044#ifdef CONFIG_DEBUG_FS
45 struct dentry *device_root;
46#endif
Linus Walleij2744e8a2011-05-02 20:50:54 +020047#ifdef CONFIG_PINMUX
Linus Walleije93bcee2012-02-09 07:23:28 +010048 struct mutex pinctrl_hogs_lock;
49 struct list_head pinctrl_hogs;
Linus Walleij2744e8a2011-05-02 20:50:54 +020050#endif
51};
52
53/**
54 * struct pin_desc - pin descriptor for each physical pin in the arch
55 * @pctldev: corresponding pin control device
56 * @name: a name for the pin, e.g. the name of the pin/pad/finger on a
57 * datasheet or such
Linus Walleijca53c5f2011-12-14 20:33:37 +010058 * @dynamic_name: if the name of this pin was dynamically allocated
Linus Walleij2744e8a2011-05-02 20:50:54 +020059 * @lock: a lock to protect the descriptor structure
60 * @mux_requested: whether the pin is already requested by pinmux or not
61 * @mux_function: a named muxing function for the pin that will be passed to
62 * subdrivers and shown in debugfs etc
63 */
64struct pin_desc {
65 struct pinctrl_dev *pctldev;
Stephen Warren9af1e442011-10-19 16:19:27 -060066 const char *name;
Linus Walleijca53c5f2011-12-14 20:33:37 +010067 bool dynamic_name;
Linus Walleij2744e8a2011-05-02 20:50:54 +020068 spinlock_t lock;
69 /* These fields only added when supporting pinmux drivers */
70#ifdef CONFIG_PINMUX
Stephen Warren5d2eaf82011-10-19 16:19:28 -060071 const char *mux_function;
Linus Walleij2744e8a2011-05-02 20:50:54 +020072#endif
73};
74
Linus Walleij9dfac4f2012-02-01 18:02:47 +010075struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name);
Marek Belisko33d58942011-10-31 21:27:52 +010076struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin);
Linus Walleijae6b4d82011-10-19 18:14:33 +020077int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name);
Linus Walleij2744e8a2011-05-02 20:50:54 +020078int pinctrl_get_device_gpio_range(unsigned gpio,
79 struct pinctrl_dev **outdev,
80 struct pinctrl_gpio_range **outrange);
Linus Walleij7afde8b2011-10-19 17:07:16 +020081int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
82 const char *pin_group);