Skip to contentSkip to conversation

APM X-Gene platform mailbox and proxy i2c driver

PATCH In review Feng Kan 4 participants 21 messages Oct 8, 2014 – Feb 2, 2015

Subsystems (3)
lore
Share & tools
lore

Feng Kan

author
#0 lore raw

cover APM X-Gene platform mailbox and proxy i2c driver

This patch set contain the APM X-Gene platform mailbox driver and a proxy i2c driver that uses the mailbox driver to communicate with the i2c bus through the slimpro coprocessor.

Feng Kan (6):
mailbox: add support for APM X-Gene platform mailbox driver
Documentation: mailbox: Add APM X-Gene SLIMpro mailbox dts
documentation
arm64: dts: mailbox device tree node for APM X-Gene platform.
i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform
Documentation: i2c: Add APM X-Gene platform SLIMpro I2C driver
documentation
arm64: dts: add proxy I2C device driver on APM X-Gene platform

 .../devicetree/bindings/i2c/i2c-xgene-slimpro.txt  |  20 +
 .../bindings/mailbox/xgene-slimpro-mailbox.txt     |  41 ++
 arch/arm64/boot/dts/apm-storm.dtsi                 |  20 +
 drivers/i2c/busses/Kconfig                         |   9 +
 drivers/i2c/busses/Makefile                        |   1 +
 drivers/i2c/busses/i2c-xgene-slimpro.c             | 531 +++++++++++++++++++++
 drivers/mailbox/Kconfig                            |  10 +
 drivers/mailbox/Makefile                           |   1 +
 drivers/mailbox/mailbox-xgene-slimpro.c            | 287 +++++++++++
 9 files changed, 920 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt
 create mode 100644 Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt
 create mode 100644 drivers/i2c/busses/i2c-xgene-slimpro.c
 create mode 100644 drivers/mailbox/mailbox-xgene-slimpro.c
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/6 mailbox: add support for APM X-Gene platform mailbox driver

Add support for APM X-Gene platform mailbox driver.

---
 drivers/mailbox/Kconfig                 |  10 ++
 drivers/mailbox/Makefile                |   1 +
 drivers/mailbox/mailbox-xgene-slimpro.c | 287 ++++++++++++++++++++++++++++++++
 3 files changed, 298 insertions(+)
 create mode 100644 drivers/mailbox/mailbox-xgene-slimpro.c
drivers/mailbox/Kconfig +10 -0
index 9fd9c67..12ed5c1 100644
@@ -33,4 +33,14 @@ config OMAP_MBOX_KFIFO_SIZE
 	  Specify the default size of mailbox's kfifo buffers (bytes).
 	  This can also be changed at runtime (via the mbox_kfifo_size
 	  module parameter).
+
+config XGENE_SLIMPRO_MBOX
+	tristate "APM SoC X-Gene SLIMpro Mailbox Controller"
+	depends on ARCH_XGENE
+	help
+	  An implementation of the APM X-Gene Interprocessor Communication
+	  Mailbox (IPCM) between the ARM 64-bit cores and SLIMpro controller.
+	  It is used to send short messages between ARM64-bit cores and
+	  the SLIMpro Management Engine, primarily for PM. Say Y here if you
+	  want to use the APM X-Gene SLIMpro IPCM support.
 endif
drivers/mailbox/Makefile +1 -0
index 94ed7ce..33b2709 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_MAILBOX)		+= mailbox.o
 obj-$(CONFIG_PL320_MBOX)	+= pl320-ipc.o
 
 obj-$(CONFIG_OMAP2PLUS_MBOX)	+= omap-mailbox.o
+obj-$(CONFIG_XGENE_SLIMPRO_MBOX) += mailbox-xgene-slimpro.o
drivers/mailbox/mailbox-xgene-slimpro.c new file +287 -0

287 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#2 lore raw

PATCH 2/6 Documentation: mailbox: Add APM X-Gene SLIMpro mailbox dts documentation

In reply to Feng Kan

This adds the APM X-Gene SLIMpro mailbox device tree node documentation.

---
 .../bindings/mailbox/xgene-slimpro-mailbox.txt     | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +41 -0
new file mode 100644
index 0000000..d0b74fb
@@ -0,0 +1,41 @@
+The APM X-Gene SLIMpro mailbox driver is used to communicate messages between
+the ARM64 processors and the Cortex M3 (dubbed SLIMpro). It uses a simple
+interrupt based door bell mechanism and can exchange simple messages using the
+internal registers.
+
+There are total of 8 interrupts in this mailbox. Each used for an individual
+door bell (or mailbox channel).
+
+Required properties:
+- compatible:	Should be as "apm, xgene-slimpro-mbox".
+
+- reg:		Contain the mailbox register address range.
+
+- interrupts:	Contain interrupt information for the mailbox device.
+
+- #mbox-cells:	Specify the number of parameters used by the mailbox client.
+		Currently only one to specify the mailbox channel number.
+
+Example:
+
+Mailbox Node:
+		slimpro-mbox: slimpro-mbox at 10540000 {
+			compatible = "apm,xgene-slimpro-mbox";
+			reg = <0x0 0x10540000 0x0 0xa000>;
+			#mbox-cells = <1>;
+			interrupts =  	<0x0 0x0 0x4>,
+					<0x0 0x1 0x4>,
+					<0x0 0x2 0x4>,
+					<0x0 0x3 0x4>,
+					<0x0 0x4 0x4>,
+					<0x0 0x5 0x4>,
+					<0x0 0x6 0x4>,
+					<0x0 0x7 0x4>;
+		};
+
+Client Node:
+		i2c-slimpro {
+			compatible = "apm,xgene-slimpro-i2c";
+			mbox = <&slimpro-mbox 0>;
+			mbox-names = "i2c-slimpro";
+		};
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH 2/6] Documentation: mailbox: Add APM X-Gene SLIMpro mailbox dts documentation

Quoted 14 lines · Feng Kan

This adds the APM X-Gene SLIMpro mailbox device tree node documentation.

---
 .../bindings/mailbox/xgene-slimpro-mailbox.txt     | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +0 -0
new file mode 100644
index 0000000..d0b74fb

Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +4 -0
@@ -0,0 +1,41 @@
+The APM X-Gene SLIMpro mailbox driver is used to communicate messages between
+the ARM64 processors and the Cortex M3 (dubbed SLIMpro). It uses a simple
+interrupt based door bell mechanism and can exchange simple messages using the
+internal registers.

The above should be a description of the hardware organisation, not the Linux driver. Removing the word "driver" in the above should be sufficient.

Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt line 7

Quoted 3 lines
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +3 -0
+
+There are total of 8 interrupts in this mailbox. Each used for an individual
+door bell (or mailbox channel).

This should be described in the interrupts property.

Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt line 10

Quoted 3 lines
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +3 -0
+
+Required properties:
+- compatible:	Should be as "apm, xgene-slimpro-mbox".

That space shouldn't be there.

Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt line 14

Quoted 4 lines
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +4 -0
+
+- reg:		Contain the mailbox register address range.
+
+- interrupts:	Contain interrupt information for the mailbox device.

Please describe the specifics of this proeprty. This description is too general to be of any use. Specific how many interrupts you expect, the order thereof, etc. If there's not a well-defined ordering, or if you believe interrupts will be omitted, use interrupt-names, and define interrutps in terms of it.

Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt line 17

Quoted 3 lines
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +3 -0
+
+- #mbox-cells:	Specify the number of parameters used by the mailbox client.
+		Currently only one to specify the mailbox channel number.

This should be a description of the specific values expected by this binding rather than the general meaning of this property. How many mbox cells do you expect (1, it seems?), and what does each encode(the index of the mailbox?)?

Thanks,
Mark.

