drivers: create a pin control subsystem
[deliverable/linux.git] / drivers / pinctrl / core.h
1 /*
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
12 /**
13 * struct pinctrl_dev - pin control class device
14 * @node: node to include this pin controller in the global pin controller list
15 * @desc: the pin controller descriptor supplied when initializing this pin
16 * controller
17 * @pin_desc_tree: each pin descriptor for this pin controller is stored in
18 * this radix tree
19 * @pin_desc_tree_lock: lock for the descriptor tree
20 * @gpio_ranges: a list of GPIO ranges that is handled by this pin controller,
21 * ranges are added to this list at runtime
22 * @gpio_ranges_lock: lock for the GPIO ranges list
23 * @dev: the device entry for this pin controller
24 * @owner: module providing the pin controller, used for refcounting
25 * @driver_data: driver data for drivers registering to the pin controller
26 * subsystem
27 * @pinmux_hogs_lock: lock for the pinmux hog list
28 * @pinmux_hogs: list of pinmux maps hogged by this device
29 */
30 struct pinctrl_dev {
31 struct list_head node;
32 struct pinctrl_desc *desc;
33 struct radix_tree_root pin_desc_tree;
34 spinlock_t pin_desc_tree_lock;
35 struct list_head gpio_ranges;
36 struct mutex gpio_ranges_lock;
37 struct device dev;
38 struct module *owner;
39 void *driver_data;
40 #ifdef CONFIG_PINMUX
41 struct mutex pinmux_hogs_lock;
42 struct list_head pinmux_hogs;
43 #endif
44 };
45
46 /**
47 * struct pin_desc - pin descriptor for each physical pin in the arch
48 * @pctldev: corresponding pin control device
49 * @name: a name for the pin, e.g. the name of the pin/pad/finger on a
50 * datasheet or such
51 * @lock: a lock to protect the descriptor structure
52 * @mux_requested: whether the pin is already requested by pinmux or not
53 * @mux_function: a named muxing function for the pin that will be passed to
54 * subdrivers and shown in debugfs etc
55 */
56 struct pin_desc {
57 struct pinctrl_dev *pctldev;
58 char name[16];
59 spinlock_t lock;
60 /* These fields only added when supporting pinmux drivers */
61 #ifdef CONFIG_PINMUX
62 bool mux_requested;
63 char mux_function[16];
64 #endif
65 };
66
67 struct pinctrl_dev *get_pinctrl_dev_from_dev(struct device *dev,
68 const char *dev_name);
69 struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, int pin);
70 int pinctrl_get_device_gpio_range(unsigned gpio,
71 struct pinctrl_dev **outdev,
72 struct pinctrl_gpio_range **outrange);
This page took 0.034344 seconds and 5 git commands to generate.