linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: vaibhav.hiremath@linaro.org (Vaibhav Hiremath)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/12] i2c: pxa: Add support for pxa910/988 & new configuration features
Date: Thu, 28 May 2015 18:33:36 +0530	[thread overview]
Message-ID: <1432818224-17070-5-git-send-email-vaibhav.hiremath@linaro.org> (raw)
In-Reply-To: <1432818224-17070-1-git-send-email-vaibhav.hiremath@linaro.org>

From: "Jett.Zhou" <jtzhou@marvell.com>

TWSI_ILCR & TWSI_IWCR registers are used to adjust clock rate
of standard & fast mode in pxa910/988; so this patch adds these two new
entries to "struct pxa_reg_layout" and "struct pxa_i2c" and also adds two
new DT properties to take configuration value for the same.

Note that, DT binding document is also updated.

Signed-off-by: Jett.Zhou <jtzhou@marvell.com>
Signed-off-by: Yi Zhang <yizhang@marvell.com>
[vaibhav.hiremath at linaro.org: Updated kernel doc for new DT properties
and updated Changelog]
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
---
 Documentation/devicetree/bindings/i2c/i2c-pxa.txt |  7 ++++
 drivers/i2c/busses/i2c-pxa.c                      | 44 +++++++++++++++++++++--
 include/linux/i2c/pxa-i2c.h                       |  2 ++
 3 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-pxa.txt b/Documentation/devicetree/bindings/i2c/i2c-pxa.txt
index 12b78ac..5750bff 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-pxa.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-pxa.txt
@@ -18,6 +18,13 @@ Recommended properties :
    status register of i2c controller instead.
  - mrvl,i2c-fast-mode : Enable fast mode of i2c controller.
 
+Optional Properties (Applicable to PXA910 family):
+
+ - mrvl,i2c-ilcr : Load Count Register: Allows minor adjustment to SCL clk to
+		   achieve std, normal and fast mode of operation.
+ - mrvl,i2c-iwcr : Wait Count Register - controls the setup and hold time
+		   together with mrvl,i2c-ilcr
+
 Examples:
 	twsi1: i2c at d4011000 {
 		compatible = "mrvl,mmp-twsi";
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index a76c901..8ca5552 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -46,12 +46,15 @@ struct pxa_reg_layout {
 	u32 icr;
 	u32 isr;
 	u32 isar;
+	u32 ilcr;
+	u32 iwcr;
 };
 
 enum pxa_i2c_types {
 	REGS_PXA2XX,
 	REGS_PXA3XX,
 	REGS_CE4100,
+	REGS_PXA910,
 };
 
 /*
@@ -79,12 +82,22 @@ static struct pxa_reg_layout pxa_reg_layout[] = {
 		.isr =	0x04,
 		/* no isar register */
 	},
+	[REGS_PXA910] = {
+		.ibmr = 0x00,
+		.idbr = 0x08,
+		.icr =	0x10,
+		.isr =	0x18,
+		.isar = 0x20,
+		.ilcr = 0x28,
+		.iwcr = 0x30,
+	},
 };
 
 static const struct platform_device_id i2c_pxa_id_table[] = {
 	{ "pxa2xx-i2c",		REGS_PXA2XX },
 	{ "pxa3xx-pwri2c",	REGS_PXA3XX },
 	{ "ce4100-i2c",		REGS_CE4100 },
+	{ "pxa910-i2c",		REGS_PXA910 },
 	{ },
 };
 MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
