Skip to contentSkip to conversation

i2c: designware: Add support for AMD i2c controller

PATCH Superseded Carl Peng 2 participants 2 messages Sep 16, 2014 1 message not in the archive

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Carl Peng

author
#0 lore raw

PATCH v3 1/1 i2c: designware: Add support for AMD i2c controller

AMD i2c bus controller is ACPI device, its ACPI ID is "AMD0010". This patch is used to add support for AMD i2c bus controller in the Designware platform driver.

---
 drivers/i2c/busses/i2c-designware-core.h    |  1 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 46 +++++++++++++++++++++++++----
 2 files changed, 41 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-designware-core.h +1 -0
index d66b6cb..c67d4ac 100644
@@ -105,6 +105,7 @@ struct dw_i2c_dev {
 	u16			ss_lcnt;
 	u16			fs_hcnt;
 	u16			fs_lcnt;
+	struct	dw_i2c_pdata	*pdata;
 };
 
 #define ACCESS_SWAP		0x00000001
drivers/i2c/busses/i2c-designware-platdrv.c +40 -6

80 lines not on this page · raw message

Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1410848458-1455-1-git-send-email-carlpeng008-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 4 lines · Carl Peng

AMD i2c bus controller is ACPI device, its ACPI ID is "AMD0010". This patch is used to add support for AMD i2c bus controller in the Designware platform driver.

This is looking better now. I still have few comments, though.

Quoted 13 lines
---
 drivers/i2c/busses/i2c-designware-core.h    |  1 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 46 +++++++++++++++++++++++++----
 2 files changed, 41 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-designware-core.h +0 -0
index d66b6cb..c67d4ac 100644

drivers/i2c/busses/i2c-designware-core.h struct dw_i2c_dev { · line 108

Quoted 4 lines
drivers/i2c/busses/i2c-designware-core.h +1 -0
@@ -105,6 +105,7 @@ struct dw_i2c_dev {
 	u16			ss_lcnt;
 	u16			fs_hcnt;
 	u16			fs_lcnt;
+	struct	dw_i2c_pdata	*pdata;

You don't need this.

drivers/i2c/busses/i2c-designware-platdrv.c line 46

Quoted 12 lines
drivers/i2c/busses/i2c-designware-core.h +0 -0
 };
 
 #define ACCESS_SWAP		0x00000001
drivers/i2c/busses/i2c-designware-platdrv.c +1 -0
index bc87733..8a96e69 100644
@@ -43,15 +43,31 @@
 #include <linux/acpi.h>
 #include "i2c-designware-core.h"
 
+#define AMD_CLK_KHZ		(133 * 1000)

Do you really need define for this?

drivers/i2c/busses/i2c-designware-platdrv.c line 50

Quoted 4 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4 -0
+
+struct dw_i2c_pdata {
+	u32 clk_rate_khz;
+};

Call it dw_i2c_config instead.

drivers/i2c/busses/i2c-designware-platdrv.c line 63

Quoted 13 lines
drivers/i2c/busses/i2c-designware-platdrv.c +6 -0
+
 static struct i2c_algorithm i2c_dw_algo = {
 	.master_xfer	= i2c_dw_xfer,
 	.functionality	= i2c_dw_func,
 };
+
+static struct dw_i2c_pdata amd_i2c_config = {
+	.clk_rate_khz = AMD_CLK_KHZ,
+};
+
 static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
 {
 	return clk_get_rate(dev->clk)/1000;

How about doing this instead?

	const struct dw_i2c_config *conf = i2c_dw_get_config(dev);

	if (conf)
		return conf->clk_rate_khz;
	return clk_get_rate(dev->clk)/1000;

And then just implement i2c_dw_get_config() that understands to look clk_rate from acpi_device_id.

drivers/i2c/busses/i2c-designware-platdrv.c line 66

Quoted 3 lines
drivers/i2c/busses/i2c-designware-platdrv.c +1 -0
 }
 
+static u32 amd_i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)

Please don't call it amd_xxx because if now some other vendor decides that their version of dw ip runs at 120MHz we would need to rename this.

Quoted 4 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4 -0
+{
+	return dev->pdata->clk_rate_khz;
+}
+