mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
* Fix DAA for the pre-reserved address case
* Fix an error path in the cadence driver -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEKmCqpbOU668PNA69Ze02AX4ItwAFAl+Ko/gACgkQZe02AX4I twAcKg//d6FTKiiphDXB7o3cNIcfV+1bbOxxl0JTqIW1kaRXvCVA7L0KQDDttefW VyjJTDLU+A3xauuC9kEOJCbX+oO3CEKtBQ5IjAaVgHirtz8E0gqJ2YV6X9zkfF86 A94Z2e4vK79OpvfFmn+odYx8iFbXWR3q5ip9vMXRzXxGYJU0UwjLNSulvA3wSVAI uZzWeuLPxZalPQpp544fx+8AB2vuFOKu80yrPZnIBPCtH4luLlIVOXR18VMEXwaC ZAT4QlMNzAbqEOWe4ZFrddoyqj7b/enAjUflGkBpb+ZcsKGHzEQKe7s5Fg5PiJfF aWmWDsUh6/8et8sx//RCS442s/ZMIDxEvwgbUe/U19z94yW80rTWC0mbJnpO8KsU 9doNmkZpjygwCnxc2fj6Sa+PlZt69SqDArWj3KOk/5UMqTh7fRDbB8DuvsTEBCiX VKOHbk44Fqdaov6g4JAg/u073ZyvI6jjlbDPuPBUVi++hqCxXk7TZ1U16xgwOsyg qiASKtQwztLvvuyHYyQNhpV9yHvSxzzUJHbL/3V3FQkGtVRTPP5+5ctCbndY1C46 im+o0nlS2OpkYyw8A0AQuI6rnypuerbcafPw1ruvSTaWv60OebneyD9mLJm5pO4D zs6XtAoyO99+IEKDz+mvVckTxaj8cyrO5pQhjbyQoIr5ZvE2OPM= =yC+2 -----END PGP SIGNATURE----- Merge tag 'i3c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux Pull i3c updates from Boris Brezillon: - Fix DAA for the pre-reserved address case - Fix an error path in the cadence driver * tag 'i3c/for-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux: i3c: master: Fix error return in cdns_i3c_master_probe() i3c: master: fix for SETDASA and DAA process i3c: master add i3c_master_attach_boardinfo to preserve boardinfo
This commit is contained in:
commit
2a934b38c0
@ -1373,7 +1373,9 @@ static int i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev,
|
||||
enum i3c_addr_slot_status status;
|
||||
int ret;
|
||||
|
||||
if (dev->info.dyn_addr != old_dyn_addr) {
|
||||
if (dev->info.dyn_addr != old_dyn_addr &&
|
||||
(!dev->boardinfo ||
|
||||
dev->info.dyn_addr != dev->boardinfo->init_dyn_addr)) {
|
||||
status = i3c_bus_get_addr_slot_status(&master->bus,
|
||||
dev->info.dyn_addr);
|
||||
if (status != I3C_ADDR_SLOT_FREE)
|
||||
@ -1432,33 +1434,49 @@ static void i3c_master_detach_i2c_dev(struct i2c_dev_desc *dev)
|
||||
master->ops->detach_i2c_dev(dev);
|
||||
}
|
||||
|
||||
static void i3c_master_pre_assign_dyn_addr(struct i3c_dev_desc *dev)
|
||||
static int i3c_master_early_i3c_dev_add(struct i3c_master_controller *master,
|
||||
struct i3c_dev_boardinfo *boardinfo)
|
||||
{
|
||||
struct i3c_master_controller *master = i3c_dev_get_master(dev);
|
||||
struct i3c_device_info info = {
|
||||
.static_addr = boardinfo->static_addr,
|
||||
};
|
||||
struct i3c_dev_desc *i3cdev;
|
||||
int ret;
|
||||
|
||||
if (!dev->boardinfo || !dev->boardinfo->init_dyn_addr ||
|
||||
!dev->boardinfo->static_addr)
|
||||
return;
|
||||
i3cdev = i3c_master_alloc_i3c_dev(master, &info);
|
||||
if (IS_ERR(i3cdev))
|
||||
return -ENOMEM;
|
||||
|
||||
ret = i3c_master_setdasa_locked(master, dev->info.static_addr,
|
||||
dev->boardinfo->init_dyn_addr);
|
||||
i3cdev->boardinfo = boardinfo;
|
||||
|
||||
ret = i3c_master_attach_i3c_dev(master, i3cdev);
|
||||
if (ret)
|
||||
return;
|
||||
goto err_free_dev;
|
||||
|
||||
dev->info.dyn_addr = dev->boardinfo->init_dyn_addr;
|
||||
ret = i3c_master_reattach_i3c_dev(dev, 0);
|
||||
ret = i3c_master_setdasa_locked(master, i3cdev->info.static_addr,
|
||||
i3cdev->boardinfo->init_dyn_addr);
|
||||
if (ret)
|
||||
goto err_detach_dev;
|
||||
|
||||
i3cdev->info.dyn_addr = i3cdev->boardinfo->init_dyn_addr;
|
||||
ret = i3c_master_reattach_i3c_dev(i3cdev, 0);
|
||||
if (ret)
|
||||
goto err_rstdaa;
|
||||
|
||||
ret = i3c_master_retrieve_dev_info(dev);
|
||||
ret = i3c_master_retrieve_dev_info(i3cdev);
|
||||
if (ret)
|
||||
goto err_rstdaa;
|
||||
|
||||
return;
|
||||
return 0;
|
||||
|
||||
err_rstdaa:
|
||||
i3c_master_rstdaa_locked(master, dev->boardinfo->init_dyn_addr);
|
||||
i3c_master_rstdaa_locked(master, i3cdev->boardinfo->init_dyn_addr);
|
||||
err_detach_dev:
|
||||
i3c_master_detach_i3c_dev(i3cdev);
|
||||
err_free_dev:
|
||||
i3c_master_free_i3c_dev(i3cdev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1625,8 +1643,8 @@ static void i3c_master_detach_free_devs(struct i3c_master_controller *master)
|
||||
* This function is following all initialisation steps described in the I3C
|
||||
* specification:
|
||||
*
|
||||
* 1. Attach I2C and statically defined I3C devs to the master so that the
|
||||
* master can fill its internal device table appropriately
|
||||
* 1. Attach I2C devs to the master so that the master can fill its internal
|
||||
* device table appropriately
|
||||
*
|
||||
* 2. Call &i3c_master_controller_ops->bus_init() method to initialize
|
||||
* the master controller. That's usually where the bus mode is selected
|
||||
@ -1638,8 +1656,10 @@ static void i3c_master_detach_free_devs(struct i3c_master_controller *master)
|
||||
*
|
||||
* 4. Disable all slave events.
|
||||
*
|
||||
* 5. Pre-assign dynamic addresses requested by the FW with SETDASA for I3C
|
||||
* devices that have a static address
|
||||
* 5. Reserve address slots for I3C devices with init_dyn_addr. And if devices
|
||||
* also have static_addr, try to pre-assign dynamic addresses requested by
|
||||
* the FW with SETDASA and attach corresponding statically defined I3C
|
||||
* devices to the master.
|
||||
*
|
||||
* 6. Do a DAA (Dynamic Address Assignment) to assign dynamic addresses to all
|
||||
* remaining I3C devices
|
||||
@ -1653,7 +1673,6 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
|
||||
enum i3c_addr_slot_status status;
|
||||
struct i2c_dev_boardinfo *i2cboardinfo;
|
||||
struct i3c_dev_boardinfo *i3cboardinfo;
|
||||
struct i3c_dev_desc *i3cdev;
|
||||
struct i2c_dev_desc *i2cdev;
|
||||
int ret;
|
||||
|
||||
@ -1685,34 +1704,6 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
|
||||
goto err_detach_devs;
|
||||
}
|
||||
}
|
||||
list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) {
|
||||
struct i3c_device_info info = {
|
||||
.static_addr = i3cboardinfo->static_addr,
|
||||
};
|
||||
|
||||
if (i3cboardinfo->init_dyn_addr) {
|
||||
status = i3c_bus_get_addr_slot_status(&master->bus,
|
||||
i3cboardinfo->init_dyn_addr);
|
||||
if (status != I3C_ADDR_SLOT_FREE) {
|
||||
ret = -EBUSY;
|
||||
goto err_detach_devs;
|
||||
}
|
||||
}
|
||||
|
||||
i3cdev = i3c_master_alloc_i3c_dev(master, &info);
|
||||
if (IS_ERR(i3cdev)) {
|
||||
ret = PTR_ERR(i3cdev);
|
||||
goto err_detach_devs;
|
||||
}
|
||||
|
||||
i3cdev->boardinfo = i3cboardinfo;
|
||||
|
||||
ret = i3c_master_attach_i3c_dev(master, i3cdev);
|
||||
if (ret) {
|
||||
i3c_master_free_i3c_dev(i3cdev);
|
||||
goto err_detach_devs;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now execute the controller specific ->bus_init() routine, which
|
||||
@ -1749,11 +1740,43 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
|
||||
goto err_bus_cleanup;
|
||||
|
||||
/*
|
||||
* Pre-assign dynamic address and retrieve device information if
|
||||
* needed.
|
||||
* Reserve init_dyn_addr first, and then try to pre-assign dynamic
|
||||
* address and retrieve device information if needed.
|
||||
* In case pre-assign dynamic address fails, setting dynamic address to
|
||||
* the requested init_dyn_addr is retried after DAA is done in
|
||||
* i3c_master_add_i3c_dev_locked().
|
||||
*/
|
||||
i3c_bus_for_each_i3cdev(&master->bus, i3cdev)
|
||||
i3c_master_pre_assign_dyn_addr(i3cdev);
|
||||
list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) {
|
||||
|
||||
/*
|
||||
* We don't reserve a dynamic address for devices that
|
||||
* don't explicitly request one.
|
||||
*/
|
||||
if (!i3cboardinfo->init_dyn_addr)
|
||||
continue;
|
||||
|
||||
ret = i3c_bus_get_addr_slot_status(&master->bus,
|
||||
i3cboardinfo->init_dyn_addr);
|
||||
if (ret != I3C_ADDR_SLOT_FREE) {
|
||||
ret = -EBUSY;
|
||||
goto err_rstdaa;
|
||||
}
|
||||
|
||||
i3c_bus_set_addr_slot_status(&master->bus,
|
||||
i3cboardinfo->init_dyn_addr,
|
||||
I3C_ADDR_SLOT_I3C_DEV);
|
||||
|
||||
/*
|
||||
* Only try to create/attach devices that have a static
|
||||
* address. Other devices will be created/attached when
|
||||
* DAA happens, and the requested dynamic address will
|
||||
* be set using SETNEWDA once those devices become
|
||||
* addressable.
|
||||
*/
|
||||
|
||||
if (i3cboardinfo->static_addr)
|
||||
i3c_master_early_i3c_dev_add(master, i3cboardinfo);
|
||||
}
|
||||
|
||||
ret = i3c_master_do_daa(master);
|
||||
if (ret)
|
||||
@ -1782,6 +1805,21 @@ static void i3c_master_bus_cleanup(struct i3c_master_controller *master)
|
||||
i3c_master_detach_free_devs(master);
|
||||
}
|
||||
|
||||
static void i3c_master_attach_boardinfo(struct i3c_dev_desc *i3cdev)
|
||||
{
|
||||
struct i3c_master_controller *master = i3cdev->common.master;
|
||||
struct i3c_dev_boardinfo *i3cboardinfo;
|
||||
|
||||
list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) {
|
||||
if (i3cdev->info.pid != i3cboardinfo->pid)
|
||||
continue;
|
||||
|
||||
i3cdev->boardinfo = i3cboardinfo;
|
||||
i3cdev->info.static_addr = i3cboardinfo->static_addr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static struct i3c_dev_desc *
|
||||
i3c_master_search_i3c_dev_duplicate(struct i3c_dev_desc *refdev)
|
||||
{
|
||||
@ -1837,10 +1875,10 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master,
|
||||
if (ret)
|
||||
goto err_detach_dev;
|
||||
|
||||
i3c_master_attach_boardinfo(newdev);
|
||||
|
||||
olddev = i3c_master_search_i3c_dev_duplicate(newdev);
|
||||
if (olddev) {
|
||||
newdev->boardinfo = olddev->boardinfo;
|
||||
newdev->info.static_addr = olddev->info.static_addr;
|
||||
newdev->dev = olddev->dev;
|
||||
if (newdev->dev)
|
||||
newdev->dev->desc = newdev;
|
||||
|
@ -1635,8 +1635,10 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)
|
||||
master->ibi.slots = devm_kcalloc(&pdev->dev, master->ibi.num_slots,
|
||||
sizeof(*master->ibi.slots),
|
||||
GFP_KERNEL);
|
||||
if (!master->ibi.slots)
|
||||
if (!master->ibi.slots) {
|
||||
ret = -ENOMEM;
|
||||
goto err_disable_sysclk;
|
||||
}
|
||||
|
||||
writel(IBIR_THR(1), master->regs + CMD_IBI_THR_CTRL);
|
||||
writel(MST_INT_IBIR_THR, master->regs + MST_IER);
|
||||
|
Loading…
Reference in New Issue
Block a user