File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed
Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1717#include <drivers/ofw_io.h>
1818#include <drivers/ofw_fdt.h>
1919#include <drivers/platform.h>
20+ #include <drivers/core/bus.h>
2021#include <drivers/core/dm.h>
2122
2223#include "../ofw/ofw_internal.h"
@@ -161,6 +162,7 @@ static rt_err_t platform_ofw_device_probe_once(struct rt_ofw_node *parent_np)
161162 }
162163
163164 pdev -> dev_id = ofw_alias_node_id (np );
165+ np -> dev = & pdev -> parent ;
164166 LOG_D ("%s register to bus" , np -> full_name );
165167
166168 rt_platform_device_register (pdev );
@@ -199,6 +201,53 @@ rt_err_t rt_platform_ofw_device_probe_child(struct rt_ofw_node *np)
199201 return err ;
200202}
201203
204+ rt_err_t rt_platform_ofw_request (struct rt_ofw_node * np )
205+ {
206+ rt_err_t err ;
207+
208+ if (np )
209+ {
210+ struct rt_device * dev = np -> dev ;
211+
212+ if (dev )
213+ {
214+ /* Was create */
215+ if (dev -> drv )
216+ {
217+ /* Was probe OK */
218+ err = RT_EOK ;
219+ }
220+ else
221+ {
222+ err = rt_bus_reload_driver_device (dev -> bus , dev );
223+ }
224+ }
225+ else
226+ {
227+ struct rt_platform_device * pdev = alloc_ofw_platform_device (np );
228+
229+ if (pdev )
230+ {
231+ pdev -> dev_id = ofw_alias_node_id (np );
232+ np -> dev = & pdev -> parent ;
233+ LOG_D ("%s register to bus" , np -> full_name );
234+
235+ err = rt_platform_device_register (pdev );
236+ }
237+ else
238+ {
239+ err = - RT_ENOMEM ;
240+ }
241+ }
242+ }
243+ else
244+ {
245+ err = - RT_EINVAL ;
246+ }
247+
248+ return err ;
249+ }
250+
202251static int platform_ofw_device_probe (void )
203252{
204253 rt_err_t err = RT_EOK ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ struct rt_ofw_node
3737 /* phandles range from 1 to 2^32-2 (0xfffffffe) */
3838 rt_phandle phandle ;
3939
40+ struct rt_device * dev ;
4041 struct rt_ofw_prop * props ;
4142 struct rt_ofw_node * parent ;
4243 struct rt_ofw_node * child ;
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ rt_err_t rt_platform_driver_register(struct rt_platform_driver *pdrv);
4545rt_err_t rt_platform_device_register (struct rt_platform_device * pdev );
4646
4747rt_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 );
4849rt_err_t rt_platform_ofw_free (struct rt_platform_device * pdev );
4950
5051#define RT_PLATFORM_DRIVER_EXPORT (driver ) RT_DRIVER_EXPORT(driver, platform, BUILIN)
You can’t perform that action at this time.
0 commit comments