core.h 2.4 KB

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