linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gregory CLEMENT <gregory.clement@free-electrons.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Andrew Lunn <andrew@lunn.ch>, Jason Cooper <jason@lakedaemon.net>,
	stable@vger.kernel.org,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	linux-i2c@vger.kernel.org,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
	linux-arm-kernel@lists.infradead.org,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v4 2/3] ARM: mvebu: Add quirk for i2c
Date: Wed, 08 Jan 2014 14:03:58 +0100	[thread overview]
Message-ID: <52CD4CBE.6010902@free-electrons.com> (raw)
In-Reply-To: <20140108112926.GB2669@katana>

On 08/01/2014 12:29, Wolfram Sang wrote:
> On Wed, Jan 08, 2014 at 11:15:05AM +0100, Gregory CLEMENT wrote:
>> Hi Wolfram,
>>
>> On 08/01/2014 00:06, Wolfram Sang wrote:
>>> On Tue, Jan 07, 2014 at 11:38:53AM -0700, Jason Gunthorpe wrote:
>>>> On Tue, Jan 07, 2014 at 05:35:03PM +0100, Gregory CLEMENT wrote:
>>>>> +static struct property i2c_offload_broken = {
>>>>> +	.name = "offload-broken",
>>>>> +};
>>>>> +
>>>>> +static void __init i2c_quirk(void)
>>>>> +{
>>>>> +	struct device_node *np;
>>>>> +	u32 dev, rev;
>>>>> +
>>>>> +	/*
>>>>> +	 * Only revisons more recent than A0 support the offload
>>>>> +	 * mechanism. We can exit only if we are sure that we can
>>>>> +	 * get the SoC revision and it is more recent than A0.
>>>>> +	 */
>>>>> +	if (mvebu_get_soc_id(&rev, &dev) == 0 && dev > MV78XX0_A0_REV)
>>>>> +		return;
>>>>> +
>>>>> +	for_each_compatible_node(np, NULL, "marvell,mv78230-i2c")
>>>>> +		of_add_property(np, &i2c_offload_broken);
>>>>
>>>> I like this approach.
>>>
>>> Sorry, but I don't.
>>>
>>>> However, when I first read this I thought it should be a -a0 specific
>>>> compatible string, not a 'offload-broken' property - any idea what the
>>>> DT consensus is here? I've seen both approach in use ..
>>>
>>> I prefer the replacement of the compatible string. If it should really
>>> be a seperate property, then it should be a vendor specific property. It
>>> is not generic, at all.
>>
>> Something like "marvell,offload-broken" would be acceptable?
> 
> A tad more, yes. Still, since this is a feature/quirk of the IP core
> revision, it should be deduced from the compatible property IMO. It
> cannot be configured anywhere, so it doesn't change on board level.

So you would prefer using the "marvell,mv78230-a0-i2c" comaptible string and
updating it with the follwing piece of code?

diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
index e2acff98e750..8c4ecf987e82 100644
--- a/arch/arm/mach-mvebu/armada-370-xp.c
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -21,6 +21,8 @@
 #include <linux/clocksource.h>
 #include <linux/dma-mapping.h>
 #include <linux/mbus.h>
+#include <linux/mvebu-soc-id.h>
+#include <linux/slab.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -45,8 +47,38 @@ static void __init armada_370_xp_timer_and_clk_init(void)
 #endif
 }

+static void __init i2c_quirk(void)
+{
+       struct device_node *np;
+       u32 dev, rev;
+       int i = 0;
+
+       /*
+        * Only revisons more recent than A0 support the offload
+        * mechanism. We can exit only if we are sure that we can
+        * get the SoC revision and it is more recent than A0.
+        */
+       if (mvebu_get_soc_id(&rev, &dev) == 0 && dev > MV78XX0_A0_REV)
+               return;
+
+       for_each_compatible_node(np, NULL, "marvell,mv78230-i2c") {
+               struct property *new_compat;
+
+               new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
+
+               new_compat->name =  kstrdup("compatible", GFP_KERNEL);
+               new_compat->length =  sizeof("marvell,mv78230-a0-i2c");
+               new_compat->value =  kstrdup("marvell,mv78230-a0-i2c",
+                                               GFP_KERNEL);
+
+               of_update_property(np, new_compat);
+       }
+       return;
+}
+
 static void __init armada_370_xp_dt_init(void)
 {
+       i2c_quirk();
        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }


> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

  reply	other threads:[~2014-01-08 13:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 16:35 [PATCH v4 0/3] Fix i2c bus hang on A0 version of the Armada XP SoCs Gregory CLEMENT
2014-01-07 16:35 ` [PATCH v4 1/3] ARM: mvebu: Add support to get the ID and the revision of a SoC Gregory CLEMENT
2014-01-08 12:55   ` Arnd Bergmann
2014-01-08 14:16     ` Gregory CLEMENT
     [not found] ` <1389112504-9931-1-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-07 16:35   ` [PATCH v4 2/3] ARM: mvebu: Add quirk for i2c Gregory CLEMENT
2014-01-07 18:38     ` Jason Gunthorpe
2014-01-07 23:06       ` Wolfram Sang
2014-01-08 10:15         ` Gregory CLEMENT
     [not found]           ` <52CD2529.6090206-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-08 11:29             ` Wolfram Sang
2014-01-08 13:03               ` Gregory CLEMENT [this message]
     [not found]                 ` <52CD4CBE.6010902-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-08 13:39                   ` Wolfram Sang
2014-01-08 13:45                     ` Arnd Bergmann
2014-01-08 14:10                       ` Gregory CLEMENT
2014-01-08 14:07                     ` Gregory CLEMENT
     [not found]                       ` <52CD5BBA.4080600-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-09 14:39                         ` Gregory CLEMENT
     [not found]     ` <1389112504-9931-3-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-08 12:52       ` Arnd Bergmann
     [not found]         ` <201401081352.57361.arnd-r2nGTMty4D4@public.gmane.org>
2014-01-08 13:42           ` Gregory CLEMENT
2014-01-08 13:44             ` Arnd Bergmann
2014-01-07 16:35 ` [PATCH v4 3/3] i2c: mv64xxx: Fix bus hang on A0 version of the Armada XP SoCs Gregory CLEMENT
2014-01-07 22:17   ` Thomas Petazzoni

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=52CD4CBE.6010902@free-electrons.com \
    --to=gregory.clement@free-electrons.com \
    --cc=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=wsa@the-dreams.de \
    /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).