Quoted 33 lines
Documentation/devicetree/bindings/mailbox/xgene-slimpro-mailbox.txt new file +24 -0
+
+Example:
+
+Mailbox Node:
+		slimpro-mbox: slimpro-mbox at 10540000 {
+			compatible = "apm,xgene-slimpro-mbox";
+			reg = <0x0 0x10540000 0x0 0xa000>;
+			#mbox-cells = <1>;
+			interrupts =  	<0x0 0x0 0x4>,
+					<0x0 0x1 0x4>,
+					<0x0 0x2 0x4>,
+					<0x0 0x3 0x4>,
+					<0x0 0x4 0x4>,
+					<0x0 0x5 0x4>,
+					<0x0 0x6 0x4>,
+					<0x0 0x7 0x4>;
+		};
+
+Client Node:
+		i2c-slimpro {
+			compatible = "apm,xgene-slimpro-i2c";
+			mbox = <&slimpro-mbox 0>;
+			mbox-names = "i2c-slimpro";
+		};
Signature · 7 lines
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#4 lore raw

PATCH 3/6 arm64: dts: mailbox device tree node for APM X-Gene platform.

In reply to Feng Kan

Mailbox device tree node for APM X-Gene platform.

---
 arch/arm64/boot/dts/apm-storm.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm64/boot/dts/apm-storm.dtsi +14 -0
index 1cd5173..249f025 100644
@@ -455,6 +455,20 @@
 			clocks = <&pcie4clk 0>;
 		};
 
+		mailbox: slimpro-mbox at 10540000 {
+			compatible = "apm,xgene-slimpro-mbox";
+			reg = <0x0 0x10540000 0x0 0xa000>;
+			#mbox-cells = <1>;
+			interrupts =    <0x0 0x0 0x4>,
+					<0x0 0x1 0x4>,
+					<0x0 0x2 0x4>,
+					<0x0 0x3 0x4>,
+					<0x0 0x4 0x4>,
+					<0x0 0x5 0x4>,
+					<0x0 0x6 0x4>,
+					<0x0 0x7 0x4>;
+		};
+
 		serial0: serial at 1c020000 {
 			status = "disabled";
 			device_type = "serial";
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH 4/6 i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

In reply to Feng Kan

Add SLIMpro I2C device driver on APM X-Gene platform. This I2C device driver use the SLIMpro Mailbox driver to tunnel message to the SLIMpro coprocessor to do the work of accessing I2C components.

---
 drivers/i2c/busses/Kconfig             |   9 +
 drivers/i2c/busses/Makefile            |   1 +
 drivers/i2c/busses/i2c-xgene-slimpro.c | 531 +++++++++++++++++++++++++++++++++
 3 files changed, 541 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-xgene-slimpro.c
drivers/i2c/busses/Kconfig +9 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
 	  connected there. This will work whatever the interface used to
 	  talk to the EC (SPI, I2C or LPC).
 
+config I2C_XGENE_SLIMPRO
+	tristate "APM X-Gene SoC I2C SLIMpro devices support"
+	depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX
+	help
+	  Enable I2C bus access using the APM X-Gene SoC SLIMpro
+	  co-processor. The I2C device access the I2C bus via the X-Gene
+	  to SLIMpro (On chip coprocessor) mailbox mechanism.
+	  If unsure, say N.
+
 config SCx200_ACB
 	tristate "Geode ACCESS.bus support"
 	depends on X86_32 && PCI
drivers/i2c/busses/Makefile +1 -0
index 49bf07e..22b5f0c 100644
@@ -99,6 +99,7 @@ obj-$(CONFIG_I2C_CROS_EC_TUNNEL)	+= i2c-cros-ec-tunnel.o
 obj-$(CONFIG_I2C_ELEKTOR)	+= i2c-elektor.o
 obj-$(CONFIG_I2C_PCA_ISA)	+= i2c-pca-isa.o
 obj-$(CONFIG_I2C_SIBYTE)	+= i2c-sibyte.o
+obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o
 obj-$(CONFIG_SCx200_ACB)	+= scx200_acb.o
 
 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
drivers/i2c/busses/i2c-xgene-slimpro.c new file +531 -0

531 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 6 lines · Feng Kan

Add SLIMpro I2C device driver on APM X-Gene platform. This I2C device driver use the SLIMpro Mailbox driver to tunnel message to the SLIMpro coprocessor to do the work of accessing I2C components.

Thank you for this submission!

Quoted 7 lines
drivers/i2c/busses/Kconfig +0 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
 	  connected there. This will work whatever the interface used to
 	  talk to the EC (SPI, I2C or LPC).

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1020

Quoted 10 lines
drivers/i2c/busses/Kconfig +9 -0
 
+config I2C_XGENE_SLIMPRO
+	tristate "APM X-Gene SoC I2C SLIMpro devices support"
+	depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX
+	help
+	  Enable I2C bus access using the APM X-Gene SoC SLIMpro
+	  co-processor. The I2C device access the I2C bus via the X-Gene
+	  to SLIMpro (On chip coprocessor) mailbox mechanism.
+	  If unsure, say N.
+

I guess this is a driver for embedded? If so, please sort it properly.

drivers/i2c/busses/Makefile obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o · line 102

Quoted 12 lines
drivers/i2c/busses/Kconfig +0 -0
 config SCx200_ACB
 	tristate "Geode ACCESS.bus support"
 	depends on X86_32 && PCI
drivers/i2c/busses/Makefile +1 -0
index 49bf07e..22b5f0c 100644
@@ -99,6 +99,7 @@ obj-$(CONFIG_I2C_CROS_EC_TUNNEL)	+= i2c-cros-ec-tunnel.o
 obj-$(CONFIG_I2C_ELEKTOR)	+= i2c-elektor.o
 obj-$(CONFIG_I2C_PCA_ISA)	+= i2c-pca-isa.o
 obj-$(CONFIG_I2C_SIBYTE)	+= i2c-sibyte.o
+obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o

Ditto.

Quoted 10 lines
drivers/i2c/busses/Makefile +0 -0
 obj-$(CONFIG_SCx200_ACB)	+= scx200_acb.o
 
 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
drivers/i2c/busses/i2c-xgene-slimpro.c new file +1 -0
new file mode 100644
index 0000000..2cf6c33
@@ -0,0 +1,531 @@
+/*

drivers/i2c/busses/i2c-xgene-slimpro.c line 11

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+ * X-Gene SLIMpro I2C Driver
+ *
+ * Copyright (c) 2014, Applied Micro Circuits Corporation
+ * Author: Feng Kan <[email protected]>
+ * Author: Hieu Le <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.

The license preamble and MODULE_LICENSE do not match!

drivers/i2c/busses/i2c-xgene-slimpro.c line 34

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/i2c.h>
+#include <linux/mailbox_client.h>
+#include <linux/delay.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>

Please sort the includes.

drivers/i2c/busses/i2c-xgene-slimpro.c line 36

Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2 -0
+
+#define XGENE_SLIMPRO_I2C		"xgene-slimpro-i2c"

Only used once, not really needed

drivers/i2c/busses/i2c-xgene-slimpro.c line 40

Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +4 -0
+
+#define SLIMPRO_I2C_WAIT_COUNT		10000
+
+#define SLIMPRO_OP_TO_MS		1000	/* Operation time out in ms */

*_TOUT_* or *_TIMEOUT_*. TO sounds like a conversion, from op to ms :)

drivers/i2c/busses/i2c-xgene-slimpro.c line 41

Quoted 1 line
drivers/i2c/busses/i2c-xgene-slimpro.c new file +1 -0
+#define SLIMPRO_IIC_BUS			1

What does this '1' mean?

