[DM/FEATURE] Support driver depends fix auto
We need a API to fix the driver load auto when a second driver get it in probe process that we can not be careful of the driver-to-driver's depends in different SoC. Signed-off-by: GuEe-GUI <2991707448@qq.com>
This commit is contained in:
parent
1bef42c64c
commit
cefe6d6380
|
@ -17,6 +17,7 @@
|
||||||
#include <drivers/ofw_io.h>
|
#include <drivers/ofw_io.h>
|
||||||
#include <drivers/ofw_fdt.h>
|
#include <drivers/ofw_fdt.h>
|
||||||
#include <drivers/platform.h>
|
#include <drivers/platform.h>
|
||||||
|
#include <drivers/core/bus.h>
|
||||||
#include <drivers/core/dm.h>
|
#include <drivers/core/dm.h>
|
||||||
|
|
||||||
#include "../ofw/ofw_internal.h"
|
#include "../ofw/ofw_internal.h"
|
||||||
|
@ -161,6 +162,7 @@ static rt_err_t platform_ofw_device_probe_once(struct rt_ofw_node *parent_np)
|
||||||
}
|
}
|
||||||
|
|
||||||
pdev->dev_id = ofw_alias_node_id(np);
|
pdev->dev_id = ofw_alias_node_id(np);
|
||||||
|
np->dev = &pdev->parent;
|
||||||
LOG_D("%s register to bus", np->full_name);
|
LOG_D("%s register to bus", np->full_name);
|
||||||
|
|
||||||
rt_platform_device_register(pdev);
|
rt_platform_device_register(pdev);
|
||||||
|
@ -199,6 +201,53 @@ rt_err_t rt_platform_ofw_device_probe_child(struct rt_ofw_node *np)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rt_err_t rt_platform_ofw_request(struct rt_ofw_node *np)
|
||||||
|
{
|
||||||
|
rt_err_t err;
|
||||||
|
|
||||||
|
if (np)
|
||||||
|
{
|
||||||
|
struct rt_device *dev = np->dev;
|
||||||
|
|
||||||
|
if (dev)
|
||||||
|
{
|
||||||
|
/* Was create */
|
||||||
|
if (dev->drv)
|
||||||
|
{
|
||||||
|
/* Was probe OK */
|
||||||
|
err = RT_EOK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = rt_bus_reload_driver_device(dev->bus, dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct rt_platform_device *pdev = alloc_ofw_platform_device(np);
|
||||||
|
|
||||||
|
if (pdev)
|
||||||
|
{
|
||||||
|
pdev->dev_id = ofw_alias_node_id(np);
|
||||||
|
np->dev = &pdev->parent;
|
||||||
|
LOG_D("%s register to bus", np->full_name);
|
||||||
|
|
||||||
|
err = rt_platform_device_register(pdev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = -RT_ENOMEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = -RT_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static int platform_ofw_device_probe(void)
|
static int platform_ofw_device_probe(void)
|
||||||
{
|
{
|
||||||
rt_err_t err = RT_EOK;
|
rt_err_t err = RT_EOK;
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct rt_ofw_node
|
||||||
/* phandles range from 1 to 2^32-2 (0xfffffffe) */
|
/* phandles range from 1 to 2^32-2 (0xfffffffe) */
|
||||||
rt_phandle phandle;
|
rt_phandle phandle;
|
||||||
|
|
||||||
|
struct rt_device *dev;
|
||||||
struct rt_ofw_prop *props;
|
struct rt_ofw_prop *props;
|
||||||
struct rt_ofw_node *parent;
|
struct rt_ofw_node *parent;
|
||||||
struct rt_ofw_node *child;
|
struct rt_ofw_node *child;
|
||||||
|
|
|
@ -45,6 +45,7 @@ rt_err_t rt_platform_driver_register(struct rt_platform_driver *pdrv);
|
||||||
rt_err_t rt_platform_device_register(struct rt_platform_device *pdev);
|
rt_err_t rt_platform_device_register(struct rt_platform_device *pdev);
|
||||||
|
|
||||||
rt_err_t rt_platform_ofw_device_probe_child(struct rt_ofw_node *np);
|
rt_err_t rt_platform_ofw_device_probe_child(struct rt_ofw_node *np);
|
||||||
|
rt_err_t rt_platform_ofw_request(struct rt_ofw_node *np);
|
||||||
rt_err_t rt_platform_ofw_free(struct rt_platform_device *pdev);
|
rt_err_t rt_platform_ofw_free(struct rt_platform_device *pdev);
|
||||||
|
|
||||||
#define RT_PLATFORM_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, platform, BUILIN)
|
#define RT_PLATFORM_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, platform, BUILIN)
|
||||||
|
|
Loading…
Reference in New Issue