* [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support
@ 2024-08-29 9:17 Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List Shyam Sundar S K
` (7 more replies)
0 siblings, 8 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2024-08-29 9:17 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Shyam Sundar S K
The AMD SoC includes an I3C IP block as part of the Fusion Controller Hub
(FCH). This series introduces the initial driver support to enable the I3C
IP block on AMD's latest processors.
Currently, the code is closely tied to dt-bindings. This initial set aims
to decouple some of these bindings by adding the MIPI ID, allowing the
current driver to support ACPI-enabled x86 systems.
It was discovered that the AMD I3C controller has several hardware issues,
including:
- Non-functional DMA mode (defaulting to PIO mode)
- Issues with Open-Drain (OD) and Push-Pull (PP) timing parameters
- Command response buffer threshold values
All of these issues have been addressed in this series.
v5->v6:
-------
- Add Reviewed-by tag
- Update to variable name from "pio_mode_support" to "mode_selector"
v4->v5:
-------
- Add Andy & Jarkko's Reviewed-by tag
- Handle major/minor number check for PIO MODE support.
v3->v4:
-------
- use AMDI5017 as the _HID
- use quirks bits within the .driver_data()
- Add Reviewed-by tag
v2->v3:
-------
- use MODULE_DEVICE_TABLE()
- address comments from Jarkko
- split version check and quirks into separate patches.
v1->v2:
-------
- Address LKP reported problems
- Guard boot_cpu_data usage with CONFIG_X86
Shyam Sundar S K (6):
i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List
i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1
i3c: mipi-i3c-hci: Add a quirk to set PIO mode
i3c: mipi-i3c-hci: Relocate helper macros to HCI header file
i3c: mipi-i3c-hci: Add a quirk to set timing parameters
i3c: mipi-i3c-hci: Add a quirk to set Response buffer threshold
drivers/i3c/master/mipi-i3c-hci/Makefile | 3 +-
drivers/i3c/master/mipi-i3c-hci/core.c | 36 ++++++++++++----
drivers/i3c/master/mipi-i3c-hci/hci.h | 10 +++++
drivers/i3c/master/mipi-i3c-hci/hci_quirks.c | 44 ++++++++++++++++++++
4 files changed, 83 insertions(+), 10 deletions(-)
create mode 100644 drivers/i3c/master/mipi-i3c-hci/hci_quirks.c
--
2.25.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
@ 2024-08-29 9:17 ` Shyam Sundar S K
2024-08-29 11:04 ` Andy Shevchenko
2024-09-02 6:17 ` Jarkko Nikula
2024-08-29 9:17 ` [PATCH v6 2/6] i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1 Shyam Sundar S K
` (6 subsequent siblings)
7 siblings, 2 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2024-08-29 9:17 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Shyam Sundar S K, Andy Shevchenko
The current driver code lacks the necessary plumbing for ACPI IDs,
preventing the mipi-i3c-hci driver from being loaded on x86
platforms that advertise I3C ACPI support.
Add the AMDI5017 ACPI ID to the list of supported IDs.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i3c/master/mipi-i3c-hci/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index 4e7d6a43ee9b..07de1cecfa30 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -834,12 +834,19 @@ static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
};
MODULE_DEVICE_TABLE(of, i3c_hci_of_match);
+static const struct acpi_device_id i3c_hci_acpi_match[] = {
+ { "AMDI5017" },
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, i3c_hci_acpi_match);
+
static struct platform_driver i3c_hci_driver = {
.probe = i3c_hci_probe,
.remove_new = i3c_hci_remove,
.driver = {
.name = "mipi-i3c-hci",
.of_match_table = of_match_ptr(i3c_hci_of_match),
+ .acpi_match_table = i3c_hci_acpi_match,
},
};
module_platform_driver(i3c_hci_driver);
--
2.25.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v6 2/6] i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List Shyam Sundar S K
@ 2024-08-29 9:17 ` Shyam Sundar S K
2024-09-02 6:15 ` Jarkko Nikula
2024-08-29 9:17 ` [PATCH v6 3/6] i3c: mipi-i3c-hci: Add a quirk to set PIO mode Shyam Sundar S K
` (5 subsequent siblings)
7 siblings, 1 reply; 12+ messages in thread
From: Shyam Sundar S K @ 2024-08-29 9:17 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Shyam Sundar S K
The HC_CONTROL_PIO_MODE bit was introduced in the HC_CONTROL register
starting from version 1.1. Therefore, checking the HC_CONTROL_PIO_MODE bit
on hardware that adheres to older specification revisions (i.e., versions
earlier than 1.1) is incorrect. To address this, add an additional check
to read the HCI version before attempting to read the HC_CONTROL_PIO_MODE
status.
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i3c/master/mipi-i3c-hci/core.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index 07de1cecfa30..a6781cfeebb8 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -630,8 +630,8 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)
static int i3c_hci_init(struct i3c_hci *hci)
{
+ bool size_in_dwords, mode_selector;
u32 regval, offset;
- bool size_in_dwords;
int ret;
/* Validate HCI hardware version */
@@ -753,10 +753,13 @@ static int i3c_hci_init(struct i3c_hci *hci)
return -EINVAL;
}
+ mode_selector = hci->version_major > 1 ||
+ (hci->version_major == 1 && hci->version_minor > 0);
+
/* Try activating DMA operations first */
if (hci->RHS_regs) {
reg_clear(HC_CONTROL, HC_CONTROL_PIO_MODE);
- if (reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE) {
+ if (mode_selector && (reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE)) {
dev_err(&hci->master.dev, "PIO mode is stuck\n");
ret = -EIO;
} else {
@@ -768,7 +771,7 @@ static int i3c_hci_init(struct i3c_hci *hci)
/* If no DMA, try PIO */
if (!hci->io && hci->PIO_regs) {
reg_set(HC_CONTROL, HC_CONTROL_PIO_MODE);
- if (!(reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE)) {
+ if (mode_selector && !(reg_read(HC_CONTROL) & HC_CONTROL_PIO_MODE)) {
dev_err(&hci->master.dev, "DMA mode is stuck\n");
ret = -EIO;
} else {
--
2.25.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v6 3/6] i3c: mipi-i3c-hci: Add a quirk to set PIO mode
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 2/6] i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1 Shyam Sundar S K
@ 2024-08-29 9:17 ` Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 4/6] i3c: mipi-i3c-hci: Relocate helper macros to HCI header file Shyam Sundar S K
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2024-08-29 9:17 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Shyam Sundar S K
The AMD HCI controller currently only supports PIO mode but exposes DMA
rings to the OS, which leads to the controller being configured in DMA
mode. To address this, add a quirk to avoid configuring the controller in
DMA mode and default to PIO mode.
Additionally, introduce a generic quirk infrastructure to the mipi-i3c-hci
driver to facilitate seamless future quirk additions.
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Co-developed-by: Krishnamoorthi M <krishnamoorthi.m@amd.com>
Signed-off-by: Krishnamoorthi M <krishnamoorthi.m@amd.com>
Co-developed-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i3c/master/mipi-i3c-hci/core.c | 8 +++++++-
drivers/i3c/master/mipi-i3c-hci/hci.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index a6781cfeebb8..23abf91b277b 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -756,6 +756,10 @@ static int i3c_hci_init(struct i3c_hci *hci)
mode_selector = hci->version_major > 1 ||
(hci->version_major == 1 && hci->version_minor > 0);
+ /* Quirk for HCI_QUIRK_PIO_MODE on AMD platforms */
+ if (hci->quirks & HCI_QUIRK_PIO_MODE)
+ hci->RHS_regs = NULL;
+
/* Try activating DMA operations first */
if (hci->RHS_regs) {
reg_clear(HC_CONTROL, HC_CONTROL_PIO_MODE);
@@ -806,6 +810,8 @@ static int i3c_hci_probe(struct platform_device *pdev)
/* temporary for dev_printk's, to be replaced in i3c_master_register */
hci->master.dev.init_name = dev_name(&pdev->dev);
+ hci->quirks = (unsigned long)device_get_match_data(&pdev->dev);
+
ret = i3c_hci_init(hci);
if (ret)
return ret;
@@ -838,7 +844,7 @@ static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
MODULE_DEVICE_TABLE(of, i3c_hci_of_match);
static const struct acpi_device_id i3c_hci_acpi_match[] = {
- { "AMDI5017" },
+ { "AMDI5017", HCI_QUIRK_PIO_MODE },
{}
};
MODULE_DEVICE_TABLE(acpi, i3c_hci_acpi_match);
diff --git a/drivers/i3c/master/mipi-i3c-hci/hci.h b/drivers/i3c/master/mipi-i3c-hci/hci.h
index f94d95e024be..c56b838fb431 100644
--- a/drivers/i3c/master/mipi-i3c-hci/hci.h
+++ b/drivers/i3c/master/mipi-i3c-hci/hci.h
@@ -135,6 +135,7 @@ struct i3c_hci_dev_data {
/* list of quirks */
#define HCI_QUIRK_RAW_CCC BIT(1) /* CCC framing must be explicit */
+#define HCI_QUIRK_PIO_MODE BIT(2) /* Set PIO mode for AMD platforms */
/* global functions */
--
2.25.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v6 4/6] i3c: mipi-i3c-hci: Relocate helper macros to HCI header file
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
` (2 preceding siblings ...)
2024-08-29 9:17 ` [PATCH v6 3/6] i3c: mipi-i3c-hci: Add a quirk to set PIO mode Shyam Sundar S K
@ 2024-08-29 9:17 ` Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 5/6] i3c: mipi-i3c-hci: Add a quirk to set timing parameters Shyam Sundar S K
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2024-08-29 9:17 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Shyam Sundar S K
The reg_* helper macros are currently limited to core.c. Moving them to
hci.h will allow their functionality to be utilized in other files outside
of core.c.
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Co-developed-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i3c/master/mipi-i3c-hci/core.c | 6 ------
drivers/i3c/master/mipi-i3c-hci/hci.h | 5 +++++
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index 23abf91b277b..c03e86690073 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -12,7 +12,6 @@
#include <linux/errno.h>
#include <linux/i3c/master.h>
#include <linux/interrupt.h>
-#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -27,11 +26,6 @@
* Host Controller Capabilities and Operation Registers
*/
-#define reg_read(r) readl(hci->base_regs + (r))
-#define reg_write(r, v) writel(v, hci->base_regs + (r))
-#define reg_set(r, v) reg_write(r, reg_read(r) | (v))
-#define reg_clear(r, v) reg_write(r, reg_read(r) & ~(v))
-
#define HCI_VERSION 0x00 /* HCI Version (in BCD) */
#define HC_CONTROL 0x04
diff --git a/drivers/i3c/master/mipi-i3c-hci/hci.h b/drivers/i3c/master/mipi-i3c-hci/hci.h
index c56b838fb431..76658789b018 100644
--- a/drivers/i3c/master/mipi-i3c-hci/hci.h
+++ b/drivers/i3c/master/mipi-i3c-hci/hci.h
@@ -10,6 +10,7 @@
#ifndef HCI_H
#define HCI_H
+#include <linux/io.h>
/* Handy logging macro to save on line length */
#define DBG(x, ...) pr_devel("%s: " x "\n", __func__, ##__VA_ARGS__)
@@ -26,6 +27,10 @@
#define W2_BIT_(x) BIT((x) - 64)
#define W3_BIT_(x) BIT((x) - 96)
+#define reg_read(r) readl(hci->base_regs + (r))
+#define reg_write(r, v) writel(v, hci->base_regs + (r))
+#define reg_set(r, v) reg_write(r, reg_read(r) | (v))
+#define reg_clear(r, v) reg_write(r, reg_read(r) & ~(v))
struct hci_cmd_ops;
--
2.25.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v6 5/6] i3c: mipi-i3c-hci: Add a quirk to set timing parameters
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
` (3 preceding siblings ...)
2024-08-29 9:17 ` [PATCH v6 4/6] i3c: mipi-i3c-hci: Relocate helper macros to HCI header file Shyam Sundar S K
@ 2024-08-29 9:17 ` Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 6/6] i3c: mipi-i3c-hci: Add a quirk to set Response buffer threshold Shyam Sundar S K
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2024-08-29 9:17 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Shyam Sundar S K
The AMD HCI controller is currently unstable at 12.5 MHz. To address this,
a quirk is added to configure the clock rate to 9 MHz as a workaround,
with proportional adjustments to the Open-Drain (OD) and Push-Pull (PP)
values.
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Co-developed-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i3c/master/mipi-i3c-hci/Makefile | 3 +-
drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++-
drivers/i3c/master/mipi-i3c-hci/hci.h | 2 ++
drivers/i3c/master/mipi-i3c-hci/hci_quirks.c | 33 ++++++++++++++++++++
4 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 drivers/i3c/master/mipi-i3c-hci/hci_quirks.c
diff --git a/drivers/i3c/master/mipi-i3c-hci/Makefile b/drivers/i3c/master/mipi-i3c-hci/Makefile
index a658e7b8262c..1f8cd5c48fde 100644
--- a/drivers/i3c/master/mipi-i3c-hci/Makefile
+++ b/drivers/i3c/master/mipi-i3c-hci/Makefile
@@ -3,4 +3,5 @@
obj-$(CONFIG_MIPI_I3C_HCI) += mipi-i3c-hci.o
mipi-i3c-hci-y := core.o ext_caps.o pio.o dma.o \
cmd_v1.o cmd_v2.o \
- dat_v1.o dct_v1.o
+ dat_v1.o dct_v1.o \
+ hci_quirks.o
diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index c03e86690073..f9ce0ee2cfd5 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -785,6 +785,10 @@ static int i3c_hci_init(struct i3c_hci *hci)
return ret;
}
+ /* Configure OD and PP timings for AMD platforms */
+ if (hci->quirks & HCI_QUIRK_OD_PP_TIMING)
+ amd_set_od_pp_timing(hci);
+
return 0;
}
@@ -838,7 +842,7 @@ static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
MODULE_DEVICE_TABLE(of, i3c_hci_of_match);
static const struct acpi_device_id i3c_hci_acpi_match[] = {
- { "AMDI5017", HCI_QUIRK_PIO_MODE },
+ { "AMDI5017", HCI_QUIRK_PIO_MODE | HCI_QUIRK_OD_PP_TIMING },
{}
};
MODULE_DEVICE_TABLE(acpi, i3c_hci_acpi_match);
diff --git a/drivers/i3c/master/mipi-i3c-hci/hci.h b/drivers/i3c/master/mipi-i3c-hci/hci.h
index 76658789b018..361e1366fe38 100644
--- a/drivers/i3c/master/mipi-i3c-hci/hci.h
+++ b/drivers/i3c/master/mipi-i3c-hci/hci.h
@@ -141,11 +141,13 @@ struct i3c_hci_dev_data {
/* list of quirks */
#define HCI_QUIRK_RAW_CCC BIT(1) /* CCC framing must be explicit */
#define HCI_QUIRK_PIO_MODE BIT(2) /* Set PIO mode for AMD platforms */
+#define HCI_QUIRK_OD_PP_TIMING BIT(3) /* Set OD and PP timings for AMD platforms */
/* global functions */
void mipi_i3c_hci_resume(struct i3c_hci *hci);
void mipi_i3c_hci_pio_reset(struct i3c_hci *hci);
void mipi_i3c_hci_dct_index_reset(struct i3c_hci *hci);
+void amd_set_od_pp_timing(struct i3c_hci *hci);
#endif
diff --git a/drivers/i3c/master/mipi-i3c-hci/hci_quirks.c b/drivers/i3c/master/mipi-i3c-hci/hci_quirks.c
new file mode 100644
index 000000000000..e8ea4d101f66
--- /dev/null
+++ b/drivers/i3c/master/mipi-i3c-hci/hci_quirks.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * I3C HCI Quirks
+ *
+ * Copyright 2024 Advanced Micro Devices, Inc.
+ *
+ * Authors: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
+ * Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
+ */
+
+#include <linux/i3c/master.h>
+#include "hci.h"
+
+/* Timing registers */
+#define HCI_SCL_I3C_OD_TIMING 0x214
+#define HCI_SCL_I3C_PP_TIMING 0x218
+#define HCI_SDA_HOLD_SWITCH_DLY_TIMING 0x230
+
+/* Timing values to configure 9MHz frequency */
+#define AMD_SCL_I3C_OD_TIMING 0x00cf00cf
+#define AMD_SCL_I3C_PP_TIMING 0x00160016
+
+void amd_set_od_pp_timing(struct i3c_hci *hci)
+{
+ u32 data;
+
+ reg_write(HCI_SCL_I3C_OD_TIMING, AMD_SCL_I3C_OD_TIMING);
+ reg_write(HCI_SCL_I3C_PP_TIMING, AMD_SCL_I3C_PP_TIMING);
+ data = reg_read(HCI_SDA_HOLD_SWITCH_DLY_TIMING);
+ /* Configure maximum TX hold time */
+ data |= W0_MASK(18, 16);
+ reg_write(HCI_SDA_HOLD_SWITCH_DLY_TIMING, data);
+}
--
2.25.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v6 6/6] i3c: mipi-i3c-hci: Add a quirk to set Response buffer threshold
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
` (4 preceding siblings ...)
2024-08-29 9:17 ` [PATCH v6 5/6] i3c: mipi-i3c-hci: Add a quirk to set timing parameters Shyam Sundar S K
@ 2024-08-29 9:17 ` Shyam Sundar S K
2024-09-03 19:41 ` [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
2024-09-05 16:36 ` Alexandre Belloni
7 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2024-08-29 9:17 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Shyam Sundar S K
The current driver sets the response buffer threshold value to 1
(N+1, 2 DWORDS) in the QUEUE THRESHOLD register. However, the AMD
I3C controller only generates interrupts when the response buffer
threshold value is set to 0 (1 DWORD).
Therefore, a quirk is added to set the response buffer threshold value
to 0.
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Co-developed-by: Krishnamoorthi M <krishnamoorthi.m@amd.com>
Signed-off-by: Krishnamoorthi M <krishnamoorthi.m@amd.com>
Co-developed-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++++-
drivers/i3c/master/mipi-i3c-hci/hci.h | 2 ++
drivers/i3c/master/mipi-i3c-hci/hci_quirks.c | 11 +++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index f9ce0ee2cfd5..a82c47c9986d 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -146,6 +146,10 @@ static int i3c_hci_bus_init(struct i3c_master_controller *m)
if (ret)
return ret;
+ /* Set RESP_BUF_THLD to 0(n) to get 1(n+1) response */
+ if (hci->quirks & HCI_QUIRK_RESP_BUF_THLD)
+ amd_set_resp_buf_thld(hci);
+
reg_set(HC_CONTROL, HC_CONTROL_BUS_ENABLE);
DBG("HC_CONTROL = %#x", reg_read(HC_CONTROL));
@@ -842,7 +846,7 @@ static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
MODULE_DEVICE_TABLE(of, i3c_hci_of_match);
static const struct acpi_device_id i3c_hci_acpi_match[] = {
- { "AMDI5017", HCI_QUIRK_PIO_MODE | HCI_QUIRK_OD_PP_TIMING },
+ { "AMDI5017", HCI_QUIRK_PIO_MODE | HCI_QUIRK_OD_PP_TIMING | HCI_QUIRK_RESP_BUF_THLD },
{}
};
MODULE_DEVICE_TABLE(acpi, i3c_hci_acpi_match);
diff --git a/drivers/i3c/master/mipi-i3c-hci/hci.h b/drivers/i3c/master/mipi-i3c-hci/hci.h
index 361e1366fe38..aaa47ac47381 100644
--- a/drivers/i3c/master/mipi-i3c-hci/hci.h
+++ b/drivers/i3c/master/mipi-i3c-hci/hci.h
@@ -142,6 +142,7 @@ struct i3c_hci_dev_data {
#define HCI_QUIRK_RAW_CCC BIT(1) /* CCC framing must be explicit */
#define HCI_QUIRK_PIO_MODE BIT(2) /* Set PIO mode for AMD platforms */
#define HCI_QUIRK_OD_PP_TIMING BIT(3) /* Set OD and PP timings for AMD platforms */
+#define HCI_QUIRK_RESP_BUF_THLD BIT(4) /* Set resp buf thld to 0 for AMD platforms */
/* global functions */
@@ -149,5 +150,6 @@ void mipi_i3c_hci_resume(struct i3c_hci *hci);
void mipi_i3c_hci_pio_reset(struct i3c_hci *hci);
void mipi_i3c_hci_dct_index_reset(struct i3c_hci *hci);
void amd_set_od_pp_timing(struct i3c_hci *hci);
+void amd_set_resp_buf_thld(struct i3c_hci *hci);
#endif
diff --git a/drivers/i3c/master/mipi-i3c-hci/hci_quirks.c b/drivers/i3c/master/mipi-i3c-hci/hci_quirks.c
index e8ea4d101f66..3b9c6e76c536 100644
--- a/drivers/i3c/master/mipi-i3c-hci/hci_quirks.c
+++ b/drivers/i3c/master/mipi-i3c-hci/hci_quirks.c
@@ -20,6 +20,8 @@
#define AMD_SCL_I3C_OD_TIMING 0x00cf00cf
#define AMD_SCL_I3C_PP_TIMING 0x00160016
+#define QUEUE_THLD_CTRL 0xD0
+
void amd_set_od_pp_timing(struct i3c_hci *hci)
{
u32 data;
@@ -31,3 +33,12 @@ void amd_set_od_pp_timing(struct i3c_hci *hci)
data |= W0_MASK(18, 16);
reg_write(HCI_SDA_HOLD_SWITCH_DLY_TIMING, data);
}
+
+void amd_set_resp_buf_thld(struct i3c_hci *hci)
+{
+ u32 data;
+
+ data = reg_read(QUEUE_THLD_CTRL);
+ data = data & ~W0_MASK(15, 8);
+ reg_write(QUEUE_THLD_CTRL, data);
+}
--
2.25.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List
2024-08-29 9:17 ` [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List Shyam Sundar S K
@ 2024-08-29 11:04 ` Andy Shevchenko
2024-09-02 6:17 ` Jarkko Nikula
1 sibling, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2024-08-29 11:04 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Alexandre Belloni, Jarkko Nikula, Guruvendra Punugupati,
Krishnamoorthi M, linux-i3c, linux-kernel
On Thu, Aug 29, 2024 at 02:47:08PM +0530, Shyam Sundar S K wrote:
> The current driver code lacks the necessary plumbing for ACPI IDs,
> preventing the mipi-i3c-hci driver from being loaded on x86
> platforms that advertise I3C ACPI support.
>
> Add the AMDI5017 ACPI ID to the list of supported IDs.
...
> static struct platform_driver i3c_hci_driver = {
> .probe = i3c_hci_probe,
> .remove_new = i3c_hci_remove,
> .driver = {
> .name = "mipi-i3c-hci",
> .of_match_table = of_match_ptr(i3c_hci_of_match),
A side note (not sure if it anyhow might be related to your kernel
configurations and builds): There is an ongoing activity to kill
of_match_ptr() for good (as it's more harmful than useful). It _might_ be
that in ACPI only kernel configurations dangling i3c_hci_of_match appears
which compiler will warn about.
> + .acpi_match_table = i3c_hci_acpi_match,
> },
> };
--
With Best Regards,
Andy Shevchenko
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v6 2/6] i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1
2024-08-29 9:17 ` [PATCH v6 2/6] i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1 Shyam Sundar S K
@ 2024-09-02 6:15 ` Jarkko Nikula
0 siblings, 0 replies; 12+ messages in thread
From: Jarkko Nikula @ 2024-09-02 6:15 UTC (permalink / raw)
To: Shyam Sundar S K, Alexandre Belloni
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel
On 8/29/24 12:17 PM, Shyam Sundar S K wrote:
> The HC_CONTROL_PIO_MODE bit was introduced in the HC_CONTROL register
> starting from version 1.1. Therefore, checking the HC_CONTROL_PIO_MODE bit
> on hardware that adheres to older specification revisions (i.e., versions
> earlier than 1.1) is incorrect. To address this, add an additional check
> to read the HCI version before attempting to read the HC_CONTROL_PIO_MODE
> status.
>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
> drivers/i3c/master/mipi-i3c-hci/core.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List
2024-08-29 9:17 ` [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List Shyam Sundar S K
2024-08-29 11:04 ` Andy Shevchenko
@ 2024-09-02 6:17 ` Jarkko Nikula
1 sibling, 0 replies; 12+ messages in thread
From: Jarkko Nikula @ 2024-09-02 6:17 UTC (permalink / raw)
To: Shyam Sundar S K, Alexandre Belloni
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel,
Andy Shevchenko
On 8/29/24 12:17 PM, Shyam Sundar S K wrote:
> The current driver code lacks the necessary plumbing for ACPI IDs,
> preventing the mipi-i3c-hci driver from being loaded on x86
> platforms that advertise I3C ACPI support.
>
> Add the AMDI5017 ACPI ID to the list of supported IDs.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
> drivers/i3c/master/mipi-i3c-hci/core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
` (5 preceding siblings ...)
2024-08-29 9:17 ` [PATCH v6 6/6] i3c: mipi-i3c-hci: Add a quirk to set Response buffer threshold Shyam Sundar S K
@ 2024-09-03 19:41 ` Shyam Sundar S K
2024-09-05 16:36 ` Alexandre Belloni
7 siblings, 0 replies; 12+ messages in thread
From: Shyam Sundar S K @ 2024-09-03 19:41 UTC (permalink / raw)
To: Alexandre Belloni, Jarkko Nikula
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel
Hi Alexandre, Jarkko,
On 8/29/2024 14:47, Shyam Sundar S K wrote:
> The AMD SoC includes an I3C IP block as part of the Fusion Controller Hub
> (FCH). This series introduces the initial driver support to enable the I3C
> IP block on AMD's latest processors.
>
> Currently, the code is closely tied to dt-bindings. This initial set aims
> to decouple some of these bindings by adding the MIPI ID, allowing the
> current driver to support ACPI-enabled x86 systems.
>
> It was discovered that the AMD I3C controller has several hardware issues,
> including:
> - Non-functional DMA mode (defaulting to PIO mode)
> - Issues with Open-Drain (OD) and Push-Pull (PP) timing parameters
> - Command response buffer threshold values
>
> All of these issues have been addressed in this series.
>
> v5->v6:
> -------
> - Add Reviewed-by tag
> - Update to variable name from "pio_mode_support" to "mode_selector"
Can this series be applied as 6.12 material? (as it has the all the
tags now)
Thanks,
Shyam
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
` (6 preceding siblings ...)
2024-09-03 19:41 ` [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
@ 2024-09-05 16:36 ` Alexandre Belloni
7 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2024-09-05 16:36 UTC (permalink / raw)
To: Jarkko Nikula, Shyam Sundar S K
Cc: Guruvendra Punugupati, Krishnamoorthi M, linux-i3c, linux-kernel
On Thu, 29 Aug 2024 14:47:07 +0530, Shyam Sundar S K wrote:
> The AMD SoC includes an I3C IP block as part of the Fusion Controller Hub
> (FCH). This series introduces the initial driver support to enable the I3C
> IP block on AMD's latest processors.
>
> Currently, the code is closely tied to dt-bindings. This initial set aims
> to decouple some of these bindings by adding the MIPI ID, allowing the
> current driver to support ACPI-enabled x86 systems.
>
> [...]
Applied, thanks!
[1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List
https://git.kernel.org/abelloni/c/8d2e56ef83ce
[2/6] i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1
https://git.kernel.org/abelloni/c/039b23609ff2
[3/6] i3c: mipi-i3c-hci: Add a quirk to set PIO mode
https://git.kernel.org/abelloni/c/014089329953
[4/6] i3c: mipi-i3c-hci: Relocate helper macros to HCI header file
https://git.kernel.org/abelloni/c/216201b3d7df
[5/6] i3c: mipi-i3c-hci: Add a quirk to set timing parameters
https://git.kernel.org/abelloni/c/46d4daa517e9
[6/6] i3c: mipi-i3c-hci: Add a quirk to set Response buffer threshold
https://git.kernel.org/abelloni/c/ced86959d28c
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-09-05 16:36 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29 9:17 [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 1/6] i3c: mipi-i3c-hci: Add AMDI5017 ACPI ID to the I3C Support List Shyam Sundar S K
2024-08-29 11:04 ` Andy Shevchenko
2024-09-02 6:17 ` Jarkko Nikula
2024-08-29 9:17 ` [PATCH v6 2/6] i3c: mipi-i3c-hci: Read HC_CONTROL_PIO_MODE only after i3c hci v1.1 Shyam Sundar S K
2024-09-02 6:15 ` Jarkko Nikula
2024-08-29 9:17 ` [PATCH v6 3/6] i3c: mipi-i3c-hci: Add a quirk to set PIO mode Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 4/6] i3c: mipi-i3c-hci: Relocate helper macros to HCI header file Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 5/6] i3c: mipi-i3c-hci: Add a quirk to set timing parameters Shyam Sundar S K
2024-08-29 9:17 ` [PATCH v6 6/6] i3c: mipi-i3c-hci: Add a quirk to set Response buffer threshold Shyam Sundar S K
2024-09-03 19:41 ` [PATCH v6 0/6] Introduce initial AMD I3C HCI driver support Shyam Sundar S K
2024-09-05 16:36 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox