soc/tegra: Implement runtime check for Tegra SoCs
authorThierry Reding <treding@nvidia.com>
Wed, 16 Jul 2014 12:01:44 +0000 (14:01 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 17 Jul 2014 12:58:41 +0000 (14:58 +0200)
Subsequent patches will move some of the initialization code from SoC
setup code to regular initcalls. To prevent breakage on other SoCs in
multi-platform builds, these initcalls need to check that they indeed
run on Tegra.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/soc/tegra/Makefile
drivers/soc/tegra/common.c [new file with mode: 0644]
include/soc/tegra/common.h [new file with mode: 0644]

index 236600f..db34987 100644 (file)
@@ -1 +1,3 @@
 obj-$(CONFIG_ARCH_TEGRA) += fuse/
+
+obj-$(CONFIG_ARCH_TEGRA) += common.o
diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c
new file mode 100644 (file)
index 0000000..a71cb74
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2014 NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/of.h>
+
+#include <soc/tegra/common.h>
+
+static const struct of_device_id tegra_machine_match[] = {
+       { .compatible = "nvidia,tegra20", },
+       { .compatible = "nvidia,tegra30", },
+       { .compatible = "nvidia,tegra114", },
+       { .compatible = "nvidia,tegra124", },
+       { }
+};
+
+bool soc_is_tegra(void)
+{
+       struct device_node *root;
+
+       root = of_find_node_by_path("/");
+       if (!root)
+               return false;
+
+       return of_match_node(tegra_machine_match, root) != NULL;
+}
diff --git a/include/soc/tegra/common.h b/include/soc/tegra/common.h
new file mode 100644 (file)
index 0000000..fc13a9a
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2014 NVIDIA Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __SOC_TEGRA_COMMON_H__
+#define __SOC_TEGRA_COMMON_H__
+
+bool soc_is_tegra(void);
+
+#endif /* __SOC_TEGRA_COMMON_H__ */