Skip to contentSkip to conversation

i2c: vt8500: Add support for I2C bus on Wondermedia SoCs

PATCH Superseded Tony Prisk 2 participants 2 messages Jun 12, 2013 – Jun 14, 2013

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tony Prisk

author
#0 lore raw

PATCH v2 1/1 i2c: vt8500: Add support for I2C bus on Wondermedia SoCs

This patch adds support for the I2C bus controllers found on Wondermedia 8xxx-series SoCs. Only master-mode is supported.

---
 .../devicetree/bindings/i2c/i2c-vt8500.txt         |   24 +
 MAINTAINERS                                        |    1 +
 drivers/i2c/busses/Kconfig                         |   10 +
 drivers/i2c/busses/Makefile                        |    1 +
 drivers/i2c/busses/i2c-wmt.c                       |  483 ++++++++++++++++++++
 5 files changed, 519 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-vt8500.txt
 create mode 100644 drivers/i2c/busses/i2c-wmt.c
Documentation/devicetree/bindings/i2c/i2c-vt8500.txt new file +24 -0
new file mode 100644
index 0000000..94a425e
@@ -0,0 +1,24 @@
+* Wondermedia I2C Controller
+
+Required properties :
+
+ - compatible : should be "wm,wm8505-i2c"
+ - reg : Offset and length of the register set for the device
+ - interrupts : <IRQ> where IRQ is the interrupt number
+ - clocks : phandle to the I2C clock source
+
+Optional properties :
+
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+	Valid values are 100000 and 400000.
+	Default to 100000 if not specified, or invalid value.
+
+Example :
+
+	i2c_0: i2c@d8280000 {
+		compatible = "wm,wm8505-i2c";
+		reg = <0xd8280000 0x1000>;
+		interrupts = <19>;
+		clocks = <&clki2c0>;
+		clock-frequency = <400000>;
+	};
MAINTAINERS +1 -0
index 3d7782b..44ea994 100644
@@ -1285,6 +1285,7 @@ S:	Maintained
 F:	arch/arm/mach-vt8500/
 F:	drivers/clocksource/vt8500_timer.c
 F:	drivers/gpio/gpio-vt8500.c
+F:	drivers/i2c/busses/i2c-wmt.c
 F:	drivers/mmc/host/wmt-sdmmc.c
 F:	drivers/pwm/pwm-vt8500.c
 F:	drivers/rtc/rtc-vt8500.c
drivers/i2c/busses/Kconfig +10 -0
index 631736e..89e7ec2 100644
@@ -724,6 +724,16 @@ config I2C_VERSATILE
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-versatile.
 
+config I2C_WMT
+	tristate "Wondermedia WM8xxx SoC I2C bus support"
+	depends on ARCH_VT8500
+	help
+	  Say yes if you want to support the I2C bus on Wondermedia 8xxx-series
+	  SoCs.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called i2c-wmt.
+
 config I2C_OCTEON
 	tristate "Cavium OCTEON I2C bus support"
 	depends on CPU_CAVIUM_OCTEON
drivers/i2c/busses/Makefile +1 -0
index 8f4fc23..3ba94a9 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_I2C_SIRF)		+= i2c-sirf.o
 obj-$(CONFIG_I2C_STU300)	+= i2c-stu300.o
 obj-$(CONFIG_I2C_TEGRA)		+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)	+= i2c-versatile.o
+obj-$(CONFIG_I2C_WMT)		+= i2c-wmt.o
 obj-$(CONFIG_I2C_OCTEON)	+= i2c-octeon.o
 obj-$(CONFIG_I2C_XILINX)	+= i2c-xiic.o
 obj-$(CONFIG_I2C_XLR)		+= i2c-xlr.o
drivers/i2c/busses/i2c-wmt.c new file +483 -0

483 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 5 lines · Tony Prisk

This patch adds support for the I2C bus controllers found on Wondermedia 8xxx-series SoCs. Only master-mode is supported.

---

Please describe here what changed since the last version. It's a lot easier and faster to review then.

drivers/i2c/busses/i2c-wmt.c line 306

Quoted 11 lines
drivers/i2c/busses/i2c-wmt.c new file +11 -0
+static int wmt_i2c_xfer(struct i2c_adapter *adap,
+			struct i2c_msg msgs[],
+			int num)
+{
+	struct i2c_msg *pmsg;
+	int i, is_last, no_start;
+	int ret = 0;
+
+	for (i = 0; ret >= 0 && i < num; i++) {
+		is_last = ((i + 1) == num);
+		no_start = (i != 0);

(i != 0) is a restart condition (start instead of stop)...

drivers/i2c/busses/i2c-wmt.c line 310

Quoted 4 lines
drivers/i2c/busses/i2c-wmt.c new file +4 -0
+
+		pmsg = &msgs[i];
+		if (pmsg->flags & I2C_M_NOSTART)
+			no_start = 1;

...and this is a no_start (concatenating messages). I do have the impression you are mixing those two?

Quoted 6 lines
drivers/i2c/busses/i2c-wmt.c new file +6 -0
+		if (pmsg->flags & I2C_M_RD)
+			ret = wmt_i2c_read(adap, pmsg, no_start, is_last);
+		else
+			ret = wmt_i2c_write(adap, pmsg, no_start, is_last);
+	}
+

drivers/i2c/busses/i2c-wmt.c

Quoted 10 lines
drivers/i2c/busses/i2c-wmt.c new file +10 -0
+	return (ret < 0) ? ret : i;
+}
+	adap = &i2c_dev->adapter;
+	i2c_set_adapdata(adap, i2c_dev);
+	strlcpy(adap->name, "WMT I2C adapter", sizeof(adap->name));
+	adap->owner = THIS_MODULE;
+	adap->algo = &wmt_i2c_algo;
+	adap->dev.parent = &pdev->dev;
+	adap->dev.of_node = pdev->dev.of_node;
+	adap->nr = of_alias_get_id(pdev->dev.of_node, "i2c");

Drop this line...

drivers/i2c/busses/i2c-wmt.c line 438

Quoted 10 lines
drivers/i2c/busses/i2c-wmt.c new file +10 -0
+
+	init_completion(&i2c_dev->complete);
+
+	err = wmt_i2c_reset_hardware(i2c_dev);
+	if (err) {
+		dev_err(&pdev->dev, "error initializing hardware\n");
+		return err;
+	}
+
+	err = i2c_add_numbered_adapter(adap);

... and use i2c_add_adpter here. Since recently the core checks the ofnode for an alias. Sorry, forgot to mention this last time.

Quoted 7 lines
drivers/i2c/busses/i2c-wmt.c new file +7 -0
+	if (err) {
+		dev_err(&pdev->dev, "failed to add adapter\n");
+		return err;
+	}
+
+	platform_set_drvdata(pdev, i2c_dev);
+

drivers/i2c/busses/i2c-wmt.c line 482

Quoted 10 lines
drivers/i2c/busses/i2c-wmt.c new file +10 -0
+	of_i2c_register_devices(adap);
+
+	return 0;
+}
+
+module_platform_driver(wmt_i2c_driver);
+
+MODULE_DESCRIPTION("Wondermedia I2C master-mode bus adapter");
+MODULE_AUTHOR("Tony Prisk <[email protected]>");
+MODULE_LICENSE("GPL and additional rights");

I see no additional rights mentioned. According to the header "GPL" should do, but you know the original sources better.

Quoted 4 lines

+MODULE_DEVICE_TABLE(of, wmt_i2c_dt_ids);

Signature · 1 line
1.7.9.5

Regards,

Wolfram