diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-03-24 14:32:16 +0200 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2020-03-24 22:36:59 +0100 |
commit | 90224e6468e15d5eb22a10ae1849cf8ca2e7360a (patch) | |
tree | f5ba968fec565daa61c1bff4d04da380873f0254 /drivers/i2c/busses/i2c-mt65xx.c | |
parent | 7b8c4c0b2acbdf355f0b78557d6f7290955d726d (diff) |
i2c: drivers: Use generic definitions for bus frequencies
Since we have generic definitions for bus frequencies, let's use them.
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: Robert Richter <rrichter@marvell.com>
Reviewed-by: Thor Thayer <thor.thayer@linux.intel.com>
Acked-by: Elie Morisse <syniurge@gmail.com>
Acked-by: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Acked-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Acked-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
Acked-by: Patrice Chotard <patrice.chotard@st.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-mt65xx.c')
-rw-r--r-- | drivers/i2c/busses/i2c-mt65xx.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 2152ec5f535c..0ca6c38a15eb 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -56,9 +56,6 @@ #define I2C_DMA_4G_MODE 0x0001 #define I2C_DEFAULT_CLK_DIV 5 -#define I2C_DEFAULT_SPEED 100000 /* hz */ -#define MAX_FS_MODE_SPEED 400000 -#define MAX_HS_MODE_SPEED 3400000 #define MAX_SAMPLE_CNT_DIV 8 #define MAX_STEP_CNT_DIV 64 #define MAX_HS_STEP_CNT_DIV 8 @@ -450,10 +447,10 @@ static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src, unsigned int best_mul; unsigned int cnt_mul; - if (target_speed > MAX_HS_MODE_SPEED) - target_speed = MAX_HS_MODE_SPEED; + if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ) + target_speed = I2C_MAX_FAST_MODE_PLUS_FREQ; - if (target_speed > MAX_FS_MODE_SPEED) + if (target_speed > I2C_MAX_FAST_MODE_FREQ) max_step_cnt = MAX_HS_STEP_CNT_DIV; else max_step_cnt = MAX_STEP_CNT_DIV; @@ -514,9 +511,9 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk) clk_src = parent_clk / i2c->clk_src_div; target_speed = i2c->speed_hz; - if (target_speed > MAX_FS_MODE_SPEED) { + if (target_speed > I2C_MAX_FAST_MODE_FREQ) { /* Set master code speed register */ - ret = mtk_i2c_calculate_speed(i2c, clk_src, MAX_FS_MODE_SPEED, + ret = mtk_i2c_calculate_speed(i2c, clk_src, I2C_MAX_FAST_MODE_FREQ, &l_step_cnt, &l_sample_cnt); if (ret < 0) return ret; @@ -581,7 +578,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, control_reg = mtk_i2c_readw(i2c, OFFSET_CONTROL) & ~(I2C_CONTROL_DIR_CHANGE | I2C_CONTROL_RS); - if ((i2c->speed_hz > MAX_FS_MODE_SPEED) || (left_num >= 1)) + if ((i2c->speed_hz > I2C_MAX_FAST_MODE_FREQ) || (left_num >= 1)) control_reg |= I2C_CONTROL_RS; if (i2c->op == I2C_MASTER_WRRD) @@ -590,7 +587,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, mtk_i2c_writew(i2c, control_reg, OFFSET_CONTROL); /* set start condition */ - if (i2c->speed_hz <= I2C_DEFAULT_SPEED) + if (i2c->speed_hz <= I2C_MAX_STANDARD_MODE_FREQ) mtk_i2c_writew(i2c, I2C_ST_START_CON, OFFSET_EXT_CONF); else mtk_i2c_writew(i2c, I2C_FS_START_CON, OFFSET_EXT_CONF); @@ -798,7 +795,7 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap, } } - if (i2c->auto_restart && num >= 2 && i2c->speed_hz > MAX_FS_MODE_SPEED) + if (i2c->auto_restart && num >= 2 && i2c->speed_hz > I2C_MAX_FAST_MODE_FREQ) /* ignore the first restart irq after the master code, * otherwise the first transfer will be discarded. */ @@ -893,7 +890,7 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c) ret = of_property_read_u32(np, "clock-frequency", &i2c->speed_hz); if (ret < 0) - i2c->speed_hz = I2C_DEFAULT_SPEED; + i2c->speed_hz = I2C_MAX_STANDARD_MODE_FREQ; ret = of_property_read_u32(np, "clock-div", &i2c->clk_src_div); if (ret < 0) |