@@ -149,6 +162,8 @@ struct pxa_i2c {
 	void __iomem		*reg_icr;
 	void __iomem		*reg_isr;
 	void __iomem		*reg_isar;
+	void __iomem		*reg_ilcr;
+	void __iomem		*reg_iwcr;
 
 	unsigned long		iobase;
 	unsigned long		iosize;
@@ -160,6 +175,8 @@ struct pxa_i2c {
 	unsigned char		master_code;
 	unsigned long		rate;
 	bool			highmode_enter;
+	unsigned int		ilcr;
+	unsigned int		iwcr;
 };
 
 #define _IBMR(i2c)	((i2c)->reg_ibmr)
@@ -167,6 +184,8 @@ struct pxa_i2c {
 #define _ICR(i2c)	((i2c)->reg_icr)
 #define _ISR(i2c)	((i2c)->reg_isr)
 #define _ISAR(i2c)	((i2c)->reg_isar)
+#define _ILCR(i2c)	((i2c)->reg_ilcr)
+#define _IWCR(i2c)	((i2c)->reg_iwcr)
 
 /*
  * I2C Slave mode address
@@ -467,11 +486,16 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 	if (i2c->reg_isar)
 		writel(i2c->slave_addr, _ISAR(i2c));
 #endif
-
 	/* set control register values */
 	writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c));
 	writel(readl(_ICR(i2c)) | (i2c->high_mode ? ICR_HS : 0), _ICR(i2c));
 
+	if (i2c->ilcr)
+		writel(i2c->ilcr, _ILCR(i2c));
+	if (i2c->iwcr)
+		writel(i2c->iwcr, _IWCR(i2c));
+	udelay(2);
+
 #ifdef CONFIG_I2C_PXA_SLAVE
 	dev_info(&i2c->adap.dev, "Enabling slave mode\n");
 	writel(readl(_ICR(i2c)) | ICR_SADIE | ICR_ALDIE | ICR_SSDIE, _ICR(i2c));
@@ -1098,7 +1122,7 @@ static const struct i2c_algorithm i2c_pxa_pio_algorithm = {
 static const struct of_device_id i2c_pxa_dt_ids[] = {
 	{ .compatible = "mrvl,pxa-i2c", .data = (void *)REGS_PXA2XX },
 	{ .compatible = "mrvl,pwri2c", .data = (void *)REGS_PXA3XX },
-	{ .compatible = "mrvl,mmp-twsi", .data = (void *)REGS_PXA2XX },
+	{ .compatible = "mrvl,mmp-twsi", .data = (void *)REGS_PXA910 },
 	{}
 };
 MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids);
@@ -1106,6 +1130,7 @@ MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids);
 static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
 			    enum pxa_i2c_types *i2c_types)
 {
+	int ret;
 	struct device_node *np = pdev->dev.of_node;
 	const struct of_device_id *of_id =
 			of_match_device(i2c_pxa_dt_ids, &pdev->dev);
@@ -1121,6 +1146,16 @@ static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
 	if (of_get_property(np, "mrvl,i2c-fast-mode", NULL))
 		i2c->fast_mode = 1;
 	*i2c_types = (u32)(of_id->data);
+
+	if (of_device_is_compatible(np, "mrvl,mmp-twsi")) {
+		ret = of_property_read_u32(np, "mrvl,i2c-ilcr", &i2c->ilcr);
+		if (ret)
+			return ret;
+		ret = of_property_read_u32(np, "mrvl,i2c-iwcr", &i2c->iwcr);
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -1206,6 +1241,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
 	if (i2c_type != REGS_CE4100)
 		i2c->reg_isar = i2c->reg_base + pxa_reg_layout[i2c_type].isar;
 
+	i2c->reg_ilcr = i2c->reg_base + pxa_reg_layout[i2c_type].ilcr;
+	i2c->reg_iwcr = i2c->reg_base + pxa_reg_layout[i2c_type].iwcr;
+
 	i2c->iobase = res->start;
 	i2c->iosize = resource_size(res);
 
@@ -1219,6 +1257,8 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		i2c->slave_addr = plat->slave_addr;
 		i2c->slave = plat->slave;
 #endif
+		i2c->ilcr = plat->ilcr;
+		i2c->iwcr = plat->iwcr;
 		i2c->adap.class = plat->class;
 	}
 
diff --git a/include/linux/i2c/pxa-i2c.h b/include/linux/i2c/pxa-i2c.h
index 53aab24..d1a44e8 100644
--- a/include/linux/i2c/pxa-i2c.h
+++ b/include/linux/i2c/pxa-i2c.h
@@ -70,6 +70,8 @@ struct i2c_pxa_platform_data {
 	unsigned int		high_mode:1;
 	unsigned char		master_code;
 	unsigned long		rate;
+	unsigned int		ilcr;
+	unsigned int		iwcr;
 };
 
 extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
-- 
1.9.1

  parent reply	other threads:[~2015-05-28 13:03 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28 13:03 [PATCH 00/12] i2c: pxa: Fixes, cleanup and support for pxa910 family Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 01/12] i2c: pxa: keep i2c irq ON in suspend Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 02/12] i2c: pxa: No need to set slave addr for i2c master mode reset Vaibhav Hiremath
