summaryrefslogtreecommitdiff
path: root/drivers/i2c/busses/i2c-designware-common.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-05-19 15:50:39 +0300
committerWolfram Sang <wsa@kernel.org>2020-05-22 17:50:27 +0300
commit20ee1d9020c9233129ba84094e7dd6fe4651cfad (patch)
treeecf26a1e8ab41f12706422c2ad0552cc87a1e6be /drivers/i2c/busses/i2c-designware-common.c
parenta19f133f694c8f5549d46b43e4b30343b35c3aa5 (diff)
downloadlinux-20ee1d9020c9233129ba84094e7dd6fe4651cfad.tar.xz
i2c: designware: Move i2c_dw_validate_speed() helper to a common code
In order to export array supported speed for wider use, move it to a header along with i2c_dw_validate_speed() helper moved to a common code. No functional changes intended. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-designware-common.c')
-rw-r--r--drivers/i2c/busses/i2c-designware-common.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index c70c6fc09ee3..9f06567be54a 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -116,6 +116,30 @@ int i2c_dw_set_reg_access(struct dw_i2c_dev *dev)
return 0;
}
+int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
+{
+ struct i2c_timings *t = &dev->timings;
+ unsigned int i;
+
+ /*
+ * Only standard mode at 100kHz, fast mode at 400kHz,
+ * fast mode plus at 1MHz and high speed mode at 3.4MHz are supported.
+ */
+ for (i = 0; i < ARRAY_SIZE(i2c_dw_supported_speeds); i++) {
+ if (t->bus_freq_hz == i2c_dw_supported_speeds[i])
+ break;
+ }
+ if (i == ARRAY_SIZE(i2c_dw_supported_speeds)) {
+ dev_err(dev->dev,
+ "%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n",
+ t->bus_freq_hz);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(i2c_dw_validate_speed);
+
u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset)
{
/*