From: Karol Lewandowski <k.lewandowsk@samsung.com>
To: ben-linux@fluff.org
Cc: thomas.abraham@linaro.org, m.szyprowski@samsung.com,
linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
devicetree-discuss@lists.ozlabs.org,
linux-samsung-soc@vger.kernel.org, t.stanislaws@samsung.com,
Karol Lewandowski <k.lewandowsk@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Subject: [PATCH 2/2] i2c-s3c2410: Add HDMIPHY quirk for S3C2440
Date: Fri, 09 Mar 2012 18:04:46 +0100 [thread overview]
Message-ID: <1331312686-2077-3-git-send-email-k.lewandowsk@samsung.com> (raw)
In-Reply-To: <1331312686-2077-1-git-send-email-k.lewandowsk@samsung.com>
From: Tomasz Stanislawski <t.stanislaws@samsung.com>
This patch adds support for s3c2440 I2C bus controller dedicated HDMIPHY device on
Exynos4 platform. Some quirks are introduced due to differences between HDMIPHY
and other I2C controllers on Exynos4. These differences are:
- no GPIOs, HDMIPHY is inside the SoC and the controller is connected
internally
- due to unknown reason (probably HW bug in HDMIPHY and/or the controller) a
transfer fails to finish. The controller hangs after sending the last byte,
the workaround for this bug is resetting the controller after each transfer
Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
Tested-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
.../devicetree/bindings/i2c/samsung-i2c.txt | 10 +++++-
drivers/i2c/busses/i2c-s3c2410.c | 34 ++++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index 38832c7..ac0917c 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -10,14 +10,20 @@ Required properties:
region.
- interrupts: interrupt number to the cpu.
- samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
- - gpios: The order of the gpios should be the following: <SDA, SCL>.
- The gpio specifier depends on the gpio controller.
Optional properties:
+ - gpios: The order of the gpios should be the following: <SDA, SCL>.
+ The gpio specifier depends on the gpio controller. Required in all cases
+ except when "samsung,i2c-no-gpio" is also specified.
+ - samsung,i2c-no-gpio: input/output lines of the controller are
+ permanently wired to the respective client, there are no gpio
+ lines that need to be configured to enable this controller
- samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
specified, default value is 0.
- samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
specified, the default value in Hz is 100000.
+ - samsung,i2c-quirk-hdmiphy: Quirk for HDMI PHY block on S3C2440 -
+ reduce timeout and reset controller when doing transefers
Example:
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 5b400c6..9f3be51 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -48,6 +48,8 @@
#define TYPE_BITS 0x000000ff
#define TYPE_S3C2410 0x00000001
#define TYPE_S3C2440 0x00000002
+#define FLAG_HDMIPHY 0x00000100
+#define FLAG_NO_GPIO 0x00000200
/* i2c controller state */
enum s3c24xx_i2c_state {
@@ -449,6 +451,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
unsigned long iicstat;
int timeout = 400;
+ /* the timeout for HDMIPHY is reduced to 10 ms because
+ * the hangup is expected to happen, so waiting 400 ms
+ * causes only unnecessary system hangup
+ */
+ if (i2c->type & FLAG_HDMIPHY)
+ timeout = 10;
+
while (timeout-- > 0) {
iicstat = readl(i2c->regs + S3C2410_IICSTAT);
@@ -458,6 +467,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
msleep(1);
}
+ /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
+ if (i2c->type & FLAG_HDMIPHY) {
+ writel(0, i2c->regs + S3C2410_IICCON);
+ writel(0, i2c->regs + S3C2410_IICSTAT);
+ writel(0, i2c->regs + S3C2410_IICDS);
+
+ return 0;
+ }
+
return -ETIMEDOUT;
}
@@ -739,6 +757,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c)
{
int idx, gpio, ret;
+ if (i2c->type & FLAG_NO_GPIO)
+ return 0;
+
for (idx = 0; idx < 2; idx++) {
gpio = of_get_gpio(i2c->dev->of_node, idx);
if (!gpio_is_valid(gpio)) {
@@ -763,6 +784,10 @@ free_gpio:
static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
{
unsigned int idx;
+
+ if (i2c->type & FLAG_NO_GPIO)
+ return;
+
for (idx = 0; idx < 2; idx++)
gpio_free(i2c->gpios[idx]);
}
@@ -846,6 +871,12 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
match = of_match_node(&s3c24xx_i2c_match[0], np);
i2c->type = (unsigned int)match->data;
+ if (i2c->type == TYPE_S3C2440 && of_get_property(np, "samsung,i2c-quirk-hdmiphy", NULL))
+ i2c->type |= FLAG_HDMIPHY;
+
+ if (of_get_property(np, "samsung,i2c-no-gpio", NULL))
+ i2c->type |= FLAG_NO_GPIO;
+
of_property_read_u32(np, "samsung,i2c-sda-delay", &pdata->sda_delay);
of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr);
of_property_read_u32(np, "samsung,i2c-max-bus-freq",
@@ -1103,6 +1134,9 @@ static struct platform_device_id s3c24xx_driver_ids[] = {
}, {
.name = "s3c2440-i2c",
.driver_data = TYPE_S3C2440,
+ }, {
+ .name = "s3c2440-hdmiphy-i2c",
+ .driver_data = TYPE_S3C2440 | FLAG_HDMIPHY | FLAG_NO_GPIO,
}, { },
};
MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
--
1.7.9
next prev parent reply other threads:[~2012-03-09 17:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-09 17:04 [PATCH 0/2] i2c-s3c2410: Updates for exynos4210 and DT-based systems Karol Lewandowski
2012-03-09 17:04 ` [PATCH 1/2] i2c-s3c2410: Rework device type handling Karol Lewandowski
2012-03-12 5:58 ` Thomas Abraham
[not found] ` <CAJuYYwRDb-NvOzpzWtV8erw8UZeHjBUDUPjm-Cg0GTz6BCCV5w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-12 13:16 ` Karol Lewandowski
[not found] ` <4F5DF72F.4020009-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-12 14:21 ` Thomas Abraham
2012-03-09 17:04 ` Karol Lewandowski [this message]
[not found] ` <1331312686-2077-3-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-12 6:08 ` [PATCH 2/2] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 Thomas Abraham
-- strict thread matches above, loose matches on Subject: below --
2012-04-23 16:23 [PATCH v4 0/2] i2c-s3c2410: Updates for exynos4210 and DT-based systems Karol Lewandowski
[not found] ` <1335198241-19344-1-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-04-23 16:24 ` [PATCH 2/2] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 Karol Lewandowski
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=1331312686-2077-3-git-send-email-k.lewandowsk@samsung.com \
--to=k.lewandowsk@samsung.com \
--cc=ben-linux@fluff.org \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=t.stanislaws@samsung.com \
--cc=thomas.abraham@linaro.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