2015-05-29 19:21   ` Robert Jarzmik
2015-05-29 19:25     ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 03/12] i2c: pxa: Add reset operation when i2c bus busy Vaibhav Hiremath
2015-05-29 19:39   ` Robert Jarzmik
2015-05-29 20:20     ` Vaibhav Hiremath
2015-05-28 13:03 ` Vaibhav Hiremath [this message]
2015-05-29 20:22   ` [PATCH 04/12] i2c: pxa: Add support for pxa910/988 & new configuration features Robert Jarzmik
2015-05-29 20:33     ` Vaibhav Hiremath
2015-06-04  2:31     ` Yi Zhang
2015-06-04  5:46       ` Vaibhav Hiremath
2015-06-01  0:13   ` Wolfram Sang
2015-06-02  5:01     ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 05/12] i2c: pxa: Add bus reset functionality Vaibhav Hiremath
2015-05-29 13:59   ` Rob Herring
2015-05-29 15:40     ` Vaibhav Hiremath
2015-05-29 20:31   ` Robert Jarzmik
2015-06-02 13:12   ` Linus Walleij
2015-06-02 16:40     ` Vaibhav Hiremath
2015-06-03 19:16     ` Vaibhav Hiremath
2015-06-02 17:33   ` Wolfram Sang
2015-06-02 17:40     ` Vaibhav Hiremath
2015-06-02 17:48       ` Wolfram Sang
2015-06-02 17:57         ` Vaibhav Hiremath
2015-06-02 18:02           ` Wolfram Sang
2015-06-02 18:06             ` Vaibhav Hiremath
2015-06-02 18:24               ` Wolfram Sang
2015-06-02 18:46                 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 06/12] i2c: pxa: Return I2C_RETRY when timeout in pio mode Vaibhav Hiremath
2015-05-29 20:46   ` Robert Jarzmik
2015-05-29 21:23     ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 07/12] i2c: pxa: Reset i2c controller on timeout in interrupt and " Vaibhav Hiremath
2015-05-29 21:13   ` Robert Jarzmik
2015-05-29 21:19     ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 08/12] i2c: pxa: enable/disable irq across message xfer Vaibhav Hiremath
2015-05-28 13:17   ` Russell King - ARM Linux
2015-05-28 13:29     ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 09/12] i2c: pxa: Remove compile warnning in 64bit mode Vaibhav Hiremath
2015-05-29 21:28   ` Robert Jarzmik
2015-05-28 13:03 ` [PATCH 10/12] i2c: pxa: Update debug function to dump more info on error Vaibhav Hiremath
2015-05-29 21:42   ` Robert Jarzmik
2015-05-29 21:45     ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 11/12] i2c:pxa: Use devm_ variants in probe function Vaibhav Hiremath
2015-05-30 15:53   ` Robert Jarzmik
2015-05-31  7:36     ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 12/12] i2c: pxa: enable/disable i2c module across msg xfer Vaibhav Hiremath
2015-05-28 13:23   ` Russell King - ARM Linux
2015-06-02 16:52     ` Vaibhav Hiremath
2015-06-02 16:59       ` Vaibhav Hiremath
2015-06-03 10:56         ` Yi Zhang
2015-06-03 18:49           ` Vaibhav Hiremath
2015-06-04  6:29         ` Yi Zhang
2015-06-04  7:19           ` Vaibhav Hiremath
2015-06-04  7:58             ` Yi Zhang
2015-06-01  0:07 ` [PATCH 00/12] i2c: pxa: Fixes, cleanup and support for pxa910 family Wolfram Sang
2015-06-02  4:58   ` Vaibhav Hiremath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432818224-17070-5-git-send-email-vaibhav.hiremath@linaro.org \
    --to=vaibhav.hiremath@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).