I2C: add CSR SiRFprimaII on-chip I2C controllers driver
Subsystems (2)
PATCH v6 1/1 I2C: add CSR SiRFprimaII on-chip I2C controllers driver
From: Zhiwu Song <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s multi-function SoC product family.
The SoC support codes are in arch/arm/mach-prima2 from Linux mainline 3.0.
There are two I2C controllers on primaII, features include:
* Two I2C controller modules are on chip
* RISC I/O bus read write register
* Up to 16 bytes data buffer for issuing commands and writing data at the same time
* Up to 16 commands, and receiving read data 16 bytes at a time
* Error INT report (ACK check)
* No-ACK bus protocols (SCCB bus protocols)
---
-v6:
fix/cleanup lots of minor issues pointed out by wolfram; add OF property clock-frequency to support freq setting by DT; add lost devicetree binding document;
Documentation/devicetree/bindings/i2c/sirf-i2c.txt | 19 + drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-sirf.c | 459 ++++++++++++++++++++ 4 files changed, 489 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/i2c/sirf-i2c.txt create mode 100644 drivers/i2c/busses/i2c-sirf.c
Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +19 -0
@@ -0,0 +1,19 @@ +I2C for SiRFprimaII platforms + +Required properties : +- compatible : Must be "sirf,prima2-i2c" +- reg: physical base address of the controller and length of memory mapped + region. +- interrupts: interrupt number to the cpu. + +Optional properties: +- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz. + The absence of the propoerty indicates the default frequency 100 kHz. + +Examples : + +i2c0: i2c at b00e0000 { + compatible = "sirf,prima2-i2c"; + reg = <0xb00e0000 0x10000>; + interrupts = <24>; +};
drivers/i2c/busses/Kconfig +10 -0
@@ -630,6 +630,16 @@ config I2C_SIMTEC This driver can also be built as a module. If so, the module will be called i2c-simtec. +config I2C_SIRF + tristate "CSR SiRFprimaII I2C interface" + depends on ARCH_PRIMA2 + help + If you say yes to this option, support will be included for the + CSR SiRFprimaII I2C interface. + + This driver can also be built as a module. If so, the module + will be called i2c-sirf. + config I2C_STU300 tristate "ST Microelectronics DDC I2C interface" depends on MACH_U300
drivers/i2c/busses/Makefile +1 -0
@@ -63,6 +63,7 @@ obj-$(CONFIG_I2C_S6000) += i2c-s6000.o obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o +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
drivers/i2c/busses/i2c-sirf.c new file +459 -0
459 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v6 1/1 I2C: add CSR SiRFprimaII on-chip I2C controllers driver
Quoted 15 lines · Barry Song
From: Zhiwu Song <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s multi-function SoC product family.
The SoC support codes are inarch/arm/mach-prima2from Linux mainline 3.0.
There are two I2C controllers on primaII, features include:
* Two I2C controller modules are on chip
* RISC I/O bus read write register
* Up to 16 bytes data buffer for issuing commands and writing data at the same time
* Up to 16 commands, and receiving read data 16 bytes at a time
* Error INT report (ACK check)
* No-ACK bus protocols (SCCB bus protocols)
Quoted 4 lines
Signed-off-by Zhiwu Song <[email protected]>Signed-off-by Xiangzhen Ye <[email protected]>Signed-off-by Yuping Luo <[email protected]>Signed-off-by Barry Song <[email protected]>
I am fine with it. Personally, I would have violated the 80 char limit a few times to keep stuff more readable, but this is taste, I guess.
Ben, will you handle it?
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120216/bc78461d/attachment-0001.sig>
PATCH v6 1/1 I2C: add CSR SiRFprimaII on-chip I2C controllers driver
Quoted 16 lines · Wolfram Sang
Quoted 15 lines · Barry Song
From: Zhiwu Song <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s multi-function SoC product family.
The SoC support codes are inarch/arm/mach-prima2from Linux mainline 3.0.
There are two I2C controllers on primaII, features include:
* Two I2C controller modules are on chip
* RISC I/O bus read write register
* Up to 16 bytes data buffer for issuing commands and writing data at the same time
* Up to 16 commands, and receiving read data 16 bytes at a time
* Error INT report (ACK check)
* No-ACK bus protocols (SCCB bus protocols)
Quoted 7 lines
Quoted 4 lines
Signed-off-by Zhiwu Song <[email protected]>Signed-off-by Xiangzhen Ye <[email protected]>Signed-off-by Yuping Luo <[email protected]>Signed-off-by Barry Song <[email protected]>I am fine with it. Personally, I would have violated the 80 char limit a few times to keep stuff more readable, but this is taste, I guess.
Picked to my for 3.4 branch
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120229/86e1eb23/attachment-0001.sig>
PATCH v6 1/1 I2C: add CSR SiRFprimaII on-chip I2C controllers driver
In reply to Barry SongHello,
Quoted 38 lines · Barry Song
From: Zhiwu Song <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s multi-function SoC product family.
The SoC support codes are inarch/arm/mach-prima2from Linux mainline 3.0.
There are two I2C controllers on primaII, features include:
* Two I2C controller modules are on chip
* RISC I/O bus read write register
* Up to 16 bytes data buffer for issuing commands and writing data ?at the same time
* Up to 16 commands, and receiving read data 16 bytes at a time
* Error INT report (ACK check)
* No-ACK bus protocols (SCCB bus protocols)Signed-off-by Zhiwu Song <[email protected]>Signed-off-by Xiangzhen Ye <[email protected]>Signed-off-by Yuping Luo <[email protected]>Signed-off-by Barry Song <[email protected]>---
?-v6:
?fix/cleanup lots of minor issues pointed out by wolfram; ?add OF property clock-frequency to support freq setting by DT; ?add lost devicetree binding document;?Documentation/devicetree/bindings/i2c/sirf-i2c.txt | ? 19 + ?drivers/i2c/busses/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? | ? 10 + ?drivers/i2c/busses/Makefile ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?drivers/i2c/busses/i2c-sirf.c ? ? ? ? ? ? ? ? ? ? ?| ?459 ++++++++++++++++++++?4 files changed, 489 insertions(+), 0 deletions(-)
?create mode 100644Documentation/devicetree/bindings/i2c/sirf-i2c.txt?create mode 100644drivers/i2c/busses/i2c-sirf.cDocumentation/devicetree/bindings/i2c/sirf-i2c.txt new file +0
-0
<snip>
Quoted 3 lines
+
+ ? ? ? ? ? ? ? if (i2c_stat&SIRFSOC_I2C_STAT_NACK)
+ ? ? ? ? ? ? ? ? ? ? ?dev_err(&siic->adapter.dev, "ACK not received\n");
Could we send stop here?
Quoted 4 lines
+ ? ? ? ? ? ? ? else
+ ? ? ? ? ? ? ? ? ? ? ?dev_err(&siic->adapter.dev, "I2C error\n"); +
+ ? ? ? ? ? ? ?complete(&siic->done);
<Snip>
Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 8 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +8
-0+static int i2c_sirfsoc_resume(struct device *dev) +{ + ? ? ? struct platform_device *pdev = to_platform_device(dev); + ? ? ? struct i2c_adapter *adapter = platform_get_drvdata(pdev); + ? ? ? struct sirfsoc_i2c *siic = adapter->algo_data; + + ? ? ? clk_enable(siic->clk); + ? ? ? writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL);
Could you explain why is a reset needed.
Or am I missing something.
Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 11 lines
+ ? ? ? writel(SIRFSOC_I2C_CORE_EN |
SIRFSOC_I2C_MASTER_MODE,
+ ? ? ? ? ? ? ?siic->base+SIRFSOC_I2C_CTRL);
+ ? ? ?writel(siic->clk_div, siic->base + SIRFSOC_I2C_CLK_CTRL);
+ ? ? ?writel(siic->sda_delay, siic->base + SIRFSOC_I2C_SDA_DELAY);
+ ? ? ?clk_disable(siic->clk);
+ ? ? ? return 0;Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +5
-0+} + +static const struct dev_pm_ops i2c_sirfsoc_pm_ops = { + ? ? ? .suspend = i2c_sirfsoc_suspend, + ? ? ? .resume = i2c_sirfsoc_resume,
Could we use simple dev_pm ops here?
Quoted 5 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +5
-0+}; +#endif + +static const struct of_device_id sirfsoc_i2c_of_match[] __devinitconst = { + ? ? ? { .compatible = "sirf,prima2-i2c", },
PATCH v6 1/1 I2C: add CSR SiRFprimaII on-chip I2C controllers driver
Barry,
On Thu, Feb 16, 2012 at 10:24:00PM +0530, Shubhrajyoti Datta wrote:
please consider these comments.
Thanks,
Wolfram
Quoted 86 lines
Hello,
Quoted 38 lines · Barry Song
From: Zhiwu Song <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s multi-function SoC product family.
The SoC support codes are inarch/arm/mach-prima2from Linux mainline 3.0.
There are two I2C controllers on primaII, features include:
* Two I2C controller modules are on chip
* RISC I/O bus read write register
* Up to 16 bytes data buffer for issuing commands and writing data ?at the same time
* Up to 16 commands, and receiving read data 16 bytes at a time
* Error INT report (ACK check)
* No-ACK bus protocols (SCCB bus protocols)Signed-off-by Zhiwu Song <[email protected]>Signed-off-by Xiangzhen Ye <[email protected]>Signed-off-by Yuping Luo <[email protected]>Signed-off-by Barry Song <[email protected]>---
?-v6:
?fix/cleanup lots of minor issues pointed out by wolfram; ?add OF property clock-frequency to support freq setting by DT; ?add lost devicetree binding document;?Documentation/devicetree/bindings/i2c/sirf-i2c.txt | ? 19 + ?drivers/i2c/busses/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? | ? 10 + ?drivers/i2c/busses/Makefile ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?drivers/i2c/busses/i2c-sirf.c ? ? ? ? ? ? ? ? ? ? ?| ?459 ++++++++++++++++++++?4 files changed, 489 insertions(+), 0 deletions(-)
?create mode 100644Documentation/devicetree/bindings/i2c/sirf-i2c.txt?create mode 100644drivers/i2c/busses/i2c-sirf.cDocumentation/devicetree/bindings/i2c/sirf-i2c.txt new file +0
-0<snip>
Quoted 3 lines
+
+ ? ? ? ? ? ? ? if (i2c_stat&SIRFSOC_I2C_STAT_NACK)
+ ? ? ? ? ? ? ? ? ? ? ?dev_err(&siic->adapter.dev, "ACK not received\n");Could we send stop here?
Quoted 4 lines
+ ? ? ? ? ? ? ? else
+ ? ? ? ? ? ? ? ? ? ? ?dev_err(&siic->adapter.dev, "I2C error\n"); +
+ ? ? ? ? ? ? ?complete(&siic->done);<Snip>
Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 8 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +8
-0+static int i2c_sirfsoc_resume(struct device *dev) +{ + ? ? ? struct platform_device *pdev = to_platform_device(dev); + ? ? ? struct i2c_adapter *adapter = platform_get_drvdata(pdev); + ? ? ? struct sirfsoc_i2c *siic = adapter->algo_data; + + ? ? ? clk_enable(siic->clk); + ? ? ? writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL);Could you explain why is a reset needed.
Or am I missing something.Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 11 lines
+ ? ? ? writel(SIRFSOC_I2C_CORE_EN |
SIRFSOC_I2C_MASTER_MODE,
+ ? ? ? ? ? ? ?siic->base+SIRFSOC_I2C_CTRL);
+ ? ? ?writel(siic->clk_div, siic->base + SIRFSOC_I2C_CLK_CTRL);
+ ? ? ?writel(siic->sda_delay, siic->base + SIRFSOC_I2C_SDA_DELAY);
+ ? ? ?clk_disable(siic->clk);
+ ? ? ? return 0;Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +5
-0+} + +static const struct dev_pm_ops i2c_sirfsoc_pm_ops = { + ? ? ? .suspend = i2c_sirfsoc_suspend, + ? ? ? .resume = i2c_sirfsoc_resume,Could we use simple
dev_pmops here?Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 5 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +5
-0+}; +#endif + +static const struct of_device_id sirfsoc_i2c_of_match[] __devinitconst = { + ? ? ? { .compatible = "sirf,prima2-i2c", },--
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
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120224/608230f5/attachment.sig>
PATCH v6 1/1 I2C: add CSR SiRFprimaII on-chip I2C controllers driver
In reply to Shubhrajyoti Dattahi Shubhrajyoti,
2012/2/17 Shubhrajyoti Datta <[email protected]>:
Quoted 43 lines
Hello,
Quoted 38 lines · Barry Song
From: Zhiwu Song <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s multi-function SoC product family.
The SoC support codes are inarch/arm/mach-prima2from Linux mainline 3.0.
There are two I2C controllers on primaII, features include:
* Two I2C controller modules are on chip
* RISC I/O bus read write register
* Up to 16 bytes data buffer for issuing commands and writing data ?at the same time
* Up to 16 commands, and receiving read data 16 bytes at a time
* Error INT report (ACK check)
* No-ACK bus protocols (SCCB bus protocols)Signed-off-by Zhiwu Song <[email protected]>Signed-off-by Xiangzhen Ye <[email protected]>Signed-off-by Yuping Luo <[email protected]>Signed-off-by Barry Song <[email protected]>---
?-v6:
?fix/cleanup lots of minor issues pointed out by wolfram; ?add OF property clock-frequency to support freq setting by DT; ?add lost devicetree binding document;?Documentation/devicetree/bindings/i2c/sirf-i2c.txt | ? 19 + ?drivers/i2c/busses/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? | ? 10 + ?drivers/i2c/busses/Makefile ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?drivers/i2c/busses/i2c-sirf.c ? ? ? ? ? ? ? ? ? ? ?| ?459 ++++++++++++++++++++?4 files changed, 489 insertions(+), 0 deletions(-)
?create mode 100644Documentation/devicetree/bindings/i2c/sirf-i2c.txt?create mode 100644drivers/i2c/busses/i2c-sirf.cDocumentation/devicetree/bindings/i2c/sirf-i2c.txt new file +0
-0<snip>
Quoted 4 lines
Quoted 3 lines
+
+ ? ? ? ? ? ? ? if (i2c_stat&SIRFSOC_I2C_STAT_NACK)
+ ? ? ? ? ? ? ? ? ? ? ?dev_err(&siic->adapter.dev, "ACK not received\n");Could we send stop here?
no. when the interrupt happens and goes into the irq, the whole i2c hw sequence has finished.
Quoted 6 lines
Quoted 4 lines
+ ? ? ? ? ? ? ? else
+ ? ? ? ? ? ? ? ? ? ? ?dev_err(&siic->adapter.dev, "I2C error\n"); +
+ ? ? ? ? ? ? ?complete(&siic->done);<Snip>
Quoted 10 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 8 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +8
-0+static int i2c_sirfsoc_resume(struct device *dev) +{ + ? ? ? struct platform_device *pdev = to_platform_device(dev); + ? ? ? struct i2c_adapter *adapter = platform_get_drvdata(pdev); + ? ? ? struct sirfsoc_i2c *siic = adapter->algo_data; + + ? ? ? clk_enable(siic->clk); + ? ? ? writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL);Could you explain why is a reset needed.
Or am I missing something.
this is helping the i2c controller restore to a stable status. this reset is not always needed, but it is sure that it can help to fix some unstable issues of hardware if they do exist.
Quoted 13 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 12 lines
+ ? ? ? writel(SIRFSOC_I2C_CORE_EN |
SIRFSOC_I2C_MASTER_MODE,
+ ? ? ? ? ? ? ?siic->base+SIRFSOC_I2C_CTRL);
+ ? ? ?writel(siic->clk_div, siic->base + SIRFSOC_I2C_CLK_CTRL);
+ ? ? ?writel(siic->sda_delay, siic->base + SIRFSOC_I2C_SDA_DELAY);
+ ? ? ?clk_disable(siic->clk);
+ ? ? ? return 0;Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +5
-0+} + +static const struct dev_pm_ops i2c_sirfsoc_pm_ops = { + ? ? ? .suspend = i2c_sirfsoc_suspend, + ? ? ? .resume = i2c_sirfsoc_resume,Could we use simple
dev_pmops here?
i guess you mean SIMPLE_DEV_PM_OPS. the only problem is i2c bus driver doesn't need entries like:
.freeze = suspend_fn, \
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn,
at least in our test, without these entries, suspend to ram, suspend to disk(hibernation) and poweroff have always worked well.
Quoted 6 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt
Quoted 6 lines
Documentation/devicetree/bindings/i2c/sirf-i2c.txt new file +5
-0+}; +#endif + +static const struct of_device_id sirfsoc_i2c_of_match[] __devinitconst = { + ? ? ? { .compatible = "sirf,prima2-i2c", },
-barry