From patchwork Thu Dec 11 08:07:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Dubey X-Patchwork-Id: 5474561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4179FBEEA8 for ; Thu, 11 Dec 2014 08:18:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19AE120172 for ; Thu, 11 Dec 2014 08:18:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92FB520166 for ; Thu, 11 Dec 2014 08:18:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyyvG-0001Em-Qy; Thu, 11 Dec 2014 08:16:30 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyyvB-00017D-MK for linux-arm-kernel@lists.infradead.org; Thu, 11 Dec 2014 08:16:27 +0000 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGE00KSXSAS0B00@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 11 Dec 2014 17:16:04 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id D4.27.18167.4C259845; Thu, 11 Dec 2014 17:16:04 +0900 (KST) X-AuditID: cbfee690-f79ab6d0000046f7-19-548952c4c9e5 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AF.72.20081.3C259845; Thu, 11 Dec 2014 17:16:04 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGE00KNAS86BGG0@mmp2.samsung.com>; Thu, 11 Dec 2014 17:16:03 +0900 (KST) From: Pankaj Dubey To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/2] soc: samsung: add exynos chipid driver support Date: Thu, 11 Dec 2014 13:37:43 +0530 Message-id: <1418285264-21763-2-git-send-email-pankaj.dubey@samsung.com> X-Mailer: git-send-email 2.2.0 In-reply-to: <1418285264-21763-1-git-send-email-pankaj.dubey@samsung.com> References: <1418285264-21763-1-git-send-email-pankaj.dubey@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupikeLIzCtJLcpLzFFi42JZI2JSq3skqDPE4McDbou/k46xWxz4s4PR 4v+j16wWvQuusllM+bOcyWLT42usFpd3zWGzmHF+H5PF7cu8Fou2fmG3aN17hN2iYxmjxapd fxgdeD1amnvYPH7/msTosXPWXXaPTas62TzuXNvD5rF5Sb1H35ZVjB7br81j9vi8SS6AM4rL JiU1J7MstUjfLoErY9PUJ+wFT5wqTr9ax9jAeNa8i5GTQ0LARGLLm+nMELaYxIV769lAbCGB pYwS208mwdRsW9DE2MXIBRSfzigx+8hTNghnApPEhG3dLCBVbAK6Ek/ezwWbJCKQLdF/ezVY nFlgCZPE9zMpILawgJvEvY4+VhCbRUBVYtqd5+wgNq+Ah0T3myesENvkJLbcegQW5xTwlDi1 /xUTxEUeEpsWzmQCWSwhcI9d4sv7pSwQgwQkvk0+BGRzACVkJTYdgPpGUuLg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qJ8yrZt4UICaQnlqRmp6YWpBbB9DFxcEo1 MAratflXv3EoF/CY93XDt7QL/Q9P1+i8NqlJ+HDB6M6FyjD+A3rqF94ZSGhL3MxbsjX/Weep ot7ctXOYYvvvHZ6tv3LV6W0vDbpWu7x4/rlTValSfG/a2ZX+m2/lRT+6/6mq2MZK3mzLEqv1 n0XCEgLtF6gfsHRdMZnPYcGCs+rNpX95rGcxpSixFGckGmoxFxUnAgA9RIor5wIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141211_001625_905991_49EB02DF X-CRM114-Status: GOOD ( 16.74 ) X-Spam-Score: -5.0 (-----) Cc: kgene.kim@samsung.com, linux@arm.linux.org.uk, heiko@sntech.de, arnd@arndb.de, Pankaj Dubey , Linus Walleij , tomasz.figa@gmail.com, Rob Herring , thomas.ab@samsung.com, Grant Likely X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Exynos SoCs have Chipid, for identification of product IDs and SoC revisions. This patch intendes to provide initialization code for all these functionalites. This driver usese existing binding for exnos-chipid. CC: Grant Likely CC: Rob Herring CC: Linus Walleij Signed-off-by: Pankaj Dubey --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/samsung/Kconfig | 14 +++ drivers/soc/samsung/Makefile | 1 + drivers/soc/samsung/exynos-chipid.c | 168 +++++++++++++++++++++++++++++++++ include/linux/soc/samsung/exynos-soc.h | 51 ++++++++++ 6 files changed, 236 insertions(+) create mode 100644 drivers/soc/samsung/Kconfig create mode 100644 drivers/soc/samsung/Makefile create mode 100644 drivers/soc/samsung/exynos-chipid.c create mode 100644 include/linux/soc/samsung/exynos-soc.h diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index 76d6bd4..c3abfbe 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -1,6 +1,7 @@ menu "SOC (System On Chip) specific Drivers" source "drivers/soc/qcom/Kconfig" +source "drivers/soc/samsung/Kconfig" source "drivers/soc/ti/Kconfig" source "drivers/soc/versatile/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 063113d..620366f 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -3,6 +3,7 @@ # obj-$(CONFIG_ARCH_QCOM) += qcom/ +obj-$(CONFIG_SOC_SAMSUNG) += samsung/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_SOC_TI) += ti/ obj-$(CONFIG_PLAT_VERSATILE) += versatile/ diff --git a/drivers/soc/samsung/Kconfig b/drivers/soc/samsung/Kconfig new file mode 100644 index 0000000..2d83652 --- /dev/null +++ b/drivers/soc/samsung/Kconfig @@ -0,0 +1,14 @@ +# +# SAMSUNG SoC drivers +# +menu "Samsung SOC driver support" + +config SOC_SAMSUNG + bool + +config EXYNOS_CHIPID + bool + depends on ARCH_EXYNOS + select SOC_BUS + +endmenu diff --git a/drivers/soc/samsung/Makefile b/drivers/soc/samsung/Makefile new file mode 100644 index 0000000..855ca05 --- /dev/null +++ b/drivers/soc/samsung/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_EXYNOS_CHIPID) += exynos-chipid.o diff --git a/drivers/soc/samsung/exynos-chipid.c b/drivers/soc/samsung/exynos-chipid.c new file mode 100644 index 0000000..8968f83 --- /dev/null +++ b/drivers/soc/samsung/exynos-chipid.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * http://www.samsung.com/ + * + * EXYNOS - CHIP ID support + * Author: Pankaj Dubey + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#define EXYNOS_SUBREV_MASK (0xF << 4) +#define EXYNOS_MAINREV_MASK (0xF << 0) +#define EXYNOS_REV_MASK (EXYNOS_SUBREV_MASK | EXYNOS_MAINREV_MASK) + +static void __iomem *exynos_chipid_base; + +struct exynos_chipid_info exynos_soc_info; +EXPORT_SYMBOL(exynos_soc_info); + +static const char * __init product_id_to_name(unsigned int product_id) +{ + const char *soc_name; + unsigned int soc_id = product_id & EXYNOS_SOC_MASK; + + switch (soc_id) { + case EXYNOS3250_SOC_ID: + soc_name = "EXYNOS3250"; + break; + case EXYNOS4210_SOC_ID: + soc_name = "EXYNOS4210"; + break; + case EXYNOS4212_SOC_ID: + soc_name = "EXYNOS4212"; + break; + case EXYNOS4412_SOC_ID: + soc_name = "EXYNOS4412"; + break; + case EXYNOS4415_SOC_ID: + soc_name = "EXYNOS4415"; + break; + case EXYNOS5250_SOC_ID: + soc_name = "EXYNOS5250"; + break; + case EXYNOS5260_SOC_ID: + soc_name = "EXYNOS5260"; + break; + case EXYNOS5420_SOC_ID: + soc_name = "EXYNOS5420"; + break; + case EXYNOS5440_SOC_ID: + soc_name = "EXYNOS5440"; + break; + case EXYNOS5800_SOC_ID: + soc_name = "EXYNOS5800"; + break; + default: + soc_name = "UNKNOWN"; + } + return soc_name; +} + +static const struct of_device_id of_exynos_chipid_ids[] __initconst = { + { + .compatible = "samsung,exynos4210-chipid", + }, + {}, +}; + +/** + * exynos_chipid_early_init: Early chipid initialization + * @dev: pointer to chipid device + */ +void __init exynos_chipid_early_init(struct device *dev) +{ + struct device_node *np; + const struct of_device_id *match; + + if (exynos_chipid_base) + return; + + if (!dev) + np = of_find_matching_node_and_match(NULL, + of_exynos_chipid_ids, &match); + else + np = dev->of_node; + + if (!np) + panic("%s, failed to find chipid node\n", __func__); + + exynos_chipid_base = of_iomap(np, 0); + + if (!exynos_chipid_base) + panic("%s: failed to map registers\n", __func__); + + exynos_soc_info.product_id = __raw_readl(exynos_chipid_base); + exynos_soc_info.revision = exynos_soc_info.product_id & EXYNOS_REV_MASK; +} + +static int __init exynos_chipid_probe(struct platform_device *pdev) +{ + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; + struct device_node *root; + int ret; + + exynos_chipid_early_init(&pdev->dev); + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENODEV; + + soc_dev_attr->family = "Samsung Exynos"; + + root = of_find_node_by_path("/"); + ret = of_property_read_string(root, "model", &soc_dev_attr->machine); + of_node_put(root); + if (ret) + goto free_soc; + + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", + exynos_soc_info.revision); + if (!soc_dev_attr->revision) + goto free_soc; + + soc_dev_attr->soc_id = product_id_to_name(exynos_soc_info.product_id); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) + goto free_rev; + + soc_device_to_device(soc_dev); + + dev_info(&pdev->dev, "Exynos: CPU[%s] CPU_REV[0x%x] Detected\n", + product_id_to_name(exynos_soc_info.product_id), + exynos_soc_info.revision); + return 0; +free_rev: + kfree(soc_dev_attr->revision); +free_soc: + kfree(soc_dev_attr); + return -EINVAL; +} + +static struct platform_driver exynos_chipid_driver __initdata = { + .driver = { + .name = "exynos-chipid", + .of_match_table = of_exynos_chipid_ids, + }, + .probe = exynos_chipid_probe, +}; + +static int __init exynos_chipid_init(void) +{ + return platform_driver_register(&exynos_chipid_driver); +} +core_initcall(exynos_chipid_init); + diff --git a/include/linux/soc/samsung/exynos-soc.h b/include/linux/soc/samsung/exynos-soc.h new file mode 100644 index 0000000..d2d9f05 --- /dev/null +++ b/include/linux/soc/samsung/exynos-soc.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Header for EXYNOS SoC Chipid support + * + * 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 __EXYNOS_SOC_H +#define __EXYNOS_SOC_H + +#define EXYNOS3250_SOC_ID 0xE3472000 +#define EXYNOS4210_SOC_ID 0x43210000 +#define EXYNOS4212_SOC_ID 0x43220000 +#define EXYNOS4412_SOC_ID 0xE4412000 +#define EXYNOS4415_SOC_ID 0xE4415000 +#define EXYNOS5250_SOC_ID 0x43520000 +#define EXYNOS5260_SOC_ID 0xE5260000 +#define EXYNOS5410_SOC_ID 0xE5410000 +#define EXYNOS5420_SOC_ID 0xE5420000 +#define EXYNOS5440_SOC_ID 0xE5440000 +#define EXYNOS5800_SOC_ID 0xE5422000 + +#define EXYNOS_SOC_MASK 0xFFFFF000 + +#define EXYNOS4210_REV_0 0x0 +#define EXYNOS4210_REV_1_0 0x10 +#define EXYNOS4210_REV_1_1 0x11 + +/** + * Struct exynos_chipid_info + * @soc_product_id: product id allocated to exynos SoC + * @soc_revision: revision of exynos SoC + */ + +struct exynos_chipid_info { + u32 product_id; + u32 revision; +}; + +extern struct exynos_chipid_info exynos_soc_info; + +/* Since we need chipid to be initialized as early as possible + * during secondary core bootup adding early initialization function + */ +extern void exynos_chipid_early_init(struct device *dev); + +#endif /* __EXYNOS_SOC_H */