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