Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


k.lewandowsk at samsung

Mar 13, 2012, 9:54 AM

Post #1 of 10 (187 views)
Permalink
[PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

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 [at] samsung>
Signed-off-by: Karol Lewandowski <k.lewandowsk [at] samsung>
Tested-by: Tomasz Stanislawski <t.stanislaws [at] samsung>
Signed-off-by: Kyungmin Park <kyungmin.park [at] samsung>
---
.../devicetree/bindings/i2c/samsung-i2c.txt | 10 ++++-
drivers/i2c/busses/i2c-s3c2410.c | 36 ++++++++++++++++++++
2 files changed, 44 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 f84d26f..23bf7fa 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -52,6 +52,8 @@ static const struct of_device_id s3c24xx_i2c_match[];
#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 {
@@ -481,6 +483,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);

@@ -490,6 +499,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;
}

@@ -771,6 +789,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)) {
@@ -795,6 +816,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]);
}
@@ -871,6 +896,14 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
return;

pdata->bus_num = -1; /* i2c bus number is dynamically assigned */
+
+ if (s3c24xx_i2c_is_type(i2c, 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",
@@ -1128,6 +1161,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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


t.stanislaws at samsung

Mar 13, 2012, 10:27 AM

Post #2 of 10 (185 views)
Permalink
Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

Hi Karol,
Please refer to comments below,

Regards,
Tomasz Stanislawski

On 03/13/2012 05:54 PM, Karol Lewandowski wrote:
> 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 [at] samsung>
> Signed-off-by: Karol Lewandowski <k.lewandowsk [at] samsung>
> Tested-by: Tomasz Stanislawski <t.stanislaws [at] samsung>
> Signed-off-by: Kyungmin Park <kyungmin.park [at] samsung>
> ---
> .../devicetree/bindings/i2c/samsung-i2c.txt | 10 ++++-
> drivers/i2c/busses/i2c-s3c2410.c | 36 ++++++++++++++++++++
> 2 files changed, 44 insertions(+), 2 deletions(-)
>
[snip]
> @@ -871,6 +896,14 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
> return;
>
> pdata->bus_num = -1; /* i2c bus number is dynamically assigned */
> +
> + if (s3c24xx_i2c_is_type(i2c, TYPE_S3C2440) &&

I think that type checking should be removed because hdmiphy quirk is something
orthogonal to the controller type.

> + 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",
> @@ -1128,6 +1161,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);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


k.lewandowsk at samsung

Mar 13, 2012, 11:00 AM

Post #3 of 10 (183 views)
Permalink
Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

On 13.03.2012 18:27, Tomasz Stanislawski wrote:

> Hi Karol,
> Please refer to comments below,
>
> Regards,
> Tomasz Stanislawski
>
> On 03/13/2012 05:54 PM, Karol Lewandowski wrote:
>> 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 [at] samsung>
>> Signed-off-by: Karol Lewandowski <k.lewandowsk [at] samsung>
>> Tested-by: Tomasz Stanislawski <t.stanislaws [at] samsung>
>> Signed-off-by: Kyungmin Park <kyungmin.park [at] samsung>
>> ---
>> .../devicetree/bindings/i2c/samsung-i2c.txt | 10 ++++-
>> drivers/i2c/busses/i2c-s3c2410.c | 36 ++++++++++++++++++++
>> 2 files changed, 44 insertions(+), 2 deletions(-)
>>
> [snip]
>> @@ -871,6 +896,14 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
>> return;
>>
>> pdata->bus_num = -1; /* i2c bus number is dynamically assigned */
>> +
>> + if (s3c24xx_i2c_is_type(i2c, TYPE_S3C2440) &&
>
> I think that type checking should be removed because hdmiphy quirk is something
> orthogonal to the controller type.


Ok, I'll drop this test and resend patch in a minute.

Thanks!
--
Karol Lewandowski | Samsung Poland R&D Center | Linux/Platform
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


k.lewandowsk at samsung

Mar 21, 2012, 12:11 PM

Post #4 of 10 (176 views)
Permalink
[PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

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 [at] samsung>
Signed-off-by: Karol Lewandowski <k.lewandowsk [at] samsung>
Tested-by: Tomasz Stanislawski <t.stanislaws [at] samsung>
Signed-off-by: Kyungmin Park <kyungmin.park [at] samsung>
---
.../devicetree/bindings/i2c/samsung-i2c.txt | 11 +++++-
drivers/i2c/busses/i2c-s3c2410.c | 35 ++++++++++++++++++++
2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index 38832c7..c6670f9 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -10,14 +10,21 @@ 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 found on
+ Exynos4 platform - reduce timeout and reset controller after each
+ transfer

Example:

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index f7b6a14..e50f523 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -50,6 +50,8 @@ static const struct of_device_id s3c24xx_i2c_match[];

/* Treat S3C2410 as baseline hardware, anything else is supported via quirks */
#define QUIRK_S3C2440 (1 << 0)
+#define QUIRK_HDMIPHY (1 << 1)
+#define QUIRK_NO_GPIO (1 << 2)

/* i2c controller state */
enum s3c24xx_i2c_state {
@@ -469,6 +471,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->quirks & QUIRK_HDMIPHY)
+ timeout = 10;
+
while (timeout-- > 0) {
iicstat = readl(i2c->regs + S3C2410_IICSTAT);

@@ -478,6 +487,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
msleep(1);
}

+ /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
+ if (i2c->quirks & QUIRK_HDMIPHY) {
+ writel(0, i2c->regs + S3C2410_IICCON);
+ writel(0, i2c->regs + S3C2410_IICSTAT);
+ writel(0, i2c->regs + S3C2410_IICDS);
+
+ return 0;
+ }
+
return -ETIMEDOUT;
}

@@ -759,6 +777,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c)
{
int idx, gpio, ret;

+ if (i2c->quirks & QUIRK_NO_GPIO)
+ return 0;
+
for (idx = 0; idx < 2; idx++) {
gpio = of_get_gpio(i2c->dev->of_node, idx);
if (!gpio_is_valid(gpio)) {
@@ -783,6 +804,10 @@ free_gpio:
static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
{
unsigned int idx;
+
+ if (i2c->quirks & QUIRK_NO_GPIO)
+ return;
+
for (idx = 0; idx < 2; idx++)
gpio_free(i2c->gpios[idx]);
}
@@ -859,6 +884,13 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
return;

pdata->bus_num = -1; /* i2c bus number is dynamically assigned */
+
+ if (of_get_property(np, "samsung,i2c-quirk-hdmiphy", NULL))
+ i2c->quirks |= QUIRK_HDMIPHY;
+
+ if (of_get_property(np, "samsung,i2c-no-gpio", NULL))
+ i2c->quirks |= QUIRK_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",
@@ -1116,6 +1148,9 @@ static struct platform_device_id s3c24xx_driver_ids[] = {
}, {
.name = "s3c2440-i2c",
.driver_data = QUIRK_S3C2440,
+ }, {
+ .name = "s3c2440-hdmiphy-i2c",
+ .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO,
}, { },
};
MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
--
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


w.sang at pengutronix

Apr 17, 2012, 10:40 AM

Post #5 of 10 (160 views)
Permalink
Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

Hi,

On Wed, Mar 21, 2012 at 08:11:53PM +0100, Karol Lewandowski wrote:
> 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 [at] samsung>
> Signed-off-by: Karol Lewandowski <k.lewandowsk [at] samsung>
> Tested-by: Tomasz Stanislawski <t.stanislaws [at] samsung>
> Signed-off-by: Kyungmin Park <kyungmin.park [at] samsung>
> ---
> .../devicetree/bindings/i2c/samsung-i2c.txt | 11 +++++-
> drivers/i2c/busses/i2c-s3c2410.c | 35 ++++++++++++++++++++
> 2 files changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
> index 38832c7..c6670f9 100644
> --- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
> +++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
> @@ -10,14 +10,21 @@ 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

Can't we just skip this property...


> - 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 found on
> + Exynos4 platform - reduce timeout and reset controller after each
> + transfer

... and this one, if we declare a new compatible-entry for exynos4?

>
> Example:
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index f7b6a14..e50f523 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -50,6 +50,8 @@ static const struct of_device_id s3c24xx_i2c_match[];
>
> /* Treat S3C2410 as baseline hardware, anything else is supported via quirks */
> #define QUIRK_S3C2440 (1 << 0)
> +#define QUIRK_HDMIPHY (1 << 1)
> +#define QUIRK_NO_GPIO (1 << 2)
>
> /* i2c controller state */
> enum s3c24xx_i2c_state {
> @@ -469,6 +471,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->quirks & QUIRK_HDMIPHY)
> + timeout = 10;
> +
> while (timeout-- > 0) {
> iicstat = readl(i2c->regs + S3C2410_IICSTAT);
>
> @@ -478,6 +487,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
> msleep(1);
> }
>
> + /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
> + if (i2c->quirks & QUIRK_HDMIPHY) {
> + writel(0, i2c->regs + S3C2410_IICCON);
> + writel(0, i2c->regs + S3C2410_IICSTAT);
> + writel(0, i2c->regs + S3C2410_IICDS);
> +
> + return 0;
> + }
> +
> return -ETIMEDOUT;
> }
>
> @@ -759,6 +777,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c)
> {
> int idx, gpio, ret;
>
> + if (i2c->quirks & QUIRK_NO_GPIO)
> + return 0;
> +
> for (idx = 0; idx < 2; idx++) {
> gpio = of_get_gpio(i2c->dev->of_node, idx);
> if (!gpio_is_valid(gpio)) {
> @@ -783,6 +804,10 @@ free_gpio:
> static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
> {
> unsigned int idx;
> +
> + if (i2c->quirks & QUIRK_NO_GPIO)
> + return;
> +
> for (idx = 0; idx < 2; idx++)
> gpio_free(i2c->gpios[idx]);
> }
> @@ -859,6 +884,13 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
> return;
>
> pdata->bus_num = -1; /* i2c bus number is dynamically assigned */
> +
> + if (of_get_property(np, "samsung,i2c-quirk-hdmiphy", NULL))
> + i2c->quirks |= QUIRK_HDMIPHY;
> +
> + if (of_get_property(np, "samsung,i2c-no-gpio", NULL))
> + i2c->quirks |= QUIRK_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",
> @@ -1116,6 +1148,9 @@ static struct platform_device_id s3c24xx_driver_ids[] = {
> }, {
> .name = "s3c2440-i2c",
> .driver_data = QUIRK_S3C2440,
> + }, {
> + .name = "s3c2440-hdmiphy-i2c",
> + .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO,
> }, { },
> };
> MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
> --
> 1.7.9
>

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Attachments: signature.asc (0.19 KB)


m.szyprowski at samsung

Apr 18, 2012, 5:11 AM

Post #6 of 10 (157 views)
Permalink
RE: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

Hi Wolfram,

On Tuesday, April 17, 2012 7:40 PM Wolfram Sang wrote:

> On Wed, Mar 21, 2012 at 08:11:53PM +0100, Karol Lewandowski wrote:
> > 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 [at] samsung>
> > Signed-off-by: Karol Lewandowski <k.lewandowsk [at] samsung>
> > Tested-by: Tomasz Stanislawski <t.stanislaws [at] samsung>
> > Signed-off-by: Kyungmin Park <kyungmin.park [at] samsung>
> > ---
> > .../devicetree/bindings/i2c/samsung-i2c.txt | 11 +++++-
> > drivers/i2c/busses/i2c-s3c2410.c | 35 ++++++++++++++++++++
> > 2 files changed, 44 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
> b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
> > index 38832c7..c6670f9 100644
> > --- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
> > +++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
> > @@ -10,14 +10,21 @@ 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
>
> Can't we just skip this property...

All standard s3c-24x0 i2c controllers require gpio lines for proper operation,
so lack of the gpios property should be considered as an error. However there
is a special case of internal, embedded i2c controller which has no such gpio
lines at all.

> > - 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 found on
> > + Exynos4 platform - reduce timeout and reset controller after each
> > + transfer
>
> ... and this one, if we declare a new compatible-entry for exynos4?

It is not strictly related to Exynos4 SoCs. Exynos4 SoC has 8 standard s3c2440 style
i2c controllers and one additional, internal controller for HDMIPHY, which needs
some workarounds in the driver. Maybe the quirk should be named 'broken timeout
detection'

(snipped)

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


w.sang at pengutronix

Apr 18, 2012, 6:46 AM

Post #7 of 10 (158 views)
Permalink
Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

> > > 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
> >
> > Can't we just skip this property...
>
> All standard s3c-24x0 i2c controllers require gpio lines for proper operation,
> so lack of the gpios property should be considered as an error. However there
> is a special case of internal, embedded i2c controller which has no such gpio
> lines at all.
>
> > > - 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 found on
> > > + Exynos4 platform - reduce timeout and reset controller after each
> > > + transfer
> >
> > ... and this one, if we declare a new compatible-entry for exynos4?
>
> It is not strictly related to Exynos4 SoCs. Exynos4 SoC has 8 standard s3c2440 style
> i2c controllers and one additional, internal controller for HDMIPHY, which needs
> some workarounds in the driver. Maybe the quirk should be named 'broken timeout
> detection'

I was wondering since you do what I suggested for platform devices already:

+ .name = "s3c2440-hdmiphy-i2c",
+ .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO,

Regards,

Wolfram

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Attachments: signature.asc (0.19 KB)


k.lewandowsk at samsung

Apr 18, 2012, 9:31 AM

Post #8 of 10 (169 views)
Permalink
Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

On 18.04.2012 15:46, Wolfram Sang wrote:

>
>>>> 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
>>>
>>> Can't we just skip this property...
>>
>> All standard s3c-24x0 i2c controllers require gpio lines for proper operation,
>> so lack of the gpios property should be considered as an error. However there
>> is a special case of internal, embedded i2c controller which has no such gpio
>> lines at all.
>>
>>>> - 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 found on
>>>> + Exynos4 platform - reduce timeout and reset controller after each
>>>> + transfer
>>>
>>> ... and this one, if we declare a new compatible-entry for exynos4?
>>
>> It is not strictly related to Exynos4 SoCs. Exynos4 SoC has 8 standard s3c2440 style
>> i2c controllers and one additional, internal controller for HDMIPHY, which needs
>> some workarounds in the driver. Maybe the quirk should be named 'broken timeout
>> detection'
>
> I was wondering since you do what I suggested for platform devices already:
>
> + .name = "s3c2440-hdmiphy-i2c",
> + .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO,


Here I've done it this way for compatibility with legacy driver and
board(s).

Device tree is new interface, and I thought that it would be better
to describe things explicitly and separately from device type.

Right now these properties are used only on S3C2440, but I don't
consider it highly unlikely to see these on S3C**** in future.

Tomasz had similar doubts when I've posted patch that checked these
quirks only for S3C2440:

http://permalink.gmane.org/gmane.linux.drivers.i2c/10305

Thus, I've chosen properties and not separate type.

It's easy to introduce compat string (see below), but given above
I'm afraid that we might end up adding -hdmiphy- variant for every
new version of i2c controller.


E.g.

diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index c6670f9..b1d106e 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -6,6 +6,8 @@ Required properties:
- compatible: value should be either of the following.
(a) "samsung, s3c2410-i2c", for i2c compatible with s3c2410 i2c.
(b) "samsung, s3c2440-i2c", for i2c compatible with s3c2440 i2c.
+ (c) "samsung, s3c2440-hdmiphy-i2c", for s3c2440-like i2c used
+ inside HDMIPHY block found on several samsung SoCs
- reg: physical base address of the controller and length of memory mapped
region.
- interrupts: interrupt number to the cpu.
@@ -13,18 +15,13 @@ Required properties:

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
+ The gpio specifier depends on the gpio controller. Required in all
+ cases except for "samsung,i2c-hdmiphy-i2c" whose input/output
+ lines are permanently wired to the respective client
- 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 found on
- Exynos4 platform - reduce timeout and reset controller after each
- transfer

Example:

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 71438eb..bc82045 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -106,6 +106,8 @@ MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
static const struct of_device_id s3c24xx_i2c_match[] = {
{ .compatible = "samsung,s3c2410-i2c", .data = (void *)0 },
{ .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 },
+ { .compatible = "samsung,s3c2440-hdmiphy-i2c",
+ .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) },
{},
};
MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
@@ -902,12 +904,6 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)

pdata->bus_num = -1; /* i2c bus number is dynamically assigned */

- if (of_get_property(np, "samsung,i2c-quirk-hdmiphy", NULL))
- i2c->quirks |= QUIRK_HDMIPHY;
-
- if (of_get_property(np, "samsung,i2c-no-gpio", NULL))
- i2c->quirks |= QUIRK_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",


Regards,
--
Karol Lewandowski | Samsung Poland R&D Center | Linux/Platform
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


w.sang at pengutronix

Apr 23, 2012, 3:01 AM

Post #9 of 10 (153 views)
Permalink
Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

Hi Karol,

> >>> ... and this one, if we declare a new compatible-entry for exynos4?
> >>
> >> It is not strictly related to Exynos4 SoCs. Exynos4 SoC has 8 standard s3c2440 style
> >> i2c controllers and one additional, internal controller for HDMIPHY, which needs
> >> some workarounds in the driver. Maybe the quirk should be named 'broken timeout
> >> detection'
> >
> > I was wondering since you do what I suggested for platform devices already:
> >
> > + .name = "s3c2440-hdmiphy-i2c",
> > + .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO,
>
>
> Here I've done it this way for compatibility with legacy driver and
> board(s).

Understood.

> Device tree is new interface, and I thought that it would be better
> to describe things explicitly and separately from device type.
>
> Right now these properties are used only on S3C2440, but I don't
> consider it highly unlikely to see these on S3C**** in future.

My experience also says that it easily can get even worse :(

> Tomasz had similar doubts when I've posted patch that checked these
> quirks only for S3C2440:
>
> http://permalink.gmane.org/gmane.linux.drivers.i2c/10305
>
> Thus, I've chosen properties and not separate type.

I understand this reasoning. I still differ, though. Think about my
above example about things getting worse. Then, you'd need another
quirk-property for $FLAW. Later, $FLAW is still there, but the timeout
issue was fixed. That would mean, the poor device-tree making person has
to know which quirks to select for this version of the controller. Just
specifying that it is the HDMI-phy and not a regular I2C controller is
much more convenient, and the driver will figure the rest.

> It's easy to introduce compat string (see below), but given above
> I'm afraid that we might end up adding -hdmiphy- variant for every
> new version of i2c controller.

I'd be fine with that, given that the upcoming hdmiphy versions will not
need all the same set of quirk-flags. I think we want that "quirk lookup
table" fixed in the driver and not encoded in the device tree where
people could get it wrong. Also, the quirks are nothing a board maker
can select from; it is implicit as soons as you want the HDMIPHY on that
SoC, thus the compatible-entry should be enough of a description.

I am not the ultimate expert about bindings, though, and am open for
corrections (I feel kinda confident on this issue, though ;))

Regards,

Wolfram

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Attachments: signature.asc (0.19 KB)


k.lewandowsk at samsung

Apr 23, 2012, 9:22 AM

Post #10 of 10 (155 views)
Permalink
Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440 [In reply to]

On 23.04.2012 12:01, Wolfram Sang wrote:

> Hi Karol,
>> Tomasz had similar doubts when I've posted patch that checked these
>> quirks only for S3C2440:
>>
>> http://permalink.gmane.org/gmane.linux.drivers.i2c/10305
>>
>> Thus, I've chosen properties and not separate type.
>
> I understand this reasoning. I still differ, though. Think about my
> above example about things getting worse. Then, you'd need another
> quirk-property for $FLAW. Later, $FLAW is still there, but the timeout
> issue was fixed. That would mean, the poor device-tree making person has
> to know which quirks to select for this version of the controller. Just
> specifying that it is the HDMI-phy and not a regular I2C controller is
> much more convenient, and the driver will figure the rest.

>

>> It's easy to introduce compat string (see below), but given above
>> I'm afraid that we might end up adding -hdmiphy- variant for every
>> new version of i2c controller.
>
> I'd be fine with that, given that the upcoming hdmiphy versions will not
> need all the same set of quirk-flags. I think we want that "quirk lookup
> table" fixed in the driver and not encoded in the device tree where
> people could get it wrong. Also, the quirks are nothing a board maker
> can select from; it is implicit as soons as you want the HDMIPHY on that
> SoC, thus the compatible-entry should be enough of a description.


Fair point, from integrator/board maker POV this makes much more sense.

> I am not the ultimate expert about bindings, though, and am open for
> corrections (I feel kinda confident on this issue, though ;))


I'm quite happy with doing it the way you just described.

I'll resend whole patchset in a minute.

Thanks!
--
Karol Lewandowski | Samsung Poland R&D Center | Linux/Platform
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.