core.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #include <linux/pinctrl/pinconf.h>
  12. struct pinctrl_gpio_range;
  13. /**
  14. * struct pinctrl_dev - pin control class device
  15. * @node: node to include this pin controller in the global pin controller list
  16. * @desc: the pin controller descriptor supplied when initializing this pin
  17. * controller
  18. * @pin_desc_tree: each pin descriptor for this pin controller is stored in
  19. * this radix tree
  20. * @pin_desc_tree_lock: lock for the descriptor tree
  21. * @gpio_ranges: a list of GPIO ranges that is handled by this pin controller,
  22. * ranges are added to this list at runtime
  23. * @gpio_ranges_lock: lock for the GPIO ranges list
  24. * @dev: the device entry for this pin controller
  25. * @owner: module providing the pin controller, used for refcounting
  26. * @driver_data: driver data for drivers registering to the pin controller
  27. * subsystem
  28. * @pinctrl_hogs_lock: lock for the pin control hog list
  29. * @pinctrl_hogs: list of pin control maps hogged by this device
  30. * @device_root: debugfs root for this device
  31. */
  32. struct pinctrl_dev {
  33. struct list_head node;
  34. struct pinctrl_desc *desc;
  35. struct radix_tree_root pin_desc_tree;
  36. spinlock_t pin_desc_tree_lock;
  37. struct list_head gpio_ranges;
  38. struct mutex gpio_ranges_lock;
  39. struct device *dev;
  40. struct module *owner;
  41. void *driver_data;
  42. struct mutex pinctrl_hogs_lock;
  43. struct list_head pinctrl_hogs;
  44. #ifdef CONFIG_DEBUG_FS
  45. struct dentry *device_root;
  46. #endif
  47. };
  48. /**
  49. * struct pinctrl - per-device pin control state holder
  50. * @node: global list node
  51. * @dev: the device using this pin control handle
  52. * @usecount: the number of active users of this pin controller setting, used
  53. * to keep track of nested use cases
  54. * @pctldev: pin control device handling this pin control handle
  55. * @mutex: a lock for the pin control state holder
  56. * @func_selector: the function selector for the pinmux device handling
  57. * this pinmux
  58. * @groups: the group selectors for the pinmux device and
  59. * selector combination handling this pinmux, this is a list that
  60. * will be traversed on all pinmux operations such as
  61. * get/put/enable/disable
  62. */
  63. struct pinctrl {
  64. struct list_head node;
  65. struct device *dev;
  66. unsigned usecount;
  67. struct pinctrl_dev *pctldev;
  68. struct mutex mutex;
  69. #ifdef CONFIG_PINMUX
  70. unsigned func_selector;
  71. struct list_head groups;
  72. #endif
  73. };
  74. /**
  75. * struct pin_desc - pin descriptor for each physical pin in the arch
  76. * @pctldev: corresponding pin control device
  77. * @name: a name for the pin, e.g. the name of the pin/pad/finger on a
  78. * datasheet or such
  79. * @dynamic_name: if the name of this pin was dynamically allocated
  80. * @lock: a lock to protect the descriptor structure
  81. * @mux_requested: whether the pin is already requested by pinmux or not
  82. * @mux_function: a named muxing function for the pin that will be passed to
  83. * subdrivers and shown in debugfs etc
  84. */
  85. struct pin_desc {
  86. struct pinctrl_dev *pctldev;
  87. const char *name;
  88. bool dynamic_name;
  89. spinlock_t lock;
  90. /* These fields only added when supporting pinmux drivers */
  91. #ifdef CONFIG_PINMUX
  92. const char *owner;
  93. #endif
  94. };
  95. struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name);
  96. struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin);
  97. int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name);
  98. int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
  99. const char *pin_group);