From 8a2b4c745ab5479bdb2a90bde321f4173f8a6801 Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Mon, 12 Dec 2016 10:43:05 +0200 Subject: [PATCH] platform: tegra: Add tegra_chipid Moved driver from t18x repository. The driver is no longer used on kernel 4.9. Bug 1834068 Change-Id: I4fba7eb5c016f7d9231d060cca6fbb5f57ce717c Signed-off-by: Mikko Perttunen Reviewed-on: http://git-master/r/1269364 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/platform/tegra/Makefile | 2 + drivers/platform/tegra/tegra_chipid.c | 80 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 drivers/platform/tegra/tegra_chipid.c diff --git a/drivers/platform/tegra/Makefile b/drivers/platform/tegra/Makefile index 223f2b8f3928..cf94931d7665 100644 --- a/drivers/platform/tegra/Makefile +++ b/drivers/platform/tegra/Makefile @@ -108,3 +108,5 @@ obj-$(CONFIG_TEGRA_FIQ_DEBUGGER) += tegra_fiq_debugger.o obj-$(CONFIG_TEGRA_FIRMWARES_CLASS) += firmwares.o obj-$(CONFIG_TEGRA_FIRMWARES_INVENTORY) += firmwares-all.o + +obj-$(CONFIG_ARCH_TEGRA_18x_SOC) += tegra_chipid.o diff --git a/drivers/platform/tegra/tegra_chipid.c b/drivers/platform/tegra/tegra_chipid.c new file mode 100644 index 000000000000..86a3f95eedcf --- /dev/null +++ b/drivers/platform/tegra/tegra_chipid.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MISCREG_HIDREV 0x4 + +static struct of_device_id tegra_chipid_of_match[] = { + { .compatible = "nvidia,tegra186-chipid" }, + {} +}; + +void tegra_get_tegraid_from_hw(void) +{ + struct device_node *np; + u32 cid; + char *priv = NULL; + struct resource r; + void __iomem *chipid_base; + u32 offset = MISCREG_HIDREV; + u32 opt_subrevision; + char prime; + + np = of_find_matching_node(NULL, tegra_chipid_of_match); + BUG_ON(!np); + + if (of_address_to_resource(np, 0, &r)) + BUG_ON("tegra-id: failed to resolve base address\n"); + + chipid_base = of_iomap(np, 0); + BUG_ON(!chipid_base); + + of_property_read_u32(np, "offset", &offset); + if (r.start + offset > r.end) + BUG_ON("tegra-id: invalid chipid offset\n"); + + cid = readl(chipid_base + offset); + + pr_info("tegra-id: chipid=%x.\n", cid); + + opt_subrevision = tegra_get_fuse_opt_subrevision(); + if (opt_subrevision == 1) { + prime = 'p'; + priv = ′ + } else if (opt_subrevision == 2) { + prime = 'q'; + priv = ′ + } else if (opt_subrevision == 3) { + prime = 'r'; + priv = ′ + } + pr_info("tegra-id: opt_subrevision=%x.\n", opt_subrevision); + + tegra_set_tegraid(tegra_hidrev_get_chipid(cid), + tegra_hidrev_get_majorrev(cid), + tegra_hidrev_get_minorrev(cid), + tegra_hidrev_get_pre_si_plat(cid), + 0, + 0, + priv); +} -- 2.39.2