All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Yangbo Lu <yangbo.lu@nxp.com>, Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Dirk Behme <dirk.behme@de.bosch.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2 7/7] soc: renesas: Identify SoC and register with the SoC bus
Date: Mon, 14 Nov 2016 11:51:15 +0100	[thread overview]
Message-ID: <CAMuHMdWavRFnYFmiL2jy3KWZnHG_F8qaxK29zHx6fsLmqXEwiA@mail.gmail.com> (raw)
In-Reply-To: <25057157.YlGi2v6RrE@wuerfel>

Hi Arnd,

On Thu, Nov 10, 2016 at 12:37 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thursday, November 10, 2016 11:19:20 AM CET Geert Uytterhoeven wrote:
>> On Wed, Nov 9, 2016 at 5:55 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> > On Monday, October 31, 2016 12:30:55 PM CET Geert Uytterhoeven wrote:
>> >> v2:
>> >>   - Drop SoC families and family names; use fixed "Renesas" instead,
>> >
>> > I think I'd rather have seen the family names left in there, but it's
>> > not important, so up to you.
>>
>> They're not useful for matching, as family names may change anytime, and don't
>> always say much about the hardware capabilities.
>> E.g. SH-Mobile -> R-Mobile -> R-Car | RZ/A | RZ/G
>> Some SH-Mobile (even some R-Car) parts are SuperH only, others have ARM and
>> SuperH.
>>
>> At least the SoC part numbers are stable (hmm, sh73a0 == r8a73a0).
>
> I think the marketing names are much more useful for humans looking
> at the sysfs files than the kernel doing matching on, but both use
> cases are important.

OK, I'll re-add the family names for humans reading sysfs.

>> >>   - Use "renesas,prr" and "renesas,cccr" device nodes in DT if
>> >>     available, else fall back to hardcoded addresses for compatibility
>> >>     with existing DTBs,

>> > It does seem wrong to have a device node for a specific register though.
>> > Shouldn't the node be for the block of registers that these are inside
>> > of?
>>
>> On R-Mobile APE6, R-Car Gen2 and Gen3, PRR is a lone register.
>> On R-Car Gen1, it's not even documented (and doesn't exist on all parts).
>
> It just seems odd to have it at address 0xff000044 when all the other
> devices are at page-aligned addresses. Do you mean that accessing
> 0xff000040 or 0xff000048 will result in a bus-level exception for a
> missing register and just 0xff000044 is actually valid for access,
> or is it just the only thing that is documented?

For PRR, all other registers in the page read as all zeroes on all SoCs that
have it. So it really is a lone register.

>> On SH-Mobile/R-Mobile, CCCR may be part of the HPB/APB register block, which
>> we further don't touch at all.
>> On R-Car Gen2, it's not documented, but does exist.
>
> This is where the family names would come in handy ;-) I now have
> no idea which chip(s) you are referring to.

SH/R-Mobile are r8a7740, r8a73a4, sh73a0.
R-Car Gen2 are r8a779[0-4].

> If you know the name of the register block, just put it into DT with
> that name. The driver can trivially add the right offset.

CCCR is different. The amount of registers that read as non-zero depends a lot
on the actual SoC.

HPB/APB is gonna need real DT bindings, which needs some more investigation.
Hence if you don't mind, I'd like to postpone that part, which only affects
the older SoCs. And I'll drop the "renesas,cccr" binding.

For now, having revision detection for R-Car Gen3 (r8a779[56]) using PRR is
most urgent, as several drivers (e.g. HDMI, Ethernet, clocks, pinctrl) are
waiting for this support. So I'd like to have that dependency in v4.10.

>> >>   - Don't register the SoC bus if the chip ID register is missing,
>> >
>> > Why? My objection was to hardcoding the register, not to registering
>> > the device? I think I'd rather see the device registered with an
>> > empty revision string.
>>
>> If there's no chip ID register, there's no reason to use soc_device_match(),
>> as we can always look at a compatible value. All SoCs listed in this driver
>> have a chip ID register.
>
> But you may still have user space tools looking into sysfs, e.g. to
> figure out how to install a kernel that the boot loader can find,
> or which hardware specific distro packages to install.
>
>> if you want me to register the soc_bus for  those SoCs regardless, I want to
>> re-add r7s72100 (RZ/A) and r8a7778 (R-Car M1A), who don't have chip ID
>> registers ;-)
>
> Right. Just don't encode too much knowledge about the SoCs into the
> driver, so we are prepared for adding new ones: We should still look
> for the registers in DT on all chips.

