of_device.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef __OF_DEVICE_H__
  2. #define __OF_DEVICE_H__
  3. #include <linux/device.h>
  4. #include <asm/prom.h>
  5. /*
  6. * The of_platform_bus_type is a bus type used by drivers that do not
  7. * attach to a macio or similar bus but still use OF probing
  8. * mecanism
  9. */
  10. extern struct bus_type of_platform_bus_type;
  11. /*
  12. * The of_device is a kind of "base class" that is a superset of
  13. * struct device for use by devices attached to an OF node and
  14. * probed using OF properties
  15. */
  16. struct of_device
  17. {
  18. struct device_node *node; /* OF device node */
  19. u64 dma_mask; /* DMA mask */
  20. struct device dev; /* Generic device interface */
  21. };
  22. #define to_of_device(d) container_of(d, struct of_device, dev)
  23. /*
  24. * Struct used for matching a device
  25. */
  26. struct of_match
  27. {
  28. char *name;
  29. char *type;
  30. char *compatible;
  31. void *data;
  32. };
  33. #define OF_ANY_MATCH ((char *)-1L)
  34. extern const struct of_match *of_match_device(
  35. const struct of_match *matches, const struct of_device *dev);
  36. extern struct of_device *of_dev_get(struct of_device *dev);
  37. extern void of_dev_put(struct of_device *dev);
  38. /*
  39. * An of_platform_driver driver is attached to a basic of_device on
  40. * the "platform bus" (of_platform_bus_type)
  41. */
  42. struct of_platform_driver
  43. {
  44. char *name;
  45. struct of_match *match_table;
  46. struct module *owner;
  47. int (*probe)(struct of_device* dev, const struct of_match *match);
  48. int (*remove)(struct of_device* dev);
  49. int (*suspend)(struct of_device* dev, pm_message_t state);
  50. int (*resume)(struct of_device* dev);
  51. int (*shutdown)(struct of_device* dev);
  52. struct device_driver driver;
  53. };
  54. #define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver)
  55. extern int of_register_driver(struct of_platform_driver *drv);
  56. extern void of_unregister_driver(struct of_platform_driver *drv);
  57. extern int of_device_register(struct of_device *ofdev);
  58. extern void of_device_unregister(struct of_device *ofdev);
  59. extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id);
  60. extern void of_release_dev(struct device *dev);
  61. #endif /* __OF_DEVICE_H__ */