platform.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. int dev_id;
  21. const char *name;
  22. #ifdef RT_USING_OFW
  23. const struct rt_ofw_node_id *id;
  24. #endif
  25. void *priv;
  26. };
  27. struct rt_platform_driver
  28. {
  29. struct rt_driver parent;
  30. const char *name;
  31. #ifdef RT_USING_OFW
  32. const struct rt_ofw_node_id *ids;
  33. #endif
  34. rt_err_t (*probe)(struct rt_platform_device *pdev);
  35. rt_err_t (*remove)(struct rt_platform_device *pdev);
  36. rt_err_t (*shutdown)(struct rt_platform_device *pdev);
  37. };
  38. struct rt_platform_device *rt_platform_device_alloc(const char *name);
  39. rt_err_t rt_platform_driver_register(struct rt_platform_driver *pdrv);
  40. rt_err_t rt_platform_device_register(struct rt_platform_device *pdev);
  41. rt_err_t rt_platform_ofw_device_probe_child(struct rt_ofw_node *np);
  42. #define RT_PLATFORM_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, platform, BUILIN)
  43. #endif /* __PLATFORM_H__ */