aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrzemyslaw Gaj <pgaj@cadence.com>2019-06-22 16:54:59 -0400
committerBoris Brezillon <boris.brezillon@collabora.com>2019-08-11 04:48:28 -0400
commitb1ac3a4b9aa2f68d498824f1235788e67b51b486 (patch)
tree2c2642336eaf927456d1fc0582c3cf35f94d8b30
parentfd3f8f3118c66c492c5fe05568569d26db258fbd (diff)
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: Przemyslaw Gaj <pgaj@cadence.com> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
-rw-r--r--drivers/i3c/master.c10
-rw-r--r--drivers/i3c/master/dw-i3c-master.c4
-rw-r--r--drivers/i3c/master/i3c-master-cdns.c4
-rw-r--r--include/linux/i3c/master.h5
4 files changed, 15 insertions, 8 deletions
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 87d0f349dd37..a38fdf325d30 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -600,6 +600,8 @@ i3c_master_alloc_i2c_dev(struct i3c_master_controller *master,
600 600
601 dev->common.master = master; 601 dev->common.master = master;
602 dev->boardinfo = boardinfo; 602 dev->boardinfo = boardinfo;
603 dev->addr = boardinfo->base.addr;
604 dev->lvr = boardinfo->lvr;
603 605
604 return dev; 606 return dev;
605} 607}
@@ -918,8 +920,8 @@ int i3c_master_defslvs_locked(struct i3c_master_controller *master)
918 920
919 desc = defslvs->slaves; 921 desc = defslvs->slaves;
920 i3c_bus_for_each_i2cdev(bus, i2cdev) { 922 i3c_bus_for_each_i2cdev(bus, i2cdev) {
921 desc->lvr = i2cdev->boardinfo->lvr; 923 desc->lvr = i2cdev->lvr;
922 desc->static_addr = i2cdev->boardinfo->base.addr << 1; 924 desc->static_addr = i2cdev->addr << 1;
923 desc++; 925 desc++;
924 } 926 }
925 927
@@ -1586,8 +1588,8 @@ static void i3c_master_detach_free_devs(struct i3c_master_controller *master)
1586 common.node) { 1588 common.node) {
1587 i3c_master_detach_i2c_dev(i2cdev); 1589 i3c_master_detach_i2c_dev(i2cdev);
1588 i3c_bus_set_addr_slot_status(&master->bus, 1590 i3c_bus_set_addr_slot_status(&master->bus,
1589 i2cdev->boardinfo->base.addr, 1591 i2cdev->addr,
1590 I3C_ADDR_SLOT_FREE); 1592 I3C_ADDR_SLOT_FREE);
1591 i3c_master_free_i2c_dev(i2cdev); 1593 i3c_master_free_i2c_dev(i2cdev);
1592 } 1594 }
1593} 1595}
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 09912d75c6d5..b0ff0e12d84c 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -1033,12 +1033,12 @@ static int dw_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev)
1033 return -ENOMEM; 1033 return -ENOMEM;
1034 1034
1035 data->index = pos; 1035 data->index = pos;
1036 master->addrs[pos] = dev->boardinfo->base.addr; 1036 master->addrs[pos] = dev->addr;
1037 master->free_pos &= ~BIT(pos); 1037 master->free_pos &= ~BIT(pos);
1038 i2c_dev_set_master_data(dev, data); 1038 i2c_dev_set_master_data(dev, data);
1039 1039
1040 writel(DEV_ADDR_TABLE_LEGACY_I2C_DEV | 1040 writel(DEV_ADDR_TABLE_LEGACY_I2C_DEV |
1041 DEV_ADDR_TABLE_STATIC_ADDR(dev->boardinfo->base.addr), 1041 DEV_ADDR_TABLE_STATIC_ADDR(dev->addr),
1042 master->regs + 1042 master->regs +
1043 DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index)); 1043 DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
1044 1044
diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c
index c8adf1eb7e1e..10db0bf0655a 100644
--- a/drivers/i3c/master/i3c-master-cdns.c
+++ b/drivers/i3c/master/i3c-master-cdns.c
@@ -1003,9 +1003,9 @@ static int cdns_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev)
1003 master->free_rr_slots &= ~BIT(slot); 1003 master->free_rr_slots &= ~BIT(slot);
1004 i2c_dev_set_master_data(dev, data); 1004 i2c_dev_set_master_data(dev, data);
1005 1005
1006 writel(prepare_rr0_dev_address(dev->boardinfo->base.addr), 1006 writel(prepare_rr0_dev_address(dev->addr),
1007 master->regs + DEV_ID_RR0(data->id)); 1007 master->regs + DEV_ID_RR0(data->id));
1008 writel(dev->boardinfo->lvr, master->regs + DEV_ID_RR2(data->id)); 1008 writel(dev->lvr, master->regs + DEV_ID_RR2(data->id));
1009 writel(readl(master->regs + DEVS_CTRL) | 1009 writel(readl(master->regs + DEVS_CTRL) |
1010 DEVS_CTRL_DEV_ACTIVE(data->id), 1010 DEVS_CTRL_DEV_ACTIVE(data->id),
1011 master->regs + DEVS_CTRL); 1011 master->regs + DEVS_CTRL);
diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
index 1f08fa8d69d2..9cb39d901cd5 100644
--- a/include/linux/i3c/master.h
+++ b/include/linux/i3c/master.h
@@ -71,6 +71,9 @@ struct i2c_dev_boardinfo {
71 * @common: common part of the I2C device descriptor 71 * @common: common part of the I2C device descriptor
72 * @boardinfo: pointer to the boardinfo attached to this I2C device 72 * @boardinfo: pointer to the boardinfo attached to this I2C device
73 * @dev: I2C device object registered to the I2C framework 73 * @dev: I2C device object registered to the I2C framework
74 * @addr: I2C device address
75 * @lvr: LVR (Legacy Virtual Register) needed by the I3C core to know about
76 * the I2C device limitations
74 * 77 *
75 * Each I2C device connected on the bus will have an i2c_dev_desc. 78 * Each I2C device connected on the bus will have an i2c_dev_desc.
76 * This object is created by the core and later attached to the controller 79 * This object is created by the core and later attached to the controller
@@ -84,6 +87,8 @@ struct i2c_dev_desc {
84 struct i3c_i2c_dev_desc common; 87 struct i3c_i2c_dev_desc common;
85 const struct i2c_dev_boardinfo *boardinfo; 88 const struct i2c_dev_boardinfo *boardinfo;
86 struct i2c_client *dev; 89 struct i2c_client *dev;
90 u16 addr;
91 u8 lvr;
87}; 92};
88 93
89/** 94/**