drivers/i2c/busses/i2c-xgene-slimpro.c line 158

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+static int start_i2c_msg_xfer(struct slimpro_i2c_dev *ctx)
+{
+	int count;
+	unsigned long flags;
+
+	if (ctx->mbox_client.tx_block) {
+		if (!wait_for_completion_timeout(&ctx->rd_complete,
+						 msecs_to_jiffies
+						 (SLIMPRO_OP_TO_MS)))
+			return -EIO;

That should be -ETIMEDOUT, no?

Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +4 -0
+	} else {
+		spin_lock_irqsave(&ctx->lock, flags);
+		ctx->i2c_rx_poll = 1;
+		for (count = SLIMPRO_I2C_WAIT_COUNT; count > 0; count--) {

drivers/i2c/busses/i2c-xgene-slimpro.c line 172

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+			if (ctx->i2c_rx_poll == 0)
+				break;
+			udelay(100);
+		}
+
+		if (count == 0) {
+			ctx->i2c_rx_poll = 0;
+			ctx->mbox_client.tx_block = true;
+			spin_unlock_irqrestore(&ctx->lock, flags);
+			return -EIO;

ditto.

Quoted 16 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +16 -0
+		}
+		ctx->mbox_client.tx_block = true;
+		spin_unlock_irqrestore(&ctx->lock, flags);
+	}
+
+	/* Check of invalid data or no device */
+	if (*ctx->resp_msg == 0xffffffff)
+		return -ENODEV;
+
+	return 0;
+}
+
+static int slimpro_i2c_blkrd(struct slimpro_i2c_dev *ctx, u32 chip, u32 addr,
+				u32 addrlen, u32 protocol, u32 readlen,
+				u32 with_data_len, void *data)
+{

drivers/i2c/busses/i2c-xgene-slimpro.c line 257

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+	dma_addr_t paddr;
+	u32 msg[3];
+	int rc;
+
+	paddr = dma_map_single(ctx->dev, ctx->dma_buffer, readlen,
+			       DMA_FROM_DEVICE);
+	if (dma_mapping_error(ctx->dev, paddr)) {
+		dev_err(&ctx->adapter.dev, "Error in mapping dma buffer %p\n",
+			ctx->dma_buffer);
+		rc = -EIO;

Return the err value from dma_mapping_error?

Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +8 -0
+		goto err;
+	}
+
+	if (irqs_disabled())
+		ctx->mbox_client.tx_block = false;
+
+	msg[0] = SLIMPRO_IIC_ENCODE_MSG(SLIMPRO_IIC_BUS, chip,
+					SLIMPRO_IIC_READ, protocol, addrlen,

drivers/i2c/busses/i2c-xgene-slimpro.c line 275

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+					readlen);
+	msg[1] = SLIMPRO_IIC_ENCODE_FLAG_BUFADDR |
+		 SLIMPRO_IIC_ENCODE_FLAG_WITH_DATA_LEN(with_data_len) |
+		 SLIMPRO_IIC_ENCODE_UPPER_BUFADDR(paddr) |
+		 SLIMPRO_IIC_ENCODE_ADDR(addr);
+	msg[2] = (u32) paddr;
+	ctx->resp_msg = msg;
+
+	if (ctx->mbox_client.tx_block)
+		init_completion(&ctx->rd_complete);

reinit_completion? and init_completion in probe?

Quoted 22 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +22 -0
+
+	rc = mbox_send_message(ctx->mbox_chan, &msg);
+	if (rc < 0)
+		goto err_unmap;
+
+	rc = start_i2c_msg_xfer(ctx);
+
+	/* Copy to destination */
+	memcpy(data, ctx->dma_buffer, readlen);
+
+err_unmap:
+	dma_unmap_single(ctx->dev, paddr, readlen, DMA_FROM_DEVICE);
+err:
+	ctx->resp_msg = NULL;
+	return rc;
+}
+
+static int slimpro_i2c_blkwr(struct slimpro_i2c_dev *ctx, u32 chip,
+			     u32 addr, u32 addrlen, u32 protocol, u32 writelen,
+			     void *data)
+{
+	dma_addr_t paddr;

drivers/i2c/busses/i2c-xgene-slimpro.c line 307

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+	u32 msg[3];
+	int rc;
+
+	memcpy(ctx->dma_buffer, data, writelen);
+	paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen,
+			       DMA_TO_DEVICE);
+	if (dma_mapping_error(ctx->dev, paddr)) {
+		dev_err(&ctx->adapter.dev, "Error in mapping dma buffer %p\n",
+			ctx->dma_buffer);
+		rc = -EIO;

same as above

Quoted 7 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +7 -0
+		goto err;
+	}
+
+	if (irqs_disabled())
+		ctx->mbox_client.tx_block = false;
+
+	msg[0] = SLIMPRO_IIC_ENCODE_MSG(SLIMPRO_IIC_BUS, chip,

drivers/i2c/busses/i2c-xgene-slimpro.c line 275

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+					SLIMPRO_IIC_WRITE, protocol, addrlen,
+					writelen);
+	msg[1] = SLIMPRO_IIC_ENCODE_FLAG_BUFADDR |
+		 SLIMPRO_IIC_ENCODE_UPPER_BUFADDR(paddr) |
+		 SLIMPRO_IIC_ENCODE_ADDR(addr);
+	msg[2] = (u32) paddr;
+	ctx->resp_msg = msg;
+
+	if (ctx->mbox_client.tx_block)
+		init_completion(&ctx->rd_complete);

ditto

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+
+	rc = mbox_send_message(ctx->mbox_chan, &msg);
+	if (rc < 0)
+		goto err_unmap;
+
+	rc = start_i2c_msg_xfer(ctx);
+
+err_unmap:
+	dma_unmap_single(ctx->dev, paddr, writelen, DMA_TO_DEVICE);
+err:

drivers/i2c/busses/i2c-xgene-slimpro.c

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+	ctx->resp_msg = NULL;
+	return rc;
+}
+
+static struct platform_driver xgene_slimpro_i2c_driver = {
+	.probe	= xgene_slimpro_i2c_probe,
+	.remove	= xgene_slimpro_i2c_remove,
+	.driver	= {
+		.name	= XGENE_SLIMPRO_I2C,
+		.owner	= THIS_MODULE,

Not needed.

drivers/i2c/busses/i2c-xgene-slimpro.c line 531

Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +8 -0
+		.of_match_table = of_match_ptr(xgene_slimpro_i2c_id)
+	},
+};
+
+module_platform_driver(xgene_slimpro_i2c_driver);
+
+MODULE_DESCRIPTION("APM X-Gene SLIMpro I2C driver");
+MODULE_LICENSE("GPL v2");

So, only minor stuff. Looking good already to me.

Thanks,

Wolfram

author
#7 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 18 lines · Wolfram Sang
Quoted 6 lines · Feng Kan

Add SLIMpro I2C device driver on APM X-Gene platform. This I2C device driver use the SLIMpro Mailbox driver to tunnel message to the SLIMpro coprocessor to do the work of accessing I2C components.

Thank you for this submission!

Quoted 8 lines
drivers/i2c/busses/Kconfig +0 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
        connected there. This will work whatever the interface used to
        talk to the EC (SPI, I2C or LPC).
 
Quoted 11 lines

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1020

Quoted 9 lines
drivers/i2c/busses/Kconfig +9 -0
+config I2C_XGENE_SLIMPRO
+     tristate "APM X-Gene SoC I2C SLIMpro devices support"
+     depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX
+     help
+       Enable I2C bus access using the APM X-Gene SoC SLIMpro
+       co-processor. The I2C device access the I2C bus via the X-Gene
+       to SLIMpro (On chip coprocessor) mailbox mechanism.
+       If unsure, say N.
+

I guess this is a driver for embedded? If so, please sort it properly.

This is a SoC chip but not for embedded platform. Also the fact that this is not a traditional I2C driver, but one that tunnels to the helper cpu using mailbox to obtain I2C information. Do you still want me to group it with the embedded drivers?

Quoted 241 lines

drivers/i2c/busses/Makefile obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o · line 102

Quoted 13 lines
drivers/i2c/busses/Kconfig +0 -0
 config SCx200_ACB
      tristate "Geode ACCESS.bus support"
      depends on X86_32 && PCI
