Skip to content

Commit 4e89bc4

Browse files
Aniketalexandrebelloni
authored andcommitted
i3c: dw: Save timing registers and other values
Add variables to store timing registers and other values. These variables would be later used to restore registers during resume without recomputation. Signed-off-by: Aniket <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 915d074 commit 4e89bc4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

drivers/i3c/master/dw-i3c-master.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,22 @@ static int dw_i3c_clk_cfg(struct dw_i3c_master *master)
543543

544544
scl_timing = SCL_I3C_TIMING_HCNT(hcnt) | SCL_I3C_TIMING_LCNT(lcnt);
545545
writel(scl_timing, master->regs + SCL_I3C_PP_TIMING);
546+
master->i3c_pp_timing = scl_timing;
546547

547548
/*
548549
* In pure i3c mode, MST_FREE represents tCAS. In shared mode, this
549550
* will be set up by dw_i2c_clk_cfg as tLOW.
550551
*/
551-
if (master->base.bus.mode == I3C_BUS_MODE_PURE)
552+
if (master->base.bus.mode == I3C_BUS_MODE_PURE) {
552553
writel(BUS_I3C_MST_FREE(lcnt), master->regs + BUS_FREE_TIMING);
554+
master->bus_free_timing = BUS_I3C_MST_FREE(lcnt);
555+
}
553556

554557
lcnt = max_t(u8,
555558
DIV_ROUND_UP(I3C_BUS_TLOW_OD_MIN_NS, core_period), lcnt);
556559
scl_timing = SCL_I3C_TIMING_HCNT(hcnt) | SCL_I3C_TIMING_LCNT(lcnt);
557560
writel(scl_timing, master->regs + SCL_I3C_OD_TIMING);
561+
master->i3c_od_timing = scl_timing;
558562

559563
lcnt = DIV_ROUND_UP(core_rate, I3C_BUS_SDR1_SCL_RATE) - hcnt;
560564
scl_timing = SCL_EXT_LCNT_1(lcnt);
@@ -565,6 +569,7 @@ static int dw_i3c_clk_cfg(struct dw_i3c_master *master)
565569
lcnt = DIV_ROUND_UP(core_rate, I3C_BUS_SDR4_SCL_RATE) - hcnt;
566570
scl_timing |= SCL_EXT_LCNT_4(lcnt);
567571
writel(scl_timing, master->regs + SCL_EXT_LCNT_TIMING);
572+
master->ext_lcnt_timing = scl_timing;
568573

569574
return 0;
570575
}
@@ -586,16 +591,21 @@ static int dw_i2c_clk_cfg(struct dw_i3c_master *master)
586591
scl_timing = SCL_I2C_FMP_TIMING_HCNT(hcnt) |
587592
SCL_I2C_FMP_TIMING_LCNT(lcnt);
588593
writel(scl_timing, master->regs + SCL_I2C_FMP_TIMING);
594+
master->i2c_fmp_timing = scl_timing;
589595

590596
lcnt = DIV_ROUND_UP(I3C_BUS_I2C_FM_TLOW_MIN_NS, core_period);
591597
hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_SCL_RATE) - lcnt;
592598
scl_timing = SCL_I2C_FM_TIMING_HCNT(hcnt) |
593599
SCL_I2C_FM_TIMING_LCNT(lcnt);
594600
writel(scl_timing, master->regs + SCL_I2C_FM_TIMING);
601+
master->i2c_fm_timing = scl_timing;
595602

596603
writel(BUS_I3C_MST_FREE(lcnt), master->regs + BUS_FREE_TIMING);
604+
master->bus_free_timing = BUS_I3C_MST_FREE(lcnt);
605+
597606
writel(readl(master->regs + DEVICE_CTRL) | DEV_CTRL_I2C_SLAVE_PRESENT,
598607
master->regs + DEVICE_CTRL);
608+
master->i2c_slv_prsnt = true;
599609

600610
return 0;
601611
}
@@ -650,7 +660,7 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m)
650660

651661
writel(DEV_ADDR_DYNAMIC_ADDR_VALID | DEV_ADDR_DYNAMIC(ret),
652662
master->regs + DEVICE_ADDR);
653-
663+
master->dev_addr = ret;
654664
memset(&info, 0, sizeof(info));
655665
info.dyn_addr = ret;
656666

@@ -1077,6 +1087,7 @@ static int dw_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev)
10771087

10781088
data->index = pos;
10791089
master->devs[pos].addr = dev->addr;
1090+
master->devs[pos].is_i2c_addr = true;
10801091
master->free_pos &= ~BIT(pos);
10811092
i2c_dev_set_master_data(dev, data);
10821093

drivers/i3c/master/dw-i3c-master.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct dw_i3c_master_caps {
1919

2020
struct dw_i3c_dat_entry {
2121
u8 addr;
22+
bool is_i2c_addr;
2223
struct i3c_dev_desc *ibi_dev;
2324
};
2425

@@ -40,6 +41,14 @@ struct dw_i3c_master {
4041
char version[5];
4142
char type[5];
4243
u32 sir_rej_mask;
44+
bool i2c_slv_prsnt;
45+
u32 dev_addr;
46+
u32 i3c_pp_timing;
47+
u32 i3c_od_timing;
48+
u32 ext_lcnt_timing;
49+
u32 bus_free_timing;
50+
u32 i2c_fm_timing;
51+
u32 i2c_fmp_timing;
4352
/*
4453
* Per-device hardware data, used to manage the device address table
4554
* (DAT)

0 commit comments

Comments
 (0)