machine.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #include "pinctrl.h"
  15. /**
  16. * struct pinctrl_map - boards/machines shall provide this map for devices
  17. * @dev_name: the name of the device using this specific mapping, the name
  18. * must be the same as in your struct device*. If this name is set to the
  19. * same name as the pin controllers own dev_name(), the map entry will be
  20. * hogged by the driver itself upon registration
  21. * @name: the name of this specific map entry for the particular machine.
  22. * This is the parameter passed to pinmux_lookup_state()
  23. * @ctrl_dev_name: the name of the device controlling this specific mapping,
  24. * the name must be the same as in your struct device*
  25. * @group: sometimes a function can map to different pin groups, so this
  26. * selects a certain specific pin group to activate for the function, if
  27. * left as NULL, the first applicable group will be used
  28. * @function: a function in the driver to use for this mapping, the driver
  29. * will lookup the function referenced by this ID on the specified
  30. * pin control device
  31. */
  32. struct pinctrl_map {
  33. const char *dev_name;
  34. const char *name;
  35. const char *ctrl_dev_name;
  36. const char *group;
  37. const char *function;
  38. };
  39. /*
  40. * Convenience macro to set a simple map from a certain pin controller and a
  41. * certain function to a named device
  42. */
  43. #define PIN_MAP(a, b, c, d) \
  44. { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
  45. /*
  46. * Convenience macro to map a system function onto a certain pinctrl device,
  47. * to be hogged by the pin control core until the system shuts down.
  48. */
  49. #define PIN_MAP_SYS_HOG(a, b) \
  50. { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \
  51. .function = b, }
  52. /*
  53. * Convenience macro to map a system function onto a certain pinctrl device
  54. * using a specified group, to be hogged by the pin control core until the
  55. * system shuts down.
  56. */
  57. #define PIN_MAP_SYS_HOG_GROUP(a, b, c) \
  58. { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \
  59. .function = b, .group = c, }
  60. #ifdef CONFIG_PINMUX
  61. extern int pinctrl_register_mappings(struct pinctrl_map const *map,
  62. unsigned num_maps);
  63. #else
  64. static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
  65. unsigned num_maps)
  66. {
  67. return 0;
  68. }
  69. #endif /* !CONFIG_PINMUX */
  70. #endif