OK, will re-add.

>> >> +static int __init renesas_soc_init(void)
>> >> +{
>> >> +       struct soc_device_attribute *soc_dev_attr;
>> >> +       const struct of_device_id *match;
>> >> +       void __iomem *chipid = NULL;
>> >> +       struct soc_device *soc_dev;
>> >> +       struct device_node *np;
>> >> +       unsigned int product;
>> >> +
>> >> +       np = of_find_matching_node_and_match(NULL, renesas_socs, &match);
>> >> +       if (!np)
>> >> +               return -ENODEV;
>> >> +
>> >> +       of_node_put(np);
>> >> +
>> >> +       /* Try PRR first, then CCCR, then hardcoded fallback */
>> >> +       np = of_find_compatible_node(NULL, NULL, "renesas,prr");
>> >> +       if (!np)
>> >> +               np = of_find_compatible_node(NULL, NULL, "renesas,cccr");
>> >> +       if (np) {
>> >> +               chipid = of_iomap(np, 0);
>> >> +               of_node_put(np);
>> >> +       } else if (match->data) {
>> >> +               chipid = ioremap((uintptr_t)match->data, 4);
>> >> +       }
>> >> +       if (!chipid)
>> >>
>> >
>> > Here, I'd turn the order around and look for the DT nodes of the
>> > devices first. Only if they are not found, look at the compatible
>> > string of the root node. No need to search for a node though,
>> > you know which one it is when you look for a compatible =
>> > "renesas,r8a73a4".
>>
>> "renesas,r8a73a4" is the root node, not the device, so it does not have the
>> "reg" property for reading the chip ID?
>
> I mean replace of_find_matching_node_and_match() with
> of_match_node(renesas_socs, of_root).
>
> It does the same thing, just more efficiently.

OK (didn't know "of_root" was available for public use ;-)

>> There is no SoC part number in the "renesas,prr" and "renesas,cccr" nodes.
>> Hence I always need to look at the root nodes.
>
> Not sure what that would protect you from. Could you have a renesas,cccr

Looks like you forgot to finish your sentence?

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: geert@linux-m68k.org (Geert Uytterhoeven)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 7/7] soc: renesas: Identify SoC and register with the SoC bus
Date: Mon, 14 Nov 2016 11:51:15 +0100	[thread overview]
Message-ID: <CAMuHMdWavRFnYFmiL2jy3KWZnHG_F8qaxK29zHx6fsLmqXEwiA@mail.gmail.com> (raw)
In-Reply-To: <25057157.YlGi2v6RrE@wuerfel>

Hi Arnd,

On Thu, Nov 10, 2016 at 12:37 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thursday, November 10, 2016 11:19:20 AM CET Geert Uytterhoeven wrote:
>> On Wed, Nov 9, 2016 at 5:55 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> > On Monday, October 31, 2016 12:30:55 PM CET Geert Uytterhoeven wrote:
>> >> v2:
>> >>   - Drop SoC families and family names; use fixed "Renesas" instead,
>> >
>> > I think I'd rather have seen the family names left in there, but it's
>> > not important, so up to you.
>>
>> They're not useful for matching, as family names may change anytime, and don't
>> always say much about the hardware capabilities.
>> E.g. SH-Mobile -> R-Mobile -> R-Car | RZ/A | RZ/G
>> Some SH-Mobile (even some R-Car) parts are SuperH only, others have ARM and
>> SuperH.
>>
>> At least the SoC part numbers are stable (hmm, sh73a0 == r8a73a0).
>
> I think the marketing names are much more useful for humans looking
> at the sysfs files than the kernel doing matching on, but both use
> cases are important.

OK, I'll re-add the family names for humans reading sysfs.

>> >>   - Use "renesas,prr" and "renesas,cccr" device nodes in DT if
>> >>     available, else fall back to hardcoded addresses for compatibility
>> >>     with existing DTBs,

>> > It does seem wrong to have a device node for a specific register though.
>> > Shouldn't the node be for the block of registers that these are inside
>> > of?
>>
>> On R-Mobile APE6, R-Car Gen2 and Gen3, PRR is a lone register.
>> On R-Car Gen1, it's not even documented (and doesn't exist on all parts).
>
> It just seems odd to have it at address 0xff000044 when all the other
> devices are at page-aligned addresses. Do you mean that accessing
> 0xff000040 or 0xff000048 will result in a bus-level exception for a
> missing register and just 0xff000044 is actually valid for access,
> or is it just the only thing that is documented?

