/include/linux/platform_device.h

https://bitbucket.org/thekraven/iscream_thunderc-2.6.35 · C++ Header · 139 lines · 100 code · 25 blank · 14 comment · 0 complexity · b40629627981f989a59f89d40fb671b3 MD5 · raw file

  1. /*
  2. * platform_device.h - generic, centralized driver model
  3. *
  4. * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
  5. *
  6. * This file is released under the GPLv2
  7. *
  8. * See Documentation/driver-model/ for more information.
  9. */
  10. #ifndef _PLATFORM_DEVICE_H_
  11. #define _PLATFORM_DEVICE_H_
  12. #include <linux/device.h>
  13. #include <linux/mod_devicetable.h>
  14. struct platform_device {
  15. const char * name;
  16. int id;
  17. struct device dev;
  18. u32 num_resources;
  19. struct resource * resource;
  20. const struct platform_device_id *id_entry;
  21. /* arch specific additions */
  22. struct pdev_archdata archdata;
  23. };
  24. #define platform_get_device_id(pdev) ((pdev)->id_entry)
  25. #define to_platform_device(x) container_of((x), struct platform_device, dev)
  26. extern int platform_device_register(struct platform_device *);
  27. extern void platform_device_unregister(struct platform_device *);
  28. extern struct bus_type platform_bus_type;
  29. extern struct device platform_bus;
  30. extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int);
  31. extern int platform_get_irq(struct platform_device *, unsigned int);
  32. extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, const char *);
  33. extern int platform_get_irq_byname(struct platform_device *, const char *);
  34. extern int platform_add_devices(struct platform_device **, int);
  35. extern struct platform_device *platform_device_register_simple(const char *, int id,
  36. const struct resource *, unsigned int);
  37. extern struct platform_device *platform_device_register_data(struct device *,
  38. const char *, int, const void *, size_t);
  39. extern struct platform_device *platform_device_alloc(const char *name, int id);
  40. extern int platform_device_add_resources(struct platform_device *pdev,
  41. const struct resource *res,
  42. unsigned int num);
  43. extern int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size);
  44. extern int platform_device_add(struct platform_device *pdev);
  45. extern void platform_device_del(struct platform_device *pdev);
  46. extern void platform_device_put(struct platform_device *pdev);
  47. struct platform_driver {
  48. int (*probe)(struct platform_device *);
  49. int (*remove)(struct platform_device *);
  50. void (*shutdown)(struct platform_device *);
  51. int (*suspend)(struct platform_device *, pm_message_t state);
  52. int (*resume)(struct platform_device *);
  53. struct device_driver driver;
  54. const struct platform_device_id *id_table;
  55. };
  56. extern int platform_driver_register(struct platform_driver *);
  57. extern void platform_driver_unregister(struct platform_driver *);
  58. /* non-hotpluggable platform devices may use this so that probe() and
  59. * its support may live in __init sections, conserving runtime memory.
  60. */
  61. extern int platform_driver_probe(struct platform_driver *driver,
  62. int (*probe)(struct platform_device *));
  63. #define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev)
  64. #define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data))
  65. extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
  66. int (*probe)(struct platform_device *),
  67. struct resource *res, unsigned int n_res,
  68. const void *data, size_t size);
  69. /* early platform driver interface */
  70. struct early_platform_driver {
  71. const char *class_str;
  72. struct platform_driver *pdrv;
  73. struct list_head list;
  74. int requested_id;
  75. char *buffer;
  76. int bufsize;
  77. };
  78. #define EARLY_PLATFORM_ID_UNSET -2
  79. #define EARLY_PLATFORM_ID_ERROR -3
  80. extern int early_platform_driver_register(struct early_platform_driver *epdrv,
  81. char *buf);
  82. extern void early_platform_add_devices(struct platform_device **devs, int num);
  83. static inline int is_early_platform_device(struct platform_device *pdev)
  84. {
  85. return !pdev->dev.driver;
  86. }
  87. extern void early_platform_driver_register_all(char *class_str);
  88. extern int early_platform_driver_probe(char *class_str,
  89. int nr_probe, int user_only);
  90. extern void early_platform_cleanup(void);
  91. #define early_platform_init(class_string, platdrv) \
  92. early_platform_init_buffer(class_string, platdrv, NULL, 0)
  93. #ifndef MODULE
  94. #define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
  95. static __initdata struct early_platform_driver early_driver = { \
  96. .class_str = class_string, \
  97. .buffer = buf, \
  98. .bufsize = bufsiz, \
  99. .pdrv = platdrv, \
  100. .requested_id = EARLY_PLATFORM_ID_UNSET, \
  101. }; \
  102. static int __init early_platform_driver_setup_func(char *buffer) \
  103. { \
  104. return early_platform_driver_register(&early_driver, buffer); \
  105. } \
  106. early_param(class_string, early_platform_driver_setup_func)
  107. #else /* MODULE */
  108. #define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
  109. static inline char *early_platform_driver_setup_func(void) \
  110. { \
  111. return bufsiz ? buf : NULL; \
  112. }
  113. #endif /* MODULE */
  114. #endif /* _PLATFORM_DEVICE_H_ */