i2c: designware_i2c: Improvements for high speed mode
cover i2c: designware_i2c: Improvements for high speed mode
From: Jun Chen <[email protected]>
This series updates the Designware I2C driver for high speed mode, fix a bug and add some improvements.
Jun Chen (4):
i2c: designware_i2c: Fix IC_CON register setting for high speed mode
i2c: designware_i2c: check is high speed possible support
i2c: designware_i2c: remove 'has_high_speed'
i2c: designware_i2c: add 'hs_hcnt' and 'hs_lcnt' for high speed
drivers/i2c/designware_i2c.c | 18 +++++++++++++++--- drivers/i2c/designware_i2c.h | 9 +++++++-- 2 files changed, 22 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/4 i2c: designware_i2c: Fix IC_CON register setting for high speed mode
From: Jun Chen <[email protected]>
IC_CON[2:1] should be 3 for high speed mode
---
drivers/i2c/designware_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/designware_i2c.c +1 -1
@@ -274,7 +274,7 @@ static int _dw_i2c_set_bus_speed(struct dw_i2c *priv, struct i2c_regs *i2c_base,switch (config.speed_mode) {case IC_SPEED_MODE_HIGH : - cntl |=IC_CON_SPD_SS ; + cntl |=IC_CON_SPD_HS ;writel (config.scl_hcnt, &i2c_base->ic_hs_scl_hcnt);writel (config.scl_lcnt, &i2c_base->ic_hs_scl_lcnt);break ;
Signature · 1 line
1.9.1
PATCH 1/4 i2c: designware_i2c: Fix IC_CON register setting for high speed mode
Hello Jun Chen,
Am 02.03.2020 um 09:58 schrieb Jun Chen:
Quoted 10 lines
From: Jun Chen <[email protected]>
IC_CON[2:1] should be 3 for high speed mode
Signed-off-by Jun Chen <[email protected]>Signed-off-by Jun Chen <[email protected]>---
drivers/i2c/designware_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-i2c next, thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 2/4 i2c: designware_i2c: check is high speed possible support
In reply to Jun ChenFrom: Jun Chen <[email protected]>
To read IC_COMP_PARAM_1[3:2] to check is high speed possible, and fall back to fast mode if not.
---
drivers/i2c/designware_i2c.c | 10 ++++++++++ drivers/i2c/designware_i2c.h | 3 +++ 2 files changed, 13 insertions(+)
drivers/i2c/designware_i2c.c +10 -0
@@ -203,9 +203,12 @@ static int calc_bus_speed(struct dw_i2c *priv, int speed, ulong bus_clk,const struct dw_scl_sda_cfg *scl_sda_cfg =NULL ;struct i2c_regs *regs = priv->regs;enum i2c_speed_mode i2c_spd; +u32 comp_param1;int spk_cnt;int ret; + comp_param1 =readl (®s->comp_param1); +if (priv) scl_sda_cfg = priv->scl_sda_cfg;/* Allow high speed if there is no config, or the config allows it */
@@ -219,6 +222,13 @@ static int calc_bus_speed(struct dw_i2c *priv, int speed, ulong bus_clk,else i2c_spd =IC_SPEED_MODE_STANDARD ; +/* Check is high speed possible and fall back to fast mode if not */ +if (i2c_spd ==IC_SPEED_MODE_HIGH ) { +if ((comp_param1 &DW_IC_COMP_PARAM_1_SPEED_MODE_MASK ) + !=DW_IC_COMP_PARAM_1_SPEED_MODE_HIGH ) + i2c_spd =IC_SPEED_MODE_FAST ; + } +/* Get the proper spike-suppression count based on target speed */ if (!priv || !priv->has_spk_cnt) spk_cnt =0 ;
drivers/i2c/designware_i2c.h +3 -0
@@ -138,6 +138,9 @@ struct i2c_regs {#define IC_STATUS_TFNF 0x0002#define IC_STATUS_ACT 0x0001 +#define DW_IC_COMP_PARAM_1_SPEED_MODE_HIGH (BIT(2) | BIT(3)) +#define DW_IC_COMP_PARAM_1_SPEED_MODE_MASK (BIT(2) | BIT(3)) +/** * struct dw_scl_sda_cfg - I2C timing configuration *
Signature · 1 line
1.9.1
PATCH 2/4 i2c: designware_i2c: check is high speed possible support
Hello Jun Chen,
Am 02.03.2020 um 09:58 schrieb Jun Chen:
Quoted 5 lines
From: Jun Chen <[email protected]>
To read IC_COMP_PARAM_1[3:2] to check is high speed possible, and fall back to fast mode if not.
Quoted 7 lines
Signed-off-by Jun Chen <[email protected]>Signed-off-by Jun Chen <[email protected]>---
drivers/i2c/designware_i2c.c | 10 ++++++++++ drivers/i2c/designware_i2c.h | 3 +++ 2 files changed, 13 insertions(+)
Applied to u-boot-i2c next, thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 3/4 i2c: designware_i2c: remove 'has_high_speed'
In reply to Jun ChenFrom: Jun Chen <[email protected]>
Remove 'has_high_speed' config since we can check high speed support from IC_COMP_PARAM_1 register.
---
drivers/i2c/designware_i2c.c | 3 +-- drivers/i2c/designware_i2c.h | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/i2c/designware_i2c.c +1 -2
@@ -212,8 +212,7 @@ static int calc_bus_speed(struct dw_i2c *priv, int speed, ulong bus_clk,if (priv) scl_sda_cfg = priv->scl_sda_cfg;/* Allow high speed if there is no config, or the config allows it */ -if (speed >=I2C_SPEED_HIGH_RATE && - (!scl_sda_cfg || scl_sda_cfg->has_high_speed)) +if (speed >=I2C_SPEED_HIGH_RATE ) i2c_spd =IC_SPEED_MODE_HIGH ;else if (speed >=I2C_SPEED_FAST_PLUS_RATE ) i2c_spd =IC_SPEED_MODE_FAST_PLUS ;
drivers/i2c/designware_i2c.h +0 -2
@@ -144,7 +144,6 @@ struct i2c_regs {/** * struct dw_scl_sda_cfg - I2C timing configuration * -* @has_high_speed: Support high speed (3.4Mbps) * @ss_hcnt: Standard speed high time in ns * @fs_hcnt: Fast speed high time in ns * @ss_lcnt: Standard speed low time in ns
@@ -152,7 +151,6 @@ struct i2c_regs {* @sda_hold: SDA hold time */ struct dw_scl_sda_cfg { -bool has_high_speed;u32 ss_hcnt;u32 fs_hcnt;u32 ss_lcnt;
Signature · 1 line
1.9.1
PATCH 3/4 i2c: designware_i2c: remove 'has_high_speed'
Hello Jun Chen,
Am 02.03.2020 um 09:58 schrieb Jun Chen:
Quoted 5 lines
From: Jun Chen <[email protected]>
Remove '
has_high_speed' config since we can check high speed support fromIC_COMP_PARAM_1register.
Quoted 7 lines
Signed-off-by Jun Chen <[email protected]>Signed-off-by Jun Chen <[email protected]>---
drivers/i2c/designware_i2c.c | 3 +-- drivers/i2c/designware_i2c.h | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-)
Applied to u-boot-i2c next, thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 4/4 i2c: designware_i2c: add 'hs_hcnt' and 'hs_lcnt' for high speed
In reply to Jun ChenFrom: Jun Chen <[email protected]>
Add support for high speed if scl_sda_cfg exist.
---
drivers/i2c/designware_i2c.c | 3 +++ drivers/i2c/designware_i2c.h | 4 ++++ 2 files changed, 7 insertions(+)
drivers/i2c/designware_i2c.c +3 -0
@@ -240,6 +240,9 @@ static int calc_bus_speed(struct dw_i2c *priv, int speed, ulong bus_clk,if (i2c_spd ==IC_SPEED_MODE_STANDARD ) { config->scl_hcnt = scl_sda_cfg->ss_hcnt; config->scl_lcnt = scl_sda_cfg->ss_lcnt; + }else if (i2c_spd ==IC_SPEED_MODE_HIGH ) { + config->scl_hcnt = scl_sda_cfg->hs_hcnt; + config->scl_lcnt = scl_sda_cfg->hs_lcnt; }else { config->scl_hcnt = scl_sda_cfg->fs_hcnt; config->scl_lcnt = scl_sda_cfg->fs_lcnt;
drivers/i2c/designware_i2c.h +4 -0
@@ -146,15 +146,19 @@ struct i2c_regs {* * @ss_hcnt: Standard speed high time in ns * @fs_hcnt: Fast speed high time in ns +* @hs_hcnt: High speed high time in ns * @ss_lcnt: Standard speed low time in ns * @fs_lcnt: Fast speed low time in ns +* @hs_lcnt: High speed low time in ns * @sda_hold: SDA hold time */ struct dw_scl_sda_cfg {u32 ss_hcnt;u32 fs_hcnt; +u32 hs_hcnt;u32 ss_lcnt;u32 fs_lcnt; +u32 hs_lcnt;u32 sda_hold; };
Signature · 1 line
1.9.1
PATCH 4/4 i2c: designware_i2c: add 'hs_hcnt' and 'hs_lcnt' for high speed
Hello Jun Chen,
Am 02.03.2020 um 09:58 schrieb Jun Chen:
Quoted 11 lines
From: Jun Chen <[email protected]>
Add support for high speed if
scl_sda_cfgexist.Signed-off-by Jun Chen <[email protected]>Signed-off-by Jun Chen <[email protected]>---
drivers/i2c/designware_i2c.c | 3 +++ drivers/i2c/designware_i2c.h | 4 ++++ 2 files changed, 7 insertions(+)
Applied to u-boot-i2c next, thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de