Skip to content

Commit

Permalink
i3c/master: cmd_v1: Fix the rule for getting i3c mode
Browse files Browse the repository at this point in the history
Based on the I3C TCRI specification, the rules for determining the I3C
mode are as follows:
I3C SCL rate > 8MHz: use SDR0, as SDR1 has a maximum data rate of 8MHz
I3C SCL rate > 6MHz: use SDR1, as SDR2 has a maximum data rate of 6MHz
I3C SCL rate > 4MHz: use SDR2, as SDR3 has a maximum data rate of 4MHz
I3C SCL rate > 2MHz: use SDR3, as SDR4 has a maximum data rate of 2MHz
Otherwise, use SDR4

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Link: https://lore.kernel.org/r/20240826033821.175591-1-billy_tsai@aspeedtech.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
  • Loading branch information
Billy Tsai authored and Alexandre Belloni committed Sep 6, 2024
1 parent 133f67b commit 061dd21
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/i3c/master/mipi-i3c-hci/cmd_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,15 @@ static enum hci_cmd_mode get_i3c_mode(struct i3c_hci *hci)
{
struct i3c_bus *bus = i3c_master_get_bus(&hci->master);

if (bus->scl_rate.i3c >= 12500000)
return MODE_I3C_SDR0;
if (bus->scl_rate.i3c > 8000000)
return MODE_I3C_SDR1;
return MODE_I3C_SDR0;
if (bus->scl_rate.i3c > 6000000)
return MODE_I3C_SDR2;
return MODE_I3C_SDR1;
if (bus->scl_rate.i3c > 4000000)
return MODE_I3C_SDR3;
return MODE_I3C_SDR2;
if (bus->scl_rate.i3c > 2000000)
return MODE_I3C_SDR4;
return MODE_I3C_Fm_FmP;
return MODE_I3C_SDR3;
return MODE_I3C_SDR4;
}

static enum hci_cmd_mode get_i2c_mode(struct i3c_hci *hci)
Expand Down

0 comments on commit 061dd21

Please sign in to comment.