From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: linux-tegra@vger.kernel.org, Allen Martin <amartin@nvidia.com>,
devicetree-discuss@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm/dt: Add SoC detection macros
Date: Sat, 17 Sep 2011 12:34:57 +0200 [thread overview]
Message-ID: <20110917103457.GP28104@game.jcrosoft.org> (raw)
In-Reply-To: <20110917102811.GC16381@n2100.arm.linux.org.uk>
On 11:28 Sat 17 Sep , Russell King - ARM Linux wrote:
> On Fri, Sep 09, 2011 at 01:02:19AM -0700, Allen Martin wrote:
> > +#ifdef CONFIG_ARCH_TEGRA_2x_SOC
> > +# ifdef SOC_NAME
> > +# undef MULTI_SOC
> > +# define MULTI_SOC
> > +# else
> > +# define SOC_NAME tegra2
> > +# endif
> > +#endif
> > +#ifdef CONFIG_ARCH_TEGRA_3x_SOC
> > +# ifdef SOC_NAME
> > +# undef MULTI_SOC
> > +# define MULTI_SOC
> > +# else
> > +# define SOC_NAME tegra3
> > +# endif
> > +#endif
> > +
> > +#define soc_is_tegra2() 0
> > +#define soc_is_tegra3() 0
> > +
> > +#if defined(MULTI_SOC)
> > +# if defined(CONFIG_ARCH_TEGRA_2x_SOC)
> > +# undef soc_is_tegra2
> > +# define soc_is_tegra2() is_tegra2()
> > +# endif
> > +# if defined(CONFIG_ARCH_TEGRA_3x_SOC)
> > +# undef soc_is_tegra3
> > +# define soc_is_tegra3() is_tegra3()
> > +# endif
> > +#else /* non-multi, only one architecture is on */
> > +# if defined(CONFIG_ARCH_TEGRA_2x_SOC)
> > +# undef soc_is_tegra2
> > +# define soc_is_tegra2() 1
> > +# elif defined(CONFIG_ARCH_TEGRA_3x_SOC)
> > +# undef soc_is_tegra3
> > +# define soc_is_tegra3() 1
> > +# endif
> > +#endif
>
> This is not the way to do this, especially for a file in asm/*.h. Look
> at the way machine_is_xxx() is dealt with in include/generated/mach-types.h.
>
> #define MULTI_SOC 0
> #undef SOC_SELECTED
>
> #ifdef CONFIG_ARCH_TEGRA_2x_SOC
> # ifdef SOC_SELECTED
> # undef MULTI_SOC
> # define MULTI_SOC 1
> # else
> # define SOC_SELECTED
> # endif
> # define soc_is_tegra2() (!MULTI_SOC || is_tegra2())
> #else
> # define soc_is_tegra2() 0
> #endif
>
> #ifdef CONFIG_ARCH_TEGRA_3x_SOC
> # ifdef SOC_SELECTED
> # undef MULTI_SOC
> # define MULTI_SOC 1
> # else
> # define SOC_SELECTED
> # endif
> # define soc_is_tegra3() (!MULTI_SOC || is_tegra3())
> #else
> # define soc_is_tegra3() 0
> #endif
>
> #undef SOC_SELECTED
>
> The above is nicely extensible - if other SoCs need to extend this they
> just need to add another outer ifdef..endif section to the file.
>
> > +
> > +enum soc_version {
> > + SOC_UNKNOWN = 0,
> > + TEGRA_T20,
> > + TEGRA_T30,
>
> I'd suggest prefixing these with SOC_ to avoid any namespace problems.
>
> > +};
> > +
> > +void soc_init_version(void);
> > +enum soc_version soc_get_version(void);
> > +
> > +static inline int is_tegra2(void)
> > +{
> > + return soc_get_version() == TEGRA_T20;
> > +}
> > +
> > +static inline int is_tegra3(void)
> > +{
> > + return soc_get_version() == TEGRA_T30;
> > +}
>
> If we require all SoCs to provide a value in soc_version, then we can use
> exactly the same method as mach-types.h uses - and while at this, please
> get rid of soc_get_version(). It's far cheaper to access the variable
> directly rather than indirect through a function, just like we do with
> __machine_arch_type. Mark it __read_mostly too.
>
> One last point to raise here is - and it's quite a fundamental one - do we
> really want this? If we're making decisions based on the SoC type, that
> suggests to me that the hardware description in DT is incomplete, and
> we're hiding stuff in the kernel behind the SoC type. That doesn't sound
> particularly appealing given the point of DT is to encode the hardware
> specific information outside the kernel code.
except if a machine can run on 2 soc so detect it will avoid to have 2 Device
Tree
Best Regards,
J.
next prev parent reply other threads:[~2011-09-17 10:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-09 8:02 [PATCH] arm/dt: Add SoC detection macros Allen Martin
[not found] ` <1315555339-12685-1-git-send-email-amartin-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-09-09 16:45 ` Olof Johansson
2011-09-17 10:28 ` Russell King - ARM Linux
2011-09-17 10:34 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
[not found] ` <20110917103457.GP28104-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2011-09-17 11:23 ` Russell King - ARM Linux
[not found] ` <20110917112321.GE16381-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-09-17 18:19 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <20110917181907.GA16141-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2011-09-17 20:56 ` Arnd Bergmann
2011-09-18 0:46 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <20110918004615.GC16141-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2011-09-18 9:28 ` Arnd Bergmann
2011-09-19 17:26 ` Allen Martin
[not found] ` <3C7A7ACA8617D24290826EC008B5CD083E17B00988-lR+7xdUAJVNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-09-19 20:08 ` Olof Johansson
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=20110917103457.GP28104@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=amartin@nvidia.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
/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).