core.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * @pinmux_hogs_lock: lock for the pinmux hog list
  29. * @pinmux_hogs: list of pinmux maps hogged by this device
  30. */
  31. struct pinctrl_dev {
  32. struct list_head node;
  33. struct pinctrl_desc *desc;
  34. struct radix_tree_root pin_desc_tree;
  35. spinlock_t pin_desc_tree_lock;
  36. struct list_head gpio_ranges;
  37. struct mutex gpio_ranges_lock;
  38. struct device *dev;
  39. struct module *owner;
  40. void *driver_data;
  41. #ifdef CONFIG_PINMUX
  42. struct mutex pinmux_hogs_lock;
  43. struct list_head pinmux_hogs;
  44. #endif
  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. * @dynamic_name: if the name of this pin was dynamically allocated
  52. * @lock: a lock to protect the descriptor structure
  53. * @mux_requested: whether the pin is already requested by pinmux or not
  54. * @mux_function: a named muxing function for the pin that will be passed to
  55. * subdrivers and shown in debugfs etc
  56. */
  57. struct pin_desc {
  58. struct pinctrl_dev *pctldev;
  59. const char *name;
  60. bool dynamic_name;
  61. spinlock_t lock;
  62. /* These fields only added when supporting pinmux drivers */
  63. #ifdef CONFIG_PINMUX
  64. const char *mux_function;
  65. #endif
  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, unsigned int pin);
  70. int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name);
  71. int pinctrl_get_device_gpio_range(unsigned gpio,
  72. struct pinctrl_dev **outdev,
  73. struct pinctrl_gpio_range **outrange);
  74. int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
  75. const char *pin_group);