machine.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_PINMUX_MACHINE_H
  13. #define __LINUX_PINMUX_MACHINE_H
  14. /**
  15. * struct pinmux_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: the pin control device to be used by this mapping, may be NULL
  20. * if you provide .ctrl_dev_name instead (this is more common)
  21. * @ctrl_dev_name: the name of the device controlling this specific mapping,
  22. * the name must be the same as in your struct device*, may be NULL if
  23. * you provide .ctrl_dev instead
  24. * @function: a function in the driver to use for this mapping, the driver
  25. * will lookup the function referenced by this ID on the specified
  26. * pin control device
  27. * @group: sometimes a function can map to different pin groups, so this
  28. * selects a certain specific pin group to activate for the function, if
  29. * left as NULL, the first applicable group will be used
  30. * @dev: the device using this specific mapping, may be NULL if you provide
  31. * .dev_name instead (this is more common)
  32. * @dev_name: the name of the device using this specific mapping, the name
  33. * must be the same as in your struct device*, may be NULL if you
  34. * provide .dev instead
  35. * @hog_on_boot: if this is set to true, the pin control subsystem will itself
  36. * hog the mappings as the pinmux device drivers are attached, so this is
  37. * typically used with system maps (mux mappings without an assigned
  38. * device) that you want to get hogged and enabled by default as soon as
  39. * a pinmux device supporting it is registered. These maps will not be
  40. * disabled and put until the system shuts down.
  41. */
  42. struct pinmux_map {
  43. const char *name;
  44. struct device *ctrl_dev;
  45. const char *ctrl_dev_name;
  46. const char *function;
  47. const char *group;
  48. struct device *dev;
  49. const char *dev_name;
  50. const bool hog_on_boot;
  51. };
  52. /*
  53. * Convenience macro to set a simple map from a certain pin controller and a
  54. * certain function to a named device
  55. */
  56. #define PINMUX_MAP(a, b, c, d) \
  57. { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
  58. /*
  59. * Convenience macro to map a system function onto a certain pinctrl device.
  60. * System functions are not assigned to a particular device.
  61. */
  62. #define PINMUX_MAP_SYS(a, b, c) \
  63. { .name = a, .ctrl_dev_name = b, .function = c }
  64. /*
  65. * Convenience macro to map a function onto the primary device pinctrl device
  66. * this is especially helpful on systems that have only one pin controller
  67. * or need to set up a lot of mappings on the primary controller.
  68. */
  69. #define PINMUX_MAP_PRIMARY(a, b, c) \
  70. { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \
  71. .dev_name = c }
  72. /*
  73. * Convenience macro to map a system function onto the primary pinctrl device.
  74. * System functions are not assigned to a particular device.
  75. */
  76. #define PINMUX_MAP_PRIMARY_SYS(a, b) \
  77. { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b }
  78. /*
  79. * Convenience macro to map a system function onto the primary pinctrl device,
  80. * to be hogged by the pinmux core until the system shuts down.
  81. */
  82. #define PINMUX_MAP_PRIMARY_SYS_HOG(a, b) \
  83. { .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \
  84. .hog_on_boot = true }
  85. #ifdef CONFIG_PINMUX
  86. extern int pinmux_register_mappings(struct pinmux_map const *map,
  87. unsigned num_maps);
  88. #else
  89. static inline int pinmux_register_mappings(struct pinmux_map const *map,
  90. unsigned num_maps)
  91. {
  92. return 0;
  93. }
  94. #endif /* !CONFIG_PINMUX */
  95. #endif