of_device.h 2.0 KB

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