i2c: busses: i2c-tegra: Set bus speed in platform data
authorColin Cross <ccross@android.com>
Mon, 14 Jun 2010 23:09:46 +0000 (16:09 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:26:44 +0000 (16:26 -0700)
Change-Id: Iebc1ad5cc56d09f1df99d09dd6456c24c93cdb0b
Signed-off-by: Colin Cross <ccross@android.com>
drivers/i2c/busses/i2c-tegra.c
include/linux/i2c-tegra.h [new file with mode: 0644]

index 97d364a69d1c3c5e51b64dfc5d24ec71f6c73d54..2586117e7c752ba036cda3d25f204cf817b79a15 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/i2c-tegra.h>
 
 #include <asm/unaligned.h>
 
@@ -107,6 +108,7 @@ struct tegra_i2c_dev {
        size_t msg_buf_remaining;
        int msg_read;
        int msg_transfer_complete;
+       unsigned long bus_clk_rate;
 };
 
 static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned long reg)
@@ -302,7 +304,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
        val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN;
        i2c_writel(i2c_dev, val, I2C_CNFG);
        i2c_writel(i2c_dev, 0, I2C_INT_MASK);
-       tegra_i2c_set_clk(i2c_dev, 100000);
+       tegra_i2c_set_clk(i2c_dev, i2c_dev->bus_clk_rate);
 
        val = 7 << I2C_FIFO_CONTROL_TX_TRIG_SHIFT |
                0 << I2C_FIFO_CONTROL_RX_TRIG_SHIFT;
@@ -490,7 +492,7 @@ static const struct i2c_algorithm tegra_i2c_algo = {
 static int tegra_i2c_probe(struct platform_device *pdev)
 {
        struct tegra_i2c_dev *i2c_dev;
-       /*struct tegra_i2c_platform_data *pdata = pdev->dev.platform_data;*/
+       struct tegra_i2c_platform_data *pdata = pdev->dev.platform_data;
        struct resource *res;
        struct resource *iomem;
        struct clk *clk;
@@ -550,6 +552,8 @@ static int tegra_i2c_probe(struct platform_device *pdev)
        i2c_dev->irq = irq;
        i2c_dev->cont_id = pdev->id;
        i2c_dev->dev = &pdev->dev;
+       i2c_dev->bus_clk_rate = pdata ? pdata->bus_clk_rate : 100000;
+
        if (pdev->id == 3)
                i2c_dev->is_dvc = 1;
        init_completion(&i2c_dev->msg_complete);
diff --git a/include/linux/i2c-tegra.h b/include/linux/i2c-tegra.h
new file mode 100644 (file)
index 0000000..9c85da4
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * drivers/i2c/busses/i2c-tegra.c
+ *
+ * Copyright (C) 2010 Google, Inc.
+ * Author: Colin Cross <ccross@android.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that 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 _LINUX_I2C_TEGRA_H
+#define _LINUX_I2C_TEGRA_H
+
+struct tegra_i2c_platform_data {
+       unsigned long bus_clk_rate;
+};
+
+#endif /* _LINUX_I2C_TEGRA_H */