Thread (1 message) 1 message, 1 author, 2011-09-09

[PATCH] arm/dt: Add SoC detection macros

From: Olof Johansson <hidden>
Date: 2011-09-09 16:45:48
Also in: linux-devicetree, linux-tegra

On Fri, Sep 9, 2011 at 1:02 AM, Allen Martin [off-list ref] wrote:
These macros allow runtime query of SoC family and version via
soc_is_*() ?If the corresponding SoC is not configured the macro will
evaluate to 0. ?If the corresponding SoC is the only architecure
configured, the macro will evaluate to 1. ?If multiple architecures
are configured the macro will evaluate to a runtime call to
soc_get_version().
+void soc_init_version(void)
+{
+ ? ? ? if (of_machine_is_compatible("nvidia,tegra20"))
+ ? ? ? ? ? ? ? soc_version = TEGRA_T20;
+ ? ? ? else if (of_machine_is_compatible("nvidia,tegra30"))
+ ? ? ? ? ? ? ? soc_version = TEGRA_T30;
+ ? ? ? else
+ ? ? ? ? ? ? ? panic("Unknown SoC");
+}

The above should be enough for your local code, no need to wrap it in
layers of indirection.

Sure, doing the of_machine_is...() calls are slow, but you shouldn't
be doing runtime decisions about what SoC you are on during critical
path anyway -- it should be done at setup/probe time, much of the rest
should be possible to handle with setting appropriate function
pointers, etc.

Also, panic:ing is unacceptable.


-Olof
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help