drivers/i2c/busses/Makefile +1 -0
index 49bf07e..22b5f0c 100644
@@ -99,6 +99,7 @@ obj-$(CONFIG_I2C_CROS_EC_TUNNEL)    += i2c-cros-ec-tunnel.o
 obj-$(CONFIG_I2C_ELEKTOR)    += i2c-elektor.o
 obj-$(CONFIG_I2C_PCA_ISA)    += i2c-pca-isa.o
 obj-$(CONFIG_I2C_SIBYTE)     += i2c-sibyte.o
+obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o

Ditto.

Quoted 10 lines
drivers/i2c/busses/Makefile +0 -0
 obj-$(CONFIG_SCx200_ACB)     += scx200_acb.o
 
 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
drivers/i2c/busses/i2c-xgene-slimpro.c new file +1 -0
new file mode 100644
index 0000000..2cf6c33
@@ -0,0 +1,531 @@
+/*

drivers/i2c/busses/i2c-xgene-slimpro.c line 11

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+ * X-Gene SLIMpro I2C Driver
+ *
+ * Copyright (c) 2014, Applied Micro Circuits Corporation
+ * Author: Feng Kan <[email protected]>
+ * Author: Hieu Le <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.

The license preamble and MODULE_LICENSE do not match!

drivers/i2c/busses/i2c-xgene-slimpro.c line 34

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/i2c.h>
+#include <linux/mailbox_client.h>
+#include <linux/delay.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>

Please sort the includes.

drivers/i2c/busses/i2c-xgene-slimpro.c line 36

Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2 -0
+
+#define XGENE_SLIMPRO_I2C            "xgene-slimpro-i2c"

Only used once, not really needed

drivers/i2c/busses/i2c-xgene-slimpro.c line 40

Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +4 -0
+
+#define SLIMPRO_I2C_WAIT_COUNT               10000
+
+#define SLIMPRO_OP_TO_MS             1000    /* Operation time out in ms */

*_TOUT_* or *_TIMEOUT_*. TO sounds like a conversion, from op to ms :)

drivers/i2c/busses/i2c-xgene-slimpro.c line 41

Quoted 1 line
drivers/i2c/busses/i2c-xgene-slimpro.c new file +1 -0
+#define SLIMPRO_IIC_BUS                      1

What does this '1' mean?

drivers/i2c/busses/i2c-xgene-slimpro.c line 158

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+static int start_i2c_msg_xfer(struct slimpro_i2c_dev *ctx)
+{
+     int count;
+     unsigned long flags;
+
+     if (ctx->mbox_client.tx_block) {
+             if (!wait_for_completion_timeout(&ctx->rd_complete,
+                                              msecs_to_jiffies
+                                              (SLIMPRO_OP_TO_MS)))
+                     return -EIO;

That should be -ETIMEDOUT, no?

Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +4 -0
+     } else {
+             spin_lock_irqsave(&ctx->lock, flags);
+             ctx->i2c_rx_poll = 1;
+             for (count = SLIMPRO_I2C_WAIT_COUNT; count > 0; count--) {

drivers/i2c/busses/i2c-xgene-slimpro.c line 172

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+                     if (ctx->i2c_rx_poll == 0)
+                             break;
+                     udelay(100);
+             }
+
+             if (count == 0) {
+                     ctx->i2c_rx_poll = 0;
+                     ctx->mbox_client.tx_block = true;
+                     spin_unlock_irqrestore(&ctx->lock, flags);
+                     return -EIO;

ditto.

Quoted 16 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +16 -0
+             }
+             ctx->mbox_client.tx_block = true;
+             spin_unlock_irqrestore(&ctx->lock, flags);
+     }
+
+     /* Check of invalid data or no device */
+     if (*ctx->resp_msg == 0xffffffff)
+             return -ENODEV;
+
+     return 0;
+}
+
+static int slimpro_i2c_blkrd(struct slimpro_i2c_dev *ctx, u32 chip, u32 addr,
+                             u32 addrlen, u32 protocol, u32 readlen,
+                             u32 with_data_len, void *data)
+{

drivers/i2c/busses/i2c-xgene-slimpro.c line 257

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+     dma_addr_t paddr;
+     u32 msg[3];
+     int rc;
+
+     paddr = dma_map_single(ctx->dev, ctx->dma_buffer, readlen,
+                            DMA_FROM_DEVICE);
+     if (dma_mapping_error(ctx->dev, paddr)) {
+             dev_err(&ctx->adapter.dev, "Error in mapping dma buffer %p\n",
+                     ctx->dma_buffer);
+             rc = -EIO;

Return the err value from dma_mapping_error?

Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +8 -0
+             goto err;
+     }
+
+     if (irqs_disabled())
+             ctx->mbox_client.tx_block = false;
+
+     msg[0] = SLIMPRO_IIC_ENCODE_MSG(SLIMPRO_IIC_BUS, chip,
+                                     SLIMPRO_IIC_READ, protocol, addrlen,

drivers/i2c/busses/i2c-xgene-slimpro.c line 275

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+                                     readlen);
+     msg[1] = SLIMPRO_IIC_ENCODE_FLAG_BUFADDR |
+              SLIMPRO_IIC_ENCODE_FLAG_WITH_DATA_LEN(with_data_len) |
+              SLIMPRO_IIC_ENCODE_UPPER_BUFADDR(paddr) |
+              SLIMPRO_IIC_ENCODE_ADDR(addr);
+     msg[2] = (u32) paddr;
+     ctx->resp_msg = msg;
+
+     if (ctx->mbox_client.tx_block)
+             init_completion(&ctx->rd_complete);

reinit_completion? and init_completion in probe?

Quoted 22 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +22 -0
+
+     rc = mbox_send_message(ctx->mbox_chan, &msg);
+     if (rc < 0)
+             goto err_unmap;
+
+     rc = start_i2c_msg_xfer(ctx);
+
+     /* Copy to destination */
+     memcpy(data, ctx->dma_buffer, readlen);
+
+err_unmap:
+     dma_unmap_single(ctx->dev, paddr, readlen, DMA_FROM_DEVICE);
+err:
+     ctx->resp_msg = NULL;
+     return rc;
+}
+
+static int slimpro_i2c_blkwr(struct slimpro_i2c_dev *ctx, u32 chip,
+                          u32 addr, u32 addrlen, u32 protocol, u32 writelen,
+                          void *data)
+{
+     dma_addr_t paddr;

drivers/i2c/busses/i2c-xgene-slimpro.c line 307

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+     u32 msg[3];
+     int rc;
+
+     memcpy(ctx->dma_buffer, data, writelen);
+     paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen,
+                            DMA_TO_DEVICE);
+     if (dma_mapping_error(ctx->dev, paddr)) {
+             dev_err(&ctx->adapter.dev, "Error in mapping dma buffer %p\n",
+                     ctx->dma_buffer);
+             rc = -EIO;

same as above

Quoted 7 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +7 -0
+             goto err;
+     }
+
+     if (irqs_disabled())
+             ctx->mbox_client.tx_block = false;
+
+     msg[0] = SLIMPRO_IIC_ENCODE_MSG(SLIMPRO_IIC_BUS, chip,

drivers/i2c/busses/i2c-xgene-slimpro.c line 275

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+                                     SLIMPRO_IIC_WRITE, protocol, addrlen,
+                                     writelen);
+     msg[1] = SLIMPRO_IIC_ENCODE_FLAG_BUFADDR |
+              SLIMPRO_IIC_ENCODE_UPPER_BUFADDR(paddr) |
+              SLIMPRO_IIC_ENCODE_ADDR(addr);
+     msg[2] = (u32) paddr;
+     ctx->resp_msg = msg;
+
+     if (ctx->mbox_client.tx_block)
+             init_completion(&ctx->rd_complete);

ditto

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+
+     rc = mbox_send_message(ctx->mbox_chan, &msg);
+     if (rc < 0)
+             goto err_unmap;
+
+     rc = start_i2c_msg_xfer(ctx);
+
+err_unmap:
+     dma_unmap_single(ctx->dev, paddr, writelen, DMA_TO_DEVICE);
+err:

