platform.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include <drivers/ofw.h>
  14. #include <drivers/core/driver.h>
  15. struct rt_platform_device
  16. {
  17. struct rt_device parent;
  18. int dev_id;
  19. const char *name;
  20. const struct rt_ofw_node_id *id;
  21. void *priv;
  22. };
  23. struct rt_platform_driver
  24. {
  25. struct rt_driver parent;
  26. const char *name;
  27. const struct rt_ofw_node_id *ids;
  28. rt_err_t (*probe)(struct rt_platform_device *pdev);
  29. rt_err_t (*remove)(struct rt_platform_device *pdev);
  30. rt_err_t (*shutdown)(struct rt_platform_device *pdev);
  31. };
  32. struct rt_platform_device *rt_platform_device_alloc(const char *name);
  33. rt_err_t rt_platform_driver_register(struct rt_platform_driver *pdrv);
  34. rt_err_t rt_platform_device_register(struct rt_platform_device *pdev);
  35. rt_err_t rt_platform_ofw_device_probe_child(struct rt_ofw_node *np);
  36. rt_err_t rt_platform_ofw_request(struct rt_ofw_node *np);
  37. rt_err_t rt_platform_ofw_free(struct rt_platform_device *pdev);
  38. #define RT_PLATFORM_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, platform, BUILIN)
  39. #endif /* __PLATFORM_H__ */