For PRR, all other registers in the page read as all zeroes on all SoCs that
have it. So it really is a lone register.

>> On SH-Mobile/R-Mobile, CCCR may be part of the HPB/APB register block, which
>> we further don't touch at all.
>> On R-Car Gen2, it's not documented, but does exist.
>
> This is where the family names would come in handy ;-) I now have
> no idea which chip(s) you are referring to.

SH/R-Mobile are r8a7740, r8a73a4, sh73a0.
R-Car Gen2 are r8a779[0-4].

> If you know the name of the register block, just put it into DT with
> that name. The driver can trivially add the right offset.

CCCR is different. The amount of registers that read as non-zero depends a lot
on the actual SoC.

HPB/APB is gonna need real DT bindings, which needs some more investigation.
Hence if you don't mind, I'd like to postpone that part, which only affects
the older SoCs. And I'll drop the "renesas,cccr" binding.

For now, having revision detection for R-Car Gen3 (r8a779[56]) using PRR is
most urgent, as several drivers (e.g. HDMI, Ethernet, clocks, pinctrl) are
waiting for this support. So I'd like to have that dependency in v4.10.

>> >>   - Don't register the SoC bus if the chip ID register is missing,
>> >
>> > Why? My objection was to hardcoding the register, not to registering
>> > the device? I think I'd rather see the device registered with an
>> > empty revision string.
>>
>> If there's no chip ID register, there's no reason to use soc_device_match(),
>> as we can always look at a compatible value. All SoCs listed in this driver
>> have a chip ID register.
>
> But you may still have user space tools looking into sysfs, e.g. to
> figure out how to install a kernel that the boot loader can find,
> or which hardware specific distro packages to install.
>
>> if you want me to register the soc_bus for  those SoCs regardless, I want to
>> re-add r7s72100 (RZ/A) and r8a7778 (R-Car M1A), who don't have chip ID
>> registers ;-)
>
> Right. Just don't encode too much knowledge about the SoCs into the
> driver, so we are prepared for adding new ones: We should still look
> for the registers in DT on all chips.

OK, will re-add.

