Commit 42ffd390 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Wolfram Sang

i2c: designware: Do not calculate SCL timing parameters needlessly

Do SCL timing parameter calculation conditionally depending are custom
parameters provided since calculated values will get instantly overwritten
by provided parameters.
Signed-off-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent c680eed5
...@@ -320,7 +320,11 @@ int i2c_dw_init(struct dw_i2c_dev *dev) ...@@ -320,7 +320,11 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
sda_falling_time = dev->sda_falling_time ?: 300; /* ns */ sda_falling_time = dev->sda_falling_time ?: 300; /* ns */
scl_falling_time = dev->scl_falling_time ?: 300; /* ns */ scl_falling_time = dev->scl_falling_time ?: 300; /* ns */
/* Standard-mode */ /* Set SCL timing parameters for standard-mode */
if (dev->ss_hcnt && dev->ss_lcnt) {
hcnt = dev->ss_hcnt;
lcnt = dev->ss_lcnt;
} else {
hcnt = i2c_dw_scl_hcnt(input_clock_khz, hcnt = i2c_dw_scl_hcnt(input_clock_khz,
4000, /* tHD;STA = tHIGH = 4.0 us */ 4000, /* tHD;STA = tHIGH = 4.0 us */
sda_falling_time, sda_falling_time,
...@@ -330,17 +334,16 @@ int i2c_dw_init(struct dw_i2c_dev *dev) ...@@ -330,17 +334,16 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
4700, /* tLOW = 4.7 us */ 4700, /* tLOW = 4.7 us */
scl_falling_time, scl_falling_time,
0); /* No offset */ 0); /* No offset */
/* Allow platforms to specify the ideal HCNT and LCNT values */
if (dev->ss_hcnt && dev->ss_lcnt) {
hcnt = dev->ss_hcnt;
lcnt = dev->ss_lcnt;
} }
dw_writel(dev, hcnt, DW_IC_SS_SCL_HCNT); dw_writel(dev, hcnt, DW_IC_SS_SCL_HCNT);
dw_writel(dev, lcnt, DW_IC_SS_SCL_LCNT); dw_writel(dev, lcnt, DW_IC_SS_SCL_LCNT);
dev_dbg(dev->dev, "Standard-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt); dev_dbg(dev->dev, "Standard-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);
/* Fast-mode */ /* Set SCL timing parameters for fast-mode */
if (dev->fs_hcnt && dev->fs_lcnt) {
hcnt = dev->fs_hcnt;
lcnt = dev->fs_lcnt;
} else {
hcnt = i2c_dw_scl_hcnt(input_clock_khz, hcnt = i2c_dw_scl_hcnt(input_clock_khz,
600, /* tHD;STA = tHIGH = 0.6 us */ 600, /* tHD;STA = tHIGH = 0.6 us */
sda_falling_time, sda_falling_time,
...@@ -350,10 +353,6 @@ int i2c_dw_init(struct dw_i2c_dev *dev) ...@@ -350,10 +353,6 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
1300, /* tLOW = 1.3 us */ 1300, /* tLOW = 1.3 us */
scl_falling_time, scl_falling_time,
0); /* No offset */ 0); /* No offset */
if (dev->fs_hcnt && dev->fs_lcnt) {
hcnt = dev->fs_hcnt;
lcnt = dev->fs_lcnt;
} }
dw_writel(dev, hcnt, DW_IC_FS_SCL_HCNT); dw_writel(dev, hcnt, DW_IC_FS_SCL_HCNT);
dw_writel(dev, lcnt, DW_IC_FS_SCL_LCNT); dw_writel(dev, lcnt, DW_IC_FS_SCL_LCNT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment