platform.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-04-12 ErikChan the first version
  9. * 2023-10-13 zmshahaha distinguish ofw and none-ofw situation
  10. */
  11. #ifndef __PLATFORM_H__
  12. #define __PLATFORM_H__
  13. #ifdef RT_USING_OFW
  14. #include <drivers/ofw.h>
  15. #endif
  16. #include <drivers/core/driver.h>
  17. struct rt_platform_device
  18. {
  19. struct rt_device parent;
  20. const char *name;
  21. #ifdef RT_USING_OFW
  22. const struct rt_ofw_node_id *id;
  23. #endif
  24. void *priv;
  25. };
  26. struct rt_platform_driver
  27. {
  28. struct rt_driver parent;
  29. const char *name;
  30. #ifdef RT_USING_OFW
  31. const struct rt_ofw_node_id *ids;
  32. #endif
  33. rt_err_t (*probe)(struct rt_platform_device *pdev);
  34. };
  35. struct rt_platform_device *rt_platform_device_alloc(const char *name);
  36. rt_err_t rt_platform_driver_register(struct rt_platform_driver *pdrv);
  37. rt_err_t rt_platform_device_register(struct rt_platform_device *pdev);
  38. #define RT_PLATFORM_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, platform, BUILIN)
  39. #endif /* __PLATFORM_H__ */