drivers/i2c/busses/i2c-xgene-slimpro.c

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+     ctx->resp_msg = NULL;
+     return rc;
+}
+
+static struct platform_driver xgene_slimpro_i2c_driver = {
+     .probe  = xgene_slimpro_i2c_probe,
+     .remove = xgene_slimpro_i2c_remove,
+     .driver = {
+             .name   = XGENE_SLIMPRO_I2C,
+             .owner  = THIS_MODULE,

Not needed.

drivers/i2c/busses/i2c-xgene-slimpro.c line 531

Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +8 -0
+             .of_match_table = of_match_ptr(xgene_slimpro_i2c_id)
+     },
+};
+
+module_platform_driver(xgene_slimpro_i2c_driver);
+
+MODULE_DESCRIPTION("APM X-Gene SLIMpro I2C driver");
+MODULE_LICENSE("GPL v2");

So, only minor stuff. Looking good already to me.

Thanks,

Wolfram

author
#8 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

In reply to Wolfram Sang
Quoted 18 lines · Wolfram Sang
Quoted 6 lines · Feng Kan

Add SLIMpro I2C device driver on APM X-Gene platform. This I2C device driver use the SLIMpro Mailbox driver to tunnel message to the SLIMpro coprocessor to do the work of accessing I2C components.

Thank you for this submission!

Quoted 8 lines
drivers/i2c/busses/Kconfig +0 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
        connected there. This will work whatever the interface used to
        talk to the EC (SPI, I2C or LPC).
 
Quoted 11 lines

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1020

Quoted 9 lines
drivers/i2c/busses/Kconfig +9 -0
+config I2C_XGENE_SLIMPRO
+     tristate "APM X-Gene SoC I2C SLIMpro devices support"
+     depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX
+     help
+       Enable I2C bus access using the APM X-Gene SoC SLIMpro
+       co-processor. The I2C device access the I2C bus via the X-Gene
+       to SLIMpro (On chip coprocessor) mailbox mechanism.
+       If unsure, say N.
+

I guess this is a driver for embedded? If so, please sort it properly.

Sorry, having let this dangle for a while. I will fix up comments and submit another version. I can move this to embedded, however Xgene is suppose to be a server class chip.

Quoted 226 lines

drivers/i2c/busses/Makefile obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o · line 102

Quoted 13 lines
drivers/i2c/busses/Kconfig +0 -0
 config SCx200_ACB
      tristate "Geode ACCESS.bus support"
      depends on X86_32 && PCI
drivers/i2c/busses/Makefile +1 -0
index 49bf07e..22b5f0c 100644
@@ -99,6 +99,7 @@ obj-$(CONFIG_I2C_CROS_EC_TUNNEL)    += i2c-cros-ec-tunnel.o
 obj-$(CONFIG_I2C_ELEKTOR)    += i2c-elektor.o
 obj-$(CONFIG_I2C_PCA_ISA)    += i2c-pca-isa.o
 obj-$(CONFIG_I2C_SIBYTE)     += i2c-sibyte.o
+obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o

Ditto.

Quoted 10 lines
drivers/i2c/busses/Makefile +0 -0
 obj-$(CONFIG_SCx200_ACB)     += scx200_acb.o
 
 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
drivers/i2c/busses/i2c-xgene-slimpro.c new file +1 -0
new file mode 100644
index 0000000..2cf6c33
@@ -0,0 +1,531 @@
+/*

drivers/i2c/busses/i2c-xgene-slimpro.c line 11

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+ * X-Gene SLIMpro I2C Driver
+ *
+ * Copyright (c) 2014, Applied Micro Circuits Corporation
+ * Author: Feng Kan <[email protected]>
+ * Author: Hieu Le <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.

The license preamble and MODULE_LICENSE do not match!

drivers/i2c/busses/i2c-xgene-slimpro.c line 34

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/i2c.h>
+#include <linux/mailbox_client.h>
+#include <linux/delay.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>

Please sort the includes.

drivers/i2c/busses/i2c-xgene-slimpro.c line 36

Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2 -0
+
+#define XGENE_SLIMPRO_I2C            "xgene-slimpro-i2c"

Only used once, not really needed

drivers/i2c/busses/i2c-xgene-slimpro.c line 40

Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +4 -0
+
+#define SLIMPRO_I2C_WAIT_COUNT               10000
+
+#define SLIMPRO_OP_TO_MS             1000    /* Operation time out in ms */

*_TOUT_* or *_TIMEOUT_*. TO sounds like a conversion, from op to ms :)

drivers/i2c/busses/i2c-xgene-slimpro.c line 41

Quoted 1 line
drivers/i2c/busses/i2c-xgene-slimpro.c new file +1 -0
+#define SLIMPRO_IIC_BUS                      1

What does this '1' mean?

drivers/i2c/busses/i2c-xgene-slimpro.c line 158

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+static int start_i2c_msg_xfer(struct slimpro_i2c_dev *ctx)
+{
+     int count;
+     unsigned long flags;
+
+     if (ctx->mbox_client.tx_block) {
+             if (!wait_for_completion_timeout(&ctx->rd_complete,
+                                              msecs_to_jiffies
+                                              (SLIMPRO_OP_TO_MS)))
+                     return -EIO;

That should be -ETIMEDOUT, no?

Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +4 -0
+     } else {
+             spin_lock_irqsave(&ctx->lock, flags);
+             ctx->i2c_rx_poll = 1;
+             for (count = SLIMPRO_I2C_WAIT_COUNT; count > 0; count--) {

drivers/i2c/busses/i2c-xgene-slimpro.c line 172

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+                     if (ctx->i2c_rx_poll == 0)
+                             break;
+                     udelay(100);
+             }
+
+             if (count == 0) {
+                     ctx->i2c_rx_poll = 0;
+                     ctx->mbox_client.tx_block = true;
+                     spin_unlock_irqrestore(&ctx->lock, flags);
+                     return -EIO;

ditto.

Quoted 16 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +16 -0
+             }
+             ctx->mbox_client.tx_block = true;
+             spin_unlock_irqrestore(&ctx->lock, flags);
+     }
+
+     /* Check of invalid data or no device */
+     if (*ctx->resp_msg == 0xffffffff)
+             return -ENODEV;
+
+     return 0;
+}
+
+static int slimpro_i2c_blkrd(struct slimpro_i2c_dev *ctx, u32 chip, u32 addr,
+                             u32 addrlen, u32 protocol, u32 readlen,
+                             u32 with_data_len, void *data)
+{

drivers/i2c/busses/i2c-xgene-slimpro.c line 257

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+     dma_addr_t paddr;
+     u32 msg[3];
+     int rc;
+
+     paddr = dma_map_single(ctx->dev, ctx->dma_buffer, readlen,
+                            DMA_FROM_DEVICE);
+     if (dma_mapping_error(ctx->dev, paddr)) {
+             dev_err(&ctx->adapter.dev, "Error in mapping dma buffer %p\n",
+                     ctx->dma_buffer);
+             rc = -EIO;

Return the err value from dma_mapping_error?

Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +8 -0
+             goto err;
+     }
+
+     if (irqs_disabled())
+             ctx->mbox_client.tx_block = false;
+
+     msg[0] = SLIMPRO_IIC_ENCODE_MSG(SLIMPRO_IIC_BUS, chip,
+                                     SLIMPRO_IIC_READ, protocol, addrlen,

drivers/i2c/busses/i2c-xgene-slimpro.c line 275

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+                                     readlen);
+     msg[1] = SLIMPRO_IIC_ENCODE_FLAG_BUFADDR |
+              SLIMPRO_IIC_ENCODE_FLAG_WITH_DATA_LEN(with_data_len) |
+              SLIMPRO_IIC_ENCODE_UPPER_BUFADDR(paddr) |
+              SLIMPRO_IIC_ENCODE_ADDR(addr);
+     msg[2] = (u32) paddr;
+     ctx->resp_msg = msg;
+
+     if (ctx->mbox_client.tx_block)
+             init_completion(&ctx->rd_complete);

reinit_completion? and init_completion in probe?

Quoted 22 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +22 -0
+
+     rc = mbox_send_message(ctx->mbox_chan, &msg);
+     if (rc < 0)
+             goto err_unmap;
+
+     rc = start_i2c_msg_xfer(ctx);
+
+     /* Copy to destination */
+     memcpy(data, ctx->dma_buffer, readlen);
+
+err_unmap:
+     dma_unmap_single(ctx->dev, paddr, readlen, DMA_FROM_DEVICE);
+err:
+     ctx->resp_msg = NULL;
+     return rc;
+}
+
+static int slimpro_i2c_blkwr(struct slimpro_i2c_dev *ctx, u32 chip,
+                          u32 addr, u32 addrlen, u32 protocol, u32 writelen,
+                          void *data)
+{
+     dma_addr_t paddr;

drivers/i2c/busses/i2c-xgene-slimpro.c line 307

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+     u32 msg[3];
+     int rc;
+
+     memcpy(ctx->dma_buffer, data, writelen);
+     paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen,
+                            DMA_TO_DEVICE);
+     if (dma_mapping_error(ctx->dev, paddr)) {
+             dev_err(&ctx->adapter.dev, "Error in mapping dma buffer %p\n",
+                     ctx->dma_buffer);
+             rc = -EIO;

same as above

Quoted 7 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +7 -0
+             goto err;
+     }
+
+     if (irqs_disabled())
+             ctx->mbox_client.tx_block = false;
+
+     msg[0] = SLIMPRO_IIC_ENCODE_MSG(SLIMPRO_IIC_BUS, chip,

drivers/i2c/busses/i2c-xgene-slimpro.c line 275

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+                                     SLIMPRO_IIC_WRITE, protocol, addrlen,
+                                     writelen);
+     msg[1] = SLIMPRO_IIC_ENCODE_FLAG_BUFADDR |
+              SLIMPRO_IIC_ENCODE_UPPER_BUFADDR(paddr) |
+              SLIMPRO_IIC_ENCODE_ADDR(addr);
+     msg[2] = (u32) paddr;
+     ctx->resp_msg = msg;
+
+     if (ctx->mbox_client.tx_block)
+             init_completion(&ctx->rd_complete);

