i2c: designware: add support of platform data to set I2C mode
authorTan, Raymond <raymond.tan@intel.com>
Wed, 3 Sep 2014 02:41:38 +0000 (10:41 +0800)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 29 Sep 2014 20:41:17 +0000 (22:41 +0200)
Use the platform data to set the clk_freq when there is no DT configuration
available. The clk_freq in turn will determine the I2C speed mode.

In Quark, there is currently no other configuration mechanism other than
board files.

Signed-off-by: Raymond Tan <raymond.tan@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Hock Leong Kweh <hock.leong.kweh@intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-designware-platdrv.c
include/linux/platform_data/i2c-designware.h [new file with mode: 0644]

index 8193e8eea7641b8dcc6df15e5fdacd60ec502119..4d6a6b94e2fa9805d237782cc758af0a0bea9db9 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/platform_data/i2c-designware.h>
 #include "i2c-designware-core.h"
 
 static struct i2c_algorithm i2c_dw_algo = {
@@ -122,6 +123,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
        struct dw_i2c_dev *dev;
        struct i2c_adapter *adap;
        struct resource *mem;
+       struct dw_i2c_platform_data *pdata;
        int irq, r;
        u32 clk_freq;
 
@@ -182,6 +184,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev, "Only 100kHz and 400kHz supported");
                        return -EINVAL;
                }
+       } else {
+               pdata = dev_get_platdata(&pdev->dev);
+               if (pdata)
+                       clk_freq = pdata->i2c_scl_freq;
        }
 
        dev->functionality =
diff --git a/include/linux/platform_data/i2c-designware.h b/include/linux/platform_data/i2c-designware.h
new file mode 100644 (file)
index 0000000..7a61fb2
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef I2C_DESIGNWARE_H
+#define I2C_DESIGNWARE_H
+
+struct dw_i2c_platform_data {
+       unsigned int i2c_scl_freq;
+};
+
+#endif