Skip to content

Commit ced8695

Browse files
Shyam Sundar S Kalexandrebelloni
authored andcommitted
i3c: mipi-i3c-hci: Add a quirk to set Response buffer threshold
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 <[email protected]> Co-developed-by: Krishnamoorthi M <[email protected]> Signed-off-by: Krishnamoorthi M <[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 46d4daa commit ced8695

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ static int i3c_hci_bus_init(struct i3c_master_controller *m)
146146
if (ret)
147147
return ret;
148148

149+
/* Set RESP_BUF_THLD to 0(n) to get 1(n+1) response */
150+
if (hci->quirks & HCI_QUIRK_RESP_BUF_THLD)
151+
amd_set_resp_buf_thld(hci);
152+
149153
reg_set(HC_CONTROL, HC_CONTROL_BUS_ENABLE);
150154
DBG("HC_CONTROL = %#x", reg_read(HC_CONTROL));
151155

@@ -842,7 +846,7 @@ static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
842846
MODULE_DEVICE_TABLE(of, i3c_hci_of_match);
843847

844848
static const struct acpi_device_id i3c_hci_acpi_match[] = {
845-
{ "AMDI5017", HCI_QUIRK_PIO_MODE | HCI_QUIRK_OD_PP_TIMING },
849+
{ "AMDI5017", HCI_QUIRK_PIO_MODE | HCI_QUIRK_OD_PP_TIMING | HCI_QUIRK_RESP_BUF_THLD },
846850
{}
847851
};
848852
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
@@ -142,12 +142,14 @@ struct i3c_hci_dev_data {
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 */
144144
#define HCI_QUIRK_OD_PP_TIMING BIT(3) /* Set OD and PP timings for AMD platforms */
145+
#define HCI_QUIRK_RESP_BUF_THLD BIT(4) /* Set resp buf thld to 0 for AMD platforms */
145146

146147

147148
/* global functions */
148149
void mipi_i3c_hci_resume(struct i3c_hci *hci);
149150
void mipi_i3c_hci_pio_reset(struct i3c_hci *hci);
150151
void mipi_i3c_hci_dct_index_reset(struct i3c_hci *hci);
151152
void amd_set_od_pp_timing(struct i3c_hci *hci);
153+
void amd_set_resp_buf_thld(struct i3c_hci *hci);
152154

153155
#endif

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define AMD_SCL_I3C_OD_TIMING 0x00cf00cf
2121
#define AMD_SCL_I3C_PP_TIMING 0x00160016
2222

23+
#define QUEUE_THLD_CTRL 0xD0
24+
2325
void amd_set_od_pp_timing(struct i3c_hci *hci)
2426
{
2527
u32 data;
@@ -31,3 +33,12 @@ void amd_set_od_pp_timing(struct i3c_hci *hci)
3133
data |= W0_MASK(18, 16);
3234
reg_write(HCI_SDA_HOLD_SWITCH_DLY_TIMING, data);
3335
}
36+
37+
void amd_set_resp_buf_thld(struct i3c_hci *hci)
38+
{
39+
u32 data;
40+
41+
data = reg_read(QUEUE_THLD_CTRL);
42+
data = data & ~W0_MASK(15, 8);
43+
reg_write(QUEUE_THLD_CTRL, data);
44+
}

0 commit comments

Comments
 (0)