ditto

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+
+     rc = mbox_send_message(ctx->mbox_chan, &msg);
+     if (rc < 0)
+             goto err_unmap;
+
+     rc = start_i2c_msg_xfer(ctx);
+
+err_unmap:
+     dma_unmap_single(ctx->dev, paddr, writelen, DMA_TO_DEVICE);
+err:

drivers/i2c/busses/i2c-xgene-slimpro.c

Quoted 10 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +10 -0
+     ctx->resp_msg = NULL;
+     return rc;
+}
+
+static struct platform_driver xgene_slimpro_i2c_driver = {
+     .probe  = xgene_slimpro_i2c_probe,
+     .remove = xgene_slimpro_i2c_remove,
+     .driver = {
+             .name   = XGENE_SLIMPRO_I2C,
+             .owner  = THIS_MODULE,

Not needed.

Quoted 10 lines

drivers/i2c/busses/i2c-xgene-slimpro.c line 531

Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +8 -0
+             .of_match_table = of_match_ptr(xgene_slimpro_i2c_id)
+     },
+};
+
+module_platform_driver(xgene_slimpro_i2c_driver);
+
+MODULE_DESCRIPTION("APM X-Gene SLIMpro I2C driver");
+MODULE_LICENSE("GPL v2");

So, only minor stuff. Looking good already to me.

Will fix the rest of the comments, thanks

Quoted 5 lines

Thanks,

Wolfram

#9 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 5 lines
Quoted 2 lines

I guess this is a driver for embedded? If so, please sort it properly.

Sorry, having let this dangle for a while. I will fix up comments and submit another version. I can move this to embedded, however Xgene is suppose to be a server class chip.

Then simply leave it as is :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150109/c44a27a2/attachment.sig>

#10 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

In reply to Feng Kan

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1014

Quoted 11 lines · On Tuesday 07 October 2014 17:06:47 Feng Kan wrote:
drivers/i2c/busses/Kconfig +3 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
 	  connected there. This will work whatever the interface used to
 	  talk to the EC (SPI, I2C or LPC).
 
+config I2C_XGENE_SLIMPRO
+	tristate "APM X-Gene SoC I2C SLIMpro devices support"
+	depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX

Why this dependency on XGENE_SLIMPRO_MBOX?

Better replace it with a dependency on MAILBOX.

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1022

