From patchwork Mon Oct 9 13:26:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 115220 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2558473qgn; Mon, 9 Oct 2017 06:27:07 -0700 (PDT) X-Received: by 10.99.62.207 with SMTP id l198mr9051851pga.376.1507555627877; Mon, 09 Oct 2017 06:27:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507555627; cv=none; d=google.com; s=arc-20160816; b=ZNh2QKHrkm3UXR0YJw0oxY94ka+3TsVDnMZCBw9sFctKk8xsr4b8pBb1rJOmo6WfkL pBf8SLzHgxl+EUgfrBjKNVXIKImLV47QlWEjpFg1wdbF4hQgo2XF0PRfPZzXL2uPUbSQ g95+ZR3dRCXOKxpEuyifedAhvU7O4SUBqlLRmHDV4640apSMyf42+Q8baTHFVaNn0qMV e1bK3bepZ5b6FQOI0e8nK7WbZEqWbzAObfBZBN5UMXTxzUYdiKvfPkfU1U/EGkDgbqYm WJJEd2XZIMyE5m4yr7FiYBzSImc12+WcndOKE05kO35xtvIDDLU2cS9y8hoJjm0WUsey focA== 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=rRMKRCIn81sJ0DdGA1k7zavi0t6YyjThSM9IKcydWsY=; b=N/1IypDnp0dueGqzD42EOSNxCHynYkwQOlThOv/nMTr/CYUmHb4dBmcleU7LafKzbL Vyn05zr1h7czSAUHfik8tBX2akQMctpW2Ou8hUcSQKBm/aDzJVRxjFOoZpYEXJDdE/wX irvNAozWo/iHbEHDJecJ2f0Pi8v9HvJwEz/Lzu7z+BQfPDQjNXYNP2kYKTL9up0rT8R1 lIf2mHDcK/Ih+1U6vU1gkhLB6YfxrwELRU71v82bxyQVbxorZ4XbF4CcdC1MxbWHYS8H sgLp+1+CDcEwGPT5pBAakrdtxTTemsoUTck3qxFNdviJerrvua/7pDRsooG74YPytowd +CAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AqRrBhSs; 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 z14si6732763plo.581.2017.10.09.06.27.07; Mon, 09 Oct 2017 06:27:07 -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=AqRrBhSs; 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 S1755465AbdJIN1G (ORCPT + 26 others); Mon, 9 Oct 2017 09:27:06 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:50078 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754751AbdJIN07 (ORCPT ); Mon, 9 Oct 2017 09:26:59 -0400 Received: by mail-wm0-f53.google.com with SMTP id b189so22434780wmd.4 for ; Mon, 09 Oct 2017 06:26:58 -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=rRMKRCIn81sJ0DdGA1k7zavi0t6YyjThSM9IKcydWsY=; b=AqRrBhSsmjg9HRZbWKDA240plYRCRtVU2lOCwAw+T8TXuT+Lp58fPsUii3PnOTZ1id lBSy2OGN40+IpCWOTdAdKcD4QEn9yZpBzv4lm2GXMcw8U7G7MP8Lqh5s9SUKGfD1REhF xxb9mLdIMzEy5bBj8KBvr6Ln0f8AiBgXciTC4= 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=rRMKRCIn81sJ0DdGA1k7zavi0t6YyjThSM9IKcydWsY=; b=hrSIAgUdgsQN1DWeVJWb91xxOWAKPyAbcV+b/GdOxVoGJceIuvxWlHOuu97rl+ul2n B/CHjfxCWwqy1iSbl/H6Uoc9MoCtDt+Onlqj8P1uI+9L2jpKZgZyYG9BFyPxhzb7CO1W nkVycb6j8G7mC5+pvzLcaQ3QHydqnOi6p88UbSWlF8GkcjU/0PawhIFX/cIPHKMbsIMj R5L6oPOJLB3vA6hYPUvEJB8+OJjiyf+KS10OsC8zTllKKGWtMmAQuYIeNYWX8DBVEfnK yt4n4k4t3gd5vDjA++OTYIgYhu0H/7/5Ek2vVgImDPQmTDXeD3lVGUiy+LcFtP4q3wE4 boiQ== X-Gm-Message-State: AMCzsaXTyRLlOUf10OQaLZ0is0qViaKYi9auJtpkc+b99jbQ+vwUClmj 6CaaVD99tEvpv+BBLavowQfplFZYIUo= X-Google-Smtp-Source: AOwi7QB5n9LeF0RPO/g+Xekpyx0XftWPBvkH2suOVB81haTAzNO/rSNtvuHYrUu6B/jNquwzFARX+g== X-Received: by 10.223.199.15 with SMTP id k15mr10560398wrg.111.1507555617602; Mon, 09 Oct 2017 06:26:57 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id 31sm3775340wrm.0.2017.10.09.06.26.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 06:26:56 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Keiji Hayashibara Subject: [PATCH 08/12] nvmem: uniphier: add UniPhier eFuse driver Date: Mon, 9 Oct 2017 15:26:37 +0200 Message-Id: <20171009132641.27169-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009132641.27169-1-srinivas.kandagatla@linaro.org> References: <20171009132641.27169-1-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 -- 2.11.0 diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index ea3044c5d6ee..2755df8f6e9b 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 4c589184acee..11825353f729 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 000000000000..2bb45c42fd6b --- /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");