Skip to content

Commit 46d4daa

Browse files
Shyam Sundar S Kalexandrebelloni
authored andcommitted
i3c: mipi-i3c-hci: Add a quirk to set timing parameters
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 <[email protected]> Co-developed-by: Guruvendra Punugupati <[email protected]> Signed-off-by: Guruvendra Punugupati <[email protected]> Signed-off-by: Shyam Sundar S K <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 216201b commit 46d4daa

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

drivers/i3c/master/mipi-i3c-hci/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
obj-$(CONFIG_MIPI_I3C_HCI) += mipi-i3c-hci.o
44
mipi-i3c-hci-y := core.o ext_caps.o pio.o dma.o \
55
cmd_v1.o cmd_v2.o \
6-
dat_v1.o dct_v1.o
6+
dat_v1.o dct_v1.o \
7+
hci_quirks.o

drivers/i3c/master/mipi-i3c-hci/core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,10 @@ static int i3c_hci_init(struct i3c_hci *hci)
785785
return ret;
786786
}
787787

788+
/* Configure OD and PP timings for AMD platforms */
789+
if (hci->quirks & HCI_QUIRK_OD_PP_TIMING)
790+
amd_set_od_pp_timing(hci);
791+
788792
return 0;
789793
}
790794

@@ -838,7 +842,7 @@ static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
838842
MODULE_DEVICE_TABLE(of, i3c_hci_of_match);
839843

840844
static const struct acpi_device_id i3c_hci_acpi_match[] = {
841-
{ "AMDI5017", HCI_QUIRK_PIO_MODE },
845+
{ "AMDI5017", HCI_QUIRK_PIO_MODE | HCI_QUIRK_OD_PP_TIMING },
842846
{}
843847
};
844848
MODULE_DEVICE_TABLE(acpi, i3c_hci_acpi_match);

drivers/i3c/master/mipi-i3c-hci/hci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ struct i3c_hci_dev_data {
141141
/* list of quirks */
142142
#define HCI_QUIRK_RAW_CCC BIT(1) /* CCC framing must be explicit */
143143
#define HCI_QUIRK_PIO_MODE BIT(2) /* Set PIO mode for AMD platforms */
144+
#define HCI_QUIRK_OD_PP_TIMING BIT(3) /* Set OD and PP timings for AMD platforms */
144145

145146

146147
/* global functions */
147148
void mipi_i3c_hci_resume(struct i3c_hci *hci);
148149
void mipi_i3c_hci_pio_reset(struct i3c_hci *hci);
149150
void mipi_i3c_hci_dct_index_reset(struct i3c_hci *hci);
151+
void amd_set_od_pp_timing(struct i3c_hci *hci);
150152

151153
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* I3C HCI Quirks
4+
*
5+
* Copyright 2024 Advanced Micro Devices, Inc.
6+
*
7+
* Authors: Shyam Sundar S K <[email protected]>
8+
* Guruvendra Punugupati <[email protected]>
9+
*/
10+
11+
#include <linux/i3c/master.h>
12+
#include "hci.h"
13+
14+
/* Timing registers */
15+
#define HCI_SCL_I3C_OD_TIMING 0x214
16+
#define HCI_SCL_I3C_PP_TIMING 0x218
17+
#define HCI_SDA_HOLD_SWITCH_DLY_TIMING 0x230
18+
19+
/* Timing values to configure 9MHz frequency */
20+
#define AMD_SCL_I3C_OD_TIMING 0x00cf00cf
21+
#define AMD_SCL_I3C_PP_TIMING 0x00160016
22+
23+
void amd_set_od_pp_timing(struct i3c_hci *hci)
24+
{
25+
u32 data;
26+
27+
reg_write(HCI_SCL_I3C_OD_TIMING, AMD_SCL_I3C_OD_TIMING);
28+
reg_write(HCI_SCL_I3C_PP_TIMING, AMD_SCL_I3C_PP_TIMING);
29+
data = reg_read(HCI_SDA_HOLD_SWITCH_DLY_TIMING);
30+
/* Configure maximum TX hold time */
31+
data |= W0_MASK(18, 16);
32+
reg_write(HCI_SDA_HOLD_SWITCH_DLY_TIMING, data);
33+
}

0 commit comments

Comments
 (0)