of_platform.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef CONFIG_OF_DEVICE
  14. #include <linux/module.h>
  15. #include <linux/device.h>
  16. #include <linux/mod_devicetable.h>
  17. #include <linux/pm.h>
  18. #include <linux/of_device.h>
  19. /*
  20. * The of_platform_bus_type is a bus type used by drivers that do not
  21. * attach to a macio or similar bus but still use OF probing
  22. * mechanism
  23. */
  24. extern struct bus_type of_platform_bus_type;
  25. extern const struct of_device_id of_default_bus_ids[];
  26. /*
  27. * An of_platform_driver driver is attached to a basic of_device on
  28. * the "platform bus" (of_platform_bus_type).
  29. */
  30. struct of_platform_driver
  31. {
  32. int (*probe)(struct of_device* dev,
  33. const struct of_device_id *match);
  34. int (*remove)(struct of_device* dev);
  35. int (*suspend)(struct of_device* dev, pm_message_t state);
  36. int (*resume)(struct of_device* dev);
  37. int (*shutdown)(struct of_device* dev);
  38. struct device_driver driver;
  39. };
  40. #define to_of_platform_driver(drv) \
  41. container_of(drv,struct of_platform_driver, driver)
  42. extern int of_register_driver(struct of_platform_driver *drv,
  43. struct bus_type *bus);
  44. extern void of_unregister_driver(struct of_platform_driver *drv);
  45. /* Platform drivers register/unregister */
  46. static inline int of_register_platform_driver(struct of_platform_driver *drv)
  47. {
  48. return of_register_driver(drv, &of_platform_bus_type);
  49. }
  50. static inline void of_unregister_platform_driver(struct of_platform_driver *drv)
  51. {
  52. of_unregister_driver(drv);
  53. }
  54. extern struct of_device *of_device_alloc(struct device_node *np,
  55. const char *bus_id,
  56. struct device *parent);
  57. #include <asm/of_platform.h>
  58. extern struct of_device *of_find_device_by_node(struct device_node *np);
  59. extern int of_bus_type_init(struct bus_type *bus, const char *name);
  60. #if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */
  61. /* Platform devices and busses creation */
  62. extern struct of_device *of_platform_device_create(struct device_node *np,
  63. const char *bus_id,
  64. struct device *parent);
  65. /* pseudo "matches" value to not do deep probe */
  66. #define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
  67. extern int of_platform_bus_probe(struct device_node *root,
  68. const struct of_device_id *matches,
  69. struct device *parent);
  70. #endif /* !CONFIG_SPARC */
  71. #endif /* CONFIG_OF_DEVICE */
  72. #endif /* _LINUX_OF_PLATFORM_H */