Quoted 8 lines
drivers/i2c/busses/Kconfig +8 -0
+	} else {
+		spin_lock_irqsave(&ctx->lock, flags);
+		ctx->i2c_rx_poll = 1;
+		for (count = SLIMPRO_I2C_WAIT_COUNT; count > 0; count--) {
+			if (ctx->i2c_rx_poll == 0)
+				break;
+			udelay(100);
+		}

No, you can't block the CPU for an extended amount of time with interrupts disabled. Please kill this code.

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL

Quoted 3 lines
drivers/i2c/busses/Kconfig +3 -0
+	ctx->resp_msg = data;
+	if (ctx->mbox_client.tx_block)
+		init_completion(&ctx->rd_complete);

reinit_completion()?

drivers/i2c/busses/Kconfig

Quoted 10 lines
drivers/i2c/busses/Kconfig +10 -0
+static int slimpro_i2c_blkrd(struct slimpro_i2c_dev *ctx, u32 chip, u32 addr,
+				u32 addrlen, u32 protocol, u32 readlen,
+				u32 with_data_len, void *data)
+{
+	dma_addr_t paddr;
+	u32 msg[3];
+	int rc;
+
+	paddr = dma_map_single(ctx->dev, ctx->dma_buffer, readlen,
+			       DMA_FROM_DEVICE);

ctx->dev is probably the wrong device here. The i2c controller is not DMA capable itself, you need to have a pointer to the device that actually performs the DMA here.

drivers/i2c/busses/Kconfig

Quoted 9 lines
drivers/i2c/busses/Kconfig +9 -0
+	/* Request mailbox channel */
+	cl->dev = &pdev->dev;
+	cl->rx_callback = slimpro_i2c_rx_cb;
+	cl->tx_done = slimpro_i2c_tx_done;
+	cl->tx_block = true;
+	cl->tx_tout = SLIMPRO_OP_TO_MS;
+	cl->knows_txdone = false;
+	cl->chan_name = "i2c-slimpro";
+	ctx->mbox_chan = mbox_request_channel(cl);

This is not the correct interface.

drivers/i2c/busses/Kconfig

Quoted 3 lines
drivers/i2c/busses/Kconfig +3 -0
+	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+	if (rc)
+		dev_warn(&pdev->dev, "Unable to set dma mask\n");

Are you sure that this is the correct device to perform the DMA?

Moreover, the mask doesn't match the usage: the slimpro_i2c_blkrd function passes in only the lower 32 bit of the address, which would be DMA_BIT_MASK(32).

Quoted 7 lines
drivers/i2c/busses/Kconfig +7 -0
+#ifdef CONFIG_OF
+static struct of_device_id xgene_slimpro_i2c_id[] = {
+	{.compatible = "apm,xgene-slimpro-i2c" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, xgene_slimpro_i2c_dt_ids);
+#endif

drivers/i2c/busses/Kconfig

Quoted 10 lines
drivers/i2c/busses/Kconfig +10 -0
+
+static struct platform_driver xgene_slimpro_i2c_driver = {
+	.probe	= xgene_slimpro_i2c_probe,
+	.remove	= xgene_slimpro_i2c_remove,
+	.driver	= {
+		.name	= XGENE_SLIMPRO_I2C,
+		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(xgene_slimpro_i2c_id)
+	},
+};

The driver only supports DT, so just drop the #ifdef and the of_match_ptr().

author
#11 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 07 October 2014 17:06:47 Feng Kan wrote:
drivers/i2c/busses/Kconfig +0 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
        connected there. This will work whatever the interface used to
        talk to the EC (SPI, I2C or LPC).
 
Quoted 7 lines

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1014

Quoted 3 lines
drivers/i2c/busses/Kconfig +3 -0
+config I2C_XGENE_SLIMPRO
+     tristate "APM X-Gene SoC I2C SLIMpro devices support"
+     depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX

Why this dependency on XGENE_SLIMPRO_MBOX?

Better replace it with a dependency on MAILBOX.

Arnd, just a question. Is this because this possibly help with future compatibility by choosing a more broad dependency?

Quoted 81 lines

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1022

Quoted 9 lines
drivers/i2c/busses/Kconfig +8 -0
+     } else {
+             spin_lock_irqsave(&ctx->lock, flags);
+             ctx->i2c_rx_poll = 1;
+             for (count = SLIMPRO_I2C_WAIT_COUNT; count > 0; count--) {
+                     if (ctx->i2c_rx_poll == 0)
+                             break;
+                     udelay(100);
+             }

No, you can't block the CPU for an extended amount of time with interrupts disabled. Please kill this code.

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL

Quoted 3 lines
drivers/i2c/busses/Kconfig +3 -0
+     ctx->resp_msg = data;
+     if (ctx->mbox_client.tx_block)
+             init_completion(&ctx->rd_complete);

reinit_completion()?

drivers/i2c/busses/Kconfig

Quoted 10 lines
drivers/i2c/busses/Kconfig +10 -0
+static int slimpro_i2c_blkrd(struct slimpro_i2c_dev *ctx, u32 chip, u32 addr,
+                             u32 addrlen, u32 protocol, u32 readlen,
+                             u32 with_data_len, void *data)
+{
+     dma_addr_t paddr;
+     u32 msg[3];
+     int rc;
+
+     paddr = dma_map_single(ctx->dev, ctx->dma_buffer, readlen,
+                            DMA_FROM_DEVICE);

ctx->dev is probably the wrong device here. The i2c controller is not DMA capable itself, you need to have a pointer to the device that actually performs the DMA here.

drivers/i2c/busses/Kconfig

Quoted 9 lines
drivers/i2c/busses/Kconfig +9 -0
+     /* Request mailbox channel */
+     cl->dev = &pdev->dev;
+     cl->rx_callback = slimpro_i2c_rx_cb;
+     cl->tx_done = slimpro_i2c_tx_done;
+     cl->tx_block = true;
+     cl->tx_tout = SLIMPRO_OP_TO_MS;
+     cl->knows_txdone = false;
+     cl->chan_name = "i2c-slimpro";
+     ctx->mbox_chan = mbox_request_channel(cl);

This is not the correct interface.

drivers/i2c/busses/Kconfig

Quoted 3 lines
drivers/i2c/busses/Kconfig +3 -0
+     rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+     if (rc)
+             dev_warn(&pdev->dev, "Unable to set dma mask\n");

Are you sure that this is the correct device to perform the DMA?

Moreover, the mask doesn't match the usage: the slimpro_i2c_blkrd function passes in only the lower 32 bit of the address, which would be DMA_BIT_MASK(32).

Quoted 7 lines
drivers/i2c/busses/Kconfig +7 -0
+#ifdef CONFIG_OF
+static struct of_device_id xgene_slimpro_i2c_id[] = {
+     {.compatible = "apm,xgene-slimpro-i2c" },
+     {},
+};
+MODULE_DEVICE_TABLE(of, xgene_slimpro_i2c_dt_ids);
+#endif

drivers/i2c/busses/Kconfig

Quoted 10 lines
drivers/i2c/busses/Kconfig +10 -0
+
+static struct platform_driver xgene_slimpro_i2c_driver = {
+     .probe  = xgene_slimpro_i2c_probe,
+     .remove = xgene_slimpro_i2c_remove,
+     .driver = {
+             .name   = XGENE_SLIMPRO_I2C,
+             .owner  = THIS_MODULE,
+             .of_match_table = of_match_ptr(xgene_slimpro_i2c_id)
+     },
+};

The driver only supports DT, so just drop the #ifdef and the of_match_ptr().

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 16 lines · On Friday 09 January 2015 10:56:51 Feng Kan wrote:
Quoted 15 lines · Arnd Bergmann

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1014

Quoted 11 lines · On Tuesday 07 October 2014 17:06:47 Feng Kan wrote:
drivers/i2c/busses/Kconfig +3 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
        connected there. This will work whatever the interface used to
        talk to the EC (SPI, I2C or LPC).
 
+config I2C_XGENE_SLIMPRO
+     tristate "APM X-Gene SoC I2C SLIMpro devices support"
+     depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX

Why this dependency on XGENE_SLIMPRO_MBOX?

Quoted 3 lines
Quoted 1 line

Better replace it with a dependency on MAILBOX.

Arnd, just a question. Is this because this possibly help with future compatibility by choosing a more broad dependency?

The dependency should ideally describe build-time dependencies, to make it possible to build on other architectures for static code analysis purposes. If the driver makes no sense on other platforms you can also use

	depends on ARCH_XGENE || COMPILE_TEST
	depends on MAILBOX

to cover both the build-time and run-time dependencies. But the dependency on XGENE_SLIMPRO_MBOX just shouldn't be there, the driver will work with any mailbox implementation if someone puts the same hardware into a different SoC.

Arnd

author
#13 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

In reply to Arnd Bergmann
Quoted 15 lines · Arnd Bergmann

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1014

Quoted 11 lines · On Tuesday 07 October 2014 17:06:47 Feng Kan wrote:
drivers/i2c/busses/Kconfig +3 -0
index 2e45ae3..a03042c 100644
@@ -1009,6 +1009,15 @@ config I2C_CROS_EC_TUNNEL
        connected there. This will work whatever the interface used to
        talk to the EC (SPI, I2C or LPC).
 
+config I2C_XGENE_SLIMPRO
+     tristate "APM X-Gene SoC I2C SLIMpro devices support"
+     depends on ARCH_XGENE && XGENE_SLIMPRO_MBOX

Why this dependency on XGENE_SLIMPRO_MBOX?

Quoted 14 lines

drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL

Quoted 10 lines
drivers/i2c/busses/Kconfig +10 -0
+static int slimpro_i2c_blkrd(struct slimpro_i2c_dev *ctx, u32 chip, u32 addr,
+                             u32 addrlen, u32 protocol, u32 readlen,
+                             u32 with_data_len, void *data)
+{
+     dma_addr_t paddr;
+     u32 msg[3];
+     int rc;
+
+     paddr = dma_map_single(ctx->dev, ctx->dma_buffer, readlen,
+                            DMA_FROM_DEVICE);

ctx->dev is probably the wrong device here. The i2c controller is not DMA capable itself, you need to have a pointer to the device that actually performs the DMA here.

Arnd, I do agree this may not be the best identification. There is no representation for this on the Linux side. I could put it as NULL. However, there are other i2c bus drivers that seem to do the same thing. Please let me know what you think.

Quoted 18 lines

drivers/i2c/busses/Kconfig

Quoted 11 lines
drivers/i2c/busses/Kconfig +9 -0
+     /* Request mailbox channel */
+     cl->dev = &pdev->dev;
+     cl->rx_callback = slimpro_i2c_rx_cb;
+     cl->tx_done = slimpro_i2c_tx_done;
+     cl->tx_block = true;
+     cl->tx_tout = SLIMPRO_OP_TO_MS;
+     cl->knows_txdone = false;
+     cl->chan_name = "i2c-slimpro";
+     ctx->mbox_chan = mbox_request_channel(cl);

This is not the correct interface.

drivers/i2c/busses/Kconfig

Quoted 3 lines
drivers/i2c/busses/Kconfig +3 -0
+     rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+     if (rc)
+             dev_warn(&pdev->dev, "Unable to set dma mask\n");
Quoted 5 lines

Are you sure that this is the correct device to perform the DMA?

Moreover, the mask doesn't match the usage: the slimpro_i2c_blkrd function passes in only the lower 32 bit of the address, which would be DMA_BIT_MASK(32).

The upper part of the address is passed in as part of the msg[1]

#14 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 9 lines
Quoted 4 lines

ctx->dev is probably the wrong device here. The i2c controller is not DMA capable itself, you need to have a pointer to the device that actually performs the DMA here.

Arnd, I do agree this may not be the best identification. There is no representation for this on the Linux side. I could put it as NULL. However, there are other i2c bus drivers that seem to do the same thing. Please let me know what you think.

For completeness: Those drivers need fixing!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150130/41b913cb/attachment.sig>

author
#15 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 11 lines · Wolfram Sang
Quoted 9 lines
Quoted 4 lines

ctx->dev is probably the wrong device here. The i2c controller is not DMA capable itself, you need to have a pointer to the device that actually performs the DMA here.

Arnd, I do agree this may not be the best identification. There is no representation for this on the Linux side. I could put it as NULL. However, there are other i2c bus drivers that seem to do the same thing. Please let me know what you think.

For completeness: Those drivers need fixing!

I have some doubts. I could hack up a dts node for the helper processor that is doing the dma. However, the dma master could be anything for that matter. I am not sure how I can write this in a generic manner.

#16 lore raw

Re: [PATCH 4/6] i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform

Quoted 11 lines · Feng Kan
Quoted 10 lines · Wolfram Sang
Quoted 9 lines
Quoted 4 lines

ctx->dev is probably the wrong device here. The i2c controller is not DMA capable itself, you need to have a pointer to the device that actually performs the DMA here.

Arnd, I do agree this may not be the best identification. There is no representation for this on the Linux side. I could put it as NULL. However, there are other i2c bus drivers that seem to do the same thing. Please let me know what you think.

Quoted 5 lines
Quoted 1 line

For completeness: Those drivers need fixing!

I have some doubts. I could hack up a dts node for the helper processor that is doing the dma. However, the dma master could be anything for that matter. I am not sure how I can write this in a generic manner.

All I wanted to say is that, to the best of my knowledge, currently all DMA capable i2c bus drivers which do not pass the DMA capable device when mapping, need a fix like 8cfcae9f0595. So, the argument "other drivers do it, too" is invalid IMO. You might have other, better, more technical arguments for your case. Like above, that could be fine, I'd say. But I leave this to the DMA experts...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150203/3aff6ca8/attachment.sig>

author
#17 lore raw

PATCH 5/6 Documentation: i2c: Add APM X-Gene platform SLIMpro I2C driver documentation

In reply to Feng Kan

Add APM X-Gene platform SLIMpro I2C driver documentation.

---
 .../devicetree/bindings/i2c/i2c-xgene-slimpro.txt    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +20 -0
new file mode 100644
index 0000000..1a79d53
@@ -0,0 +1,20 @@
+APM X-Gene SLIMpro Mailbox I2C Driver
+
+This is a I2C driver that access the I2C bus through the mailbox mechanism.
+There is documentation of the mailbox driver in the
+Documentation/devicetree/binding/mailbox/xgene-slimpro-mbox.txt
+
+Required properties :
+
+ - compatible : should be "apm,xgene-slimpro-i2c"
+ - mbox : ptr to the mailbox dts node, use the name of the mailbox as the
+	  first parameter. The second parameter is the channel number.
+	  The APM X-Gene SLIMpro mailbox has 8 channels.
+ - mbox-names : the name of the mailbox channel.
+
+Example :
+	i2cslimpro {
+		compatible = "apm,xgene-slimpro-i2c";
+		mbox = <&mailbox 0>;
+		mbox-names = "i2c-slimpro";
+	};
Signature · 1 line
1.9.1
#18 lore raw

Re: [PATCH 5/6] Documentation: i2c: Add APM X-Gene platform SLIMpro I2C driver documentation

Quoted 15 lines · Feng Kan

Add APM X-Gene platform SLIMpro I2C driver documentation.

---
 .../devicetree/bindings/i2c/i2c-xgene-slimpro.txt    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +0 -0
new file mode 100644
index 0000000..1a79d53

Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt line 5

Quoted 5 lines
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +5 -0
@@ -0,0 +1,20 @@
+APM X-Gene SLIMpro Mailbox I2C Driver
+
+This is a I2C driver that access the I2C bus through the mailbox mechanism.
+There is documentation of the mailbox driver in the
+Documentation/devicetree/binding/mailbox/xgene-slimpro-mbox.txt

This should not describe the driver. It should describe the hardware (an I2C controller accessed over the "slimpro" mailbox).

Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt line 11

Quoted 6 lines
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +6 -0
+
+Required properties :
+
+ - compatible : should be "apm,xgene-slimpro-i2c"
+ - mbox : ptr to the mailbox dts node, use the name of the mailbox as the
+	  first parameter. The second parameter is the channel number.

This is a phandle + specificer pair, the "name" you mention is a label reference (which generates a phandle).

Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt line 12

Quoted 1 line
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +1 -0
+	  The APM X-Gene SLIMpro mailbox has 8 channels.

Does it really make sense to model the slimpro in this way if all the clients are going to rely on the particulars of this mailbox?

Either this is somewhat generic and the mailbox details are unimportant, or it is not and the entire device would be better modelled as an MFD.

Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt line 13

Quoted 1 line
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +1 -0
+ - mbox-names : the name of the mailbox channel.

For any *-names property, you must define the _exact_ names you expect, or you shouldn't use the property. The entire point of the property is to disambiguate entries, and this is _more_ ambiguous than without the property.

Mark.

Quoted 16 lines
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +7 -0
+
+Example :
+	i2cslimpro {
+		compatible = "apm,xgene-slimpro-i2c";
+		mbox = <&mailbox 0>;
+		mbox-names = "i2c-slimpro";
+	};
Signature · 7 lines
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#19 lore raw

Re: [PATCH 5/6] Documentation: i2c: Add APM X-Gene platform SLIMpro I2C driver documentation

In reply to Feng Kan
Quoted 2 lines · On Tuesday 07 October 2014 17:06:48 Feng Kan wrote:

Add APM X-Gene platform SLIMpro I2C driver documentation.

Don't just repeat the subject line, explain what this is for.

Quoted 16 lines
---
 .../devicetree/bindings/i2c/i2c-xgene-slimpro.txt    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +3 -0
new file mode 100644
index 0000000..1a79d53
@@ -0,0 +1,20 @@
+APM X-Gene SLIMpro Mailbox I2C Driver
+
+This is a I2C driver that access the I2C bus through the mailbox mechanism.

Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt line 13

Quoted 10 lines
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +10 -0
+There is documentation of the mailbox driver in the
+Documentation/devicetree/binding/mailbox/xgene-slimpro-mbox.txt
+
+Required properties :
+
+ - compatible : should be "apm,xgene-slimpro-i2c"
+ - mbox : ptr to the mailbox dts node, use the name of the mailbox as the
+	  first parameter. The second parameter is the channel number.
+	  The APM X-Gene SLIMpro mailbox has 8 channels.
+ - mbox-names : the name of the mailbox channel.

The current form of the mailbox interface no longer uses mbox-names, so just drop that. In the old form, the binding would have been incomplete because you don't list the required name.

Arnd

author
#20 lore raw

PATCH 6/6 arm64: dts: add proxy I2C device driver on APM X-Gene platform

In reply to Feng Kan

Add proxy I2C device driver on APM X-Gene platform.

---
 arch/arm64/boot/dts/apm-storm.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/apm-storm.dtsi +6 -0
index 249f025..09daf4c 100644
@@ -469,6 +469,12 @@
 					<0x0 0x7 0x4>;
 		};
 
+		i2cslimpro {
+			compatible = "apm,xgene-slimpro-i2c";
+			mbox = <&mailbox 0>;
+			mbox-names = "i2c-slimpro";
+		};
+
 		serial0: serial at 1c020000 {
 			status = "disabled";
 			device_type = "serial";
Signature · 1 line
1.9.1