1.
Now we are porting rproc diver from NxP to our own u-boot which is based on
NXP's v2020.04 version, and we find that if we don't do any changes to the
device_bind_common interface in drivers/core/device.c and the rproc driver
doesn't work. Then if we add some codes(two red lines below) to the
device_bind_common interface in drivers/core/device.c and the rproc driver
works well.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int device_bind_common(struct udevice *parent, const struct driver *drv,
const char *name, void
*platdata,
ulong driver_data, ofnode node,
uint of_platdata_size, struct
udevice **devp)
{
struct udevice *dev;
struct uclass *uc;
int size, ret = 0;
if (devp)
*devp = NULL;
if (!name)
return -EINVAL;
ret = uclass_get(drv->id, &uc);
if (ret) {
debug("Missing uclass for driver %s\n", drv->name);
return ret;
}
dev = calloc(1, sizeof(struct udevice));
if (!dev)
return -ENOMEM;
INIT_LIST_HEAD(&dev->sibling_node);
INIT_LIST_HEAD(&dev->child_head);
INIT_LIST_HEAD(&dev->uclass_node);
#ifdef CONFIG_DEVRES
INIT_LIST_HEAD(&dev->devres_head);
#endif
dev->platdata = platdata;
dev->driver_data = driver_data;
dev->name = name;
dev->node = node;
dev->parent = parent;
dev->driver = drv;
dev->uclass = uc;
dev->seq = -1;
dev->req_seq = -1;
if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
(uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
/*
* Some devices, such as a SPI bus, I2C bus and
serial ports
* are numbered using aliases.
*
* This is just a 'requested' sequence, and will be
* resolved (and ->seq updated) when the device is
probed.
*/
if (CONFIG_IS_ENABLED(OF_CONTROL) &&
!CONFIG_IS_ENABLED(OF_PLATDATA)) {
if (uc->uc_drv->name &&
ofnode_valid(node)){
dev_read_alias_seq(dev, &dev->req_seq);
if (strcmp(dev->name,
"imx8mm-cm4") == 0)
dev->req_seq = uclass_find_next_free_req_seq(drv->id);
}
#if CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
if (dev->req_seq == -1)
dev->req_seq =
uclass_find_next_free_req_seq(drv->id);
#endif
} else {
dev->req_seq =
uclass_find_next_free_req_seq(drv->id);
}
}
......
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
My question is why I should add these two lines code.
Note: We have one node in our dts file below.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
imx8mm-cm4 {
compatible = "fsl,imx8mm-cm4";
syscon = <&src>;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2.
I notice that device_bind_common in drivers/core/device.c was changed as
follows in v2021.04 version.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int device_bind_common(struct udevice *parent, const struct driver *drv,
const char *name, void *plat,
ulong driver_data, ofnode node,
uint of_plat_size, struct
udevice **devp)
{
struct udevice *dev;
struct uclass *uc;
int size, ret = 0;
bool auto_seq = true;
void *ptr;
if (CONFIG_IS_ENABLED(OF_PLATDATA_NO_BIND))
return -ENOSYS;
if (devp)
*devp = NULL;
if (!name)
return -EINVAL;
ret = uclass_get(drv->id, &uc);
if (ret) {
dm_warn("Missing uclass for driver %s\n",
drv->name);
return ret;
}
dev = calloc(1, sizeof(struct udevice));
if (!dev)
return -ENOMEM;
INIT_LIST_HEAD(&dev->sibling_node);
INIT_LIST_HEAD(&dev->child_head);
INIT_LIST_HEAD(&dev->uclass_node);
#if CONFIG_IS_ENABLED(DEVRES)
INIT_LIST_HEAD(&dev->devres_head);
#endif
dev_set_plat(dev, plat);
dev->driver_data = driver_data;
dev->name = name;
dev_set_ofnode(dev, node);
dev->parent = parent;
dev->driver = drv;
dev->uclass = uc;
dev->seq_ = -1;
if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
(uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
/*
* Some devices, such as a SPI bus, I2C bus and
serial ports
* are numbered using aliases.
*/
if (CONFIG_IS_ENABLED(OF_CONTROL) &&
!CONFIG_IS_ENABLED(OF_PLATDATA)) {
if (uc->uc_drv->name &&
ofnode_valid(node)) {
if
(!dev_read_alias_seq(dev, &dev->seq_)) {
auto_seq = false;
log_debug(" - seq=%d\n", dev->seq_); (1)
}
}
}
}
if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
(2)
dev->seq_ = uclass_find_next_free_seq(uc);
......
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
My questions are:
1. (1) and (2) are mutually exclusive, are they? What I mean is that only
one of them can be executed for scanning and bonding one udevice.
2. What is the condition that (2) is executed?
Thanks!
BRs
Xiujun Wang