12744e8afSLinus Walleij /* 22744e8afSLinus Walleij * Core private header for the pin control subsystem 32744e8afSLinus Walleij * 42744e8afSLinus Walleij * Copyright (C) 2011 ST-Ericsson SA 52744e8afSLinus Walleij * Written on behalf of Linaro for ST-Ericsson 62744e8afSLinus Walleij * 72744e8afSLinus Walleij * Author: Linus Walleij <linus.walleij@linaro.org> 82744e8afSLinus Walleij * 92744e8afSLinus Walleij * License terms: GNU General Public License (GPL) version 2 102744e8afSLinus Walleij */ 112744e8afSLinus Walleij 12ae6b4d85SLinus Walleij #include <linux/pinctrl/pinconf.h> 13ae6b4d85SLinus Walleij 14ae6b4d85SLinus Walleij struct pinctrl_gpio_range; 15ae6b4d85SLinus Walleij 162744e8afSLinus Walleij /** 172744e8afSLinus Walleij * struct pinctrl_dev - pin control class device 182744e8afSLinus Walleij * @node: node to include this pin controller in the global pin controller list 192744e8afSLinus Walleij * @desc: the pin controller descriptor supplied when initializing this pin 202744e8afSLinus Walleij * controller 212744e8afSLinus Walleij * @pin_desc_tree: each pin descriptor for this pin controller is stored in 222744e8afSLinus Walleij * this radix tree 232744e8afSLinus Walleij * @pin_desc_tree_lock: lock for the descriptor tree 242744e8afSLinus Walleij * @gpio_ranges: a list of GPIO ranges that is handled by this pin controller, 252744e8afSLinus Walleij * ranges are added to this list at runtime 262744e8afSLinus Walleij * @gpio_ranges_lock: lock for the GPIO ranges list 272744e8afSLinus Walleij * @dev: the device entry for this pin controller 282744e8afSLinus Walleij * @owner: module providing the pin controller, used for refcounting 292744e8afSLinus Walleij * @driver_data: driver data for drivers registering to the pin controller 302744e8afSLinus Walleij * subsystem 31e93bcee0SLinus Walleij * @pinctrl_hogs_lock: lock for the pin control hog list 32e93bcee0SLinus Walleij * @pinctrl_hogs: list of pin control maps hogged by this device 33*befe5bdfSLinus Walleij * @device_root: debugfs root for this device 342744e8afSLinus Walleij */ 352744e8afSLinus Walleij struct pinctrl_dev { 362744e8afSLinus Walleij struct list_head node; 372744e8afSLinus Walleij struct pinctrl_desc *desc; 382744e8afSLinus Walleij struct radix_tree_root pin_desc_tree; 392744e8afSLinus Walleij spinlock_t pin_desc_tree_lock; 402744e8afSLinus Walleij struct list_head gpio_ranges; 412744e8afSLinus Walleij struct mutex gpio_ranges_lock; 4251cd24eeSStephen Warren struct device *dev; 432744e8afSLinus Walleij struct module *owner; 442744e8afSLinus Walleij void *driver_data; 45*befe5bdfSLinus Walleij struct mutex pinctrl_hogs_lock; 46*befe5bdfSLinus Walleij struct list_head pinctrl_hogs; 4702157160STony Lindgren #ifdef CONFIG_DEBUG_FS 4802157160STony Lindgren struct dentry *device_root; 4902157160STony Lindgren #endif 50*befe5bdfSLinus Walleij }; 51*befe5bdfSLinus Walleij 52*befe5bdfSLinus Walleij /** 53*befe5bdfSLinus Walleij * struct pinctrl - per-device pin control state holder 54*befe5bdfSLinus Walleij * @node: global list node 55*befe5bdfSLinus Walleij * @dev: the device using this pin control handle 56*befe5bdfSLinus Walleij * @usecount: the number of active users of this pin controller setting, used 57*befe5bdfSLinus Walleij * to keep track of nested use cases 58*befe5bdfSLinus Walleij * @pctldev: pin control device handling this pin control handle 59*befe5bdfSLinus Walleij * @mutex: a lock for the pin control state holder 60*befe5bdfSLinus Walleij * @func_selector: the function selector for the pinmux device handling 61*befe5bdfSLinus Walleij * this pinmux 62*befe5bdfSLinus Walleij * @groups: the group selectors for the pinmux device and 63*befe5bdfSLinus Walleij * selector combination handling this pinmux, this is a list that 64*befe5bdfSLinus Walleij * will be traversed on all pinmux operations such as 65*befe5bdfSLinus Walleij * get/put/enable/disable 66*befe5bdfSLinus Walleij */ 67*befe5bdfSLinus Walleij struct pinctrl { 68*befe5bdfSLinus Walleij struct list_head node; 69*befe5bdfSLinus Walleij struct device *dev; 70*befe5bdfSLinus Walleij unsigned usecount; 71*befe5bdfSLinus Walleij struct pinctrl_dev *pctldev; 72*befe5bdfSLinus Walleij struct mutex mutex; 732744e8afSLinus Walleij #ifdef CONFIG_PINMUX 74*befe5bdfSLinus Walleij unsigned func_selector; 75*befe5bdfSLinus Walleij struct list_head groups; 762744e8afSLinus Walleij #endif 772744e8afSLinus Walleij }; 782744e8afSLinus Walleij 792744e8afSLinus Walleij /** 802744e8afSLinus Walleij * struct pin_desc - pin descriptor for each physical pin in the arch 812744e8afSLinus Walleij * @pctldev: corresponding pin control device 822744e8afSLinus Walleij * @name: a name for the pin, e.g. the name of the pin/pad/finger on a 832744e8afSLinus Walleij * datasheet or such 84ca53c5f1SLinus Walleij * @dynamic_name: if the name of this pin was dynamically allocated 852744e8afSLinus Walleij * @lock: a lock to protect the descriptor structure 862744e8afSLinus Walleij * @mux_requested: whether the pin is already requested by pinmux or not 872744e8afSLinus Walleij * @mux_function: a named muxing function for the pin that will be passed to 882744e8afSLinus Walleij * subdrivers and shown in debugfs etc 892744e8afSLinus Walleij */ 902744e8afSLinus Walleij struct pin_desc { 912744e8afSLinus Walleij struct pinctrl_dev *pctldev; 929af1e44fSStephen Warren const char *name; 93ca53c5f1SLinus Walleij bool dynamic_name; 942744e8afSLinus Walleij spinlock_t lock; 952744e8afSLinus Walleij /* These fields only added when supporting pinmux drivers */ 962744e8afSLinus Walleij #ifdef CONFIG_PINMUX 975d2eaf80SStephen Warren const char *mux_function; 982744e8afSLinus Walleij #endif 992744e8afSLinus Walleij }; 1002744e8afSLinus Walleij 1019dfac4fdSLinus Walleij struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name); 10233d58949SMarek Belisko struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin); 103ae6b4d85SLinus Walleij int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name); 1042744e8afSLinus Walleij int pinctrl_get_device_gpio_range(unsigned gpio, 1052744e8afSLinus Walleij struct pinctrl_dev **outdev, 1062744e8afSLinus Walleij struct pinctrl_gpio_range **outrange); 1077afde8baSLinus Walleij int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, 1087afde8baSLinus Walleij const char *pin_group); 109