[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241017150330.3035568-5-Shyam-sundar.S-k@amd.com>
Date: Thu, 17 Oct 2024 20:33:28 +0530
From: Shyam Sundar S K <Shyam-sundar.S-k@....com>
To: Alexandre Belloni <alexandre.belloni@...tlin.com>, Jarkko Nikula
<jarkko.nikula@...ux.intel.com>
CC: <Sanket.Goswami@....com>, <linux-i3c@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, Shyam Sundar S K <Shyam-sundar.S-k@....com>
Subject: [PATCH 4/6] i3c: master: Add a routine to include the I3C SPD device
Implement the i3c_master_add_spd_dev() function in the I3C master to
handle SPD (Serial Presence Detect) device creation and map the board
information into the I3C device structure.
Co-developed-by: Sanket Goswami <Sanket.Goswami@....com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@....com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@....com>
---
drivers/i3c/master.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 20b83ca52d31..4f149519170e 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -1657,6 +1657,45 @@ i3c_master_register_new_i3c_devs(struct i3c_master_controller *master)
}
}
+static int i3c_master_add_spd_dev(struct i3c_master_controller *master,
+ struct i3c_dev_boardinfo *boardinfo)
+{
+ struct i3c_dev_desc *i3cdev;
+ int ret;
+
+ list_for_each_entry(boardinfo, &master->boardinfo.i3c, node) {
+ struct i3c_device_info info = {
+ .static_addr = boardinfo->static_addr,
+ };
+
+ ret = i3c_bus_get_addr_slot_status(&master->bus, boardinfo->static_addr);
+ if (ret != I3C_ADDR_SLOT_FREE)
+ return -EBUSY;
+
+ i3cdev = i3c_master_alloc_i3c_dev(master, &info);
+ if (IS_ERR(i3cdev))
+ return -ENOMEM;
+
+ i3cdev->boardinfo = boardinfo;
+ ret = i3c_master_attach_i3c_dev(master, i3cdev);
+ if (ret)
+ goto err_free_dev;
+
+ i3cdev->info.pid = i3cdev->boardinfo->pid;
+ i3cdev->info.dyn_addr = i3cdev->boardinfo->init_dyn_addr;
+
+ i3c_bus_normaluse_lock(&master->bus);
+ i3c_master_register_new_i3c_devs(master);
+ i3c_bus_normaluse_unlock(&master->bus);
+ }
+
+ return 0;
+
+err_free_dev:
+ i3c_master_free_i3c_dev(i3cdev);
+ return ret;
+}
+
/**
* i3c_master_do_daa() - do a DAA (Dynamic Address Assignment)
* @master: master doing the DAA
@@ -1868,6 +1907,8 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
goto err_bus_cleanup;
}
+ i3c_master_add_spd_dev(master, i3cboardinfo);
+
if (master->ops->set_speed) {
ret = master->ops->set_speed(master, I3C_OPEN_DRAIN_SLOW_SPEED);
if (ret)
--
2.34.1
Powered by blists - more mailing lists