From patchwork Mon Nov 12 21:07:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150878 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3612417ljp; Mon, 12 Nov 2018 13:08:20 -0800 (PST) X-Google-Smtp-Source: AJdET5fd0X9O1cwhGljyve4b2zOL62kGxM0kiX1Wpo7xvaH2+DjllkpkPjNXlljTg4/XKXW3/8HQ X-Received: by 2002:a62:32c4:: with SMTP id y187-v6mr2427667pfy.4.1542056900347; Mon, 12 Nov 2018 13:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542056900; cv=none; d=google.com; s=arc-20160816; b=HmBkY9gLqBswf7QhBFVl8QQGczHb2Rtsp9Vuq3izJjdcSW6VNy4emtSJvH/JU2QHYr 9pXeEBvjYoXaWlHbUpgmlS/PM75yr5pyyM0O4EJNrjUj7Dq6210WbOKWAVzzL3x9gUkQ w2XCByiD8TohmmgMORLDA6okRWkE7fsAQr+eSxGVPdWykwS1DPALjoijcRh/xfHJ0Br5 iu0/c+ijnxGFyLlu+x07i3eJFE2bKwM2nym5knBTulGgv/q0eYku/k3QSXLu7R9osPvs s526zEwXEXpiz7qYrhXcYBV/WnQXvZ2sqT2wsmYR0KoxwcJVEtDwDcAhGuLB3ehDgJ1U Gxwg== 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=2Y18NbfOitvtAkcW4uY5FsoJ4OYvynSnh15bKWX0e2E=; b=BbmTCP+vekXyyhrgFQnCVFGV/dZkjxA/R7ipx1r4wLBNaRoKYB3IUDPVCXydq0LxP0 U0P7374x3vumczoMLQ2P4t28YM6aGovJBSlfmaGMfGNVMkJ3gaqnSkGvGBIjXyOGwi74 5fVwud67FQgK35kiPBl9CPHjFUbzlh+g5OL6Owb8ajAFTY4GBTUdqNtd+atCylBOhF5R 5zWVYPjTNvXmm8XXlBl17kO8rjUqrPLFiNl1zyl3eYVspkv4fd+k3mTDOUMpTYMbfRwt 5Do0FoUWuutsYoQMQmX9qj3xlKb0KDHO83FmpaV5Q3TpYXJMVMrPjLDyGin3sBOvdFr3 fIww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=MIRbECBt; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g251d1Xq; 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 c7si4408832plz.118.2018.11.12.13.08.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 13:08:20 -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=MIRbECBt; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g251d1Xq; 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=2Y18NbfOitvtAkcW4uY5FsoJ4OYvynSnh15bKWX0e2E=; b=MIRbECBtsBznS0 oq/blgfCKFktSAcc1bZYf+9QjU9JDvfJzYbzOLwFaY1UUIJI4yy/g5xmrCPpt2VqrTDyMUkqF90l1 mNrn61rQTY+rUEl1g4wP+wwC44/NhwXNtRfgwbO40iMAdjb7bk3utGxHMYM1FMTrauVozhtDauJLi Z1e8Pt4MM9aL6n3Ef0KMy4jgtfv96rUaWYhJ2Sthpdr2LO3UYrAJLOXUv5L5q07gfTYM8iWXJYvyu 2s15xZeqaHvC36OTdM9BXlqqkjSLAWmHczBsaYjX2GumhKge6aPvRjYSvKHRVJ+JNeWoAsraSLOlu 2IBvDyev2DdbtqQgh9Rw==; 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 1gMJRF-00054U-K4; Mon, 12 Nov 2018 21:08:05 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMJQx-00053s-CR for linux-mtd@lists.infradead.org; Mon, 12 Nov 2018 21:07:48 +0000 Received: by mail-lf1-x142.google.com with SMTP id p86so7223954lfg.5 for ; Mon, 12 Nov 2018 13:07:36 -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=koiI/1PHULaymWnfoLRpn9RaWBQbhzFzLBZrC2fVCK0=; b=g251d1XqUOdzx1CNyn+UAIaOQX4Hd5tV3dj0h9dNDgNLe2oLgbJk1A/6fi4S4kfIhE 5M+sE+ZwGemSd8qHAxP4s2Wt513c1zl06MCWnGjy/m6w4LVsekJZI1N/a+KBvQ2sm8pz ISSPAbTIqQvGUtCqVeQL667Ct4MdI5Q4Ct3Bk= 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=koiI/1PHULaymWnfoLRpn9RaWBQbhzFzLBZrC2fVCK0=; b=Ztf17LU7I4Fo+lIvsGb/mXt6CZSNCw/M6Cz7PzElafy8CjbzBpg78wBtAFI8jlyVrG ToaDOm6eQ9AFTGC1bfbmdq2q3gMsKCS0BR1pdrOSdBRzbUADCzP6zjV0MhTA7yBT+fty PpRh84f8EPbjH1ASQ+DpoW1fGkmclnt4HMjbnxu76IT8TftiarWLmgYCYGFA0bNJkLHl lDmQGqqg0kp3j9BlkS/WxoxGtQExcedShG3TNbImrD+BC5vtArnYWZp6H3Lo1BxcNfLa 8lbEphBtdLuxv6+eM3VXc5V/McVdNQgkfGZCsCeSKWAPC8EZK2nU3SY2hjpIAaJfkt0U bMjg== X-Gm-Message-State: AGRZ1gL/ldDX9MO9zquOHAaWxYr8Vm864Pfu12WT5ygL7rgLy+166edH 8r43DQn/HUyseCW9g1/R21cXTg== X-Received: by 2002:a19:d5:: with SMTP id 204mr1442119lfa.116.1542056854836; Mon, 12 Nov 2018 13:07:34 -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 q30sm3325736lfi.94.2018.11.12.13.07.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 13:07:33 -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 v2] mtd: maps: Leave assigned complex mappings Date: Mon, 12 Nov 2018 22:07:28 +0100 Message-Id: <20181112210729.23580-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-20181112_130747_445483_F267FBBC X-CRM114-Status: GOOD ( 13.68 ) 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:142 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -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 -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 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 v1->v2: - Rebase on latest MTD development branch - Use a new approach as the code changed under me --- drivers/mtd/maps/map_funcs.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.19.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/maps/map_funcs.c b/drivers/mtd/maps/map_funcs.c index 3f268370eeca..60e132293e1c 100644 --- a/drivers/mtd/maps/map_funcs.c +++ b/drivers/mtd/maps/map_funcs.c @@ -31,6 +31,10 @@ static void __xipram simple_map_copy_to(struct map_info *map, unsigned long to, void simple_map_init(struct map_info *map) { + /* Complex map functions already assigned */ + if (map->read) + return; + BUG_ON(!map_bankwidth_supported(map->bankwidth)); map->read = simple_map_read; From patchwork Mon Nov 12 21:07:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150879 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3612460ljp; Mon, 12 Nov 2018 13:08:23 -0800 (PST) X-Google-Smtp-Source: AJdET5dY/Yhhka68Z63KppBfm5bxWTXDRarVH+87NsKHWn0AUUrJnnTq7vsKr+yOt6+HCivmaqMo X-Received: by 2002:a17:902:7e0d:: with SMTP id b13-v6mr2390551plm.246.1542056903046; Mon, 12 Nov 2018 13:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542056903; cv=none; d=google.com; s=arc-20160816; b=BT8UkPOW220wfZkpXmU8kzGcQi55DN44KT3phF4zKZ9zA8TOYOcwwisQ0L3mVNxHH7 EpPe/M3V4BS+WAlIzwuK2/4sMi5NVnQNDbXhdvmV2S1ce+Wxcs0qz9eU1orSG4nlzn+D 54atXOikpBqzdEBXKRCSTd3S+iluPxSLC8o9qXXUSG8SqvhiiHlvlFXogsjkBBbMDFAE lEpBhjYt7Uk2qxEPMT3xsHgXrYlveYmWyN+y69LLFao39G1K+7OgZDB6G4tdwHrl1Dqq b6yMCBHR73WPZOwneT5eKQU5y7bSdb2s+WiPLncED0+2Fyaw78GYKiHPWk+brrFCg9Qo F/bQ== 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=fvbMCFlnCE9JoLj7ONRvy2SJLVkjCGodFTa2olVHszI=; b=wKcrx4laOuErjE/NNMsQ76f4SmdM4IUNCs0w7zoICEbGfX55sgnwyZMnCyU0mFwQxl RWUHXmaKMaa0tA2YJFrGIUk1ekuVmgU/bPRL5LfPE8v/3J0v74vMsg5ORDMPUyqEkn+i ybPQXlmIUhdLrf5t7PXmbdbkE7xrT6S9DyC5MXGAoCYD2gnWkq6cuDiVI/8kAA3SjylQ WiYRyRuep4LDmTtspWIn22V1U8uzi+nOY/OyNHMGfit/LaJIZSxQjzx/b9frFp0jVa81 cJ7TWvSlUA1BFn7DSOI9RwQ0khiHwPvUd2Tq2Xqmq2OKpw2bAd06kvQ2xsqICbR5iEap zBlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=THhTLrCa; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jdSQUFBm; 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 n11-v6si17935597pff.39.2018.11.12.13.08.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 13:08:23 -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=THhTLrCa; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jdSQUFBm; 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=fvbMCFlnCE9JoLj7ONRvy2SJLVkjCGodFTa2olVHszI=; b=THhTLrCaPzj4Pc DcYLNMbPIFC9cOPS7LoduerRIUuowWfNlJPgebabPWP3okfDqgGIEgDego4htq1AEPv2Cigzo5wmO G7MlReNB3akpk/hXkv1aYkMc9ehCTU0V2G6HMbkI24gEPA4VW9Lt3kMYn2/hr5KA1Ly6eu3fiq+xd XA3PMlB/KXJkUtT2mzUIWCRGFRlNvKcbMG8SUONkixOvfxK/cMD3ytM8mPWdJTLqhAoMPjYse7R// ibYdlrLu1XT/35L2eeAh1Zl/5E5iyxVm4GzG5/npRilyo/upQq8FXSvP2pYTvT6PzmlgDQXkgrXgH zPfP3+DfyCZ6t/W6xI+w==; 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 1gMJRK-0005B1-In; Mon, 12 Nov 2018 21:08:10 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMJQz-00053t-NL for linux-mtd@lists.infradead.org; Mon, 12 Nov 2018 21:07:51 +0000 Received: by mail-lj1-x241.google.com with SMTP id z80-v6so8879423ljb.8 for ; Mon, 12 Nov 2018 13:07:39 -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=gLsx+y+h0WoKdNSDyNZCUMAvHC02sR+LHZCyFbEesaM=; b=jdSQUFBmr82nmZZf5KaWGQNmtu7A5MmUBTDtvLunf9BsDLIaPDKsVPWJnBRsuK4rW4 YgVOkg1XVHwy74Z8GYdpMdfC+Eopt1qMSYjwvzRa2mc6cxzp/8Jl4L12s7za70YoIVUR HDwM406Mebb2bidfaWWQ1lXnqk8HEPFjHzFtc= 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=gLsx+y+h0WoKdNSDyNZCUMAvHC02sR+LHZCyFbEesaM=; b=F2Or8gUE6h5qHr+paYlZlmiZErDjbZEo245eFdg1UCEqGc3yPVC/R5C81ysuOi1hy0 28RRKZK7u1aBVTiXkmZsCxk38jCEjwWPYJHP+P52N8UAiExSDBMWcFIZcRel6BdC75ZM H/7le94M9oQ7rfgQaDnH0seq5z+5uv/SSFZ161PQPaZFhTDB5n5ohgeoUuE8knnsUwTx +yJHOjywQbO5f7Se+1HrbrAu19DITN0c3PQjGFuOGe+YqZpS9mJptelBLjfW7rliuUIm vb6yyp4M/wrXP5Ruy8VtqDnaLS1TBb0fJdJijtLnK0RZ5Wey9b3PietMw3uQNU1GU5md /Gpw== X-Gm-Message-State: AGRZ1gIAndPhrPKWLvmzsnlTWYH04SUSTjmcsmSnDF9spthzZhU+qyOW Rk2xSZ4GsmkoFwOrLyV/FHSjqH61Fl5vLA== X-Received: by 2002:a2e:8605:: with SMTP id a5-v6mr1607597lji.145.1542056857629; Mon, 12 Nov 2018 13:07:37 -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 q30sm3325736lfi.94.2018.11.12.13.07.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 13:07:36 -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 v2] mtd: physmap_of_gemini: Handle pin control Date: Mon, 12 Nov 2018 22:07:29 +0100 Message-Id: <20181112210729.23580-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181112210729.23580-1-linus.walleij@linaro.org> References: <20181112210729.23580-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-20181112_130749_757262_6EC03119 X-CRM114-Status: GOOD ( 24.16 ) 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:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -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 -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 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 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; }