From: Jeremy Kerr <jk@codeconstruct.com.au>
To: linux-i3c@lists.infradead.org
Cc: Matt Johnston <matt@codeconstruct.com.au>,
Vitor Soares <ivitro@gmail.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Jack Chen <zenghuchen@google.com>,
Billy Tsai <billy_tsai@aspeedtech.com>,
Dylan Hung <dylan_hung@aspeedtech.com>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>
Subject: [PATCH 2/5] i3c: dw: Turn DAT array entry into a struct
Date: Thu, 30 Mar 2023 15:50:33 +0800 [thread overview]
Message-ID: <9dc0d9e2857e851a0cf04819df48e5d31921f83e.1680161823.git.jk@codeconstruct.com.au> (raw)
In-Reply-To: <cover.1680161823.git.jk@codeconstruct.com.au>
In an upcoming change, we will want to store additional data about the
devices we have in the data address table.
Change the type of the DAT entries into a struct, which currently just
has the address data.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
drivers/i3c/master/dw-i3c-master.c | 22 +++++++++++-----------
drivers/i3c/master/dw-i3c-master.h | 11 ++++++++++-
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index cb38ef95f21a..a086d9c5ff35 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -291,7 +291,7 @@ static int dw_i3c_master_get_addr_pos(struct dw_i3c_master *master, u8 addr)
int pos;
for (pos = 0; pos < master->maxdevs; pos++) {
- if (addr == master->addrs[pos])
+ if (addr == master->devs[pos].addr)
return pos;
}
@@ -769,7 +769,7 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
if (ret < 0)
return -ENOSPC;
- master->addrs[pos] = ret;
+ master->devs[pos].addr = ret;
p = even_parity(ret);
last_addr = ret;
ret |= (p << 7);
@@ -806,7 +806,7 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
for (pos = 0; pos < master->maxdevs; pos++) {
if (newdevs & BIT(pos))
- i3c_master_add_i3c_dev_locked(m, master->addrs[pos]);
+ i3c_master_add_i3c_dev_locked(m, master->devs[pos].addr);
}
dw_i3c_master_free_xfer(xfer);
@@ -905,11 +905,11 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev,
master->regs +
DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
- master->addrs[data->index] = 0;
+ master->devs[data->index].addr = 0;
master->free_pos |= BIT(data->index);
data->index = pos;
- master->addrs[pos] = dev->info.dyn_addr;
+ master->devs[pos].addr = dev->info.dyn_addr;
master->free_pos &= ~BIT(pos);
}
@@ -917,7 +917,7 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev,
master->regs +
DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
- master->addrs[data->index] = dev->info.dyn_addr;
+ master->devs[data->index].addr = dev->info.dyn_addr;
return 0;
}
@@ -938,11 +938,11 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev)
return -ENOMEM;
data->index = pos;
- master->addrs[pos] = dev->info.dyn_addr ? : dev->info.static_addr;
+ master->devs[pos].addr = dev->info.dyn_addr ? : dev->info.static_addr;
master->free_pos &= ~BIT(pos);
i3c_dev_set_master_data(dev, data);
- writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->addrs[pos]),
+ writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr),
master->regs +
DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
@@ -960,7 +960,7 @@ static void dw_i3c_master_detach_i3c_dev(struct i3c_dev_desc *dev)
DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
i3c_dev_set_master_data(dev, NULL);
- master->addrs[data->index] = 0;
+ master->devs[data->index].addr = 0;
master->free_pos |= BIT(data->index);
kfree(data);
}
@@ -1046,7 +1046,7 @@ static int dw_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev)
return -ENOMEM;
data->index = pos;
- master->addrs[pos] = dev->addr;
+ master->devs[pos].addr = dev->addr;
master->free_pos &= ~BIT(pos);
i2c_dev_set_master_data(dev, data);
@@ -1069,7 +1069,7 @@ static void dw_i3c_master_detach_i2c_dev(struct i2c_dev_desc *dev)
DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
i2c_dev_set_master_data(dev, NULL);
- master->addrs[data->index] = 0;
+ master->devs[data->index].addr = 0;
master->free_pos |= BIT(data->index);
kfree(data);
}
diff --git a/drivers/i3c/master/dw-i3c-master.h b/drivers/i3c/master/dw-i3c-master.h
index 9f1e48211aa4..dd0b77e2c66a 100644
--- a/drivers/i3c/master/dw-i3c-master.h
+++ b/drivers/i3c/master/dw-i3c-master.h
@@ -17,6 +17,10 @@ struct dw_i3c_master_caps {
u8 datafifodepth;
};
+struct dw_i3c_dat_entry {
+ u8 addr;
+};
+
struct dw_i3c_master {
struct i3c_master_controller base;
u16 maxdevs;
@@ -33,7 +37,12 @@ struct dw_i3c_master {
struct clk *core_clk;
char version[5];
char type[5];
- u8 addrs[DW_I3C_MAX_DEVS];
+
+ /*
+ * Per-device hardware data, used to manage the device address table
+ * (DAT)
+ */
+ struct dw_i3c_dat_entry devs[DW_I3C_MAX_DEVS];
/* platform-specific data */
const struct dw_i3c_platform_ops *platform_ops;
--
2.39.2
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2023-03-30 13:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 7:50 [PATCH 0/5] i3c: dw,ast2600: Add In-Band Interrupt support Jeremy Kerr
2023-03-30 7:50 ` [PATCH 1/5] i3c: dw: Create a generic fifo read function Jeremy Kerr
2023-03-30 19:18 ` Ben Dooks
2023-03-31 2:16 ` Jeremy Kerr
2023-03-30 7:50 ` Jeremy Kerr [this message]
2023-03-30 7:50 ` [PATCH 3/5] i3c: dw: Add support for in-band interrupts Jeremy Kerr
2023-03-30 7:50 ` [PATCH 4/5] i3c: dw: Add a platform facility for IBI PEC workarounds Jeremy Kerr
2023-03-30 7:50 ` [PATCH 5/5] i3c: ast2600: enable IBI support Jeremy Kerr
2023-04-05 2:27 ` [PATCH 0/5] i3c: dw,ast2600: Add In-Band Interrupt support Joel Stanley
2023-04-27 22:35 ` Alexandre Belloni
2023-04-28 0:01 ` Jeremy Kerr
2023-04-28 6:51 ` Alexandre Belloni
2023-04-28 7:34 ` Jeremy Kerr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9dc0d9e2857e851a0cf04819df48e5d31921f83e.1680161823.git.jk@codeconstruct.com.au \
--to=jk@codeconstruct.com.au \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@aj.id.au \
--cc=billy_tsai@aspeedtech.com \
--cc=dylan_hung@aspeedtech.com \
--cc=ivitro@gmail.com \
--cc=joel@jms.id.au \
--cc=linux-i3c@lists.infradead.org \
--cc=matt@codeconstruct.com.au \
--cc=zenghuchen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox