Commit b1ac3a4b authored by Przemyslaw Gaj's avatar Przemyslaw Gaj Committed by Boris Brezillon

i3c: add addr and lvr to i2c_dev_desc structure

I need to store address and lvr value for I2C devices without static definition
in DT. This allows secondary master to transmit DEFSLVS command properly.

Main changes between v4 and v5:
- Change in defslvs to use addr and lvr from i2c_dev_desc structure
- Change in CDNS and DW drivers to use addr and lvr from i2c_dev_desc structure
Signed-off-by: default avatarPrzemyslaw Gaj <pgaj@cadence.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
parent fd3f8f31
...@@ -600,6 +600,8 @@ i3c_master_alloc_i2c_dev(struct i3c_master_controller *master, ...@@ -600,6 +600,8 @@ i3c_master_alloc_i2c_dev(struct i3c_master_controller *master,
dev->common.master = master; dev->common.master = master;
dev->boardinfo = boardinfo; dev->boardinfo = boardinfo;
dev->addr = boardinfo->base.addr;
dev->lvr = boardinfo->lvr;
return dev; return dev;
} }
...@@ -918,8 +920,8 @@ int i3c_master_defslvs_locked(struct i3c_master_controller *master) ...@@ -918,8 +920,8 @@ int i3c_master_defslvs_locked(struct i3c_master_controller *master)
desc = defslvs->slaves; desc = defslvs->slaves;
i3c_bus_for_each_i2cdev(bus, i2cdev) { i3c_bus_for_each_i2cdev(bus, i2cdev) {
desc->lvr = i2cdev->boardinfo->lvr; desc->lvr = i2cdev->lvr;
desc->static_addr = i2cdev->boardinfo->base.addr << 1; desc->static_addr = i2cdev->addr << 1;
desc++; desc++;
} }
...@@ -1586,8 +1588,8 @@ static void i3c_master_detach_free_devs(struct i3c_master_controller *master) ...@@ -1586,8 +1588,8 @@ static void i3c_master_detach_free_devs(struct i3c_master_controller *master)
common.node) { common.node) {
i3c_master_detach_i2c_dev(i2cdev); i3c_master_detach_i2c_dev(i2cdev);
i3c_bus_set_addr_slot_status(&master->bus, i3c_bus_set_addr_slot_status(&master->bus,
i2cdev->boardinfo->base.addr, i2cdev->addr,
I3C_ADDR_SLOT_FREE); I3C_ADDR_SLOT_FREE);
i3c_master_free_i2c_dev(i2cdev); i3c_master_free_i2c_dev(i2cdev);
} }
} }
......
...@@ -1033,12 +1033,12 @@ static int dw_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev) ...@@ -1033,12 +1033,12 @@ static int dw_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev)
return -ENOMEM; return -ENOMEM;
data->index = pos; data->index = pos;
master->addrs[pos] = dev->boardinfo->base.addr; master->addrs[pos] = dev->addr;
master->free_pos &= ~BIT(pos); master->free_pos &= ~BIT(pos);
i2c_dev_set_master_data(dev, data); i2c_dev_set_master_data(dev, data);
writel(DEV_ADDR_TABLE_LEGACY_I2C_DEV | writel(DEV_ADDR_TABLE_LEGACY_I2C_DEV |
DEV_ADDR_TABLE_STATIC_ADDR(dev->boardinfo->base.addr), DEV_ADDR_TABLE_STATIC_ADDR(dev->addr),
master->regs + master->regs +
DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index)); DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
......
...@@ -1003,9 +1003,9 @@ static int cdns_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev) ...@@ -1003,9 +1003,9 @@ static int cdns_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev)
master->free_rr_slots &= ~BIT(slot); master->free_rr_slots &= ~BIT(slot);
i2c_dev_set_master_data(dev, data); i2c_dev_set_master_data(dev, data);
writel(prepare_rr0_dev_address(dev->boardinfo->base.addr), writel(prepare_rr0_dev_address(dev->addr),
master->regs + DEV_ID_RR0(data->id)); master->regs + DEV_ID_RR0(data->id));
writel(dev->boardinfo->lvr, master->regs + DEV_ID_RR2(data->id)); writel(dev->lvr, master->regs + DEV_ID_RR2(data->id));
writel(readl(master->regs + DEVS_CTRL) | writel(readl(master->regs + DEVS_CTRL) |
DEVS_CTRL_DEV_ACTIVE(data->id), DEVS_CTRL_DEV_ACTIVE(data->id),
master->regs + DEVS_CTRL); master->regs + DEVS_CTRL);
......
...@@ -71,6 +71,9 @@ struct i2c_dev_boardinfo { ...@@ -71,6 +71,9 @@ struct i2c_dev_boardinfo {
* @common: common part of the I2C device descriptor * @common: common part of the I2C device descriptor
* @boardinfo: pointer to the boardinfo attached to this I2C device * @boardinfo: pointer to the boardinfo attached to this I2C device
* @dev: I2C device object registered to the I2C framework * @dev: I2C device object registered to the I2C framework
* @addr: I2C device address
* @lvr: LVR (Legacy Virtual Register) needed by the I3C core to know about
* the I2C device limitations
* *
* Each I2C device connected on the bus will have an i2c_dev_desc. * Each I2C device connected on the bus will have an i2c_dev_desc.
* This object is created by the core and later attached to the controller * This object is created by the core and later attached to the controller
...@@ -84,6 +87,8 @@ struct i2c_dev_desc { ...@@ -84,6 +87,8 @@ struct i2c_dev_desc {
struct i3c_i2c_dev_desc common; struct i3c_i2c_dev_desc common;
const struct i2c_dev_boardinfo *boardinfo; const struct i2c_dev_boardinfo *boardinfo;
struct i2c_client *dev; struct i2c_client *dev;
u16 addr;
u8 lvr;
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment