Skip to content

Commit

Permalink
soc/tegra: Implement runtime check for Tegra SoCs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thierryreding committed Jul 17, 2014
1 parent dd849e5 commit a268676
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/soc/tegra/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
obj-$(CONFIG_ARCH_TEGRA) += fuse/

obj-$(CONFIG_ARCH_TEGRA) += common.o
30 changes: 30 additions & 0 deletions drivers/soc/tegra/common.c
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 14 additions & 0 deletions include/soc/tegra/common.h
Original file line number Diff line number Diff line change
@@ -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__ */

0 comments on commit a268676

Please sign in to comment.