From patchwork Fri Mar 31 12:44:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96424 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp728730qgd; Fri, 31 Mar 2017 06:26:42 -0700 (PDT) X-Received: by 10.99.109.12 with SMTP id i12mr3294418pgc.91.1490966802270; Fri, 31 Mar 2017 06:26:42 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si5266499pfa.151.2017.03.31.06.26.42; Fri, 31 Mar 2017 06:26:42 -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 S933272AbdCaN0l (ORCPT + 21 others); Fri, 31 Mar 2017 09:26:41 -0400 Received: from mail-wr0-f176.google.com ([209.85.128.176]:32880 "EHLO mail-wr0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932918AbdCaMpN (ORCPT ); Fri, 31 Mar 2017 08:45:13 -0400 Received: by mail-wr0-f176.google.com with SMTP id w43so104342002wrb.0 for ; Fri, 31 Mar 2017 05:45:12 -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=poBnKEg7Ah9qVw3Hey9MaIRJAApT7lbra9wylhvIn9U=; b=NW1Jaq0hhlLt4deda/bN86c6zuhAzDaEaBAHCPSbrgtKXwtCE5DBnnCR06ivnexGsk akMnQpRzIbUyyQ8zmJr98prQKa6jw+uzGj8j0lQupgrDGlPB0TlRfCe+5GLIovzq2Kv8 zDGY34+u69jkVx62ko9nI0nzjHrkPPQfw96A4= 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=poBnKEg7Ah9qVw3Hey9MaIRJAApT7lbra9wylhvIn9U=; b=KltwnqMosRJPwx3fnJgH1S0BWQE1pMI9d98CkXv1rPBTZvUVdsiFiaLCc5Ki2Cj4ri T2GCYjMdqC3l21IE+ehU2ovsxPpSBxPeDvfjezJrS8vpIcqUi/40jcMevENKdGaoTxbg PspzjhTy/1DyL08Xfan5z98OuqLOAh9D7zfTOZvw0ydXmuD15SqFrF1xI7CHVIm4Juiw uXr588OBgT7ToC/+qHD0huc6PiylsQ7UBHzeR8wLcb3TXAN2DoHgRpbCHnwllWIpRYeK cntqvKSfI7J/NF5uDCi6GHwGvo2ythFk/z1eeJIyTxsXGvsr5L9qCmvTlCKwzZjTzQw1 clhQ== X-Gm-Message-State: AFeK/H0o+qEO5PIgGQO6dg7YByi8dqq38Gt4VIDgEGO1KmEE0KW4CFgPTKlDGV7SkPEJGDTS X-Received: by 10.28.28.16 with SMTP id c16mr2853086wmc.38.1490964311404; Fri, 31 Mar 2017 05:45:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:10 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Srinivas Kandagatla Subject: [PATCH 01/11] MAINTAINERS: nvmem: Remove myself from maintainers Date: Fri, 31 Mar 2017 13:44:45 +0100 Message-Id: <1490964295-9647-2-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: Maxime Ripard I've never been really been maintaining nvmem, so make that official. Signed-off-by: Maxime Ripard Signed-off-by: Srinivas Kandagatla --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) -- 2.7.4 diff --git a/MAINTAINERS b/MAINTAINERS index c776906..5db21b8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9027,7 +9027,6 @@ F: drivers/nvme/target/fcloop.c NVMEM FRAMEWORK M: Srinivas Kandagatla -M: Maxime Ripard S: Maintained F: drivers/nvmem/ F: Documentation/devicetree/bindings/nvmem/ From patchwork Fri Mar 31 12:44:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96396 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp710366qgd; Fri, 31 Mar 2017 05:45:18 -0700 (PDT) X-Received: by 10.99.172.84 with SMTP id z20mr3097645pgn.123.1490964317988; Fri, 31 Mar 2017 05:45:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s128si5144562pgc.85.2017.03.31.05.45.17; Fri, 31 Mar 2017 05:45:17 -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 S933230AbdCaMpQ (ORCPT + 21 others); Fri, 31 Mar 2017 08:45:16 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:35858 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932864AbdCaMpP (ORCPT ); Fri, 31 Mar 2017 08:45:15 -0400 Received: by mail-wr0-f171.google.com with SMTP id w11so103531945wrc.3 for ; Fri, 31 Mar 2017 05:45:13 -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=O9NwnWCksBTXuvqz0DuHtBfwXnl502Od3g6WW+aaa8M=; b=VH3eWrPsgE64XqiK7gdpyEAY2EWrb2yY7FLKOc0+Lhlf44Q1f1R6a69BgJ+knXJEQl QBJ5dIUr48WSjSOAxWcvHXKhRzS1redVS+ZuGIpIwafQysZKKcv91PgzxyRlFJfUgBwJ wSylLZQhF3JdeIvYyWVPlGlTvIu46vqHcpayQ= 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=O9NwnWCksBTXuvqz0DuHtBfwXnl502Od3g6WW+aaa8M=; b=pNDLGqD1Z3UMeYHdtN0EBwgs2fVY39sWOsJR9uKTLZTOolTR8FEKzg9nwRST5UcZNW 6ad0SccGV/B6nRmgGnD59IDi293Teb0Chd+DUFbjbNyGJY+7lOnSeGJuttTvrxFy6vz/ tjObsGliJ2bJNGT2ZjfE4KEEHM67QIickSfIgt/O0r2aJlWCGMJH4G9lc+TzQ5xmWljM qnwpJtJNk65jo58ZiBwUGDt6E9PVNaw4ExGFT3tl14ZrdrCCuqkLVhWBYr2+0RSxw/Lz BGRPi0hlv7S3aiTDzIaNX4ZZ8V9xNke8v8np9OqV1LoRl2xKZvWMeH+pB5cAQjginsiT Q1cw== X-Gm-Message-State: AFeK/H2NSZUXpwV3zAzLry7Rynqkwr5I1PDwNAKKe1BkFVSIUUkOx2X56BukhLvoX9hDO43J X-Received: by 10.28.207.14 with SMTP id f14mr2761406wmg.72.1490964312642; Fri, 31 Mar 2017 05:45:12 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:11 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Aban Bedel , Srinivas Kandagatla Subject: [PATCH 02/11] nvmem: core: Allow allocating several anonymous nvmem devices Date: Fri, 31 Mar 2017 13:44:46 +0100 Message-Id: <1490964295-9647-3-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: Aban Bedel Currently the nvmem core expect the config to provide a name and ID that are then used to create the device name. When no device name is given 'nvmem' is used. However if there is several such anonymous devices they all get named 'nvmem0', which doesn't work. To fix this problem use the ID from the config only when the config also provides a name. When no name is provided take the uinque ID of the nvmem device instead. Signed-off-by: Aban Bedel Reviewed-by: Moritz Fischer Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 408b521..8c830a8 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -468,7 +468,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) np = config->dev->of_node; nvmem->dev.of_node = np; dev_set_name(&nvmem->dev, "%s%d", - config->name ? : "nvmem", config->id); + config->name ? : "nvmem", + config->name ? config->id : nvmem->id); nvmem->read_only = of_property_read_bool(np, "read-only") | config->read_only; 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); From patchwork Fri Mar 31 12:44:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96397 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp710993qgd; Fri, 31 Mar 2017 05:46:55 -0700 (PDT) X-Received: by 10.84.160.227 with SMTP id v32mr3465935plg.87.1490964415699; Fri, 31 Mar 2017 05:46:55 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y21si5157278pgi.140.2017.03.31.05.46.55; Fri, 31 Mar 2017 05:46: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; 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 S933266AbdCaMpT (ORCPT + 21 others); Fri, 31 Mar 2017 08:45:19 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:34537 "EHLO mail-wr0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933173AbdCaMpR (ORCPT ); Fri, 31 Mar 2017 08:45:17 -0400 Received: by mail-wr0-f170.google.com with SMTP id l43so106204539wre.1 for ; Fri, 31 Mar 2017 05:45:15 -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=/LiBOoDKFiUM2vAGApdvNbHJEtzI48ZLT5PjVnVg7LU=; b=LlpZ9EZBMuvMcKyqyUvUxZ5To773p4IYSYy/9YDZ1oTqrt+qzDQGHN5MINA3Hrvfry v7id+DWOuC3ufh/rgS25oYCHYGcjut2D4f+Z1To0iUm2V8dArKRtiShJ58fX9LghjTeA t2kzNx0myYJU3Y9PNd7Tfw8/X9CjmdFdNNeIM= 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=/LiBOoDKFiUM2vAGApdvNbHJEtzI48ZLT5PjVnVg7LU=; b=TTaS3aetrzzGqJMCaVKjgwKSIPfNzkOlR3PU3Dp930BCLQLCXE8QNbOKP0f4vzAby4 IgJRt5dXe/RwI0Rl9JY7fBNUelNX35bi/mdBxJw8zS8PIHCQVuA3+OmQgueLWHKxVCWN 2Gw+3dzDdqMNf5Pk7jT8sst+YoAJ+s68V6vciOQ7hdB+JTW78W5ByPumDrtL3evoZVA4 IJaEiCtEkxL/GiAc6Dazd5DAJN07W4/1SsTfeQ92ywRAt0zsWSP8331gKYNppCBXvKig tcYvF3PN1Q03f9KC3xJxuwEShnvEP7aQQwjgJBJnDKUdoGZkKtCztMq18MpMtedzy/RB NQZg== X-Gm-Message-State: AFeK/H0r7kLA8yv/oQoeJKbvAgYOS8gvD2DH3Y56QT7ff4BC5lsszg5UcSFeupInuQUN1YJu X-Received: by 10.28.93.3 with SMTP id r3mr2716859wmb.27.1490964314709; Fri, 31 Mar 2017 05:45:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:13 -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 04/11] nvmem: sunxi-sid: add support for H3's SID controller Date: Fri, 31 Mar 2017 13:44:48 +0100 Message-Id: <1490964295-9647-5-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 The H3 SoC have a bigger SID controller, which has its direct read address at 0x200 position in the SID block, not 0x0. Also, H3 SID controller has some silicon bug that makes the direct read value wrong at cold boot, add code to workaround the bug. (This bug has already been fixed on A64 and later SoCs) Signed-off-by: Icenowy Zheng Acked-by: Maxime Ripard Signed-off-by: Srinivas Kandagatla --- .../bindings/nvmem/allwinner,sunxi-sid.txt | 6 ++- drivers/nvmem/sunxi_sid.c | 62 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt b/Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt index d543ed3..ef06d06 100644 --- a/Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt +++ b/Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt @@ -1,7 +1,11 @@ Allwinner sunxi-sid Required properties: -- compatible: "allwinner,sun4i-a10-sid" or "allwinner,sun7i-a20-sid" +- compatible: Should be one of the following: + "allwinner,sun4i-a10-sid" + "allwinner,sun7i-a20-sid" + "allwinner,sun8i-h3-sid" + - reg: Should contain registers location and length = Data cells = diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index 69524b6..0d6648b 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,15 @@ #include #include +/* Registers and special values for doing register-based SID readout on H3 */ +#define SUN8I_SID_PRCTL 0x40 +#define SUN8I_SID_RDKEY 0x60 + +#define SUN8I_SID_OFFSET_MASK 0x1FF +#define SUN8I_SID_OFFSET_SHIFT 16 +#define SUN8I_SID_OP_LOCK (0xAC << 8) +#define SUN8I_SID_READ BIT(1) + static struct nvmem_config econfig = { .name = "sunxi-sid", .read_only = true, @@ -34,11 +44,14 @@ static struct nvmem_config econfig = { }; struct sunxi_sid_cfg { + u32 value_offset; u32 size; + bool need_register_readout; }; struct sunxi_sid { void __iomem *base; + u32 value_offset; }; /* We read the entire key, due to a 32 bit read alignment requirement. Since we @@ -63,12 +76,36 @@ static int sunxi_sid_read(void *context, unsigned int offset, struct sunxi_sid *sid = context; u8 *buf = val; + /* Offset the read operation to the real position of SID */ + offset += sid->value_offset; + while (bytes--) *buf++ = sunxi_sid_read_byte(sid, offset++); return 0; } +static int sun8i_sid_register_readout(const struct sunxi_sid *sid, + const unsigned int word) +{ + u32 reg_val; + int ret; + + /* Set word, lock access, and set read command */ + reg_val = (word & SUN8I_SID_OFFSET_MASK) + << SUN8I_SID_OFFSET_SHIFT; + reg_val |= SUN8I_SID_OP_LOCK | SUN8I_SID_READ; + writel(reg_val, sid->base + SUN8I_SID_PRCTL); + + ret = readl_poll_timeout(sid->base + SUN8I_SID_PRCTL, reg_val, + !(reg_val & SUN8I_SID_READ), 100, 250000); + if (ret) + return ret; + + writel(0, sid->base + SUN8I_SID_PRCTL); + return 0; +} + static int sunxi_sid_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -86,6 +123,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) cfg = of_device_get_match_data(dev); if (!cfg) return -EINVAL; + sid->value_offset = cfg->value_offset; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sid->base = devm_ioremap_resource(dev, res); @@ -94,6 +132,23 @@ static int sunxi_sid_probe(struct platform_device *pdev) size = cfg->size; + if (cfg->need_register_readout) { + /* + * H3's SID controller have a bug that the value at 0x200 + * offset is not the correct value when the hardware is reseted. + * However, after doing a register-based read operation, the + * value become right. + * Do a full read operation here, but ignore its value + * (as it's more fast to read by direct MMIO value than + * with registers) + */ + for (i = 0; i < (size >> 2); i++) { + ret = sun8i_sid_register_readout(sid, i); + if (ret) + return ret; + } + } + econfig.size = size; econfig.dev = dev; econfig.reg_read = sunxi_sid_read; @@ -138,9 +193,16 @@ static const struct sunxi_sid_cfg sun7i_a20_cfg = { .size = 0x200, }; +static const struct sunxi_sid_cfg sun8i_h3_cfg = { + .value_offset = 0x200, + .size = 0x100, + .need_register_readout = true, +}; + static const struct of_device_id sunxi_sid_of_match[] = { { .compatible = "allwinner,sun4i-a10-sid", .data = &sun4i_a10_cfg }, { .compatible = "allwinner,sun7i-a20-sid", .data = &sun7i_a20_cfg }, + { .compatible = "allwinner,sun8i-h3-sid", .data = &sun8i_h3_cfg }, {/* sentinel */}, }; MODULE_DEVICE_TABLE(of, sunxi_sid_of_match); From patchwork Fri Mar 31 12:44:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96401 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp711116qgd; Fri, 31 Mar 2017 05:47:17 -0700 (PDT) X-Received: by 10.99.54.69 with SMTP id d66mr3133384pga.116.1490964437277; Fri, 31 Mar 2017 05:47:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si5146902pge.321.2017.03.31.05.47.17; Fri, 31 Mar 2017 05:47:17 -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 S933408AbdCaMrE (ORCPT + 21 others); Fri, 31 Mar 2017 08:47:04 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:35898 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933269AbdCaMpW (ORCPT ); Fri, 31 Mar 2017 08:45:22 -0400 Received: by mail-wr0-f181.google.com with SMTP id w11so103533738wrc.3 for ; Fri, 31 Mar 2017 05:45:16 -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=5Gl6k0QbqJJfuUIOs/4Jeo33b1iEx/xZuLIDpGPfqjI=; b=a+lDdO7qTRWn7SzgPKDYDRAmTYw02UtUPs4WSHGDuMXd+VHabNyREAdHKlVaXbD2FQ 9zunH20dVq4YDCnbgLKJgyYJPTUNedxowhE8CTpN8aPPdi8G9zsCNJycwZpt7TXb6h7p YNYjgu3khCnoogZC7KBRgXHkNDDBelpFRx8pM= 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=5Gl6k0QbqJJfuUIOs/4Jeo33b1iEx/xZuLIDpGPfqjI=; b=DwRK+7R6kiIWDIZDr2P9/j5Qn5Wb9gmmTKx+2bpCI75e40XjNr1r4vLudoFdzCBdmz B53EsT2fLusICQZhhHlYMXSbTg8TbTboIzd/i06IVpWMfyyXFCfNvWsUTLxEWBjG+0XN ji2wDazRtkTI0sC22Qkxa/bzMeM8/sX2Zar5iYfmnVALFCPt/fJbEfQPD1eGvK2WqiRS C4fktTJwOt/GT/SGVUIL9N/ZzCvz99YH0ReB1fNcFSNo8BTKx1u9euPR/aT7EOGb9pfz oVn6UW58X3w73aOoFFnjUQVLOaoHqCyo+evzV14F3g+3OSRipRlCgTZeZPuHLLFXGP0r 3u/w== X-Gm-Message-State: AFeK/H0D/GAmHViv4TsAV3rjHQxyj5cS340LI+sZBYI9e6L4KnwWKa/2eQAIV2wq/iRi7Ng3 X-Received: by 10.223.155.17 with SMTP id b17mr2680976wrc.181.1490964315678; Fri, 31 Mar 2017 05:45:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:15 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Richard Leitner , Srinivas Kandagatla Subject: [PATCH 05/11] nvmem: imx-ocotp: fix usage of "dev" pointers Date: Fri, 31 Mar 2017 13:44:49 +0100 Message-Id: <1490964295-9647-6-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: Richard Leitner Assign the correct dev pointer to struct ocotp_priv during probe. This is needed to display dev_* messages correctly. Furthermore harmonize the usage of dev (instead of &pdev->dev) in the probe function. Signed-off-by: Richard Leitner Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/imx-ocotp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index b8ca1e6..549177d 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -90,12 +90,14 @@ static int imx_ocotp_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->dev = dev; + 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); - priv->clk = devm_clk_get(&pdev->dev, NULL); + priv->clk = devm_clk_get(dev, NULL); if (IS_ERR(priv->clk)) return PTR_ERR(priv->clk); From patchwork Fri Mar 31 12:44:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96399 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp711028qgd; Fri, 31 Mar 2017 05:47:02 -0700 (PDT) X-Received: by 10.99.112.18 with SMTP id l18mr3206801pgc.142.1490964421981; Fri, 31 Mar 2017 05:47:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21si5147699pgg.373.2017.03.31.05.47.01; Fri, 31 Mar 2017 05:47:01 -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 S933365AbdCaMrB (ORCPT + 21 others); Fri, 31 Mar 2017 08:47:01 -0400 Received: from mail-wr0-f175.google.com ([209.85.128.175]:35919 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933275AbdCaMpY (ORCPT ); Fri, 31 Mar 2017 08:45:24 -0400 Received: by mail-wr0-f175.google.com with SMTP id w11so103534652wrc.3 for ; Fri, 31 Mar 2017 05:45:23 -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=Ml5Uq8xG4XrDEFeRC56YLdFsIa3Y1OoO6hlnk5tn++Y=; b=VInaK7j4kgP6c6+0MeQBubS1Erf9ikaRokftbhQmBNnJSA3mVI2OwjVcbNesbai0/0 DCVXRAjoaw9Me6CgcC3A2JuLokccUw4hpj749LBdbqTZXlp2C9Um13ro9nT8EhIZsSWK uE+zkapF0W3C3YkO2x6/E4wrMc5YPPcPB2oNU= 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=Ml5Uq8xG4XrDEFeRC56YLdFsIa3Y1OoO6hlnk5tn++Y=; b=kiv6BA2/oFgzjO3fJdU3dZWswONGoCojCgzSfYX8ZMKl5vII/iKVpnggfocS/HXwkG hCh86mUAmsSEqB8bewF8Hbn9OmzleXqPRX1XEWexLXMazYHpP//Pfg44Rdu21p0njiH7 r1nrOdS7wk+OZKl3H30y6YSkkjv2JU2ehx6kxAB8H8TaHkzw3fJAVltST7T5Glg6dQd6 bVIMun7p5vdVgfgY4GHwd2P7CNvuc9osVPpHB0EE1kqvitA5LC2BNwt/30CjNnJV2L6S spXaSddm6k1quPUpO/CyvLbT39ew2U2rKur555p85NAsylcwahAC8uoNfxu0bDTF9Vd0 ssIA== X-Gm-Message-State: AFeK/H2ovD8AeOs95TpFOzzb1uvVoH8pY1oVDVqeWTtuqkuPvR+HetbUyGW+KyHZPI5Xsuei X-Received: by 10.28.234.147 with SMTP id g19mr3195595wmi.102.1490964316889; Fri, 31 Mar 2017 05:45:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:16 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Michael Grzeschik , Sascha Hauer , Srinivas Kandagatla Subject: [PATCH 06/11] nvmem: Add driver for the i.MX IIM Date: Fri, 31 Mar 2017 13:44:50 +0100 Message-Id: <1490964295-9647-7-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: Michael Grzeschik This adds a readonly nvmem driver for the i.MX IC Identification Module (IIM). The IIM is found on the older i.MX SoCs like the i.MX25, i.MX27, i.MX31, i.MX35, i.MX51 and the i.MX53. The IIM can control up to 8 fuse banks with 256 bit each. Not all of the banks are equipped on the different SoCs. The actual number of fuses differ from 512 on the i.MX27 and 1152 on the i.MX53. The fuses are one time writable, but writing is currently not supported in the driver. Signed-off-by: Michael Grzeschik Signed-off-by: Sascha Hauer Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/Kconfig | 11 +++ drivers/nvmem/Makefile | 2 + drivers/nvmem/imx-iim.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 drivers/nvmem/imx-iim.c -- 2.7.4 diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 650f1b1..101ced4 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -13,6 +13,17 @@ menuconfig NVMEM if NVMEM +config NVMEM_IMX_IIM + tristate "i.MX IC Identification Module support" + depends on ARCH_MXC || COMPILE_TEST + help + This is a driver for the IC Identification Module (IIM) available on + i.MX SoCs, providing access to 4 Kbits of programmable + eFuses. + + This driver can also be built as a module. If so, the module + will be called nvmem-imx-iim. + config NVMEM_IMX_OCOTP tristate "i.MX6 On-Chip OTP Controller support" depends on SOC_IMX6 || COMPILE_TEST diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 86e4599..1731406 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -8,6 +8,8 @@ nvmem_core-y := core.o # Devices obj-$(CONFIG_NVMEM_BCM_OCOTP) += nvmem-bcm-ocotp.o nvmem-bcm-ocotp-y := bcm-ocotp.o +obj-$(CONFIG_NVMEM_IMX_IIM) += nvmem-imx-iim.o +nvmem-imx-iim-y := imx-iim.o obj-$(CONFIG_NVMEM_IMX_OCOTP) += nvmem-imx-ocotp.o nvmem-imx-ocotp-y := imx-ocotp.o obj-$(CONFIG_NVMEM_LPC18XX_EEPROM) += nvmem_lpc18xx_eeprom.o diff --git a/drivers/nvmem/imx-iim.c b/drivers/nvmem/imx-iim.c new file mode 100644 index 0000000..52ff65e --- /dev/null +++ b/drivers/nvmem/imx-iim.c @@ -0,0 +1,173 @@ +/* + * i.MX IIM driver + * + * Copyright (c) 2017 Pengutronix, Michael Grzeschik + * + * Based on the barebox iim driver, + * Copyright (c) 2010 Baruch Siach , + * Orex Computed Radiography + * + * 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. + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define IIM_BANK_BASE(n) (0x800 + 0x400 * (n)) + +struct imx_iim_drvdata { + unsigned int nregs; +}; + +struct iim_priv { + void __iomem *base; + struct clk *clk; + struct nvmem_config nvmem; +}; + +static int imx_iim_read(void *context, unsigned int offset, + void *buf, size_t bytes) +{ + struct iim_priv *iim = context; + int i, ret; + u8 *buf8 = buf; + + ret = clk_prepare_enable(iim->clk); + if (ret) + return ret; + + for (i = offset; i < offset + bytes; i++) { + int bank = i >> 5; + int reg = i & 0x1f; + + *buf8++ = readl(iim->base + IIM_BANK_BASE(bank) + reg * 4); + } + + clk_disable_unprepare(iim->clk); + + return 0; +} + +static struct imx_iim_drvdata imx27_drvdata = { + .nregs = 2 * 32, +}; + +static struct imx_iim_drvdata imx25_imx31_imx35_drvdata = { + .nregs = 3 * 32, +}; + +static struct imx_iim_drvdata imx51_drvdata = { + .nregs = 4 * 32, +}; + +static struct imx_iim_drvdata imx53_drvdata = { + .nregs = 4 * 32 + 16, +}; + +static const struct of_device_id imx_iim_dt_ids[] = { + { + .compatible = "fsl,imx25-iim", + .data = &imx25_imx31_imx35_drvdata, + }, { + .compatible = "fsl,imx27-iim", + .data = &imx27_drvdata, + }, { + .compatible = "fsl,imx31-iim", + .data = &imx25_imx31_imx35_drvdata, + }, { + .compatible = "fsl,imx35-iim", + .data = &imx25_imx31_imx35_drvdata, + }, { + .compatible = "fsl,imx51-iim", + .data = &imx51_drvdata, + }, { + .compatible = "fsl,imx53-iim", + .data = &imx53_drvdata, + }, { + /* sentinel */ + }, +}; +MODULE_DEVICE_TABLE(of, imx_iim_dt_ids); + +static int imx_iim_probe(struct platform_device *pdev) +{ + const struct of_device_id *of_id; + struct device *dev = &pdev->dev; + struct resource *res; + struct iim_priv *iim; + struct nvmem_device *nvmem; + struct nvmem_config *cfg; + const struct imx_iim_drvdata *drvdata = NULL; + + iim = devm_kzalloc(dev, sizeof(*iim), GFP_KERNEL); + if (!iim) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + iim->base = devm_ioremap_resource(dev, res); + if (IS_ERR(iim->base)) + return PTR_ERR(iim->base); + + of_id = of_match_device(imx_iim_dt_ids, dev); + if (!of_id) + return -ENODEV; + + drvdata = of_id->data; + + iim->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(iim->clk)) + return PTR_ERR(iim->clk); + + cfg = &iim->nvmem; + + cfg->name = "imx-iim", + cfg->read_only = true, + cfg->word_size = 1, + cfg->stride = 1, + cfg->owner = THIS_MODULE, + cfg->reg_read = imx_iim_read, + cfg->dev = dev; + cfg->size = drvdata->nregs; + cfg->priv = iim; + + nvmem = nvmem_register(cfg); + if (IS_ERR(nvmem)) + return PTR_ERR(nvmem); + + platform_set_drvdata(pdev, nvmem); + + return 0; +} + +static int imx_iim_remove(struct platform_device *pdev) +{ + struct nvmem_device *nvmem = platform_get_drvdata(pdev); + + return nvmem_unregister(nvmem); +} + +static struct platform_driver imx_iim_driver = { + .probe = imx_iim_probe, + .remove = imx_iim_remove, + .driver = { + .name = "imx-iim", + .of_match_table = imx_iim_dt_ids, + }, +}; +module_platform_driver(imx_iim_driver); + +MODULE_AUTHOR("Michael Grzeschik "); +MODULE_DESCRIPTION("i.MX IIM driver"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Mar 31 12:44:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96398 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp711024qgd; Fri, 31 Mar 2017 05:47:01 -0700 (PDT) X-Received: by 10.99.101.67 with SMTP id z64mr3255260pgb.78.1490964421199; Fri, 31 Mar 2017 05:47:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21si5147699pgg.373.2017.03.31.05.47.00; Fri, 31 Mar 2017 05:47:01 -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 S933343AbdCaMrA (ORCPT + 21 others); Fri, 31 Mar 2017 08:47:00 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:34894 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932886AbdCaMpa (ORCPT ); Fri, 31 Mar 2017 08:45:30 -0400 Received: by mail-wr0-f179.google.com with SMTP id k6so99270480wre.2 for ; Fri, 31 Mar 2017 05:45:28 -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=avoK7Je+64X/ZUIEk/qBBtk8keN5GFnF9JDoevotja8=; b=hJ6MS8n5otJp5nG8vVyVCdDGcbV8B0aXm1xXpvrGSqatScIZVaB7kWjKtYR2GNLCOe piW4Z2FbpTGKnrSfigcoD8x/lf3VKbxNDKB44+/aLcuHETw9hjhYfIkF22D9T9M8vu0V 6JooQANMwUuse15tJgoGBeFhLwdRjTft40Qps= 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=avoK7Je+64X/ZUIEk/qBBtk8keN5GFnF9JDoevotja8=; b=poUsu0pExvoKZrs24ZkgG2kHwC74CNeC3e7jyi8As8F5fCvgzNCPkSXH8EyEE2T/GM 3Kw2595jIrNADNj7agok7RvpybZ6b82nEg4AiBpCjqrhK17dNlg2PCNJGazZIfbOaGxT 6zLeao2D/vMnDdV7+zwQfimPz5nsw9uyGmEzX9ZAT8kib3fsYxF5bVm7Dhf/2qnl5FM2 gjMOn8bO43aJfrE2hF5sj2ipLsDxke/yH3w6Cul9Bmyp2QsC83gjMsROz+XLue1tQsAy YMf/UAudIFR8Upt/WlUX+tPmNUbVpRWbHL1iUuA6D+/ixsVTo2KvKMruw/PWN8S3mqOG /W9g== X-Gm-Message-State: AFeK/H02S7L15kj5cC5NR7fZRwjFiLVW9oantSPgS4zY1WBeQ97f7mbDVuHW05mGzVm+cnRE X-Received: by 10.28.69.72 with SMTP id s69mr3190970wma.85.1490964317993; Fri, 31 Mar 2017 05:45:17 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:17 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Sascha Hauer , Srinivas Kandagatla Subject: [PATCH 07/11] dt-bindings: nvmem: Add i.MX IIM binding doc Date: Fri, 31 Mar 2017 13:44:51 +0100 Message-Id: <1490964295-9647-8-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: Sascha Hauer The IIM is part of the i.MX device trees for long already, add a binding document for it. Signed-off-by: Sascha Hauer Signed-off-by: Srinivas Kandagatla --- .../devicetree/bindings/nvmem/imx-iim.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/imx-iim.txt -- 2.7.4 diff --git a/Documentation/devicetree/bindings/nvmem/imx-iim.txt b/Documentation/devicetree/bindings/nvmem/imx-iim.txt new file mode 100644 index 0000000..1978c5b --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/imx-iim.txt @@ -0,0 +1,22 @@ +Freescale i.MX IC Identification Module (IIM) device tree bindings + +This binding represents the IC Identification Module (IIM) found on +i.MX25, i.MX27, i.MX31, i.MX35, i.MX51 and i.MX53 SoCs. + +Required properties: +- compatible: should be one of + "fsl,imx25-iim", "fsl,imx27-iim", + "fsl,imx31-iim", "fsl,imx35-iim", + "fsl,imx51-iim", "fsl,imx53-iim", +- reg: Should contain the register base and length. +- interrupts: Should contain the interrupt for the IIM +- clocks: Should contain a phandle pointing to the gated peripheral clock. + +Example: + + iim: iim@63f98000 { + compatible = "fsl,imx53-iim", "fsl,imx27-iim"; + reg = <0x63f98000 0x4000>; + interrupts = <69>; + clocks = <&clks IMX5_CLK_IIM_GATE>; + }; From patchwork Fri Mar 31 12:44:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96417 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp713828qgd; Fri, 31 Mar 2017 05:53:52 -0700 (PDT) X-Received: by 10.99.96.72 with SMTP id u69mr3216930pgb.194.1490964832727; Fri, 31 Mar 2017 05:53:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si5157614pgn.352.2017.03.31.05.53.52; Fri, 31 Mar 2017 05:53:52 -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 S933447AbdCaMsV (ORCPT + 21 others); Fri, 31 Mar 2017 08:48:21 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:34908 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933173AbdCaMpV (ORCPT ); Fri, 31 Mar 2017 08:45:21 -0400 Received: by mail-wr0-f179.google.com with SMTP id k6so99271140wre.2 for ; Fri, 31 Mar 2017 05:45:19 -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=F0piGvFLIlEuLNKC8v0OpiRDP68Og46fSXS9fOEfXcE=; b=gFywpzYPSuezudRQnv61fsf5h//KmWczkRrxvdGyVlCTbzFcEnSAb4TlBGkEjp7WRj 4mHHoe4MUylTsan1In7w5rMDeHg0gLaS4xFm3CDK3RF2+wnGdVCuwCkmTgXWss8Rxp8m fwjwxFZjlcVtXS6NtcdJ7Jv8i0DVPHFLj5cJ4= 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=F0piGvFLIlEuLNKC8v0OpiRDP68Og46fSXS9fOEfXcE=; b=MtZbc9H2v466HkauYtCsz0PkdrhXOJFiUNrrD5ixKUCQ7a0/N5R5n61giyPQSMulvh 1mSH2J0LyjOJPIWXL77WhR65AhkrdcSUs+MPCqrpnhVPfykvBimw6W6pdZmOZLQAIOGe qHQ+NR/fiLBSoxn2EEhUFjYNXylPSfdxOkW8QD30vZbQwvhOlduamMNY4rrbYWlSwUv+ spTN1c0C+X8wEApc6VaDlzi8k06VRIPY6cZEBPmJVP1BNu/qv012eS+vK4RIL0wF4nal 0bKizuVur2I/jnV0RMTJ6wPS2sf4LYj10WtueHZGwsTLaZtuHNafHAmxn/cM+Im7XxXo jAwg== X-Gm-Message-State: AFeK/H0PWSX7NL5JTqizTU7WFDjeoIHDHVYH8PLv8eb1SEuyN02DetWZCwF9UWT8Plva0fwy X-Received: by 10.28.193.197 with SMTP id r188mr3300159wmf.116.1490964319074; Fri, 31 Mar 2017 05:45:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:18 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Peng Fan , Shawn Guo , Srinivas Kandagatla , Rob Herring , Mark Rutland Subject: [PATCH 08/11] dt-bindings: imx-ocotp: add compatible string for i.MX7D/S Date: Fri, 31 Mar 2017 13:44:52 +0100 Message-Id: <1490964295-9647-9-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: Peng Fan Add compatible string for i.MX7D/S Signed-off-by: Peng Fan Cc: Shawn Guo Cc: Srinivas Kandagatla Cc: Maxime Ripard Cc: Rob Herring Cc: Mark Rutland Signed-off-by: Srinivas Kandagatla --- Documentation/devicetree/bindings/nvmem/imx-ocotp.txt | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 Acked-by: Rob Herring diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt index 966a72e..bbde2e4 100644 --- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt +++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt @@ -9,6 +9,7 @@ Required properties: "fsl,imx6sl-ocotp" (i.MX6SL), or "fsl,imx6sx-ocotp" (i.MX6SX), "fsl,imx6ul-ocotp" (i.MX6UL), + "fsl,imx7d-ocotp" (i.MX7D/S), followed by "syscon". - reg: Should contain the register base and length. - clocks: Should contain a phandle pointing to the gated peripheral clock. From patchwork Fri Mar 31 12:44:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96400 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp711073qgd; Fri, 31 Mar 2017 05:47:09 -0700 (PDT) X-Received: by 10.98.202.80 with SMTP id n77mr2715338pfg.167.1490964428938; Fri, 31 Mar 2017 05:47:08 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si5146902pge.321.2017.03.31.05.47.08; Fri, 31 Mar 2017 05:47:08 -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 S933430AbdCaMrF (ORCPT + 21 others); Fri, 31 Mar 2017 08:47:05 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:35599 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933268AbdCaMpW (ORCPT ); Fri, 31 Mar 2017 08:45:22 -0400 Received: by mail-lf0-f50.google.com with SMTP id j90so43210510lfk.2 for ; Fri, 31 Mar 2017 05:45:21 -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=J5WGFyy96wVpcXmtGroJcy5rn3Wi2MN2lqwfRJRlIkM=; b=HUQ0CPIky6QzYhoRRp/2LKnwG+aFstbbxs6IV+glp31MhjxXV998e4WABedL44vmRk gk9kp8QvRtv1ofJnjKBekyJ2500FY8igPMqxX2RSohNX6NCk89sUWzYlUyFV4o5Jwwka PJIL9iARvbFFL4wGuUW7l6A9qZ7RUislZsPi4= 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=J5WGFyy96wVpcXmtGroJcy5rn3Wi2MN2lqwfRJRlIkM=; b=g1R5cYoKXE+fOzNXPz9U9m/S1lMQoz9PIgpKwVfbCWqujiIREGr7jXjDSApmaOBjt4 R+w5k7DiPJaH974cE1MAa6/E20kW/sRRxAnRP/47GbW6V0adXIzqwZ0Si/DSWCfdcVr8 Efb3YyOKlQD61iILf+T0jQjGFUwYfsu5BYZ2ARrwrvwX1afwNZAwBDxZTk2vwCiL8QM3 RJgsw6MBd3zKeG2qFA3r1TcNKblq6YJo9KyP79Ie8kcTydt9eIJeVSmqmUVVFCQI5oOk sKoYJzAV6sKsSGtZZ3lYsdIFNrDJZaDLo/pXBKIk6vpt3dVTr5HfR8cdgqtJsrnjAJ4i he5g== X-Gm-Message-State: AFeK/H0RtWQFSzRk4tJNavuj5JT9hWVShwNLiMziL1HjGcwfz9+SSD4+aO5EI2Qrbe23kXnb X-Received: by 10.28.170.212 with SMTP id t203mr2797859wme.4.1490964320072; Fri, 31 Mar 2017 05:45:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:19 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Peng Fan , Srinivas Kandagatla , Shawn Guo Subject: [PATCH 09/11] nvmem: octop: Add i.MX7D support Date: Fri, 31 Mar 2017 13:44:53 +0100 Message-Id: <1490964295-9647-10-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: Peng Fan Add i.MX7D support. There is 16 banks, each bank 4 words. Signed-off-by: Peng Fan Cc: Srinivas Kandagatla Cc: Maxime Ripard Cc: Shawn Guo Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/imx-ocotp.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 549177d..0d33705 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -74,6 +74,7 @@ static const struct of_device_id imx_ocotp_dt_ids[] = { { .compatible = "fsl,imx6sl-ocotp", (void *)64 }, { .compatible = "fsl,imx6sx-ocotp", (void *)128 }, { .compatible = "fsl,imx6ul-ocotp", (void *)128 }, + { .compatible = "fsl,imx7d-ocotp", (void *)64 }, { }, }; MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids); From patchwork Fri Mar 31 12:44:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96402 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp711233qgd; Fri, 31 Mar 2017 05:47:33 -0700 (PDT) X-Received: by 10.98.57.26 with SMTP id g26mr2217319pfa.38.1490964453779; Fri, 31 Mar 2017 05:47:33 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si5148638pfk.350.2017.03.31.05.47.33; Fri, 31 Mar 2017 05:47:33 -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 S933384AbdCaMrC (ORCPT + 21 others); Fri, 31 Mar 2017 08:47:02 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:35971 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933270AbdCaMpX (ORCPT ); Fri, 31 Mar 2017 08:45:23 -0400 Received: by mail-wr0-f179.google.com with SMTP id w11so103536930wrc.3 for ; Fri, 31 Mar 2017 05:45:21 -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=QEyMP1OU79SIj1oUAMoooyhs0cXCgc4tHdVVxZjFR0E=; b=SFLEaQSFuMDpHBt4UDd8WIycO1HDsAv1W41OBvFSk38Db48L/13KmeoKuxxkE8hqaW T9tAL4VvzKs4kyp5t0JIxQPnXngRI7WPFGsejTs1w0s9LltHxu4VieZghDruQ2mexr/9 KvawmY3PgZ+GaSrQmvoL4rEftT+aJOF+4aL4Y= 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=QEyMP1OU79SIj1oUAMoooyhs0cXCgc4tHdVVxZjFR0E=; b=fEXhDbj0mUlASofyJ6ioUVfRGwbPuy5PGgDNktvNx0EidAoDZ7pPGA5/rEPYqPAG2h yBEDwXeX5k85+RveqNMEhxrfRzjZgYK7f+C835eylTycWctK3lDwAN4ERpk7WMgSOgZt vtUdHOJR2VsVSsuEgHt2aQau1qPBe9KqXVqfkisfnKmASr5TyNJ+0wlhd5q3JOb6FNfp TpWIAZkREA9rOcN7Ya8Vad6Pq0E3LqatYAIV4ESsPqhjWjUD1W7Mu2rzJOnwqd1Iegd9 USs0cBOpvSL5cElYh9GSmbLr96rPjhvCL+06+4Y4OGiaNQa1IkqUni1BYydC0OZHiyQ/ a6Og== X-Gm-Message-State: AFeK/H1KGe+eA5xO3sqBogUvQGQt4X6ntJpotmdmiGgeESvzsaXasaiiFIeKfin5LaXutAFG X-Received: by 10.223.171.22 with SMTP id q22mr2723547wrc.163.1490964320991; Fri, 31 Mar 2017 05:45:20 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:20 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Richard Leitner , Srinivas Kandagatla Subject: [PATCH 10/11] nvmem: imx-ocotp: clear error bit after reading locked values Date: Fri, 31 Mar 2017 13:44:54 +0100 Message-Id: <1490964295-9647-11-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: Richard Leitner When reading a "read locked" value from the OCOTP controller on i.MX6 SoC's an error bit is set. This bit has to be cleared by software before any new write, read or reload access can be issued. Therefore clear it after we detect such an "locked read". Signed-off-by: Richard Leitner Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/imx-ocotp.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 0d33705..0bb8d0d 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -25,6 +25,19 @@ #include #include +#define IMX_OCOTP_OFFSET_B0W0 0x400 /* Offset from base address of the + * OTP Bank0 Word0 + */ +#define IMX_OCOTP_OFFSET_PER_WORD 0x10 /* Offset between the start addr + * of two consecutive OTP words. + */ +#define IMX_OCOTP_ADDR_CTRL 0x0000 +#define IMX_OCOTP_ADDR_CTRL_CLR 0x0008 + +#define IMX_OCOTP_BM_CTRL_ERROR 0x00000200 + +#define IMX_OCOTP_READ_LOCKED_VAL 0xBADABADA + struct ocotp_priv { struct device *dev; struct clk *clk; @@ -32,6 +45,17 @@ struct ocotp_priv { unsigned int nregs; }; +static void imx_ocotp_clr_err_if_set(void __iomem *base) +{ + u32 c; + + c = readl(base + IMX_OCOTP_ADDR_CTRL); + if (!(c & IMX_OCOTP_BM_CTRL_ERROR)) + return; + + writel(IMX_OCOTP_BM_CTRL_ERROR, base + IMX_OCOTP_ADDR_CTRL_CLR); +} + static int imx_ocotp_read(void *context, unsigned int offset, void *val, size_t bytes) { @@ -52,11 +76,22 @@ static int imx_ocotp_read(void *context, unsigned int offset, dev_err(priv->dev, "failed to prepare/enable ocotp clk\n"); return ret; } - for (i = index; i < (index + count); i++) - *buf++ = readl(priv->base + 0x400 + i * 0x10); - clk_disable_unprepare(priv->clk); + for (i = index; i < (index + count); i++) { + *buf++ = readl(priv->base + IMX_OCOTP_OFFSET_B0W0 + + i * IMX_OCOTP_OFFSET_PER_WORD); + + /* 47.3.1.2 + * For "read locked" registers 0xBADABADA will be returned and + * HW_OCOTP_CTRL[ERROR] will be set. It must be cleared by + * software before any new write, read or reload access can be + * issued + */ + if (*(buf - 1) == IMX_OCOTP_READ_LOCKED_VAL) + imx_ocotp_clr_err_if_set(priv->base); + } + clk_disable_unprepare(priv->clk); return 0; } From patchwork Fri Mar 31 12:44:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96403 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp711408qgd; Fri, 31 Mar 2017 05:48:04 -0700 (PDT) X-Received: by 10.84.245.2 with SMTP id i2mr3372661pll.131.1490964483987; Fri, 31 Mar 2017 05:48:03 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f86si5162324pff.324.2017.03.31.05.48.03; Fri, 31 Mar 2017 05:48:03 -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 S933324AbdCaMq6 (ORCPT + 21 others); Fri, 31 Mar 2017 08:46:58 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:34955 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933279AbdCaMpe (ORCPT ); Fri, 31 Mar 2017 08:45:34 -0400 Received: by mail-wr0-f174.google.com with SMTP id k6so99273254wre.2 for ; Fri, 31 Mar 2017 05:45:28 -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=NcqSZ96agFY+EfAHZd6WfP1qvLoSUw3mW+6ND+S9Bjg=; b=CJS1z9Ba+NNrY2b9izmknFwCjqdyoQ/4MU1uI6XkeYYrZKyWYZF7OJGa6d40eKmGTB xBfsdt/DQIBeTNxcCf5hwdmGdBUfqpfh1HTuiMMS/FvoA2Oi4nqPgHFs2uflXDCwzINt 4XNuKVChp+Dc9ipnl7HiTp7Zi4m06n/bwoMzw= 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=NcqSZ96agFY+EfAHZd6WfP1qvLoSUw3mW+6ND+S9Bjg=; b=rxmFW5pcTxJR3azaBl2DCgD7x7x4W5GQyB4jZyL0WGNWBu53WKBtUvP4YfVYIwAztD VxFwhLth345fbF9ry4fdKkv5PIs96bEg+Il8ugawRPMwBIj2GLr9TZI284jtSG2pL215 3OEF7nx2/24r8V/bUBhoNEMDRDi3BsEELysaM6UVVpRtNBHsDFFsdJPAp0zJ66LEDhIW 2bQMmtvI7ggIsl06X582qG7Ung2tTetdGbnuE+/I6MEe8zUPCzTRHhMGr1BnUpxuPeLn KLWqw5G83SNMYBkiDTYINcrCuJj0QrPB6Do64ojys9l1/1/tLUUAhB2F5sjyyEGhRtM8 K/gQ== X-Gm-Message-State: AFeK/H0l2QkiPCQ0kzcwseeefcqnatGMNyNzhwqS1XEzKJLPNwy0sX+lr072JFqqEfSPhLEv X-Received: by 10.223.149.35 with SMTP id 32mr2955139wrs.107.1490964322113; Fri, 31 Mar 2017 05:45:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:21 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Richard Leitner , Srinivas Kandagatla Subject: [PATCH 11/11] nvmem: imx-ocotp: add write support Date: Fri, 31 Mar 2017 13:44:55 +0100 Message-Id: <1490964295-9647-12-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: Richard Leitner Implement write routine for OCOTP controller found in i.MX6 SoC's. Furthermore add locking to the read function to prevent race conditions. The write routine code is based on the fsl_otp driver from Freescale. Signed-off-by: Richard Leitner Signed-off-by: Srinivas Kandagatla --- .../devicetree/bindings/nvmem/imx-ocotp.txt | 4 + drivers/nvmem/imx-ocotp.c | 210 ++++++++++++++++++++- 2 files changed, 212 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt index bbde2e4..70d791b 100644 --- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt +++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.txt @@ -14,10 +14,14 @@ Required properties: - reg: Should contain the register base and length. - clocks: Should contain a phandle pointing to the gated peripheral clock. +Optional properties: +- read-only: disable write access + Example: ocotp: ocotp@021bc000 { compatible = "fsl,imx6q-ocotp", "syscon"; reg = <0x021bc000 0x4000>; clocks = <&clks IMX6QDL_CLK_IIM>; + read-only; }; diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 0bb8d0d..193ca8f 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -7,6 +7,9 @@ * Copyright (c) 2010 Baruch Siach , * Orex Computed Radiography * + * Write support based on the fsl_otp driver, + * Copyright (C) 2010-2013 Freescale Semiconductor, 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. @@ -24,6 +27,7 @@ #include #include #include +#include #define IMX_OCOTP_OFFSET_B0W0 0x400 /* Offset from base address of the * OTP Bank0 Word0 @@ -31,20 +35,69 @@ #define IMX_OCOTP_OFFSET_PER_WORD 0x10 /* Offset between the start addr * of two consecutive OTP words. */ + #define IMX_OCOTP_ADDR_CTRL 0x0000 +#define IMX_OCOTP_ADDR_CTRL_SET 0x0004 #define IMX_OCOTP_ADDR_CTRL_CLR 0x0008 +#define IMX_OCOTP_ADDR_TIMING 0x0010 +#define IMX_OCOTP_ADDR_DATA 0x0020 +#define IMX_OCOTP_BM_CTRL_ADDR 0x0000007F +#define IMX_OCOTP_BM_CTRL_BUSY 0x00000100 #define IMX_OCOTP_BM_CTRL_ERROR 0x00000200 +#define IMX_OCOTP_BM_CTRL_REL_SHADOWS 0x00000400 +#define DEF_RELAX 20 /* > 16.5ns */ +#define IMX_OCOTP_WR_UNLOCK 0x3E770000 #define IMX_OCOTP_READ_LOCKED_VAL 0xBADABADA +static DEFINE_MUTEX(ocotp_mutex); + struct ocotp_priv { struct device *dev; struct clk *clk; void __iomem *base; unsigned int nregs; + struct nvmem_config *config; }; +static int imx_ocotp_wait_for_busy(void __iomem *base, u32 flags) +{ + int count; + u32 c, mask; + + mask = IMX_OCOTP_BM_CTRL_BUSY | IMX_OCOTP_BM_CTRL_ERROR | flags; + + for (count = 10000; count >= 0; count--) { + c = readl(base + IMX_OCOTP_ADDR_CTRL); + if (!(c & mask)) + break; + cpu_relax(); + } + + if (count < 0) { + /* HW_OCOTP_CTRL[ERROR] will be set under the following + * conditions: + * - A write is performed to a shadow register during a shadow + * reload (essentially, while HW_OCOTP_CTRL[RELOAD_SHADOWS] is + * set. In addition, the contents of the shadow register shall + * not be updated. + * - A write is performed to a shadow register which has been + * locked. + * - A read is performed to from a shadow register which has + * been read locked. + * - A program is performed to a fuse word which has been locked + * - A read is performed to from a fuse word which has been read + * locked. + */ + if (c & IMX_OCOTP_BM_CTRL_ERROR) + return -EPERM; + return -ETIMEDOUT; + } + + return 0; +} + static void imx_ocotp_clr_err_if_set(void __iomem *base) { u32 c; @@ -71,12 +124,21 @@ static int imx_ocotp_read(void *context, unsigned int offset, if (count > (priv->nregs - index)) count = priv->nregs - index; + mutex_lock(&ocotp_mutex); + ret = clk_prepare_enable(priv->clk); if (ret < 0) { + mutex_unlock(&ocotp_mutex); dev_err(priv->dev, "failed to prepare/enable ocotp clk\n"); return ret; } + ret = imx_ocotp_wait_for_busy(priv->base, 0); + if (ret < 0) { + dev_err(priv->dev, "timeout during read setup\n"); + goto read_end; + } + for (i = index; i < (index + count); i++) { *buf++ = readl(priv->base + IMX_OCOTP_OFFSET_B0W0 + i * IMX_OCOTP_OFFSET_PER_WORD); @@ -90,18 +152,160 @@ static int imx_ocotp_read(void *context, unsigned int offset, if (*(buf - 1) == IMX_OCOTP_READ_LOCKED_VAL) imx_ocotp_clr_err_if_set(priv->base); } + ret = 0; +read_end: clk_disable_unprepare(priv->clk); - return 0; + mutex_unlock(&ocotp_mutex); + return ret; +} + +static int imx_ocotp_write(void *context, unsigned int offset, void *val, + size_t bytes) +{ + struct ocotp_priv *priv = context; + u32 *buf = val; + int ret; + + unsigned long clk_rate = 0; + unsigned long strobe_read, relax, strobe_prog; + u32 timing = 0; + u32 ctrl; + u8 waddr; + + /* allow only writing one complete OTP word at a time */ + if ((bytes != priv->config->word_size) || + (offset % priv->config->word_size)) + return -EINVAL; + + mutex_lock(&ocotp_mutex); + + ret = clk_prepare_enable(priv->clk); + if (ret < 0) { + mutex_unlock(&ocotp_mutex); + dev_err(priv->dev, "failed to prepare/enable ocotp clk\n"); + return ret; + } + + /* 47.3.1.3.1 + * Program HW_OCOTP_TIMING[STROBE_PROG] and HW_OCOTP_TIMING[RELAX] + * fields with timing values to match the current frequency of the + * ipg_clk. OTP writes will work at maximum bus frequencies as long + * as the HW_OCOTP_TIMING parameters are set correctly. + */ + clk_rate = clk_get_rate(priv->clk); + + relax = clk_rate / (1000000000 / DEF_RELAX) - 1; + strobe_prog = clk_rate / (1000000000 / 10000) + 2 * (DEF_RELAX + 1) - 1; + strobe_read = clk_rate / (1000000000 / 40) + 2 * (DEF_RELAX + 1) - 1; + + timing = strobe_prog & 0x00000FFF; + timing |= (relax << 12) & 0x0000F000; + timing |= (strobe_read << 16) & 0x003F0000; + + writel(timing, priv->base + IMX_OCOTP_ADDR_TIMING); + + /* 47.3.1.3.2 + * Check that HW_OCOTP_CTRL[BUSY] and HW_OCOTP_CTRL[ERROR] are clear. + * Overlapped accesses are not supported by the controller. Any pending + * write or reload must be completed before a write access can be + * requested. + */ + ret = imx_ocotp_wait_for_busy(priv->base, 0); + if (ret < 0) { + dev_err(priv->dev, "timeout during timing setup\n"); + goto write_end; + } + + /* 47.3.1.3.3 + * Write the requested address to HW_OCOTP_CTRL[ADDR] and program the + * unlock code into HW_OCOTP_CTRL[WR_UNLOCK]. This must be programmed + * for each write access. The lock code is documented in the register + * description. Both the unlock code and address can be written in the + * same operation. + */ + /* OTP write/read address specifies one of 128 word address locations */ + waddr = offset / 4; + + ctrl = readl(priv->base + IMX_OCOTP_ADDR_CTRL); + ctrl &= ~IMX_OCOTP_BM_CTRL_ADDR; + ctrl |= waddr & IMX_OCOTP_BM_CTRL_ADDR; + ctrl |= IMX_OCOTP_WR_UNLOCK; + + writel(ctrl, priv->base + IMX_OCOTP_ADDR_CTRL); + + /* 47.3.1.3.4 + * Write the data to the HW_OCOTP_DATA register. This will automatically + * set HW_OCOTP_CTRL[BUSY] and clear HW_OCOTP_CTRL[WR_UNLOCK]. To + * protect programming same OTP bit twice, before program OCOTP will + * automatically read fuse value in OTP and use read value to mask + * program data. The controller will use masked program data to program + * a 32-bit word in the OTP per the address in HW_OCOTP_CTRL[ADDR]. Bit + * fields with 1's will result in that OTP bit being programmed. Bit + * fields with 0's will be ignored. At the same time that the write is + * accepted, the controller makes an internal copy of + * HW_OCOTP_CTRL[ADDR] which cannot be updated until the next write + * sequence is initiated. This copy guarantees that erroneous writes to + * HW_OCOTP_CTRL[ADDR] will not affect an active write operation. It + * should also be noted that during the programming HW_OCOTP_DATA will + * shift right (with zero fill). This shifting is required to program + * the OTP serially. During the write operation, HW_OCOTP_DATA cannot be + * modified. + */ + writel(*buf, priv->base + IMX_OCOTP_ADDR_DATA); + + /* 47.4.1.4.5 + * Once complete, the controller will clear BUSY. A write request to a + * protected or locked region will result in no OTP access and no + * setting of HW_OCOTP_CTRL[BUSY]. In addition HW_OCOTP_CTRL[ERROR] will + * be set. It must be cleared by software before any new write access + * can be issued. + */ + ret = imx_ocotp_wait_for_busy(priv->base, 0); + if (ret < 0) { + if (ret == -EPERM) { + dev_err(priv->dev, "failed write to locked region"); + imx_ocotp_clr_err_if_set(priv->base); + } else { + dev_err(priv->dev, "timeout during data write\n"); + } + goto write_end; + } + + /* 47.3.1.4 + * Write Postamble: Due to internal electrical characteristics of the + * OTP during writes, all OTP operations following a write must be + * separated by 2 us after the clearing of HW_OCOTP_CTRL_BUSY following + * the write. + */ + udelay(2); + + /* reload all shadow registers */ + writel(IMX_OCOTP_BM_CTRL_REL_SHADOWS, + priv->base + IMX_OCOTP_ADDR_CTRL_SET); + ret = imx_ocotp_wait_for_busy(priv->base, + IMX_OCOTP_BM_CTRL_REL_SHADOWS); + if (ret < 0) { + dev_err(priv->dev, "timeout during shadow register reload\n"); + goto write_end; + } + +write_end: + clk_disable_unprepare(priv->clk); + mutex_unlock(&ocotp_mutex); + if (ret < 0) + return ret; + return bytes; } static struct nvmem_config imx_ocotp_nvmem_config = { .name = "imx-ocotp", - .read_only = true, + .read_only = false, .word_size = 4, .stride = 4, .owner = THIS_MODULE, .reg_read = imx_ocotp_read, + .reg_write = imx_ocotp_write, }; static const struct of_device_id imx_ocotp_dt_ids[] = { @@ -142,7 +346,9 @@ static int imx_ocotp_probe(struct platform_device *pdev) imx_ocotp_nvmem_config.size = 4 * priv->nregs; imx_ocotp_nvmem_config.dev = dev; imx_ocotp_nvmem_config.priv = priv; + priv->config = &imx_ocotp_nvmem_config; nvmem = nvmem_register(&imx_ocotp_nvmem_config); + if (IS_ERR(nvmem)) return PTR_ERR(nvmem);