>> >> +static int __init renesas_soc_init(void)
>> >> +{
>> >> +       struct soc_device_attribute *soc_dev_attr;
>> >> +       const struct of_device_id *match;
>> >> +       void __iomem *chipid = NULL;
>> >> +       struct soc_device *soc_dev;
>> >> +       struct device_node *np;
>> >> +       unsigned int product;
>> >> +
>> >> +       np = of_find_matching_node_and_match(NULL, renesas_socs, &match);
>> >> +       if (!np)
>> >> +               return -ENODEV;
>> >> +
>> >> +       of_node_put(np);
>> >> +
>> >> +       /* Try PRR first, then CCCR, then hardcoded fallback */
>> >> +       np = of_find_compatible_node(NULL, NULL, "renesas,prr");
>> >> +       if (!np)
>> >> +               np = of_find_compatible_node(NULL, NULL, "renesas,cccr");
>> >> +       if (np) {
>> >> +               chipid = of_iomap(np, 0);
>> >> +               of_node_put(np);
>> >> +       } else if (match->data) {
>> >> +               chipid = ioremap((uintptr_t)match->data, 4);
>> >> +       }
>> >> +       if (!chipid)
>> >>
>> >
>> > Here, I'd turn the order around and look for the DT nodes of the
>> > devices first. Only if they are not found, look at the compatible
>> > string of the root node. No need to search for a node though,
>> > you know which one it is when you look for a compatible =
>> > "renesas,r8a73a4".
>>
>> "renesas,r8a73a4" is the root node, not the device, so it does not have the
>> "reg" property for reading the chip ID?
>
> I mean replace of_find_matching_node_and_match() with
> of_match_node(renesas_socs, of_root).
>
> It does the same thing, just more efficiently.

OK (didn't know "of_root" was available for public use ;-)

>> There is no SoC part number in the "renesas,prr" and "renesas,cccr" nodes.
>> Hence I always need to look at the root nodes.
>
> Not sure what that would protect you from. Could you have a renesas,cccr

Looks like you forgot to finish your sentence?

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2016-11-14 10:51 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 11:30 [PATCH v2 0/7] soc: renesas: Identify SoC and register with the SoC bus Geert Uytterhoeven
2016-10-31 11:30 ` Geert Uytterhoeven
2016-10-31 11:30 ` [PATCH v2 1/7] base: soc: Early register bus when needed Geert Uytterhoeven
2016-10-31 11:30 ` [PATCH v2 2/7] base: soc: Introduce soc_device_match() interface Geert Uytterhoeven
2016-10-31 11:30 ` [PATCH v2 3/7] base: soc: Check for NULL SoC device attributes Geert Uytterhoeven
2016-10-31 11:30   ` Geert Uytterhoeven
2016-10-31 11:30 ` [PATCH v2 4/7] base: soc: Provide a dummy implementation of soc_device_match() Geert Uytterhoeven
2016-10-31 11:30 ` [PATCH v2 5/7] ARM: shmobile: Document DT bindings for CCCR and PRR Geert Uytterhoeven
2016-10-31 11:30   ` Geert Uytterhoeven
2016-11-09 18:24   ` Rob Herring
2016-11-09 18:24     ` Rob Herring
2016-11-09 18:24     ` Rob Herring
2016-10-31 11:30 ` [PATCH v2 6/7] arm64: dts: r8a7795: Add device node for PRR Geert Uytterhoeven
2016-10-31 11:30 ` [PATCH v2 7/7] soc: renesas: Identify SoC and register with the SoC bus Geert Uytterhoeven
2016-10-31 11:30   ` Geert Uytterhoeven
2016-11-09 16:55   ` Arnd Bergmann
2016-11-09 16:55     ` Arnd Bergmann
2016-11-10 10:19     ` Geert Uytterhoeven
2016-11-10 10:19       ` Geert Uytterhoeven
2016-11-10 10:19       ` Geert Uytterhoeven
2016-11-10 11:37       ` Arnd Bergmann
2016-11-10 11:37         ` Arnd Bergmann
2016-11-10 11:37         ` Arnd Bergmann
2016-11-14 10:51         ` Geert Uytterhoeven [this message]
2016-11-14 10:51           ` Geert Uytterhoeven
2016-11-14 10:51           ` Geert Uytterhoeven
2016-11-14 11:22           ` Arnd Bergmann
2016-11-14 11:22             ` Arnd Bergmann
2016-11-14 11:22             ` Arnd Bergmann
2016-11-07  9:35 ` [PATCH v2 0/7] " Geert Uytterhoeven
2016-11-07  9:35   ` Geert Uytterhoeven
2016-11-07  9:35   ` Geert Uytterhoeven
2016-11-07 18:33   ` Krzysztof Kozlowski
2016-11-07 18:33     ` Krzysztof Kozlowski
2016-11-07 18:33     ` Krzysztof Kozlowski
2016-11-07 18:33     ` Krzysztof Kozlowski
2016-11-09 13:34   ` Geert Uytterhoeven
2016-11-09 13:34     ` Geert Uytterhoeven
2016-11-09 13:34     ` Geert Uytterhoeven
2016-11-09 16:56     ` Arnd Bergmann
2016-11-09 16:56       ` Arnd Bergmann
2016-11-09 16:56       ` Arnd Bergmann
2016-11-09 16:56       ` Arnd Bergmann
2016-11-09 17:19       ` Geert Uytterhoeven
2016-11-09 17:19         ` Geert Uytterhoeven
2016-11-09 17:19         ` Geert Uytterhoeven
2016-11-09 21:12         ` Arnd Bergmann
2016-11-09 21:12           ` Arnd Bergmann
2016-11-09 21:12           ` Arnd Bergmann
2016-11-10  9:22           ` Geert Uytterhoeven
2016-11-10  9:22             ` Geert Uytterhoeven
2016-11-10  9:22             ` Geert Uytterhoeven
2016-11-10  9:22             ` Geert Uytterhoeven
2016-11-10 10:56             ` Geert Uytterhoeven
2016-11-10 10:56               ` Geert Uytterhoeven
2016-11-10 10:56               ` Geert Uytterhoeven
2016-11-10 10:59             ` Ulf Hansson
2016-11-10 10:59               ` Ulf Hansson
2016-11-10 10:59               ` Ulf Hansson

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=CAMuHMdWavRFnYFmiL2jy3KWZnHG_F8qaxK29zHx6fsLmqXEwiA@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dirk.behme@de.bosch.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@verge.net.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=magnus.damm@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=yangbo.lu@nxp.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.