From patchwork Tue Oct 24 09:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 116920 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp405532edm; Tue, 24 Oct 2017 02:56:55 -0700 (PDT) X-Received: by 10.84.132.98 with SMTP id 89mr12453147ple.98.1508839015090; Tue, 24 Oct 2017 02:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508839015; cv=none; d=google.com; s=arc-20160816; b=volsppghy1E4QbPs6h73rkfEbyMaqS2XzUzrkPf7Ik3gKTdjX3kl5AVCRsVwVtt5dw hPbtqyt5e/f326nI3P/5JbLR7qS0HfbPEoWQsAIBkyPVsRaLFuZGq+u9JoTGSxB9UYBf 1HIb9+y1BQ7tuCE5N45ZzHZ0TEjknq/sLR5NIhn2QVI3G92h24DlIa3a7qaow8VGekt3 GdIYeun46vfAZemB3D8S2LanvQoEXkyqbRzMHhRhN++d5cYCkc08QiqS2DG3r6ZtDcP8 FMDozUGvHk6bkxbRBq8H+BRQD6Zn9W9mlgIBVIMfOUJYpxzFiNWhPit/oAjQTdH1eejs Xp4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=IgIl20KUCMQDAyZXnoxs7y7LanMSEubYXmCqLwChL5w=; b=tGENAFfHsV0FodHOxbwO9GIlKe4qX8kwPJDgDNteKQ0/7x9yqtXRKTpbhyX2GTTAW1 J1bBAxiA3no7uwkixQxMYXkOJLp4m7tW4bkw3L1AFCyvqfQdpWTwf5wga7Na1hrvkbER junKN3fEPMSXVwjkfnpxHmm5R7pJzCgxpZyn741zTx6xK0wif4yM7qpufrx8fNRGUElQ n4sc8rHx3sQnjZN6xni9mnjk/Ww6IWaISRMDYgv022jQxqZIoPd8boLt+TgTKVprsGPY 66Cv0Nphftv8DrK6V9ytjFDSX09bqJ4Qse+oGuRBVuhH7fdv2hjJqeuovW3wnaYbva4+ Ld+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hv+1CTgH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 43si5195171plb.774.2017.10.24.02.56.54; Tue, 24 Oct 2017 02:56:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hv+1CTgH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932344AbdJXJ4v (ORCPT + 27 others); Tue, 24 Oct 2017 05:56:51 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:50647 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752033AbdJXJ4s (ORCPT ); Tue, 24 Oct 2017 05:56:48 -0400 Received: by mail-wm0-f68.google.com with SMTP id u138so14530908wmu.5 for ; Tue, 24 Oct 2017 02:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IgIl20KUCMQDAyZXnoxs7y7LanMSEubYXmCqLwChL5w=; b=hv+1CTgH2ZxtSXB137RRRCWQl9t7rWUoJyQ/GK49xs1xZL/mHgT2fWyp8TIzjxxpHm iraP4XAG7jNb+fjmUMdfy0KbJ7XVSOJm3eC1SfqaL/c2vFPg9PGa3k2wML+Q3/bvGGpX mz0mWfZiyMqGVUoF1ZCppB6vjKCMEedi92Vrs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IgIl20KUCMQDAyZXnoxs7y7LanMSEubYXmCqLwChL5w=; b=G8BCh2OvhmavI9s3BhNOjR15gCwegdjm7Q/HYz64WLsvgdmLXmxaqrCKIze9Smsf6M /w8e0xgleyIKTbt0HSqV1wRautbVJfwzKyjhqo6XoPTPWaRV4XW5chQKtJFNeQxHmy2g w/CIucvh2EoKS7p7tnbirvUSQ1/OWYnMZcgRZnJwMHtnBo2xtZy8HFonCAs82qDQUJeu zQxVVdHJwneE6BHa5fe++3u2wzKqqz0x3L15uQtmdm0wDWAz22Fuqtgg9zabfZm8T1hk zsyWlnjRnALfKwex6Y/7dctw8Mhb/XyXRktDcLra9JIMgFWpWhSUGm2xk8GexwTT1B/D 2CTQ== X-Gm-Message-State: AMCzsaXwoZX6ke7c/3ykd7MaKHlqkUPMnLfRp6l5f+UfQITYwYdgVlu4 6Psn69BtmNtGFpZb7pczAPZNxg== X-Google-Smtp-Source: ABhQp+SWaSrkBP1BdJ00jPeRcYBYgeCrXK7A3AP70ZdofE79cwQTAkXjsl8olCNukYvLf3Cz3aHAhQ== X-Received: by 10.28.6.6 with SMTP id 6mr7977388wmg.114.1508839006852; Tue, 24 Oct 2017 02:56:46 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id 29sm9666451wrz.77.2017.10.24.02.56.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 02:56:46 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Keiji Hayashibara , Srinivas Kandagatla Subject: [PATCH 02/10] nvmem: uniphier: add UniPhier eFuse driver Date: Tue, 24 Oct 2017 10:54:26 +0100 Message-Id: <1508838874-32252-3-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508838874-32252-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1508838874-32252-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keiji Hayashibara Add eFuse driver for Socionext UniPhier series SoC. Note that eFuse device is under soc-glue and this register implements as read only. Signed-off-by: Keiji Hayashibara Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/Kconfig | 11 +++++ drivers/nvmem/Makefile | 2 + drivers/nvmem/uniphier-efuse.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 drivers/nvmem/uniphier-efuse.c -- 1.9.1 diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index eb09916..ff505af 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -123,6 +123,17 @@ config NVMEM_SUNXI_SID This driver can also be built as a module. If so, the module will be called nvmem_sunxi_sid. +config UNIPHIER_EFUSE + tristate "UniPhier SoCs eFuse support" + depends on ARCH_UNIPHIER || COMPILE_TEST + depends on HAS_IOMEM + help + This is a simple driver to dump specified values of UniPhier SoC + from eFuse. + + This driver can also be built as a module. If so, the module + will be called nvmem-uniphier-efuse. + config NVMEM_VF610_OCOTP tristate "VF610 SoC OCOTP support" depends on SOC_VF610 || COMPILE_TEST diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 362f394d..64849e9 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -26,6 +26,8 @@ obj-$(CONFIG_ROCKCHIP_EFUSE) += nvmem_rockchip_efuse.o nvmem_rockchip_efuse-y := rockchip-efuse.o obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o nvmem_sunxi_sid-y := sunxi_sid.o +obj-$(CONFIG_UNIPHIER_EFUSE) += nvmem-uniphier-efuse.o +nvmem-uniphier-efuse-y := uniphier-efuse.o obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o nvmem-vf610-ocotp-y := vf610-ocotp.o obj-$(CONFIG_MESON_EFUSE) += nvmem_meson_efuse.o diff --git a/drivers/nvmem/uniphier-efuse.c b/drivers/nvmem/uniphier-efuse.c new file mode 100644 index 0000000..9d278b4 --- /dev/null +++ b/drivers/nvmem/uniphier-efuse.c @@ -0,0 +1,97 @@ +/* + * UniPhier eFuse driver + * + * Copyright (C) 2017 Socionext Inc. + * + * 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. + * + * 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 + +struct uniphier_efuse_priv { + void __iomem *base; +}; + +static int uniphier_reg_read(void *context, + unsigned int reg, void *_val, size_t bytes) +{ + struct uniphier_efuse_priv *priv = context; + u32 *val = _val; + int offs; + + for (offs = 0; offs < bytes; offs += sizeof(u32)) + *val++ = readl(priv->base + reg + offs); + + return 0; +} + +static int uniphier_efuse_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *res; + struct nvmem_device *nvmem; + struct nvmem_config econfig = {}; + struct uniphier_efuse_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + priv->base = devm_ioremap_resource(dev, res); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + econfig.stride = 4; + econfig.word_size = 4; + econfig.read_only = true; + econfig.reg_read = uniphier_reg_read; + econfig.size = resource_size(res); + econfig.priv = priv; + econfig.dev = dev; + nvmem = nvmem_register(&econfig); + if (IS_ERR(nvmem)) + return PTR_ERR(nvmem); + + platform_set_drvdata(pdev, nvmem); + + return 0; +} + +static int uniphier_efuse_remove(struct platform_device *pdev) +{ + struct nvmem_device *nvmem = platform_get_drvdata(pdev); + + return nvmem_unregister(nvmem); +} + +static const struct of_device_id uniphier_efuse_of_match[] = { + { .compatible = "socionext,uniphier-efuse",}, + {/* sentinel */}, +}; +MODULE_DEVICE_TABLE(of, uniphier_efuse_of_match); + +static struct platform_driver uniphier_efuse_driver = { + .probe = uniphier_efuse_probe, + .remove = uniphier_efuse_remove, + .driver = { + .name = "uniphier-efuse", + .of_match_table = uniphier_efuse_of_match, + }, +}; +module_platform_driver(uniphier_efuse_driver); + +MODULE_AUTHOR("Keiji Hayashibara "); +MODULE_DESCRIPTION("UniPhier eFuse driver"); +MODULE_LICENSE("GPL v2");