machine.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Machine interface for the pinctrl subsystem.
  3. *
  4. * Copyright (C) 2011 ST-Ericsson SA
  5. * Written on behalf of Linaro for ST-Ericsson
  6. * Based on bits of regulator core, gpio core and clk core
  7. *
  8. * Author: Linus Walleij <linus.walleij@linaro.org>
  9. *
  10. * License terms: GNU General Public License (GPL) version 2
  11. */
  12. #ifndef __LINUX_PINCTRL_MACHINE_H
  13. #define __LINUX_PINCTRL_MACHINE_H
  14. /**
  15. * struct pinctrl_map - boards/machines shall provide this map for devices
  16. * @name: the name of this specific map entry for the particular machine.
  17. * This is the second parameter passed to pinmux_get() when you want
  18. * to have several mappings to the same device
  19. * @ctrl_dev_name: the name of the device controlling this specific mapping,
  20. * the name must be the same as in your struct device*
  21. * @function: a function in the driver to use for this mapping, the driver
  22. * will lookup the function referenced by this ID on the specified
  23. * pin control device
  24. * @group: sometimes a function can map to different pin groups, so this
  25. * selects a certain specific pin group to activate for the function, if
  26. * left as NULL, the first applicable group will be used
  27. * @dev_name: the name of the device using this specific mapping, the name
  28. * must be the same as in your struct device*
  29. * @hog_on_boot: if this is set to true, the pin control subsystem will itself
  30. * hog the mappings as the pinmux device drivers are attached, so this is
  31. * typically used with system maps (mux mappings without an assigned
  32. * device) that you want to get hogged and enabled by default as soon as
  33. * a pinmux device supporting it is registered. These maps will not be
  34. * disabled and put until the system shuts down.
  35. */
  36. struct pinctrl_map {
  37. const char *name;
  38. const char *ctrl_dev_name;
  39. const char *function;
  40. const char *group;
  41. const char *dev_name;
  42. bool hog_on_boot;
  43. };
  44. /*
  45. * Convenience macro to set a simple map from a certain pin controller and a
  46. * certain function to a named device
  47. */
  48. #define PIN_MAP(a, b, c, d) \
  49. { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
  50. /*
  51. * Convenience macro to map a system function onto a certain pinctrl device.
  52. * System functions are not assigned to a particular device.
  53. */
  54. #define PIN_MAP_SYS(a, b, c) \
  55. { .name = a, .ctrl_dev_name = b, .function = c }
  56. /*
  57. * Convenience macro to map a system function onto a certain pinctrl device,
  58. * to be hogged by the pin control core until the system shuts down.
  59. */
  60. #define PIN_MAP_SYS_HOG(a, b, c) \
  61. { .name = a, .ctrl_dev_name = b, .function = c, \
  62. .hog_on_boot = true }
  63. /*
  64. * Convenience macro to map a system function onto a certain pinctrl device
  65. * using a specified group, to be hogged by the pin control core until the
  66. * system shuts down.
  67. */
  68. #define PIN_MAP_SYS_HOG_GROUP(a, b, c, d) \
  69. { .name = a, .ctrl_dev_name = b, .function = c, .group = d, \
  70. .hog_on_boot = true }
  71. #ifdef CONFIG_PINMUX
  72. extern int pinctrl_register_mappings(struct pinctrl_map const *map,
  73. unsigned num_maps);
  74. #else
  75. static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
  76. unsigned num_maps)
  77. {
  78. return 0;
  79. }
  80. #endif /* !CONFIG_PINMUX */
  81. #endif