All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-i3c@lists.infradead.org,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>
Subject: [PATCH 03/12] i3c: mipi-i3c-hci: Fix DAT/DCT entry sizes
Date: Thu, 21 Sep 2023 08:56:55 +0300	[thread overview]
Message-ID: <20230921055704.1087277-4-jarkko.nikula@linux.intel.com> (raw)
In-Reply-To: <20230921055704.1087277-1-jarkko.nikula@linux.intel.com>

MIPI I3C HCI specification v1.1 describes the ENTRY_SIZE field for the
Device Address Table (DAT) and the Device Characteristics Table (DCT)
section offset registers (DAT_SECTION_OFFSET and DCT_SECTION_OFFSET).
That field is not documented in earlier version.

ENTRY_SIZE value 0 is meant to be backward compatible. For the DAT entry
size it is interpreted as 2 DWORDs (8-bytes) and for the DCT entry size
as 4 DWORDs (16-bytes). Values 1-15 are reserved for future use.

New version I believe fixes also the TABLE_SIZE field description.
Before it was defined in DWORDs which I believe is incorrect since the
DAT/DCT table entry structures, and sizes, are described having
8-bytes/16-bytes entries.

This is more clear in the specification v1.1 which states the TABLE_SIZE
fields are interpreted as number of entries in the DAT/DCT tables. I
believe this same holds also in earlier version, at least it makes more
sense.

Fix code accordingly and let the DAT_entry_size and the DCT_entry_size
variables carry the size as bytes. Which is how it is already
interpreted in the dat_v1.c: hci_dat_v1_init().

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
 drivers/i3c/master/mipi-i3c-hci/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index 8f43ad81fbfd..76a3e6bb3665 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -610,17 +610,17 @@ static int i3c_hci_init(struct i3c_hci *hci)
 	offset = FIELD_GET(DAT_TABLE_OFFSET, regval);
 	hci->DAT_regs = offset ? hci->base_regs + offset : NULL;
 	hci->DAT_entries = FIELD_GET(DAT_TABLE_SIZE, regval);
-	hci->DAT_entry_size = FIELD_GET(DAT_ENTRY_SIZE, regval);
+	hci->DAT_entry_size = FIELD_GET(DAT_ENTRY_SIZE, regval) ? 0 : 8;
 	dev_info(&hci->master.dev, "DAT: %u %u-bytes entries at offset %#x\n",
-		 hci->DAT_entries, hci->DAT_entry_size * 4, offset);
+		 hci->DAT_entries, hci->DAT_entry_size, offset);
 
 	regval = reg_read(DCT_SECTION);
 	offset = FIELD_GET(DCT_TABLE_OFFSET, regval);
 	hci->DCT_regs = offset ? hci->base_regs + offset : NULL;
 	hci->DCT_entries = FIELD_GET(DCT_TABLE_SIZE, regval);
-	hci->DCT_entry_size = FIELD_GET(DCT_ENTRY_SIZE, regval);
+	hci->DCT_entry_size = FIELD_GET(DCT_ENTRY_SIZE, regval) ? 0 : 16;
 	dev_info(&hci->master.dev, "DCT: %u %u-bytes entries at offset %#x\n",
-		 hci->DCT_entries, hci->DCT_entry_size * 4, offset);
+		 hci->DCT_entries, hci->DCT_entry_size, offset);
 
 	regval = reg_read(RING_HEADERS_SECTION);
 	offset = FIELD_GET(RING_HEADERS_OFFSET, regval);
-- 
2.40.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  parent reply	other threads:[~2023-09-21  5:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21  5:56 [PATCH 00/12] i3c: mipi-i3c-hci: Enabling fixes Jarkko Nikula
2023-09-21  5:56 ` [PATCH 01/12] i3c: master: Inherit DMA masks and parameters from parent device Jarkko Nikula
2023-09-21  5:56 ` [PATCH 02/12] i3c: mipi-i3c-hci: Add MODULE_ALIAS Jarkko Nikula
2023-09-21  5:56 ` Jarkko Nikula [this message]
2023-09-21  5:56 ` [PATCH 04/12] i3c: mipi-i3c-hci: Fix out of bounds access in hci_dma_irq_handler Jarkko Nikula
2023-09-21  5:56 ` [PATCH 05/12] i3c: mipi-i3c-hci: Remove BUG() when Ring Abort request times out Jarkko Nikula
2023-09-21  5:56 ` [PATCH 06/12] i3c: mipi-i3c-hci: Set ring start request together with enable Jarkko Nikula
2023-09-21  5:56 ` [PATCH 07/12] i3c: mipi-i3c-hci: Fix race between bus cleanup and interrupt Jarkko Nikula
2023-09-21  5:57 ` [PATCH 08/12] i3c: mipi-i3c-hci: Set number of SW enabled Ring Bundles earlier Jarkko Nikula
2023-09-21  5:57 ` [PATCH 09/12] i3c: mipi-i3c-hci: Do not unmap region not mapped for transfer Jarkko Nikula
2023-09-21  5:57 ` [PATCH 10/12] i3c: mipi-i3c-hci: Fix missing xfer->completion in hci_cmd_v1_daa() Jarkko Nikula
2023-09-21  5:57 ` [PATCH 11/12] i3c: mipi-i3c-hci: Resume controller explicitly Jarkko Nikula
2023-09-21  5:57 ` [PATCH 12/12] i3c: mipi-i3c-hci: Resume controller after aborted transfer Jarkko Nikula
2023-09-25 21:36 ` [PATCH 00/12] i3c: mipi-i3c-hci: Enabling fixes Alexandre Belloni

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=20230921055704.1087277-4-jarkko.nikula@linux.intel.com \
    --to=jarkko.nikula@linux.intel.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-i3c@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.