From patchwork Tue Nov 27 20:53:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152170 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp256946ljp; Tue, 27 Nov 2018 12:54:28 -0800 (PST) X-Google-Smtp-Source: AJdET5dxjeQRnIo/Gz+LsUdspJL1Ce6/JiQTD9iQt6ZxzYRKQiqqfYZKtbyBjMwnv+XvIdWQoS2O X-Received: by 2002:a63:4e41:: with SMTP id o1mr31287762pgl.282.1543352068111; Tue, 27 Nov 2018 12:54:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543352068; cv=none; d=google.com; s=arc-20160816; b=Z4JRjLo2z2uK8bm3hau1tps2VaI/yWsZxjnqa4ES1mWxnO1pz5mTNhrnJr8ExWB2zD QVEzJQ7W7gLYNHcpf1ys3QwFborDkHQFZgq6Rkj7CXOoA7IobM6e8VPGjcmHqSor6XoE DcUqUwpEswM1pfv+LBXmandnTl4fb3fHP5lbcdOeNjbhlEKkGu2242mYKw8A84WFIMNM qgaEVtsS+PnTaL37pIVUdP2iutP2OcmsDgeQGJJnM0H++CBvk0EG3nFDGiOI5HYW1X8G abn89sBDAGta6yMMeZ6jrTzC6aqieBNy1/Uu1WSw6AvSHneJKV6KT19ZozUslge2ht2j 92dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:dkim-signature; bh=jleRBnhIUtXDEVs1cSNBHTuNKV5RSkm07WmSgsaShd4=; b=Xiuuc5MRN8mMzCXJM0Cw4ZZrFGrYCoj4djTTcZluhs29OK7KicnBMYJeWbv6TsSmp8 n2+vJZm+SSLxg5BjtiGUJXJAF5fAU4EE65YL6T/7Bedb+/BqI8wRWCOjTjlLD6h2t5ZR YdeMSeyUOH9ZnUhQBrq4sO8jFS24wCCtqibMvEOkoJ7RobS+qDsQHoz0Cx0yIxOLiaEw T65bFL0tvUL1E7PO8cKO95DnpXd0NRzAYBwLOyiLT9Uri1KGn5bNqdYmg43IGrp+8Uis ifrBBXWrgX69FkYJHNmzN4fwoP5k+Ve49GrhYQEfzMWcfI6PH7qwrFoqOpM7IF4U8O1s +rUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b="SPIAc/5x"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="O/EJH9zq"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id j184-v6si5322180pfb.149.2018.11.27.12.54.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 12:54:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b="SPIAc/5x"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="O/EJH9zq"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jleRBnhIUtXDEVs1cSNBHTuNKV5RSkm07WmSgsaShd4=; b=SPIAc/5xZa4oE8 /PZwBIaM5cdIdSVUOIBqh+v4tVJsOJ0naa23ACgAgccYaGc6EVcNHNNYNKuiT9e2JUfnwq6DTusD6 Fp0Qnl8jU8ADndDQZeT9Guw+LMRv1QQbD4Mww2l+mTQbs478RaQaCRQ5ERfZ584vr+c3pd8IjwD/U mpyvzVCpCi/y885uQQI/NvEnPclW0S5G3udQOKVinNj553WnMzrSrWjFgbwrUJljJrZZDHyuh3l4f mZb7Gkt7SSHBcmqBT5rLbC6B6xnReW+VZ4U85tElxlKLH0JBD4xerLUUmR+sRZ4i60Ym53WIg8ocN aFRGfPB6fgzgurl7t4kg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRkNA-0007sI-Jl; Tue, 27 Nov 2018 20:54:20 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRkN7-0007rP-22 for linux-mtd@lists.infradead.org; Tue, 27 Nov 2018 20:54:18 +0000 Received: by mail-lj1-x243.google.com with SMTP id k19-v6so21338051lji.11 for ; Tue, 27 Nov 2018 12:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hdJFNJ9DXPfwPzK/fB9QhlU5ENVRXnCa/SVXN/8gfGE=; b=O/EJH9zq1r80lm4QhUnRxfUOCz/G0mQqY6+Wz2BZuJSdHnxr+OqI6VKcR1h5MUmuqa ILaV66LEut7AaQsc4LBy+EckmJCbcCSzjfb1JVVK51HyKXHgC6+LKQsTTZBPlG0WyiS5 UBs/hvQgsybqilrVKy8+gaAzKkvzOIKReEwDk= 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:mime-version :content-transfer-encoding; bh=hdJFNJ9DXPfwPzK/fB9QhlU5ENVRXnCa/SVXN/8gfGE=; b=i4EZU8Ktk6O5+j/U+AJ5WEGgsiYQFU2DOWNYyDWjevqqg2jWJcDBVii6f7J2e4R/XX w5PNZCWRflaAY4YDDtZJCUZAVGR0gtr/gaN+GqKQ4P0Sby7GvEDU4D4Z1jlImLWygK7h tOgbbt5XxfeSxfM5VXE3G2HMJk4ACCDk3NTHVTY8SSF8cvTx6GZ54aDcIxmm+Z0yYhwy A71PeGNNJJ/80EG7zyu7nb3hosmO2BqlWH+5pGMr2J+DUPecXVy2IRX3WtFLrVqdJtOx 4jyUS4uXiUAJdw15jQqQVLnsYNF4a+UwfNLh+FfGH8+OglgK/JHx1VT53goYLPiE9Avt jwZg== X-Gm-Message-State: AA+aEWalzP1TCFrPJ/RoqPCcjEwbbkIvbS/vR/zASUu5XAjIK0X26zaV Ufw/kmdyuvmF+/YWNeTBBvf53g== X-Received: by 2002:a2e:9603:: with SMTP id v3-v6mr18075221ljh.15.1543352043671; Tue, 27 Nov 2018 12:54:03 -0800 (PST) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id k3-v6sm784625lja.8.2018.11.27.12.54.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 12:54:02 -0800 (PST) From: Linus Walleij To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH 1/2 v3] mtd: maps: Leave assigned complex mappings Date: Tue, 27 Nov 2018 21:53:57 +0100 Message-Id: <20181127205358.32502-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181127_125417_094971_BCD9397C X-CRM114-Status: GOOD ( 17.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The simple_map_init() may need to be called with some function pointers already assigned for complex mappings, just bail out if complex handlers have already been assigned. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Move check for pre-initialized simple map into physmap-core.c ChangeLog v1->v2: - Rebase on latest MTD development branch - Use a new approach as the code changed under me --- drivers/mtd/maps/physmap-core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.19.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c index e8c3b250d842..ecca7784de06 100644 --- a/drivers/mtd/maps/physmap-core.c +++ b/drivers/mtd/maps/physmap-core.c @@ -514,10 +514,16 @@ static int physmap_flash_probe(struct platform_device *dev) err = physmap_addr_gpios_map_init(&info->maps[i]); if (err) goto err_out; - } else { - simple_map_init(&info->maps[i]); } + /* + * Only use the simple_map implementation if map hooks are not + * implemented. Since map->read() is mandatory checking for its + * presence is enough. + */ + if (!info->maps[i].read) + simple_map_init(&info->maps[i]); + if (info->probe_type) { info->mtds[i] = do_map_probe(info->probe_type, &info->maps[i]); From patchwork Tue Nov 27 20:53:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152171 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp257029ljp; Tue, 27 Nov 2018 12:54:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/XB/LpGUNf06E3nEmD5BGhE8bwQXVFZBXy8W4W86q0w2TGQMHn/sqLiv008RrPDpZg1fH65 X-Received: by 2002:a65:55ca:: with SMTP id k10mr30346244pgs.448.1543352073912; Tue, 27 Nov 2018 12:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543352073; cv=none; d=google.com; s=arc-20160816; b=GT0oXToFTkgqrsa3SRUdFn9GFuKf3gOTqKS/0lUN4XDDiZvOJtvUyyPWDDLVYNwUf9 wqDeOFRcErd49hu/E0u9uSnzJKOkWKaSjG0QCo30VGCrsdpaF17HFnCq6vDRhMO3Re7I DBi9QbOgLG/Iep1cepUAiiM+lEMnTRbKjNTzy9wNIgJpftEtJBPtEQpsqiggEKIBY5Zk TB+Pxnvj59gHnONgRas0jWJPpeDGe2QmH12jewroHzIvSM0Kgas9OsO/Q2TEaODNHQRe FBVChQ//V38jbp80jOIHfeapPR/uEGKneVsnKD5zGon/SbaqchxVvNEp3eILoR39j+ZE IkUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:dkim-signature; bh=OjrFt6beQwoZDwCfVJllJwukzcnXsxlgtREw7bAMNqo=; b=VnGHMIfX5IFYesfqCbt0WSmA96VHeH8zsWnQ15/dFYWS9kQhoAtf9tOXAFbEYhwNAR irUote9ANQTDGLJZ5nbqQWp0GOEMy22xh3ehC+ACVW/odh/jtTVJGOmvPGatzHUmQPdJ 8/RuXw2bzwmfCwd7K0Ivd0DPB40iobwkLGmqcrh6tNI+2dvGys2+OAQzPtIjHrj+hEEU lrbmbBrkqpahtTC3nIIvMZHlBJ/tMUkXJM/J7r157HjYbUuuvn6qSbffeACVmFdFBd4U DeE7cQCfrBTPSZIL22djkA+DDwF/2sA2MNYduxlxAj/F4AQbTyoPf3AGX+2eAYEpn1yb x9gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=ja8OFntG; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WtQmbvp4; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id s5si4755058pgl.481.2018.11.27.12.54.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 12:54:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=ja8OFntG; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WtQmbvp4; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OjrFt6beQwoZDwCfVJllJwukzcnXsxlgtREw7bAMNqo=; b=ja8OFntGGzNxSf 8jI07Kv098PQemJEQJz3TAn1YrIH8UYbbBeqCWuMLL8m+vIhrM9xVSL1+uHBX2hNFkbgjmsQ6AE0S Nt8Z9eOoV8ntScDvpwe+jMAfW/NiHs4n5HaL1ZePp6TqH4bh+6y/MUximHOaeNrjLArfiAYUpZaLj nL3YjyKXGmNGeTB2gDHHYrCQUxJ+HYUcibaLQi9HIwttKL/F8J92CntdfUTM0xx4lFH1gbATxecHg MFnTg9lRnyZfZk3yWymT/jk/bxey84Y126usPGebNhcVrQA7b6IPYwZtcqHNnNAiGyN8NFQkPOkTG c5/0c7vXBuZZwW6pr7HQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRkNI-0007zF-DH; Tue, 27 Nov 2018 20:54:28 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRkN8-0007rR-3m for linux-mtd@lists.infradead.org; Tue, 27 Nov 2018 20:54:19 +0000 Received: by mail-lf1-x141.google.com with SMTP id c16so17653596lfj.8 for ; Tue, 27 Nov 2018 12:54:07 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=2jzhAZFhqgA/ua3H4fs8vEqNhOKN2TSv+25LA3ws/8E=; b=WtQmbvp45XpRZ16egbdMoHPxxBKuf+QZodXbxU7MLTGUQveDveqhRLXz1hjGL0mSoE OSLB005BEDnYl+/pNaubKKozFgaJJrzEa6EEBzSlxZ5dotsd6cDo6QX9XB107QRQsSfi hQrDEZ4g2aaCSrwqA8C7mt01wcBvzEenQNi+4= 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:mime-version:content-transfer-encoding; bh=2jzhAZFhqgA/ua3H4fs8vEqNhOKN2TSv+25LA3ws/8E=; b=KGNb/5WaxBUUHM+hK9d9sj4VpGHpHswuRrWNYtYTKheV6d7g6A2bDeBolE80CB++a+ ChGz0RJhyyVsP9bWWakSf8K9MDegB9Q2TzNDayiDah1pn0s2Cdee4T8SACDEn7AFLgkS 7toScxJVn8A2HDyi+PCDBjEQFs+ofHb4n7h//oBM0/eQcCB+9MX4Fe6CkEDkWy3W4r/u qAgin32IO1Wzne5A8NMejvFbVqK/G44tvm2gDx1+CcgYs1XwQ8bfO5gxplREglcY+eq0 FRV87Hpnz0UbZerF0nuqG3/tOdoze+Vgj9u18hU78+Li3ZyjSDYXU9fzq7gzr+iLBhtY o7fA== X-Gm-Message-State: AGRZ1gL27bJE72A3A8DhOkhCmClgZS0JaYpqDslJE7ZddTzfmtLClbEj PuS5HlGhfTnss6U6xRh9csR8Kg== X-Received: by 2002:a19:4402:: with SMTP id r2mr19018402lfa.111.1543352045793; Tue, 27 Nov 2018 12:54:05 -0800 (PST) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id k3-v6sm784625lja.8.2018.11.27.12.54.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 12:54:04 -0800 (PST) From: Linus Walleij To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH 2/2 v3] mtd: physmap_of_gemini: Handle pin control Date: Tue, 27 Nov 2018 21:53:58 +0100 Message-Id: <20181127205358.32502-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181127205358.32502-1-linus.walleij@linaro.org> References: <20181127205358.32502-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181127_125418_149561_6022C6E2 X-CRM114-Status: GOOD ( 24.30 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:141 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org This enables the complex mapping for the Gemini and kicks in custom read/write functions that will wrap the existing simple functions in calls to enable/disable the parallel flash pins using pin controls. This is necessary on some hardware such as the D-Link DIR-685 where all flash pins are patched in/out at the same time, but some of the flash pins are in practice unused by the flash and have anyway been reused as GPIO. This concerns specifically CE1 on the Gemini. There is only one flash chip, so only CE0 is used, and the line for CE1 has been reused as chip select for the emulated SPI port connected to the display. If we try to use the same lines for flash and GPIO at the same time, one of them will loose: the GPIO line will disappear because it gets disconnected from the pin when the flash group is muxed out. Fix this by introducing two pin control states named simply "enabled" and "disabled" and only enable the flash lines when absolutely necessary (during read/write/copy). This way, they are available for GPIO at all other times and the display works. Collect all the state variables in a struct named struct gemini_flash and allocate this struct at probe time. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resend ChangeLog v1->v2: - Rebase on latest MTD development branch --- drivers/mtd/maps/Kconfig | 1 + drivers/mtd/maps/physmap-gemini.c | 110 +++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 1 deletion(-) -- 2.19.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 2edd8bcdbe1c..e0cf869c8544 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig @@ -88,6 +88,7 @@ config MTD_PHYSMAP_GEMINI bool "Cortina Gemini OF-based physical memory map handling" depends on MTD_PHYSMAP_OF depends on MFD_SYSCON + select MTD_COMPLEX_MAPPINGS default ARCH_GEMINI help This provides some extra DT physmap parsing for the Gemini diff --git a/drivers/mtd/maps/physmap-gemini.c b/drivers/mtd/maps/physmap-gemini.c index 1cf128a0526d..60775b208fc9 100644 --- a/drivers/mtd/maps/physmap-gemini.c +++ b/drivers/mtd/maps/physmap-gemini.c @@ -10,9 +10,11 @@ #include #include #include +#include #include #include #include +#include #include "physmap-gemini.h" /* @@ -44,6 +46,82 @@ #define FLASH_PARALLEL_HIGH_PIN_CNT (1 << 20) /* else low pin cnt */ +static const struct of_device_id syscon_match[] = { + { .compatible = "cortina,gemini-syscon" }, + { }, +}; + +struct gemini_flash { + struct device *dev; + struct pinctrl *p; + struct pinctrl_state *enabled_state; + struct pinctrl_state *disabled_state; +}; + +/* Static local state */ +static struct gemini_flash *gf; + +static void gemini_flash_enable_pins(void) +{ + int ret; + + if (IS_ERR(gf->enabled_state)) + return; + ret = pinctrl_select_state(gf->p, gf->enabled_state); + if (ret) + dev_err(gf->dev, "failed to enable pins\n"); +} + +static void gemini_flash_disable_pins(void) +{ + int ret; + + if (IS_ERR(gf->disabled_state)) + return; + ret = pinctrl_select_state(gf->p, gf->disabled_state); + if (ret) + dev_err(gf->dev, "failed to disable pins\n"); +} + +static map_word __xipram gemini_flash_map_read(struct map_info *map, + unsigned long ofs) +{ + map_word __xipram ret; + + gemini_flash_enable_pins(); + ret = inline_map_read(map, ofs); + gemini_flash_disable_pins(); + + return ret; +} + +static void __xipram gemini_flash_map_write(struct map_info *map, + const map_word datum, + unsigned long ofs) +{ + gemini_flash_enable_pins(); + inline_map_write(map, datum, ofs); + gemini_flash_disable_pins(); +} + +static void __xipram gemini_flash_map_copy_from(struct map_info *map, + void *to, unsigned long from, + ssize_t len) +{ + gemini_flash_enable_pins(); + inline_map_copy_from(map, to, from, len); + gemini_flash_disable_pins(); +} + +static void __xipram gemini_flash_map_copy_to(struct map_info *map, + unsigned long to, + const void *from, ssize_t len) +{ + gemini_flash_enable_pins(); + inline_map_copy_to(map, to, from, len); + gemini_flash_disable_pins(); +} + int of_flash_probe_gemini(struct platform_device *pdev, struct device_node *np, struct map_info *map) @@ -57,6 +135,11 @@ int of_flash_probe_gemini(struct platform_device *pdev, if (!of_device_is_compatible(np, "cortina,gemini-flash")) return 0; + gf = devm_kzalloc(dev, sizeof(*gf), GFP_KERNEL); + if (!gf) + return -ENOMEM; + gf->dev = dev; + rmap = syscon_regmap_lookup_by_phandle(np, "syscon"); if (IS_ERR(rmap)) { dev_err(dev, "no syscon\n"); @@ -91,7 +174,32 @@ int of_flash_probe_gemini(struct platform_device *pdev, map->bankwidth * 8); } - dev_info(&pdev->dev, "initialized Gemini-specific physmap control\n"); + gf->p = devm_pinctrl_get(dev); + if (IS_ERR(gf->p)) { + dev_err(dev, "no pinctrl handle\n"); + ret = PTR_ERR(gf->p); + return ret; + } + + gf->enabled_state = pinctrl_lookup_state(gf->p, "enabled"); + if (IS_ERR(gf->enabled_state)) + dev_err(dev, "no enabled pin control state\n"); + + gf->disabled_state = pinctrl_lookup_state(gf->p, "disabled"); + if (IS_ERR(gf->enabled_state)) { + dev_err(dev, "no disabled pin control state\n"); + } else { + ret = pinctrl_select_state(gf->p, gf->disabled_state); + if (ret) + dev_err(gf->dev, "failed to disable pins\n"); + } + + map->read = gemini_flash_map_read; + map->write = gemini_flash_map_write; + map->copy_from = gemini_flash_map_copy_from; + map->copy_to = gemini_flash_map_copy_to; + + dev_info(dev, "initialized Gemini-specific physmap control\n"); return 0; }