From patchwork Fri Mar 31 12:44:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96422 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp722984qgd; Fri, 31 Mar 2017 06:12:50 -0700 (PDT) X-Received: by 10.84.232.79 with SMTP id f15mr3510469pln.90.1490965970663; Fri, 31 Mar 2017 06:12:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n69si5197211pfa.358.2017.03.31.06.12.50; Fri, 31 Mar 2017 06:12:50 -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; 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 S933393AbdCaNJe (ORCPT + 21 others); Fri, 31 Mar 2017 09:09:34 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:32910 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933144AbdCaMpP (ORCPT ); Fri, 31 Mar 2017 08:45:15 -0400 Received: by mail-wr0-f171.google.com with SMTP id w43so104343338wrb.0 for ; Fri, 31 Mar 2017 05:45:14 -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=Ut7TNelBt6QNh0P6695dZQJo8HxPa+rOm386/aeBe6U=; b=Luv8lcS+po8w2IIxX93gXBVQoeIAiZCMdv6YwVJ65hZc6Ftv8iA/3rwuYl3ZSG7HKP SPPYE6vMJU5jXy066vMrLFzXBGOTOH0SMssPEs6pMCCf/7odqXNCmzA+E96tc2O3Ocdw Fa9ucN2i34/k22zxJKZhclEB5yYxtX8zqi8Ik= 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=Ut7TNelBt6QNh0P6695dZQJo8HxPa+rOm386/aeBe6U=; b=ccWzgjf5vc55V+YrxcH8OajVsscQ56v3EqoAjhAT4gMMjNlRQnf86AG12uMo4AQNRW yzPpogZ7jcogEQHYC0DuIIwpjD292z1vPvxnmdy3pbHdGR3Xd4G5opWdBaXJwJp+WDKW ZrofyC+Hy0fs57KU9OSx1xLKKlM2s9rT6eTdHAPxSw4LwV16YweFgGHHK5QSptEiWf3A m6zQ0kiQjmnirWgq5fehCfaswywFg7zl1IRHrgm992pnTpPsft3f4o9uE8aZBbImS5Li VivxtBsA/J4oJnBI1lZNRQQJnJcBRyhvDcr4EwPmnVk5iREORwM2MnDiAUCTYfb9bgxk 1uVw== X-Gm-Message-State: AFeK/H3KmBVPT8X30WIrYpXJWoCO2uKAdT21/izp6yzF5xlB2Pd+yNpUa6WajEo9fy0bg2qO X-Received: by 10.28.16.149 with SMTP id 143mr2580751wmq.42.1490964313635; Fri, 31 Mar 2017 05:45:13 -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 n80sm6615514wrb.24.2017.03.31.05.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:12 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Icenowy Zheng , Srinivas Kandagatla Subject: [PATCH 03/11] nvmem: sunxi-sid: read NVMEM size from device compatible Date: Fri, 31 Mar 2017 13:44:47 +0100 Message-Id: <1490964295-9647-4-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490964295-9647-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1490964295-9647-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: Icenowy Zheng Sometimes the SID device have more memory address space than the real NVMEM size (for the registers used to read/write the SID). Fetch the NVMEM size from device compatible, rather than the memory address space's length, in order to prepare for adding some registers-based read support. Signed-off-by: Icenowy Zheng Acked-by: Maxime Ripard Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/sunxi_sid.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index 1567ccc..69524b6 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,10 @@ static struct nvmem_config econfig = { .owner = THIS_MODULE, }; +struct sunxi_sid_cfg { + u32 size; +}; + struct sunxi_sid { void __iomem *base; }; @@ -72,18 +77,24 @@ static int sunxi_sid_probe(struct platform_device *pdev) struct sunxi_sid *sid; int ret, i, size; char *randomness; + const struct sunxi_sid_cfg *cfg; sid = devm_kzalloc(dev, sizeof(*sid), GFP_KERNEL); if (!sid) return -ENOMEM; + cfg = of_device_get_match_data(dev); + if (!cfg) + return -EINVAL; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sid->base = devm_ioremap_resource(dev, res); if (IS_ERR(sid->base)) return PTR_ERR(sid->base); - size = resource_size(res) - 1; - econfig.size = resource_size(res); + size = cfg->size; + + econfig.size = size; econfig.dev = dev; econfig.reg_read = sunxi_sid_read; econfig.priv = sid; @@ -119,9 +130,17 @@ static int sunxi_sid_remove(struct platform_device *pdev) return nvmem_unregister(nvmem); } +static const struct sunxi_sid_cfg sun4i_a10_cfg = { + .size = 0x10, +}; + +static const struct sunxi_sid_cfg sun7i_a20_cfg = { + .size = 0x200, +}; + static const struct of_device_id sunxi_sid_of_match[] = { - { .compatible = "allwinner,sun4i-a10-sid" }, - { .compatible = "allwinner,sun7i-a20-sid" }, + { .compatible = "allwinner,sun4i-a10-sid", .data = &sun4i_a10_cfg }, + { .compatible = "allwinner,sun7i-a20-sid", .data = &sun7i_a20_cfg }, {/* sentinel */}, }; MODULE_DEVICE_TABLE(of, sunxi_sid_of_match);