of_platform.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef _LINUX_OF_PLATFORM_H
  2. #define _LINUX_OF_PLATFORM_H
  3. /*
  4. * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
  5. * <benh@kernel.crashing.org>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. */
  13. #include <linux/device.h>
  14. #include <linux/mod_devicetable.h>
  15. #include <linux/pm.h>
  16. #include <linux/of_device.h>
  17. #include <linux/platform_device.h>
  18. /**
  19. * struct of_dev_auxdata - lookup table entry for device names & platform_data
  20. * @compatible: compatible value of node to match against node
  21. * @phys_addr: Start address of registers to match against node
  22. * @name: Name to assign for matching nodes
  23. * @platform_data: platform_data to assign for matching nodes
  24. *
  25. * This lookup table allows the caller of of_platform_populate() to override
  26. * the names of devices when creating devices from the device tree. The table
  27. * should be terminated with an empty entry. It also allows the platform_data
  28. * pointer to be set.
  29. *
  30. * The reason for this functionality is that some Linux infrastructure uses
  31. * the device name to look up a specific device, but the Linux-specific names
  32. * are not encoded into the device tree, so the kernel needs to provide specific
  33. * values.
  34. *
  35. * Note: Using an auxdata lookup table should be considered a last resort when
  36. * converting a platform to use the DT. Normally the automatically generated
  37. * device name will not matter, and drivers should obtain data from the device
  38. * node instead of from an anonymous platform_data pointer.
  39. */
  40. struct of_dev_auxdata {
  41. char *compatible;
  42. resource_size_t phys_addr;
  43. char *name;
  44. void *platform_data;
  45. };
  46. /* Macro to simplify populating a lookup table */
  47. #define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \
  48. { .compatible = _compat, .phys_addr = _phys, .name = _name, \
  49. .platform_data = _pdata }
  50. extern const struct of_device_id of_default_bus_match_table[];
  51. /* Platform drivers register/unregister */
  52. extern struct platform_device *of_device_alloc(struct device_node *np,
  53. const char *bus_id,
  54. struct device *parent);
  55. extern struct platform_device *of_find_device_by_node(struct device_node *np);
  56. /* Platform devices and busses creation */
  57. extern struct platform_device *of_platform_device_create(struct device_node *np,
  58. const char *bus_id,
  59. struct device *parent);
  60. extern int of_platform_bus_probe(struct device_node *root,
  61. const struct of_device_id *matches,
  62. struct device *parent);
  63. #ifdef CONFIG_OF_ADDRESS
  64. extern int of_platform_populate(struct device_node *root,
  65. const struct of_device_id *matches,
  66. const struct of_dev_auxdata *lookup,
  67. struct device *parent);
  68. extern int of_platform_default_populate(struct device_node *root,
  69. const struct of_dev_auxdata *lookup,
  70. struct device *parent);
  71. extern void of_platform_depopulate(struct device *parent);
  72. #else
  73. static inline int of_platform_populate(struct device_node *root,
  74. const struct of_device_id *matches,
  75. const struct of_dev_auxdata *lookup,
  76. struct device *parent)
  77. {
  78. return -ENODEV;
  79. }
  80. static inline int of_platform_default_populate(struct device_node *root,
  81. const struct of_dev_auxdata *lookup,
  82. struct device *parent)
  83. {
  84. return -ENODEV;
  85. }
  86. static inline void of_platform_depopulate(struct device *parent) { }
  87. #endif
  88. #if defined(CONFIG_OF_DYNAMIC) && defined(CONFIG_OF_ADDRESS)
  89. extern void of_platform_register_reconfig_notifier(void);
  90. #else
  91. static inline void of_platform_register_reconfig_notifier(void) { }
  92. #endif
  93. #endif /* _LINUX_OF_PLATFORM_H */