i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform
Subsystems (3)
PATCH v2 1/3 i2c: busses: add SLIMpro I2C device driver on APM X-Gene platform
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 | 464 +++++++++++++++++++++++++++++++++ 3 files changed, 474 insertions(+) create mode 100644 drivers/i2c/busses/i2c-xgene-slimpro.c
drivers/i2c/busses/Kconfig +9 -0
@@ -1072,6 +1072,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 && MAILBOX + 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
@@ -106,6 +106,7 @@ obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o obj-$(CONFIG_I2C_OPAL) += i2c-opal.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 +464 -0
464 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 2/3 Documentation: i2c: Add APM X-Gene platform SLIMpro I2C driver documentation
Add APM X-Gene platform SLIMpro I2C driver documentation.
--- .../devicetree/bindings/i2c/i2c-xgene-slimpro.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt
Documentation/devicetree/bindings/i2c/i2c-xgene-slimpro.txt new file +15 -0
@@ -0,0 +1,15 @@ +APM X-Gene SLIMpro Mailbox I2C Driver + +An I2C controller accessed over the "SLIMpro" mailbox. + +Required properties : + + - compatible : should be "apm,xgene-slimpro-i2c" + - mboxes : use the label reference for the mailbox as the first parameter. + The second parameter is the channel number. + +Example : + i2cslimpro { + compatible = "apm,xgene-slimpro-i2c"; + mboxes = <&mailbox 0>; + };
Signature · 1 line
1.9.1
PATCH v2 3/3 arm64: dts: add proxy I2C device driver on APM X-Gene platform
In reply to Feng KanAdd proxy I2C device driver on APM X-Gene platform.
--- arch/arm64/boot/dts/apm/apm-storm.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/apm/apm-storm.dtsi +5 -0
@@ -483,6 +483,11 @@ <0x0 0x7 0x4>; }; + i2cslimpro { + compatible = "apm,xgene-slimpro-i2c"; + mboxes = <&mailbox 0>; + }; + serial0: serial at 1c020000 { status = "disabled"; device_type = "serial";
Signature · 1 line
1.9.1
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.
Signed-off-by Feng Kan <[email protected]>Signed-off-by Hieu Le <[email protected]>
Sigh, I lost my first review, so here we go again...
It looks mostly good. Using checkpatch with '--strict' will show some whitespace issues. Please fix these.
drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1077
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 && MAILBOX
COMPILE_TEST?
drivers/i2c/busses/i2c-xgene-slimpro.c line 136
Quoted 6 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +6
-0+static int start_i2c_msg_xfer (struct slimpro_i2c_dev *ctx) +{ +if (ctx->mbox_client.tx_block) { +if (!wait_for_completion_timeout (&ctx->rd_complete, +msecs_to_jiffies + (MAILBOX_OP_TIMEOUT )))
Don't be too strict with the 80 char limit IMHO. I think it is more readable to combine the last two lines into one.
drivers/i2c/busses/i2c-xgene-slimpro.c line 156
Quoted 3 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +3
-0+ msg[0 ] =SLIMPRO_IIC_ENCODE_MSG (SLIMPRO_IIC_BUS , chip, +SLIMPRO_IIC_READ , protocol, addrlen, + readlen);
ditto
drivers/i2c/busses/i2c-xgene-slimpro.c line 179
Quoted 3 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +3
-0+ msg[0 ] =SLIMPRO_IIC_ENCODE_MSG (SLIMPRO_IIC_BUS , chip, +SLIMPRO_IIC_WRITE , protocol, addrlen, + writelen);
ditto
drivers/i2c/busses/i2c-xgene-slimpro.c line 203
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+ paddr =dma_map_single (ctx->dev, ctx->dma_buffer, readlen, +DMA_FROM_DEVICE );
The device should be the device of the dma channel.
drivers/i2c/busses/i2c-xgene-slimpro.c line 247
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+ paddr =dma_map_single (ctx->dev, ctx->dma_buffer, writelen, +DMA_TO_DEVICE );
ditto
Review
Quoted 2 lines
(quoted diff) +2
-0+ rc = dma_mapping_error(ctx->dev, paddr); + if (dma_mapping_error(ctx->dev, paddr)) {
if (rc)
drivers/i2c/busses/i2c-xgene-slimpro.c line 381
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+static struct i2c_algorithm xgene_slimpro_i2c_algorithm = { + .smbus_xfer = xgene_slimpro_i2c_xfer,
Might be a tad less confusing to name this function xgene_slimpro_smbus_xfer. You decide.
drivers/i2c/busses/i2c-xgene-slimpro.c line 429
Quoted 9 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +9
-0+ rc =i2c_add_adapter (adapter); +if (rc) { +dev_err (&pdev->dev,"Adapter registeration failed\n" ); +return rc; + } + + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); +if (rc) +dev_warn (&pdev->dev,"Unable to set dma mask\n" );
Shouldn't that be before i2c_add_adapter?
drivers/i2c/busses/i2c-xgene-slimpro.c line 457
Quoted 6 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +6
-0+static struct platform_driver xgene_slimpro_i2c_driver = { + .probe = xgene_slimpro_i2c_probe, + .remove = xgene_slimpro_i2c_remove, + .driver = { + .name ="xgene-slimpro-i2c" , + .of_match_table =of_match_ptr (xgene_slimpro_i2c_id)
You are DT only, do we need of_match_ptr?
drivers/i2c/busses/i2c-xgene-slimpro.c line 464
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+MODULE_DESCRIPTION ("APM X-Gene SLIMpro I2C driver" ); +MODULE_LICENSE ("GPL" );
MODULE_AUTHOR left out intentionally?
Thanks,
Wolfram
Quoted 38 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.
Signed-off-by Feng Kan <[email protected]>Signed-off-by Hieu Le <[email protected]>Sigh, I lost my first review, so here we go again...
It looks mostly good. Using checkpatch with '--strict' will show some whitespace issues. Please fix these.drivers/i2c/busses/Kconfig config I2C_CROS_EC_TUNNEL · line 1077
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 && MAILBOX
COMPILE_TEST?drivers/i2c/busses/i2c-xgene-slimpro.c line 136
Quoted 6 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +6
-0+static int start_i2c_msg_xfer (struct slimpro_i2c_dev *ctx) +{ +if (ctx->mbox_client.tx_block) { +if (!wait_for_completion_timeout (&ctx->rd_complete, +msecs_to_jiffies + (MAILBOX_OP_TIMEOUT )))Don't be too strict with the 80 char limit IMHO. I think it is more readable to combine the last two lines into one.
drivers/i2c/busses/i2c-xgene-slimpro.c line 156
Quoted 3 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +3
-0+ msg[0 ] =SLIMPRO_IIC_ENCODE_MSG (SLIMPRO_IIC_BUS , chip, +SLIMPRO_IIC_READ , protocol, addrlen, + readlen);ditto
drivers/i2c/busses/i2c-xgene-slimpro.c line 179
Quoted 3 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +3
-0+ msg[0 ] =SLIMPRO_IIC_ENCODE_MSG (SLIMPRO_IIC_BUS , chip, +SLIMPRO_IIC_WRITE , protocol, addrlen, + writelen);
Quoted 6 lines
ditto
drivers/i2c/busses/i2c-xgene-slimpro.c line 203
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+ paddr =dma_map_single (ctx->dev, ctx->dma_buffer, readlen, +DMA_FROM_DEVICE );The device should be the device of the dma channel.
The device is not visible on linux, DMA is done by the helper processor. Perhaps you cah give me some idea how to do this. Thanks
Quoted 47 lines
drivers/i2c/busses/i2c-xgene-slimpro.c line 247
Quoted 3 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+ paddr =dma_map_single (ctx->dev, ctx->dma_buffer, writelen, +DMA_TO_DEVICE );ditto
Review
Quoted 2 lines
(quoted diff) +2
-0+ rc = dma_mapping_error(ctx->dev, paddr); + if (dma_mapping_error(ctx->dev, paddr)) {if (rc)
drivers/i2c/busses/i2c-xgene-slimpro.c line 381
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+static struct i2c_algorithm xgene_slimpro_i2c_algorithm = { + .smbus_xfer = xgene_slimpro_i2c_xfer,Might be a tad less confusing to name this function
xgene_slimpro_smbus_xfer. You decide.drivers/i2c/busses/i2c-xgene-slimpro.c line 429
Quoted 9 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +9
-0+ rc =i2c_add_adapter (adapter); +if (rc) { +dev_err (&pdev->dev,"Adapter registeration failed\n" ); +return rc; + } + + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); +if (rc) +dev_warn (&pdev->dev,"Unable to set dma mask\n" );Shouldn't that be before
i2c_add_adapter?drivers/i2c/busses/i2c-xgene-slimpro.c line 457
Quoted 6 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +6
-0+static struct platform_driver xgene_slimpro_i2c_driver = { + .probe = xgene_slimpro_i2c_probe, + .remove = xgene_slimpro_i2c_remove, + .driver = { + .name ="xgene-slimpro-i2c" , + .of_match_table =of_match_ptr (xgene_slimpro_i2c_id)You are DT only, do we need
of_match_ptr?drivers/i2c/busses/i2c-xgene-slimpro.c line 464
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+MODULE_DESCRIPTION ("APM X-Gene SLIMpro I2C driver" ); +MODULE_LICENSE ("GPL" );
MODULE_AUTHORleft out intentionally?Thanks,
Wolfram
Quoted 7 lines
Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c line 203
Quoted 2 lines
drivers/i2c/busses/i2c-xgene-slimpro.c new file +2
-0+ paddr =dma_map_single (ctx->dev, ctx->dma_buffer, readlen, +DMA_FROM_DEVICE );The device should be the device of the dma channel.
The device is not visible on linux, DMA is done by the helper processor. Perhaps you cah give me some idea how to do this. Thanks
Well, that is a question for the DMA maintainers. But we can fix this later, I guess.