From patchwork Mon Aug 6 22:29:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10557989 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 602F813AC for ; Mon, 6 Aug 2018 22:30:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E6502986E for ; Mon, 6 Aug 2018 22:30:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4282429877; Mon, 6 Aug 2018 22:30:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E47FB2986E for ; Mon, 6 Aug 2018 22:30:12 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=IF/KgrrOxQYl2gxxuMfol8nu4/vYyu6FYaSUalSoGnc=; b=TiPz7bphXnkLw6i1v8VLYPNUE7 0TP1GxnRouvswwZjJHqWdDIxQiD+zZhMYB/qLeBDyueB7DWxOBawtRNIMuXGQu2A5XCsYA6RbKqG+ wn8NrAL6NWq6dzSbrzOkv702bP/bQzuJJTvTMRwPg+xEsoRxFkVKa5hEH6kNdyVIyU9XO7jDMZ0VP jju5BDTQ+/pNrXD8bqtdurHJQzePgkCQkOJTA1l+M73GGuuBSE6mQ9VwTGMU2+2NYI2W1fIz5nOMo 3XDRwBKeW2fHSkE1ZCzTiuizDv+KmBUy0AxGFGOl5iDv9bUPRQU9Tc4j6ht5ATLs6WkglwOgZrW0U cu3eas5A==; 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 1fmo0s-000613-VN; Mon, 06 Aug 2018 22:30:06 +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 1fmo0V-0005Qn-Nw; Mon, 06 Aug 2018 22:29:45 +0000 Received: by mail-lj1-x243.google.com with SMTP id v9-v6so11861857ljk.4; Mon, 06 Aug 2018 15:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y+2LyEwByW4zxwwsLlaC1XUGA47kDs2qqVs9Rm/IVKw=; b=VVRKU1FkDhRKCs/bp0gKnclYBzSXh+B6bnxWekrUKOTBVYmu0IRVRSNbSk39oBMtbX chWoCByBdLQ6EH+iBbMrgv4mdt28IbSSr4Xbprbu1/rT5k7GkpZI27jYQ1NcFEF5jHPw FlbKG+QOKca8kHcPqPtbLf7z+oxH766qCjcYF2H0mA/IBM270yEM2SXoicAVOr4+NV4A +Ht2oWIzrwitqQXgSCoZD1Zk5iY6TEAb0pWVLC4FkD0YJrvb49NXo/eMl2dSCL/1hMVI QI9B1X3A4X8WH1PIlrBqt2oCZjaV3rQsPbJWAPtoGjnoIJvBewGXctM9xz8tRyETC4h8 nuJw== 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=Y+2LyEwByW4zxwwsLlaC1XUGA47kDs2qqVs9Rm/IVKw=; b=WPnFQCj8hvnINSNYJW7aC0oTF/1b2KaNkvlEj8sSvAq6MM0Th4WYcbdzqZzQ+Ebz/A eZarM9z6mftPSvGAQk/I8oH8EOChAF+Gvw6Nr33lKp2mpiUJWLkVRDZJLQnvbN3HR4jF cpXEhyndefDJ2PatNW27Ze5zXOjZ6WEq+a1/UELOdtHLfhY1mMQolKmK1mJrXfaRVvXt Pmgf8ouCokv42QqZOUp9GKWnx6uS5sLjbDwMHeRW8vgmTxPoSoSyzurU6b3fpQaDtWuQ Zrkk76L/NRs6iWqxqWbGXl83s2kRZMdreCMQnbQ7lfWdSkssVMkT16Y6Lf2DQn2Lwti2 qSbg== X-Gm-Message-State: AOUpUlFnDsexTqPyDI+5B6zsGM9IZrQeFOOvivi/YsB1KRxPslnSyhZ6 93Xg8DIlXTvs9mEXLt7XAkI= X-Google-Smtp-Source: AAOMgpdFORBMvg9yWcrZM5IFEvZ3StNHD23q85ghgy1e+ZYuXriIDAmi9G3G2iV7WMKXEf0JQaoMIw== X-Received: by 2002:a2e:63c5:: with SMTP id s66-v6mr14441401lje.23.1533594568957; Mon, 06 Aug 2018 15:29:28 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:28 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 01/12] mtd: rawnand: ams-delta: Assign mtd->dev.parent, not mtd->owner Date: Tue, 7 Aug 2018 00:29:07 +0200 Message-Id: <20180806222918.12644-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152943_782273_4540DF85 X-CRM114-Status: GOOD ( 14.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Fix missing mtd->dev.parent assignment and drop useless mtd->owner. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon --- drivers/mtd/nand/raw/ams-delta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 2a8872ebd14a..af313c620264 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -162,7 +162,7 @@ static int ams_delta_init(struct platform_device *pdev) } ams_delta_mtd = nand_to_mtd(this); - ams_delta_mtd->owner = THIS_MODULE; + ams_delta_mtd->dev.parent = &pdev->dev; /* * Don't try to request the memory region from here, From patchwork Mon Aug 6 22:29:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10557997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B85DA1390 for ; Mon, 6 Aug 2018 22:30:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A72512986E for ; Mon, 6 Aug 2018 22:30:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B30C29881; Mon, 6 Aug 2018 22:30:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F26F42986E for ; Mon, 6 Aug 2018 22:30:37 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=f8qBzgN8xkRNkhLIqFrjyZw/kLVFAy19FBXsDXZDcuo=; b=sA0fKZ5ktOXndqjuMlO3lxPoCM eqCihens706f/qfuB8XKwWHCEkncYYYsvbExMHK2zATsF7A7kD4R7muLvFX9zU5roMJzVjLaAmtcX y1aXOlx/WbeDF1AoRkRbQIB3a3nPjIpI9M0LdyTW0kvBIZG03CAPzH452oaSuprPv24HcFSmDUC8f 3DHyd8Pu9EVLgttr0mG2nXlCB2h4i1Bf5yaNUyODBtc8Z1GP8WWEMM0/wFnGY9ZTSomSObv4ZNeVC LYZR0hOmHTzr9sr8AHHyxvKhmFMAY4gu/gkc7fH2LvhDEJkmYngSfVWQI755sapoZoEZh2nqjE7DM UnJNtaIw==; 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 1fmo1H-0006gz-0m; Mon, 06 Aug 2018 22:30:31 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmo0X-0005Qo-Ms; Mon, 06 Aug 2018 22:29:50 +0000 Received: by mail-lj1-x242.google.com with SMTP id l15-v6so11850409lji.6; Mon, 06 Aug 2018 15:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zd3kEAiZ7mszPNOyJOnF5cmgoqqIeUq9AivweCn5fTk=; b=lGp59bsYE+aBAfOjWJbzm9g57ekVfHo8Nt5TvBLins74QYXQ0UA71Csg2UBADGrR7a qX0FQWrOtlD+S8o9gbSo1uKikoEvAWfcbMGrbnYopgYXfi3B8ptiH5fLyf4oRdEYujvB n8GK/Xc6FvWYDoB1kTfDdhfoN/BUraYQvRRxdwl8WVdqL6lqJwmxAtfuyXkz4KIKWJvq Aba9v2u2UpKY6hll1dnS00eq3Jmuo9Z1g0fTupqoIZjSCk8TWee93usrIzYqulSWsonl AgulUan/giffOhupMPchQGd01ect8sE2JijUzG63Bm4D6RQTmXpdif7tnBhT1vu4BmU+ D4rQ== 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=Zd3kEAiZ7mszPNOyJOnF5cmgoqqIeUq9AivweCn5fTk=; b=mHABT9bLKfDjyoFOLuPKduQ9ZPC5vymQaukaffL+RrD6El9NVXS1Jgdskjutg4cISm hamQdle+CyCsoLiElvAezZfzjMuRp6e4dvVGkzfsHhwCXZbQgoHT2VcBX53PpURfXx5d UxUhj1xNImbLg6M6zVJ77d9ybPTZWGc9QcC3lAyBTseK4EFIuaBElzm3e7EbrUnbtFl/ sn71mhHEdbiDK3eUTmZho8aBXsPUr9jiNk2GpJarEMHTmGNYJDHVzXnHsABDnHTfWoN1 JTLUC3BQL/zM678qBr+oRBisGYiAi8rcb2lsH7VRbDC3g1A5EPaV7cZ8b9yrwVqXS0CP ybbw== X-Gm-Message-State: AOUpUlF9clQZsTdryNJTFbB+Th7kxhSjpgoSOyxrFCpDkqTTKBoFKbpS uLr9cNvwEpRQX9amTf/5fdY= X-Google-Smtp-Source: AAOMgpdIOVkqRRGOjgvjo7z5QXF/qtNzLpqiEZwK0pbgZl1Y+wmOaTTGjsiDN+rCuqwyw6DIxJ/2cA== X-Received: by 2002:a2e:4e02:: with SMTP id c2-v6mr13227006ljb.108.1533594570462; Mon, 06 Aug 2018 15:29:30 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:29 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 02/12] mtd: rawnand: ams-delta: Use private structure Date: Tue, 7 Aug 2018 00:29:08 +0200 Message-Id: <20180806222918.12644-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152946_050672_ABEF67AE X-CRM114-Status: GOOD ( 18.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a driver private structure and allocate it on device probe. Use it for storing nand_chip structure, GPIO descriptors prevoiusly stored in static variables as well as io_base pointer previously passed as nand controller data or platform driver data. Subsequent patches may populate the structure with more members as needed. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon --- drivers/mtd/nand/raw/ams-delta.c | 126 +++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 57 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index af313c620264..48233d638d2a 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -34,14 +34,18 @@ /* * MTD structure for E3 (Delta) */ -static struct mtd_info *ams_delta_mtd = NULL; -static struct gpio_desc *gpiod_rdy; -static struct gpio_desc *gpiod_nce; -static struct gpio_desc *gpiod_nre; -static struct gpio_desc *gpiod_nwp; -static struct gpio_desc *gpiod_nwe; -static struct gpio_desc *gpiod_ale; -static struct gpio_desc *gpiod_cle; + +struct ams_delta_nand { + struct nand_chip nand_chip; + struct gpio_desc *gpiod_rdy; + struct gpio_desc *gpiod_nce; + struct gpio_desc *gpiod_nre; + struct gpio_desc *gpiod_nwp; + struct gpio_desc *gpiod_nwe; + struct gpio_desc *gpiod_ale; + struct gpio_desc *gpiod_cle; + void __iomem *io_base; +}; /* * Define partitions for flash devices @@ -71,26 +75,28 @@ static const struct mtd_partition partition_info[] = { static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) { struct nand_chip *this = mtd_to_nand(mtd); - void __iomem *io_base = (void __iomem *)nand_get_controller_data(this); + struct ams_delta_nand *priv = nand_get_controller_data(this); + void __iomem *io_base = priv->io_base; writew(0, io_base + OMAP_MPUIO_IO_CNTL); writew(byte, this->IO_ADDR_W); - gpiod_set_value(gpiod_nwe, 0); + gpiod_set_value(priv->gpiod_nwe, 0); ndelay(40); - gpiod_set_value(gpiod_nwe, 1); + gpiod_set_value(priv->gpiod_nwe, 1); } static u_char ams_delta_read_byte(struct mtd_info *mtd) { u_char res; struct nand_chip *this = mtd_to_nand(mtd); - void __iomem *io_base = (void __iomem *)nand_get_controller_data(this); + struct ams_delta_nand *priv = nand_get_controller_data(this); + void __iomem *io_base = priv->io_base; - gpiod_set_value(gpiod_nre, 0); + gpiod_set_value(priv->gpiod_nre, 0); ndelay(40); writew(~0, io_base + OMAP_MPUIO_IO_CNTL); res = readw(this->IO_ADDR_R); - gpiod_set_value(gpiod_nre, 1); + gpiod_set_value(priv->gpiod_nre, 1); return res; } @@ -123,11 +129,13 @@ static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) { + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); if (ctrl & NAND_CTRL_CHANGE) { - gpiod_set_value(gpiod_nce, !(ctrl & NAND_NCE)); - gpiod_set_value(gpiod_cle, !!(ctrl & NAND_CLE)); - gpiod_set_value(gpiod_ale, !!(ctrl & NAND_ALE)); + gpiod_set_value(priv->gpiod_nce, !(ctrl & NAND_NCE)); + gpiod_set_value(priv->gpiod_cle, !!(ctrl & NAND_CLE)); + gpiod_set_value(priv->gpiod_ale, !!(ctrl & NAND_ALE)); } if (cmd != NAND_CMD_NONE) @@ -136,7 +144,10 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, static int ams_delta_nand_ready(struct mtd_info *mtd) { - return gpiod_get_value(gpiod_rdy); + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); + + return gpiod_get_value(priv->gpiod_rdy); } @@ -145,7 +156,9 @@ static int ams_delta_nand_ready(struct mtd_info *mtd) */ static int ams_delta_init(struct platform_device *pdev) { + struct ams_delta_nand *priv; struct nand_chip *this; + struct mtd_info *mtd; struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); void __iomem *io_base; int err = 0; @@ -154,15 +167,16 @@ static int ams_delta_init(struct platform_device *pdev) return -ENXIO; /* Allocate memory for MTD device structure and private data */ - this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL); - if (!this) { + priv = devm_kzalloc(&pdev->dev, sizeof(struct ams_delta_nand), + GFP_KERNEL); + if (!priv) { pr_warn("Unable to allocate E3 NAND MTD device structure.\n"); - err = -ENOMEM; - goto out; + return -ENOMEM; } + this = &priv->nand_chip; - ams_delta_mtd = nand_to_mtd(this); - ams_delta_mtd->dev.parent = &pdev->dev; + mtd = nand_to_mtd(this); + mtd->dev.parent = &pdev->dev; /* * Don't try to request the memory region from here, @@ -177,7 +191,8 @@ static int ams_delta_init(struct platform_device *pdev) goto out_free; } - nand_set_controller_data(this, (void *)io_base); + priv->io_base = io_base; + nand_set_controller_data(this, priv); /* Set address of NAND IO lines */ this->IO_ADDR_R = io_base + OMAP_MPUIO_INPUT_LATCH; @@ -187,14 +202,14 @@ static int ams_delta_init(struct platform_device *pdev) this->read_buf = ams_delta_read_buf; this->cmd_ctrl = ams_delta_hwcontrol; - gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", GPIOD_IN); - if (IS_ERR(gpiod_rdy)) { - err = PTR_ERR(gpiod_rdy); + priv->gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", GPIOD_IN); + if (IS_ERR(priv->gpiod_rdy)) { + err = PTR_ERR(priv->gpiod_rdy); dev_warn(&pdev->dev, "RDY GPIO request failed (%d)\n", err); goto out_mtd; } - if (gpiod_rdy) + if (priv->gpiod_rdy) this->dev_ready = ams_delta_nand_ready; /* 25 us command delay time */ @@ -202,66 +217,64 @@ static int ams_delta_init(struct platform_device *pdev) this->ecc.mode = NAND_ECC_SOFT; this->ecc.algo = NAND_ECC_HAMMING; - platform_set_drvdata(pdev, io_base); + platform_set_drvdata(pdev, priv); /* Set chip enabled, but */ - gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_HIGH); - if (IS_ERR(gpiod_nwp)) { - err = PTR_ERR(gpiod_nwp); + priv->gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_HIGH); + if (IS_ERR(priv->gpiod_nwp)) { + err = PTR_ERR(priv->gpiod_nwp); dev_err(&pdev->dev, "NWP GPIO request failed (%d)\n", err); goto out_mtd; } - gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_HIGH); - if (IS_ERR(gpiod_nce)) { - err = PTR_ERR(gpiod_nce); + priv->gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_HIGH); + if (IS_ERR(priv->gpiod_nce)) { + err = PTR_ERR(priv->gpiod_nce); dev_err(&pdev->dev, "NCE GPIO request failed (%d)\n", err); goto out_mtd; } - gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_HIGH); - if (IS_ERR(gpiod_nre)) { - err = PTR_ERR(gpiod_nre); + priv->gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_HIGH); + if (IS_ERR(priv->gpiod_nre)) { + err = PTR_ERR(priv->gpiod_nre); dev_err(&pdev->dev, "NRE GPIO request failed (%d)\n", err); goto out_mtd; } - gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_HIGH); - if (IS_ERR(gpiod_nwe)) { - err = PTR_ERR(gpiod_nwe); + priv->gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_HIGH); + if (IS_ERR(priv->gpiod_nwe)) { + err = PTR_ERR(priv->gpiod_nwe); dev_err(&pdev->dev, "NWE GPIO request failed (%d)\n", err); goto out_mtd; } - gpiod_ale = devm_gpiod_get(&pdev->dev, "ale", GPIOD_OUT_LOW); - if (IS_ERR(gpiod_ale)) { - err = PTR_ERR(gpiod_ale); + priv->gpiod_ale = devm_gpiod_get(&pdev->dev, "ale", GPIOD_OUT_LOW); + if (IS_ERR(priv->gpiod_ale)) { + err = PTR_ERR(priv->gpiod_ale); dev_err(&pdev->dev, "ALE GPIO request failed (%d)\n", err); goto out_mtd; } - gpiod_cle = devm_gpiod_get(&pdev->dev, "cle", GPIOD_OUT_LOW); - if (IS_ERR(gpiod_cle)) { - err = PTR_ERR(gpiod_cle); + priv->gpiod_cle = devm_gpiod_get(&pdev->dev, "cle", GPIOD_OUT_LOW); + if (IS_ERR(priv->gpiod_cle)) { + err = PTR_ERR(priv->gpiod_cle); dev_err(&pdev->dev, "CLE GPIO request failed (%d)\n", err); goto out_mtd; } /* Scan to find existence of the device */ - err = nand_scan(ams_delta_mtd, 1); + err = nand_scan(mtd, 1); if (err) goto out_mtd; /* Register the partitions */ - mtd_device_register(ams_delta_mtd, partition_info, - ARRAY_SIZE(partition_info)); + mtd_device_register(mtd, partition_info, ARRAY_SIZE(partition_info)); goto out; out_mtd: iounmap(io_base); out_free: - kfree(this); out: return err; } @@ -271,16 +284,15 @@ static int ams_delta_init(struct platform_device *pdev) */ static int ams_delta_cleanup(struct platform_device *pdev) { - void __iomem *io_base = platform_get_drvdata(pdev); + struct ams_delta_nand *priv = platform_get_drvdata(pdev); + struct mtd_info *mtd = nand_to_mtd(&priv->nand_chip); + void __iomem *io_base = priv->io_base; /* Release resources, unregister device */ - nand_release(ams_delta_mtd); + nand_release(mtd); iounmap(io_base); - /* Free the MTD device structure */ - kfree(mtd_to_nand(ams_delta_mtd)); - return 0; } From patchwork Mon Aug 6 22:29:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E240014E5 for ; Mon, 6 Aug 2018 22:40:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9F3329A7B for ; Mon, 6 Aug 2018 22:40:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A90029A91; Mon, 6 Aug 2018 22:40:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47EB729A7B for ; Mon, 6 Aug 2018 22:40:26 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=QbshNLRA//S+gmTPx23f7WawJPwQ7UIDi8ENxBle94U=; b=eBsIYOYcu/L1w5ksq2dgJXXXgE ZEGXU08Gh+boNAFXFdAN/xUwGmEv3afGxoBhlZ7fBN6dIADl05mIoUyc30Ozxg5mYCYFqHfWV//fe E9XQNfqIp8m2UqkdmUgeI2pksloJDMugyHPylR+hGQQxsmHMprA67fXe4G8LMF7naZuI/rxBnd6ew xGqR0yfJ1nOOLPMSiQBdqM/+lDSonZ4FZNS3eCBthDYmFItpamXAEsCPiZeacJNWwfg1fv1qhP4Y0 VnUECWOS666gRbfVNMudkkqZ1kl32Vm/jsCBGeA3jXwsHzSo81rHbHTOydukWvn5ettj1FQTAaA2Y 9HAcNj6Q==; 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 1fmoAp-00017i-0i; Mon, 06 Aug 2018 22:40:23 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmo0Y-0005Qq-9C; Mon, 06 Aug 2018 22:29:55 +0000 Received: by mail-lf1-x144.google.com with SMTP id u202-v6so10191460lff.9; Mon, 06 Aug 2018 15:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qE651b7//Tbsbpcejonm6kJTFp1EXDTRFlY4lg7NZoU=; b=UzmOCFOqDbEGpqK5M4xDrxNAXdA3kP3pyZWsy3bzWt+QEaIOW0BJvYmUtU0eHMSfWa t5oVqRitJyP6DHIEZXrdHyovb1X2Z36+gu4NJLjnfQES3lDRH7S2v9e3yapUI7mhjh83 kn+SzD0tfX6JQV5IqXDNdFLEdYJPNEbuVpUZJV9TQSKe+hJ1bPnYIoOieYMLOVLTQzO7 SPikvaqzL/0F0YuqFhAOJeSD562MHRn2wn0OMrX6KZWDezmsDRvMLqGvOEHHqLslcPc4 nST822MJLIEu+ih9X92tJjWoNSpMGhYy1tVBsJtaY3+Y1cVLKcMuhduwqC/YOBJs3xxx wp1w== 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=qE651b7//Tbsbpcejonm6kJTFp1EXDTRFlY4lg7NZoU=; b=PtDsJ8eBtTNZRkQMvPeAZMTmiDAKz5Ved0sxj9L0a3Enhp0PqQklG92VEjUKIi63oz zIM/FEBYpIp8g78zjFNJ+vcqg2SkCbB7aE/V1szVqFZz0rKtOlF2I13FE2vDEceZ8nn/ Qenxw8r0JRlfJ/FCb4j/NUgAORRkebWT/MCMPKsYZD/hvVsBbh8K8Khwei6H4JVNilhr lzF/0cBgZz43sobaTPw622ECByrTxmXOqtjvFoABRsgmesM9Wt3VPPTwV2+r+O2cRgJ8 01B1ZRuvYFP1QMLKx6V1hlt5pXwUupbvGsJfNYPRUWh9AHz9t7KCoQ0QP1fvzx+/obLZ I1zg== X-Gm-Message-State: AOUpUlEwB7fOukjyuyunQfO+PMdrArPUp3eDJ3r9GWVQTYfT5EvT5QAn aqbaODyXAzqTRgk3deuKTpo= X-Google-Smtp-Source: AAOMgpfPA1GoyiViwrZ+zcc9ED1kWg0CchOueaRUSh+QIUJrLIOeXMRKB062ROUOwBPzBoziWlnPxg== X-Received: by 2002:a19:4e06:: with SMTP id c6-v6mr11876651lfb.30.1533594571832; Mon, 06 Aug 2018 15:29:31 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:31 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 03/12] ARM: OMAP1: ams-delta: Provide GPIO lookup table for NAND data port Date: Tue, 7 Aug 2018 00:29:09 +0200 Message-Id: <20180806222918.12644-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152946_702378_C4B0C6E6 X-CRM114-Status: GOOD ( 14.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Data port used by Amstrad Delta NAND driver is actually an OMAP MPUIO device, already under control of gpio-omap driver. The NAND driver gets access to the port by ioremapping it and performs read/write operations. That is done without any proteciton from other users legally manipulating the port pins over GPIO API. The plan is to convert the driver to access the port over GPIO consumer API. Before that is implemented, the driver can already obtain exclusive access to the port by requesting an array of its GPIO descriptors. Add respective entries to the NAND GPIO lookup table. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon Reviewed-by: Linus Walleij --- arch/arm/mach-omap1/board-ams-delta.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index eedacdfe9725..16f7bbe47607 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -337,7 +337,8 @@ static struct platform_device ams_delta_nand_device = { .resource = ams_delta_nand_resources, }; -#define OMAP_GPIO_LABEL "gpio-0-15" +#define OMAP_GPIO_LABEL "gpio-0-15" +#define OMAP_MPUIO_LABEL "mpuio" static struct gpiod_lookup_table ams_delta_nand_gpio_table = { .table = { @@ -349,6 +350,14 @@ static struct gpiod_lookup_table ams_delta_nand_gpio_table = { GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe", 0), GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0), GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle", 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 0, "data", 0, 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 1, "data", 1, 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 2, "data", 2, 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 3, "data", 3, 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 4, "data", 4, 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 5, "data", 5, 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 6, "data", 6, 0), + GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 7, "data", 7, 0), { }, }, }; From patchwork Mon Aug 6 22:29:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F8C013AC for ; Mon, 6 Aug 2018 22:40:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECD0929A7B for ; Mon, 6 Aug 2018 22:40:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E061B29A91; Mon, 6 Aug 2018 22:40:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8EB5829A7B for ; Mon, 6 Aug 2018 22:40:43 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=paS015iefZk4Xct4QzZ0/yX1xYUz3THpV4KMnqlBNG4=; b=eavlCcx3FxCXI5F2k2TRntTiMc 89O6E+dFyt++t0UUNtNVy3OQW2LGH+s6JewSNKZRisvj0JzZO37loUVjmH10vyMsRpj5NtwFMhD6F apoINZhFFx0qTfKs8mlL9iGj56VH/iKvY+sorR6lipR6oSRllNq2G/yG3UjAUNoo5AdqMgdAKmKKv lOVpMPJF0oHsqxaE+E3ET105I2t3mdkWfbxgj3B0/dHl1jp/0BA3hTnimPfpNvPAP3NiAIDu3TVkc 9YVqnJEhBDnExoe9PWQRBaI1bzEYoakQOPSN9k5cZRHQyA/4XXgiz+8tSmnnIU3my1J+2HCDTaECf aX7y3uUA==; 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 1fmoB5-0001Uj-C1; Mon, 06 Aug 2018 22:40:39 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmo0Y-0005Qy-9A; Mon, 06 Aug 2018 22:29:55 +0000 Received: by mail-lf1-x144.google.com with SMTP id a4-v6so10208121lff.5; Mon, 06 Aug 2018 15:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8Ttieek8EVt2mQNwFsLifOKl+ByDrQm129q1TWk/MX0=; b=IcxD45QPCPRzl8lvaY9qsjTGsRNs6gWfl2bUuk41J5q5nlNd/Fj4+pM9RgOb76Q+U2 QCaN54RsUEQdvWW5sJ6YABUFPk05R+SVe3un3mnPX5pEBfeyTIqCWgNFFhTv7DMayYO1 UWFExZhfYv+7AKsNAu2/dSz33ocTaOIo9k8JoVwPEmic4aEPZM5DcDJByX2djQxqgyex YQuNwHMaR9bdjr2mRGVeR2U+QzEyRM1W4ZNJ39DSnyZRikWRiSe7o8TAIECDNENqXRUR msBwhq4dzMfYMLobnm2H8/kTmAjU9b2SnxkUq/L3HdWgUfgClF1aUNt7fKU4pEJnT0Rs eRJw== 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=8Ttieek8EVt2mQNwFsLifOKl+ByDrQm129q1TWk/MX0=; b=M5FKNXCBEbTxB5EFlo6em60b97dWq8nGsQPWOYaKXI4Txqjy9XvQFCv7a3XngHSA9O E97WyoNwGraCoPv6MyN/K0dAMkpEzmQR9AFRi+gLE/4FprBa6Ech33JRpymq5DJ5fxMt ewJqJjWlWRlyO8plC4NgRgfyadLz+ylqZw59piXczrYv7pBSymAcgnqqt6nfG8PM9Lvj P7zM+GoHV/yxTIJu+G++OuxoL7VwampbkXynCqOfr/ZMgxoP1zlNLQY5VtoJObWHDGYY wS9jnqj4axOib7FgfYZHDrY/Gkm9XcLQwAE1cFoFGTdkuAL+gIkbcZS9UixDHDDXHfVl BG/A== X-Gm-Message-State: AOUpUlEJ8CdklA0fGasRtnnuymbinikEUluQyReJ1x7gOVXni39PPuw6 NzCnGHZJo/O7yoCbCZS+cFI= X-Google-Smtp-Source: AAOMgpelyUDqoYptEF511iNccJY2bUI4ITVIU7db9touIXSemg7s5zfKdMCLVZdy7hJLf7GIx+2KPA== X-Received: by 2002:a19:c64c:: with SMTP id w73-v6mr12902280lff.2.1533594573278; Mon, 06 Aug 2018 15:29:33 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:32 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 04/12] mtd: rawnand: ams-delta: request data port GPIO resource Date: Tue, 7 Aug 2018 00:29:10 +0200 Message-Id: <20180806222918.12644-5-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152946_707177_4D57D748 X-CRM114-Status: GOOD ( 15.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Data port used by the driver is actually an OMAP MPUIO device, already under control of gpio-omap driver. For that reason we used to not request the memory region of the port as that would fail because the region is already busy. Despite that, we are still accessing the port by just ioremapping it and performing read/write operations. Moreover, we are doing that without any proteciton from other users legally manipulating the port pins over GPIO API. The plan is to convert the driver to access the port over functions exposed by the gpio-omap driver. Before that happens, already prevent from other users accessing the port pins by requesting an array of its GPIO descriptors. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon Reviewed-by: Linus Walleij --- drivers/mtd/nand/raw/ams-delta.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 48233d638d2a..09d6901fc94d 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -161,6 +161,7 @@ static int ams_delta_init(struct platform_device *pdev) struct mtd_info *mtd; struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); void __iomem *io_base; + struct gpio_descs *data_gpiods; int err = 0; if (!res) @@ -261,6 +262,13 @@ static int ams_delta_init(struct platform_device *pdev) dev_err(&pdev->dev, "CLE GPIO request failed (%d)\n", err); goto out_mtd; } + /* Request array of data pins, initialize them as input */ + data_gpiods = devm_gpiod_get_array(&pdev->dev, "data", GPIOD_IN); + if (IS_ERR(data_gpiods)) { + err = PTR_ERR(data_gpiods); + dev_err(&pdev->dev, "data GPIO request failed: %d\n", err); + goto out_mtd; + } /* Scan to find existence of the device */ err = nand_scan(mtd, 1); From patchwork Mon Aug 6 22:29:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C90EA174A for ; Mon, 6 Aug 2018 22:55:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B368A294DB for ; Mon, 6 Aug 2018 22:55:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A42C32984B; Mon, 6 Aug 2018 22:55:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B0E5294DB for ; Mon, 6 Aug 2018 22:55:26 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=WNeziXYaeqXF1FZ3JnD0Q3sCdetIcOecDS+JfQ1oP1k=; b=ItsjrhrLPOlm5vstzmfoMn6TCo zvyKwcC5E9nIxqpEp4F8v44d22/RO0s/lTCSDgLndSyg7nzgZc3sWjUMr67nbGamfMf0hTg8iXonp x3Jg1IJc3UdYQBccx3kIE249+rPC4fBG8C5DKXesvOR8B0wbg4GR20by0VqzusUJ4c0sG/++owsMq Kz4JMkZ09r0Iayz2f6dH8i6uQmpT8qd6a17JKv7RERHlY7a5v/LZhjwGfQAJRDzuzoCQPKtz2GB2V 29h8oWy/Pf5a3rjb5dHxkbvXOepDfhPuY2Lpvj329fJz0pzbGaydgQfqgREy/Rt3C5qXPlBT8XwCV kHVjsi9w==; 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 1fmoPL-0006XJ-1M; Mon, 06 Aug 2018 22:55:23 +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 1fmo0Y-0005Ra-Pf; Mon, 06 Aug 2018 22:29:58 +0000 Received: by mail-lf1-x142.google.com with SMTP id u202-v6so10191531lff.9; Mon, 06 Aug 2018 15:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/bFrJqpkYAXIA89qeP/MiX5sn2g+I7ZzvqYqwTt5+3M=; b=nyFSQZIgFoC06japxmtl4hUOpncO2u0KUo72C9x12Wj9nY9UKs2lwF8+2azFrfK/8D nsIG6bGMySqPaXcAaj5WeoQVO3N//DzjMQLTujsoCeN/RFbjFRC56y5wyPg6eSaWg4TA H90b+u0D8IBv2Uk7XfANBJmMxgjNlUnZojwsCaQvNj7Zm8ygtr3gxx+TetQuZ6xQLSu9 yiX4iJBWYErE8x/Rh1/lnxZW3S8HT7Xnqi7d4HxvBReiluc90NfPKDRrfrcSBPssu37u K377uup2Tnz9YVF5ZfvyiU9eFIfu1uihH+pPJ91QwMIZe9y78xmTUp7oiiZP+q91Ki+O JNWQ== 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=/bFrJqpkYAXIA89qeP/MiX5sn2g+I7ZzvqYqwTt5+3M=; b=O7/6S7Bzw8ympAui0aLxmE/pSl64XbLEq0tyKV5nw3EFHw3pZjEcXXM01CI82KPad1 o6FfxIXyJBrUx2rZW3s0lEN03BDdzDB9A4Pdgw9WR4DZ50wAL42xIiDn8yd794Y8b6So 1kb63oz/BqRxk5lm683pXjo1NLHxUMtjN5BhHctyN6bRNy9Jg0XmD2chvWo6sAFqWnn6 nUG7+hLZ7gEYT0HloubVcXz6n1kAHTHNlhFIpNA2ScI6uh+fvinNVNZNEtFp/c1jkNDJ Tbu1M16S6L3QVlev7USllHcef8FXHYcTA3opFvE9p4/WcNbRhH0bcCfXom9nqGMFj1c1 uLrQ== X-Gm-Message-State: AOUpUlGm347zneZhE5RlgwmWcRoTR3CtuVGnHs0daRX6UpQu7Ly4KqLB +yYbfw897PjjeKgJtK0YOvE= X-Google-Smtp-Source: AAOMgpeICtnonekoALrQpCgO/KhPn3gCvsWVa6RcYpMYX0ddp0xVRxdUrLc5QM6Ser8285T1uhYRog== X-Received: by 2002:ac2:428f:: with SMTP id m15-v6mr12815358lfh.52.1533594574784; Mon, 06 Aug 2018 15:29:34 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:34 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 05/12] mtd: rawnand: ams-delta: use GPIO API for data read/write Date: Tue, 7 Aug 2018 00:29:11 +0200 Message-Id: <20180806222918.12644-6-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152947_169930_9FB877C4 X-CRM114-Status: GOOD ( 20.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Don't readw()/writew() data directly from/to GPIO port which is under control of gpio-omap driver, use GPIO API instead. Degrade of performance on Amstrad Delta is completely not acceptable. The driver should work with any 8+-bit bidirectional GPIO port, not only OMAP. Signed-off-by: Janusz Krzysztofik Reviewed-by: Linus Walleij --- drivers/mtd/nand/raw/ams-delta.c | 97 ++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 59 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 09d6901fc94d..78996ddf82e0 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -24,13 +24,10 @@ #include #include #include -#include +#include -#include #include -#include - /* * MTD structure for E3 (Delta) */ @@ -44,7 +41,7 @@ struct ams_delta_nand { struct gpio_desc *gpiod_nwe; struct gpio_desc *gpiod_ale; struct gpio_desc *gpiod_cle; - void __iomem *io_base; + struct gpio_descs *data_gpiods; }; /* @@ -76,10 +73,14 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) { struct nand_chip *this = mtd_to_nand(mtd); struct ams_delta_nand *priv = nand_get_controller_data(this); - void __iomem *io_base = priv->io_base; + struct gpio_descs *data_gpiods = priv->data_gpiods; + unsigned long bits = byte; + int i; + + for (i = 0; i < data_gpiods->ndescs; i++) + gpiod_direction_output_raw(data_gpiods->desc[i], + test_bit(i, &bits)); - writew(0, io_base + OMAP_MPUIO_IO_CNTL); - writew(byte, this->IO_ADDR_W); gpiod_set_value(priv->gpiod_nwe, 0); ndelay(40); gpiod_set_value(priv->gpiod_nwe, 1); @@ -87,18 +88,28 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) static u_char ams_delta_read_byte(struct mtd_info *mtd) { - u_char res; struct nand_chip *this = mtd_to_nand(mtd); struct ams_delta_nand *priv = nand_get_controller_data(this); - void __iomem *io_base = priv->io_base; + struct gpio_descs *data_gpiods = priv->data_gpiods; + unsigned long bits = 0; + int i, value_array[data_gpiods->ndescs]; + + for (i = 0; i < data_gpiods->ndescs; i++) + gpiod_direction_input(data_gpiods->desc[i]); gpiod_set_value(priv->gpiod_nre, 0); ndelay(40); - writew(~0, io_base + OMAP_MPUIO_IO_CNTL); - res = readw(this->IO_ADDR_R); + + gpiod_get_raw_array_value(data_gpiods->ndescs, data_gpiods->desc, + value_array); + gpiod_set_value(priv->gpiod_nre, 1); - return res; + for (i = 0; i < data_gpiods->ndescs; i++) + if (value_array[i]) + __set_bit(i, &bits); + + return bits; } static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, @@ -159,14 +170,8 @@ static int ams_delta_init(struct platform_device *pdev) struct ams_delta_nand *priv; struct nand_chip *this; struct mtd_info *mtd; - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - void __iomem *io_base; - struct gpio_descs *data_gpiods; int err = 0; - if (!res) - return -ENXIO; - /* Allocate memory for MTD device structure and private data */ priv = devm_kzalloc(&pdev->dev, sizeof(struct ams_delta_nand), GFP_KERNEL); @@ -179,25 +184,8 @@ static int ams_delta_init(struct platform_device *pdev) mtd = nand_to_mtd(this); mtd->dev.parent = &pdev->dev; - /* - * Don't try to request the memory region from here, - * it should have been already requested from the - * gpio-omap driver and requesting it again would fail. - */ - - io_base = ioremap(res->start, resource_size(res)); - if (io_base == NULL) { - dev_err(&pdev->dev, "ioremap failed\n"); - err = -EIO; - goto out_free; - } - - priv->io_base = io_base; nand_set_controller_data(this, priv); - /* Set address of NAND IO lines */ - this->IO_ADDR_R = io_base + OMAP_MPUIO_INPUT_LATCH; - this->IO_ADDR_W = io_base + OMAP_MPUIO_OUTPUT; this->read_byte = ams_delta_read_byte; this->write_buf = ams_delta_write_buf; this->read_buf = ams_delta_read_buf; @@ -207,7 +195,7 @@ static int ams_delta_init(struct platform_device *pdev) if (IS_ERR(priv->gpiod_rdy)) { err = PTR_ERR(priv->gpiod_rdy); dev_warn(&pdev->dev, "RDY GPIO request failed (%d)\n", err); - goto out_mtd; + return err; } if (priv->gpiod_rdy) @@ -225,66 +213,60 @@ static int ams_delta_init(struct platform_device *pdev) if (IS_ERR(priv->gpiod_nwp)) { err = PTR_ERR(priv->gpiod_nwp); dev_err(&pdev->dev, "NWP GPIO request failed (%d)\n", err); - goto out_mtd; + return err; } priv->gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_HIGH); if (IS_ERR(priv->gpiod_nce)) { err = PTR_ERR(priv->gpiod_nce); dev_err(&pdev->dev, "NCE GPIO request failed (%d)\n", err); - goto out_mtd; + return err; } priv->gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_HIGH); if (IS_ERR(priv->gpiod_nre)) { err = PTR_ERR(priv->gpiod_nre); dev_err(&pdev->dev, "NRE GPIO request failed (%d)\n", err); - goto out_mtd; + return err; } priv->gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_HIGH); if (IS_ERR(priv->gpiod_nwe)) { err = PTR_ERR(priv->gpiod_nwe); dev_err(&pdev->dev, "NWE GPIO request failed (%d)\n", err); - goto out_mtd; + return err; } priv->gpiod_ale = devm_gpiod_get(&pdev->dev, "ale", GPIOD_OUT_LOW); if (IS_ERR(priv->gpiod_ale)) { err = PTR_ERR(priv->gpiod_ale); dev_err(&pdev->dev, "ALE GPIO request failed (%d)\n", err); - goto out_mtd; + return err; } priv->gpiod_cle = devm_gpiod_get(&pdev->dev, "cle", GPIOD_OUT_LOW); if (IS_ERR(priv->gpiod_cle)) { err = PTR_ERR(priv->gpiod_cle); dev_err(&pdev->dev, "CLE GPIO request failed (%d)\n", err); - goto out_mtd; + return err; } /* Request array of data pins, initialize them as input */ - data_gpiods = devm_gpiod_get_array(&pdev->dev, "data", GPIOD_IN); - if (IS_ERR(data_gpiods)) { - err = PTR_ERR(data_gpiods); + priv->data_gpiods = devm_gpiod_get_array(&pdev->dev, "data", GPIOD_IN); + if (IS_ERR(priv->data_gpiods)) { + err = PTR_ERR(priv->data_gpiods); dev_err(&pdev->dev, "data GPIO request failed: %d\n", err); - goto out_mtd; + return err; } /* Scan to find existence of the device */ err = nand_scan(mtd, 1); if (err) - goto out_mtd; + return err; /* Register the partitions */ mtd_device_register(mtd, partition_info, ARRAY_SIZE(partition_info)); - goto out; - - out_mtd: - iounmap(io_base); -out_free: - out: - return err; + return 0; } /* @@ -294,13 +276,10 @@ static int ams_delta_cleanup(struct platform_device *pdev) { struct ams_delta_nand *priv = platform_get_drvdata(pdev); struct mtd_info *mtd = nand_to_mtd(&priv->nand_chip); - void __iomem *io_base = priv->io_base; - /* Release resources, unregister device */ + /* Unregister device */ nand_release(mtd); - iounmap(io_base); - return 0; } From patchwork Mon Aug 6 22:29:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 838B41390 for ; Mon, 6 Aug 2018 22:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F5B22986E for ; Mon, 6 Aug 2018 22:32:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 626FA29877; Mon, 6 Aug 2018 22:32:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F8EB2986E for ; Mon, 6 Aug 2018 22:32:19 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=yc5jRybgCxnYwYAK86VzUgv/8yCREj5hKEA14LeNVNM=; b=jdmF5y9LIX8b0pt/smnkKM0wt9 f0bR2NibQerj39wNWws1Tv9ndQlbkFmdlXXTVv3yftDjceGxTmUn70KqSvR76T9YiNiOMG3xL7mPb 7RGH722j4s/z9zfdol554i594wgkRmn+MDBoSvK88L5I5GV/YuJWLht2ul6fvZTR3Z77AJKGI8Ncq c+CuQO5Grk667LHRBSGDaIVnZTu5ukzqTMMsKgoaP9ircr7S5m+D/pFeIocOSayOBJUVYZzZ+cYvQ Bq2EmiuKiOBjEyqG8eEJLyFrqVhka5UVGyN9fYaZlEpESg03rdlYixgMlLPYrB336+/VZCB6opQ/0 Qr2QSRfQ==; 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 1fmo2y-0001Sr-En; Mon, 06 Aug 2018 22:32:16 +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 1fmo0a-0005Rg-Ft; Mon, 06 Aug 2018 22:30:00 +0000 Received: by mail-lf1-x141.google.com with SMTP id a4-v6so10208190lff.5; Mon, 06 Aug 2018 15:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SWahyGay3HwJh/h6LbGc9ebdup+F8+u0inyd1av1TUw=; b=DLvbaHVfIveNt1OnDBxk12VwUJvePDKmfiwXglM8Uv329JWmzCEgl669za2CUifPxP Hy/RM5Po8w2Rizm2UAqw925zl6afSZnTysAgUv4eTEgd0o9RULFOvaNWd685MERyVlno /3HKK3vEbIVySzzxS1MeAcU6cr4FOyLQd6a9bXNGZlLF7pwSoHWj4RA4Dij/Nt9i2Ax5 tKOgYi2oGqk90uBFRuoR+jeHRnty87f1pbB1vrr0aDx/G4GAOEvuDrMLsPOkfX3+9s2V XYhjsq5ipuSjpjvh4uvVPEUzW5NdTSWi1//1rNYc4xc/geueFlZk0u+Vkv1QPPSoq/jY dX/w== 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=SWahyGay3HwJh/h6LbGc9ebdup+F8+u0inyd1av1TUw=; b=mFz+K3xx37pnpv4lYXJeYV1+AIPZVneF//4IrBWIDHZ8QACcyZKmtRUVogXzi+gVQP d6w7aWoETr/IfuCoEiI/N0olHjarXhyM0wH5fW+6yr0sUYnfoXIhr8W92M43cJIaQq5/ 1IMPR0aE5ohY3BjqCpp746o6nX1n9XWjJpUIbYE2AM5u3vOaf1J35UkDSeF7dlgBg5aT dKOqAddf1SxZS3hiR5Sx4IVdPeuKhMGPnbc+8kHneKcA3Ie2V8D3lthYbGVjK47XSFIt 3Bk3Vvv2WenXnsX3Ep9RFTrToj603eElE7qh/QQiosMMylT+OR3t02kOvaqoeF3i3mGB eBfA== X-Gm-Message-State: AOUpUlGva+y1eA7yPcMhx6Pm9Jj2qJd6ZT6IJ3jff48KTfGRfZb0eKJw AeeD6NXnfH6xd8LawqDtBuA= X-Google-Smtp-Source: AAOMgpceb/pNRnyiT5iMuDkPQySRSy5cQViz00DEdxe0K16VqXpbOtlW/bnNiEeDAh+rdvIlKYft9g== X-Received: by 2002:a19:1dcf:: with SMTP id d198-v6mr11998875lfd.144.1533594576160; Mon, 06 Aug 2018 15:29:36 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:35 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 06/12] ARM: OMAP1: ams-delta: drop obsolete NAND resources Date: Tue, 7 Aug 2018 00:29:12 +0200 Message-Id: <20180806222918.12644-7-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152949_033530_CAC6D447 X-CRM114-Status: GOOD ( 12.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Amstrad Delta NAND device now uses GPIO API for data I/O so there is no need to assign memory I/O resource to the device any longer. Drop it. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/board-ams-delta.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 16f7bbe47607..08e732bc1cd2 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -321,20 +321,9 @@ struct modem_private_data { static struct modem_private_data modem_priv; -static struct resource ams_delta_nand_resources[] = { - [0] = { - .start = OMAP1_MPUIO_BASE, - .end = OMAP1_MPUIO_BASE + - OMAP_MPUIO_IO_CNTL + sizeof(u32) - 1, - .flags = IORESOURCE_MEM, - }, -}; - static struct platform_device ams_delta_nand_device = { .name = "ams-delta-nand", .id = -1, - .num_resources = ARRAY_SIZE(ams_delta_nand_resources), - .resource = ams_delta_nand_resources, }; #define OMAP_GPIO_LABEL "gpio-0-15" From patchwork Mon Aug 6 22:29:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F0641390 for ; Mon, 6 Aug 2018 22:33:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C354297BF for ; Mon, 6 Aug 2018 22:33:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F60C297CE; Mon, 6 Aug 2018 22:33:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B2208297BF for ; Mon, 6 Aug 2018 22:33:40 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=AImdDK5TNZCogFRJzNpTWXM2w15RObpx6RMQbJA3JDo=; b=DM/VKZ4kMoNZTloIjsgnfp/AUj lsx2ZpFXUcHYrqqDGUhSXEfw3YBMI5IgXXQDsALorYVN3uTAu4qgIb9R5uDY51DwN4zEJvQJ7FZTf Hd4axQndiXpUuxpetkpuo9aNRcq0IKpocmo0jCkDpu9M+P9eUFQ8yM+q/K1o0Sn8esbVfpdLKtGSW mR51FaQqNEMBJCcTlbtQAbJh20IfFdXcHyArXWNk50dtTMon+SvXS61UTWtG2oajrssCi9Zk6rKmP dgy3jZFa5dU/cZ/gAcnDmvQRQer/tT4NrvH9oeLz1k5lNbKy8g6VPzuWOPHADmOXphGq7qFNE01cB G/YkTFpQ==; 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 1fmo4G-0003Fy-5c; Mon, 06 Aug 2018 22:33:36 +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 1fmo0Y-0005S0-Pd; Mon, 06 Aug 2018 22:29:56 +0000 Received: by mail-lf1-x142.google.com with SMTP id a4-v6so10208222lff.5; Mon, 06 Aug 2018 15:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kc0UzhE5a74AT1i79aXGGOwb60l9x1wE3g4xDA9GbLE=; b=aiaJY+wGP5udMA1gIXrJ03dzpSnoHmM17OF2+mZ0FFuAVAlc7ToGOCaJzEZqj0MzT5 6AI0KU5o+Jpgv+oI1FgxlZg7fc1Hz+RjG6elpcJ5rTa3vs2lLeCDDHxO0XTcREJ0HDiL W+SxYkqYP20qW2KvKNw67HV9tgYxKpIZRftHYwQlmYO9DSu4WOk95QakCnsgCQW7sLbb DqUiMvk0tnlS5Kt4WBTfxcdy+EnCR/iiXm9qZ5SkZns3SBmN4wD0luM2MM/8AYDGH0Qg AFRCUBUkqExs6vRPmWtIXiR1DGLuJGIfXX5mvArvNzgK/PUieR0B/7Mi5c3BEWCz7GRD XNhg== 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=kc0UzhE5a74AT1i79aXGGOwb60l9x1wE3g4xDA9GbLE=; b=T3s7IMFe2fINwprUfJM0m9whTcrOzndqItS7nycFJWhu5Jn7rvjelVFS2D1nzjDs8j TghuOOiR3paTo0OmQfnR3oi48nJwEhsnQ+Nv5mQtW+2OE/DmCCmHZ5ooJJuXEYV3+Wct JTKDp2cfY9fbP3FUEirmvY68niUb0umihOdsJeiOQBk4RZorMrITqajdBKwrOdIKly7Y UNyBLSoROC9LjE9qLRbOxBY4T8YsohBhA2FoWP7u0sfezEEMqq6reJSJ0965Moub6KiQ EHumV+9KwrJpuUYIlEKPZDF+KxLrj06h4aoMDKPXDizoql2dhxQ7WepsaKCwqoj3eJP4 eJow== X-Gm-Message-State: AOUpUlF4o7M5PingA+NhkLr1D7qd3p5rWktIJsF183J3tzzTjPc9qve8 PeoH556Jec1jPZsJhr8R9Qs= X-Google-Smtp-Source: AAOMgpftlgT2LBNt75HgnmEVXCUbyxfdlV1qSGS8i1KDsP4Pv+onp7UCIBniLpb4ZMscgW11lZsMRA== X-Received: by 2002:a19:2c4f:: with SMTP id s76-v6mr13073045lfs.25.1533594577560; Mon, 06 Aug 2018 15:29:37 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:36 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 07/12] mtd: rawnand: ams-delta: Set port direction once per transfer Date: Tue, 7 Aug 2018 00:29:13 +0200 Message-Id: <20180806222918.12644-8-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152947_307918_0E18F142 X-CRM114-Status: GOOD ( 16.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In its current shape, the driver sets data port direction before each byte read/write operation, even during multi-byte transfers. Since performance of the driver is completely not acceptable on Amstrad Delta after it has been converted to GPIO bitbang, try to improve things a bit by setting the port direction only on first byte of each transfer. Resulting performance on Amstrad Delta is still far from acceptable. Signed-off-by: Janusz Krzysztofik --- drivers/mtd/nand/raw/ams-delta.c | 58 ++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 78996ddf82e0..d02c48c013e8 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -69,6 +69,30 @@ static const struct mtd_partition partition_info[] = { .size = 3 * SZ_256K }, }; +static void ams_delta_write_commit(struct ams_delta_nand *priv) +{ + gpiod_set_value(priv->gpiod_nwe, 0); + ndelay(40); + gpiod_set_value(priv->gpiod_nwe, 1); +} + +static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) +{ + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); + struct gpio_descs *data_gpiods = priv->data_gpiods; + unsigned long bits = byte; + int i, value_array[data_gpiods->ndescs]; + + for (i = 0; i < data_gpiods->ndescs; i++) + value_array[i] = test_bit(i, &bits); + + gpiod_set_raw_array_value(data_gpiods->ndescs, data_gpiods->desc, + value_array); + + ams_delta_write_commit(priv); +} + static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) { struct nand_chip *this = mtd_to_nand(mtd); @@ -81,12 +105,10 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) gpiod_direction_output_raw(data_gpiods->desc[i], test_bit(i, &bits)); - gpiod_set_value(priv->gpiod_nwe, 0); - ndelay(40); - gpiod_set_value(priv->gpiod_nwe, 1); + ams_delta_write_commit(priv); } -static u_char ams_delta_read_byte(struct mtd_info *mtd) +static u_char ams_delta_read_next_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd_to_nand(mtd); struct ams_delta_nand *priv = nand_get_controller_data(this); @@ -94,9 +116,6 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) unsigned long bits = 0; int i, value_array[data_gpiods->ndescs]; - for (i = 0; i < data_gpiods->ndescs; i++) - gpiod_direction_input(data_gpiods->desc[i]); - gpiod_set_value(priv->gpiod_nre, 0); ndelay(40); @@ -112,21 +131,38 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) return bits; } +static u_char ams_delta_read_byte(struct mtd_info *mtd) +{ + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); + struct gpio_descs *data_gpiods = priv->data_gpiods; + int i; + + for (i = 0; i < data_gpiods->ndescs; i++) + gpiod_direction_input(data_gpiods->desc[i]); + + return ams_delta_read_next_byte(mtd); +} + static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { int i; - for (i=0; i 0) + ams_delta_write_byte(mtd, buf[0]); + for (i = 1; i < len; i++) + ams_delta_write_next_byte(mtd, buf[i]); } static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) { int i; - for (i=0; i 0) + buf[0] = ams_delta_read_byte(mtd); + for (i = 1; i < len; i++) + buf[i] = ams_delta_read_next_byte(mtd); } /* From patchwork Mon Aug 6 22:29:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D7EC13AC for ; Mon, 6 Aug 2018 22:30:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AA722986E for ; Mon, 6 Aug 2018 22:30:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C63229877; Mon, 6 Aug 2018 22:30:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 155652986E for ; Mon, 6 Aug 2018 22:30:50 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=iGEmHuEjtu7yQ52rEvDL1rRBr7CzKFa1UfciqTdmGZo=; b=FgMOzruOnFsig5ZT0761fTqA32 YbGS+nl86p5ULP8k+ss6bmEWr0qU2enAcyrN8rF93uLLaNPNFAMyRsUmok6lBu6Yt4AzuMt1yT87Y v0VmvDftWMffWvoj52giGmiX0f6PDuMBpFsO76Q4eiqYG5umrq7zvS7z11jqx18yiW5sdInYDLl7e 0xwaEECk4lqRXJvvddEsEwPtgRt0ZlFdK3Cal5+F8mwSrv7dRk5kkM+oog7SaDUfjqOd1NNFh+CMw olBJeUo2lBWZgDW+kfCk3rDJP1DqHoZzsMiI93NaWVOf23Izrs9SybcNDuUldvS2wnlI+v2aj5BQw lFgbXcBw==; 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 1fmo1S-00071g-OJ; Mon, 06 Aug 2018 22:30:42 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmo0Y-0005S2-99; Mon, 06 Aug 2018 22:29:50 +0000 Received: by mail-lf1-x144.google.com with SMTP id v22-v6so10200924lfe.8; Mon, 06 Aug 2018 15:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4e/NwWX8gPdhcOi4ymtYKpIzD8tGLix7YzF3NFcH+jE=; b=VSk24Lf11fISUKBVBalTBrkygdyEiRw+2NBUCIf7HMFRpwZbhciE7EQse8VY8vAjmS JLJ2wZr7G+u30e0OlVgwZKVGYeHTHgnCPxYsuzl+tdcCZR4zj9zU/o4ndDnyr8PpN+E8 4KBvTZa3raeWY87i32JIiXzbyLYJTzgwSr1NsyCSuDIhxsgLjetfdxVuiK1Ij7xTOR3Q FzNKFaMgy6UteO25l/wkolUXbcDypWSnKLPjrLmv9lp30taqmNXt4V+X2mMPeDhq0OCC voBnXuZZeqt8pfgSN6BXAKm+iVXZNKmJw1dbj3UNoTculPG3y8i/zfRXLHK6u7Le8rQt VEDQ== 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=4e/NwWX8gPdhcOi4ymtYKpIzD8tGLix7YzF3NFcH+jE=; b=YGxZFvNvwEmwWRs7HdOaEkKTV6W6d4QOQlr8wq86pVERP+EV5oVkgxPwk2Cc2vFN4j KggP5DGXnWtuyfoml77VMpZXDyb21Ff0D2mSYz17tEd7crAa0MK2ePBvW4Ff+ydmIUa8 k22I8R47pExr8VoED/LigN5y8FB++2HC38z4YvMpRumYwfsCJ0JR3PVXFxAKNAMZ9fpb VyVeKSnqirrBEx1sfXR9S85ciXeJB/p/Aq1pPLCVhpidzAJziyDfgvywHnxqrIoAWzBK YJlwnxq9QSmDGcURlNhuFrB85Aw3y8QJuR6jrTrHazQD2P6MhT5qO3iPyBQEa5YJVGlw B/6Q== X-Gm-Message-State: AOUpUlG3XCjADmSw6q2h8WmjZgYVUFCTI1J4BFS8M2jOITy/xn9begAj K4p4KhwTtbpRbUYvl4vsbRE= X-Google-Smtp-Source: AAOMgpddBt3OviQvsIPmqSEfWASOM2oWUiaQyCmIbh57aYMBUm8SYN9CxOmsoM9b9ESTsH3Foa+b3Q== X-Received: by 2002:a19:c3c7:: with SMTP id t190-v6mr11873113lff.108.1533594578952; Mon, 06 Aug 2018 15:29:38 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:38 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 08/12] mtd: rawnand: ams-delta: Simplify pointer resolution on read/write Date: Tue, 7 Aug 2018 00:29:14 +0200 Message-Id: <20180806222918.12644-9-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152946_623964_9DBCD9F6 X-CRM114-Status: GOOD ( 13.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Simplify data read/write sub-functions by changing their APIs so they accept driver private structure pointer instead of mtd_info. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon --- drivers/mtd/nand/raw/ams-delta.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index d02c48c013e8..30c461138195 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -76,10 +76,8 @@ static void ams_delta_write_commit(struct ams_delta_nand *priv) gpiod_set_value(priv->gpiod_nwe, 1); } -static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) +static void ams_delta_write_next_byte(struct ams_delta_nand *priv, u_char byte) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); struct gpio_descs *data_gpiods = priv->data_gpiods; unsigned long bits = byte; int i, value_array[data_gpiods->ndescs]; @@ -93,10 +91,8 @@ static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) ams_delta_write_commit(priv); } -static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) +static void ams_delta_write_first_byte(struct ams_delta_nand *priv, u_char byte) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); struct gpio_descs *data_gpiods = priv->data_gpiods; unsigned long bits = byte; int i; @@ -108,10 +104,8 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) ams_delta_write_commit(priv); } -static u_char ams_delta_read_next_byte(struct mtd_info *mtd) +static u_char ams_delta_read_next_byte(struct ams_delta_nand *priv) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); struct gpio_descs *data_gpiods = priv->data_gpiods; unsigned long bits = 0; int i, value_array[data_gpiods->ndescs]; @@ -131,38 +125,48 @@ static u_char ams_delta_read_next_byte(struct mtd_info *mtd) return bits; } -static u_char ams_delta_read_byte(struct mtd_info *mtd) +static u_char ams_delta_read_first_byte(struct ams_delta_nand *priv) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); struct gpio_descs *data_gpiods = priv->data_gpiods; int i; for (i = 0; i < data_gpiods->ndescs; i++) gpiod_direction_input(data_gpiods->desc[i]); - return ams_delta_read_next_byte(mtd); + return ams_delta_read_next_byte(priv); +} + +static u_char ams_delta_read_byte(struct mtd_info *mtd) +{ + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); + + return ams_delta_read_first_byte(priv); } static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); int i; if (len > 0) - ams_delta_write_byte(mtd, buf[0]); + ams_delta_write_first_byte(priv, buf[0]); for (i = 1; i < len; i++) - ams_delta_write_next_byte(mtd, buf[i]); + ams_delta_write_next_byte(priv, buf[i]); } static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) { + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); int i; if (len > 0) - buf[0] = ams_delta_read_byte(mtd); + buf[0] = ams_delta_read_first_byte(priv); for (i = 1; i < len; i++) - buf[i] = ams_delta_read_next_byte(mtd); + buf[i] = ams_delta_read_next_byte(priv); } /* @@ -186,7 +190,7 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, } if (cmd != NAND_CMD_NONE) - ams_delta_write_byte(mtd, cmd); + ams_delta_write_first_byte(priv, cmd); } static int ams_delta_nand_ready(struct mtd_info *mtd) From patchwork Mon Aug 6 22:29:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2C141390 for ; Mon, 6 Aug 2018 22:32:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F55829871 for ; Mon, 6 Aug 2018 22:32:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8317729877; Mon, 6 Aug 2018 22:32:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D5AE29881 for ; Mon, 6 Aug 2018 22:32:39 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=oEbSvGKmB9pQ3YnApDcwcQDrb7c18yOwlG18Kra6nXY=; b=iiK0TkwsNHcKTVIb27XpmjDMrh sHcYQuh4iaL72sJUKYricTbBs0z4yjClDpOA1IhUYSawN7JVY9e5AkuX4+M8NFBqbcLxKasmmBNXj m78zCIwkFs2OxwIqpVbaptssoZfK/VdE7u6x3LbPWLWoE0q5DxV1HOMPwLMVp5Rf8/ifEoq6Pf0WD ti+hqQx+k2ZBwhiu83UCnfW0CQGJnCDmWOucofQI1UGcSZqWyVZLYoJUYepM5XRsMBOaSGbe496lA biG70ydgf6KWe/PSWlywFSqHOT59d52kPWb61HPL/LaO+EpO58tYE3ORw4cOzdnIQEevgG5QOHkWz hD1VqUzQ==; 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 1fmo3F-0001tm-Rr; Mon, 06 Aug 2018 22:32:33 +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 1fmo0a-0005Sc-Fp; Mon, 06 Aug 2018 22:30:01 +0000 Received: by mail-lf1-x141.google.com with SMTP id v22-v6so10200956lfe.8; Mon, 06 Aug 2018 15:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ddxbjKWbH/qs2/dbAkPSUgMcTxkDVe7XOShiS2ShNhg=; b=O4rnAwwU+E19y/dHgqfV5/LNr5ueAwgq1W7nBCLWP9ADhnJm3CbxcOA0zniiu5qIaB uMdeXG1Q0fL84RvXKIoJI12MkL7KR5sbIs/gEK2NUFnDr2nNHfKYnZharQuaiiuKFqC8 8RgIEEsCaErRxPzNN4yUOpduIm/yGT/ExpYhfRrzE/E9DEVPDnqyg7SxAAGs4+nYSoeY LVnc1S7SZeQOeDGnalM3AWlivmjquUd0keZr4mfAr6GXPsj+JMkcFaHaSIeveco+BJUJ MogHKF5Y2TLZGnBsmEwjw2scpufQ0GLAqf+kps9CmBrEz8DYUiN0iQEQDdZjIlILRTwa GNug== 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=ddxbjKWbH/qs2/dbAkPSUgMcTxkDVe7XOShiS2ShNhg=; b=U465vM1lNenRCJOwynaiTOyySAmZ6bL/n8/1WheALMSCF4JUQygn61RnHPNJl+pAWp 614H4qG0b9zJpWBix4DS2I7lomWUGNNqAQ34HErplySfppJsVZpB+/NGUmgb66Vpu5q0 ttqg7Cs/zI4dOwX3uiD71Cs2N1qnwAZsja2U8bCuVflzBlSl0Th01jAbOl7pK4ehKW5O QOb5x7LAcMy6Fal/GYZ9veyRv7NpGmSV+uWxElkecDftnK48vyWz7htnILhSydcvI90C ilODzfYBtEhUd5ZtMfUsQc0vX/4Q3VlFduqxlXH0/ZEtkr1FDFcdyVEW9gZ/22moAuXZ 9V5Q== X-Gm-Message-State: AOUpUlGDAaBC1Jifri2h3/ijH+1xUggq04iysQtSuCWaDjclYsxsdIEx V5psAtSA52zKqhEF9BWXF9c= X-Google-Smtp-Source: AAOMgpe1kBSzm5J6s2TGZ6xuh9XrZ36DhEPwqaDLXIoZov77FCx7o+JryEyDTjswU9SaAdSCixn93A== X-Received: by 2002:a19:14dc:: with SMTP id 89-v6mr11947557lfu.45.1533594580408; Mon, 06 Aug 2018 15:29:40 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:39 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 09/12] gpiolib: Identify GPIO descriptor arrays with direct mapping Date: Tue, 7 Aug 2018 00:29:15 +0200 Message-Id: <20180806222918.12644-10-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152949_079748_02A3359D X-CRM114-Status: GOOD ( 16.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Certain GPIO array lookup results may map directly to GPIO pins of a single GPIO chip in hardware order. If that condition is recognized and handled efficiently, significant performance gain of get/set array functions may be possible. While processing a request for an array of GPIO descriptors, verify if the descriptors just collected represent consecutive pins of a single GPIO chip. Pass that information with the array to the caller so it can benefit from enhanced performance as soon as bitmap based get/set array functions which can make efficient use of that are available. Signed-off-by: Janusz Krzysztofik --- Documentation/driver-api/gpio/consumer.rst | 4 +++- drivers/gpio/gpiolib.c | 14 ++++++++++++++ include/linux/gpio/consumer.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst index aa03f389d41d..38a990b5f3b6 100644 --- a/Documentation/driver-api/gpio/consumer.rst +++ b/Documentation/driver-api/gpio/consumer.rst @@ -109,11 +109,13 @@ For a function using multiple GPIOs all of those can be obtained with one call:: enum gpiod_flags flags) This function returns a struct gpio_descs which contains an array of -descriptors:: +descriptors. It may also contain a valid descriptor of a single GPIO chip in +case the array strictly matches pin hardware layout of the chip:: struct gpio_descs { unsigned int ndescs; struct gpio_desc *desc[]; + struct gpio_chip *chip; } The following function returns NULL instead of -ENOENT if no GPIOs have been diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bdbfc95793e7..c50bcec6e2d7 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -4161,6 +4161,7 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev, { struct gpio_desc *desc; struct gpio_descs *descs; + struct gpio_chip *chip; int count; count = gpiod_count(dev, con_id); @@ -4177,6 +4178,19 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev, gpiod_put_array(descs); return ERR_CAST(desc); } + + /* + * Verify if the array qualifies for fast bitmap operations + * (single chip, pins in hardware order starting from 0) + * and mark the array with the chip descriptor if true. + */ + chip = gpiod_to_chip(desc); + if (descs->chip == NULL) + descs->chip = chip; + if (!IS_ERR(descs->chip) && (chip != descs->chip || + gpio_chip_hwgpio(desc) != descs->ndescs)) + descs->chip = ERR_PTR(-EINVAL); + descs->desc[descs->ndescs] = desc; descs->ndescs++; } diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 21ddbe440030..862ee027a02f 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -22,6 +22,7 @@ struct gpio_desc; * gpiod_get_array(). */ struct gpio_descs { + struct gpio_chip *chip; unsigned int ndescs; struct gpio_desc *desc[]; }; From patchwork Mon Aug 6 22:29:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7B811390 for ; Mon, 6 Aug 2018 22:33:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93FE7297BF for ; Mon, 6 Aug 2018 22:33:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85F4E297CE; Mon, 6 Aug 2018 22:33:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC4B8297BF for ; Mon, 6 Aug 2018 22:33:54 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=JRF68eH5NYxwXFlVSfRVJwtKimLWvjEdEQd8Ewxg0iQ=; b=csqdmC8eF2odlK7OB3rt0ENzzm laMgSVfL7HCyYwj1QnMHz9I+C8BuSd4N74lKmrYqKCCopKqCH/SUZjL8IJ78VjKi9ozo5JIQcEfHE guUSn9Z4RImWfgIup3csBqEOvG3eDumt3YFNqjUXjwkB0MJgv5SSSNfs/eMYeNFRLjd4zjktnhaES 7wp6VLxdftaNueQn2ZUuh7EXCpVoGrZUZ0BhzrJWc+bxT87rr2lzOmGDaBdVk92BYX0/gPBoShaL1 GY9/BaJQVcDoqnkDFmkvI3vQrPgHhTQPqrl+olxCQZwPxxXPC8LtrHZ82XRZM4K4Qsv81R4XN6MPc pW1gVl6A==; 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 1fmo4S-0003WY-20; Mon, 06 Aug 2018 22:33:48 +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 1fmo0a-0005T1-G1; Mon, 06 Aug 2018 22:30:06 +0000 Received: by mail-lf1-x141.google.com with SMTP id j143-v6so10187991lfj.12; Mon, 06 Aug 2018 15:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ebIIlYMRwOV2gYgWi7T9qT+QmjkOUcUsHwsxQZ0n6Tk=; b=WhVqN1At68jh0Y7HUfCj4y3WSZTCj9P89b9nXlw1PQ5rNy/IL1jpTWuCmtpfoPOY5v FuKeruPHb2LFCCkefM4a38qkltc7Z/OxFQreVur2EJFzQaUmhKykhcSJkIKsS5x/5WAL gmq4YoM86EfL7xH591j4hLOipTrI3ZvQ7uQ5my67n/bnsejrZftrqBD+P3aGYztAOxPJ aN/ePJL8CCYoSGIfda/+uHePDu23bZwMp3O6qFC2NIVz7GyR/y2wnBVWQHJ3qF1WDPGx gu08VrnAtUogqQWJSFijFjwBFj4Qz5qAyxt5H+BiuGLQ9ZKEjkwbJUcK8Bh452DMCNI5 0w6g== 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=ebIIlYMRwOV2gYgWi7T9qT+QmjkOUcUsHwsxQZ0n6Tk=; b=s2uSGccCRiVAADvJNPDIoQIichH7MwIRtxvGuMK5gSoOsMJPfehGQFZHC7oYpoiQiG 49jPgB5vEyHb4plpYRgOX24hR215Nz3qly3clZCpU8ayNRooNnVgrePYll5OOCG9RSv6 6kgo+hg9mp5OAYRohneNw7Vmw+/ICQVAhgW4+Tyez9GQN92cS4X1I6gMHq1sAeBhwPMF v2zJkQHKJc50A8Wwnc52VI1ClUMsAdAf+DKL2AzmoUlG7ydQGSZFUDg9vZTxBWFKGkas dnt0Z7TAv7ITAFmdmtXyTdOa1djUSl227NlFmssOWxydNQZJM12Aw6IO/ThIGGQk1g/I qesA== X-Gm-Message-State: AOUpUlHGDikgjv6h41pWgk6WyIghWB3D3Q2oy5HbgNd8f72bUYzCWfHy RBYDKH/qI9XM49q+TXSzqJU= X-Google-Smtp-Source: AAOMgpdN9LZehLcDgBA7w0nORZ3SY79wH/6RfscsmGRAExgcZ4fMvUNIaZmKPIAqkV0EoWG/wHvlrw== X-Received: by 2002:a19:7609:: with SMTP id c9-v6mr11952619lff.73.1533594581791; Mon, 06 Aug 2018 15:29:41 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:41 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 10/12] gpiolib: Introduce bitmap get/set array API extension Date: Tue, 7 Aug 2018 00:29:16 +0200 Message-Id: <20180806222918.12644-11-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152948_988996_1FB1A8D8 X-CRM114-Status: GOOD ( 17.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Certain GPIO array lookups may return arrays marked as applicable for fast get/set array operations. In order to make use of that information, a new API extension which allows passing it to get/set functions is needed. Create a set of frontends to get/set array functions which accept strict descriptor array structures returned by gpiod_get_array() instead of arbitrary descriptor arrays. Since the intended purpose of the new API extension is to speed up get/set array operations, also replace array of integer values argument with their bitmap representation, ready for being passed directly to chip callback functions, without iterating them. Applicability of the new API is limited to arrays not exceeding bit length of type unsigned long (32 pins). Signed-off-by: Janusz Krzysztofik --- Documentation/driver-api/gpio/consumer.rst | 26 ++++ drivers/gpio/gpiolib.c | 209 +++++++++++++++++++++++++++++ include/linux/gpio/consumer.h | 14 ++ 3 files changed, 249 insertions(+) diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst index 38a990b5f3b6..bec4eab3b87c 100644 --- a/Documentation/driver-api/gpio/consumer.rst +++ b/Documentation/driver-api/gpio/consumer.rst @@ -383,6 +383,32 @@ or negative on error. Note the difference to gpiod_get_value(), which returns 0 or 1 on success to convey the GPIO value. With the array functions, the GPIO values are stored in value_array rather than passed back as return value. +Additionally, the following variants of the above functions exist which operate +on bitmaps of values instead of arrays of values:: + + int gpiod_get_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits); + int gpiod_get_raw_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits); + int gpiod_get_array_bitmap_cansleep(struct gpio_desc *desc_array, + unsigned long *bits); + int gpiod_get_raw_array_bitmap_cansleep(struct gpio_desc **desc_array, + unsigned long *bits) + + void gpiod_set_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits) + void gpiod_set_raw_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bitmap) + void gpiod_set_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits) + void gpiod_set_raw_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits) + +Unlike their counterparts, these functions don't accept arbitrary GPIO +descriptor arrays, only those of type struct gpio_descs returned by +gpiod_get_array() and its variants. Supported array size is limited to the size +of the bitmap, i.e., sizeof(unsigned long). + GPIOs mapped to IRQs -------------------- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c50bcec6e2d7..5b541364dee0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2836,6 +2836,27 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep, return 0; } +int gpiod_get_array_bitmap_complex(bool raw, bool can_sleep, + struct gpio_descs *array, + unsigned long *bits) +{ + int value_array[sizeof(*bits)]; + int i; + + if (array->ndescs > sizeof(*bits)) + return -EINVAL; + + i = gpiod_get_array_value_complex(raw, can_sleep, array->ndescs, + array->desc, value_array); + if (i) + return i; + + for (i = 0; i < array->ndescs; i++) + __assign_bit(i, bits, value_array[i]); + + return 0; +} + /** * gpiod_get_raw_value() - return a gpio's raw value * @desc: gpio whose value will be returned @@ -2929,6 +2950,50 @@ int gpiod_get_array_value(unsigned int array_size, } EXPORT_SYMBOL_GPL(gpiod_get_array_value); +/** + * gpiod_get_raw_array_bitmap() - read raw values from an array of GPIOs + * @desc_array: array of GPIO descriptors whose values will be read, obtained + * with gpiod_get_array(), + * @bits: bitmap to store the read values + * + * Read the raw values of the GPIOs, i.e. the values of the physical lines + * without regard for their ACTIVE_LOW status. Return 0 in case of success, + * else an error code. + * + * This function should be called from contexts where we cannot sleep, + * and it will complain if the GPIO chip functions potentially sleep. + */ +int gpiod_get_raw_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits) +{ + if (!desc_array) + return -EINVAL; + return gpiod_get_array_bitmap_complex(true, false, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_get_raw_array_bitmap); + +/** + * gpiod_get_array_bitmap() - read values from an array of GPIOs + * @desc_array: array of GPIO descriptors whose values will be read, obtained + * with gpiod_get_array(), + * @bits: bitmap to store the read values + * + * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status + * into account. Return 0 in case of success, else an error code. + * + * This function should be called from contexts where we cannot sleep, + * and it will complain if the GPIO chip functions potentially sleep. + */ + +int gpiod_get_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits) +{ + if (!desc_array) + return -EINVAL; + return gpiod_get_array_bitmap_complex(false, false, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_get_raw_array_bitmap); + /* * gpio_set_open_drain_value_commit() - Set the open drain gpio's value. * @desc: gpio descriptor whose state need to be set. @@ -3081,6 +3146,23 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, return 0; } +int gpiod_set_array_bitmap_complex(bool raw, bool can_sleep, + struct gpio_descs *array, + unsigned long *bits) +{ + int value_array[sizeof(*bits)]; + int i; + + if (array->ndescs > sizeof(*bits)) + return -EINVAL; + + for (i = 0; i < array->ndescs; i++) + value_array[i] = test_bit(i, bits); + + return gpiod_set_array_value_complex(raw, can_sleep, array->ndescs, + array->desc, value_array); +} + /** * gpiod_set_raw_value() - assign a gpio's raw value * @desc: gpio whose value will be assigned @@ -3185,6 +3267,48 @@ void gpiod_set_array_value(unsigned int array_size, } EXPORT_SYMBOL_GPL(gpiod_set_array_value); +/** + * gpiod_set_raw_array_bitmap() - assign values to an array of GPIOs + * @desc_array: array of GPIO descriptors whose values will be assigned, + * obtained with gpiod_get_array(), + * @bits: bitmap of values to assign + * + * Set the raw values of the GPIOs, i.e. the values of the physical lines + * without regard for their ACTIVE_LOW status. + * + * This function should be called from contexts where we cannot sleep, and will + * complain if the GPIO chip functions potentially sleep. + */ +int gpiod_set_raw_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits) +{ + if (!desc_array) + return -EINVAL; + return gpiod_set_array_bitmap_complex(true, false, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_set_raw_array_bitmap); + +/** + * gpiod_set_array_bitmap() - assign values to an array of GPIOs + * @array_size: number of elements in the descriptor / value arrays + * @desc_array: array of GPIO descriptors whose values will be assigned + * @bits: bitmap of values to assign + * + * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status + * into account. + * + * This function should be called from contexts where we cannot sleep, and will + * complain if the GPIO chip functions potentially sleep. + */ +void gpiod_set_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits) +{ + if (!desc_array) + return; + gpiod_set_array_bitmap_complex(false, false, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_set_array_bitmap); + /** * gpiod_cansleep() - report whether gpio value access may sleep * @desc: gpio to check @@ -3446,6 +3570,49 @@ int gpiod_get_array_value_cansleep(unsigned int array_size, } EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep); +/** + * gpiod_get_raw_array_bitmap_cansleep() - read raw values from array of GPIOs + * @desc_array: array of GPIO descriptors whose values will be read, obtained + * with gpiod_get_array(), + * @bits: bitmap to store the read values + * + * Read the raw values of the GPIOs, i.e. the values of the physical lines + * without regard for their ACTIVE_LOW status. Return 0 in case of success, + * else an error code. + * + * This function is to be called from contexts that can sleep. + */ +int gpiod_get_raw_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits) +{ + might_sleep_if(extra_checks); + if (!desc_array) + return -EINVAL; + return gpiod_get_array_bitmap_complex(true, true, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_get_raw_array_bitmap_cansleep); + +/** + * gpiod_get_array_bitmap_cansleep() - read values from an array of GPIOs + * @desc_array: array of GPIO descriptors whose values will be read, obtained + * with gpiod_get_array(), + * @bits: bitmap to store the read values + * + * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status + * into account. Return 0 in case of success, else an error code. + * + * This function is to be called from contexts that can sleep. + */ +int gpiod_get_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits) +{ + might_sleep_if(extra_checks); + if (!desc_array) + return -EINVAL; + return gpiod_get_array_bitmap_complex(false, true, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_get_array_bitmap_cansleep); + /** * gpiod_set_raw_value_cansleep() - assign a gpio's raw value * @desc: gpio whose value will be assigned @@ -3545,6 +3712,48 @@ void gpiod_set_array_value_cansleep(unsigned int array_size, } EXPORT_SYMBOL_GPL(gpiod_set_array_value_cansleep); +/** + * gpiod_set_raw_array_bitmap_cansleep() - assign values to an array of GPIOs + * @desc_array: array of GPIO descriptors whose values will be assigned, + * obtained with gpiod_get_array(), + * @bits: bitmap of values to assign + * + * Set the raw values of the GPIOs, i.e. the values of the physical lines + * without regard for their ACTIVE_LOW status. + * + * This function is to be called from contexts that can sleep. + */ +int gpiod_set_raw_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits) +{ + might_sleep_if(extra_checks); + if (!desc_array) + return -EINVAL; + return gpiod_set_array_bitmap_complex(true, true, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_set_raw_array_bitmap_cansleep); + +/** + * gpiod_set_array_bitmap_cansleep() - assign values to an array of GPIOs + * @desc_array: array of GPIO descriptors whose values will be assigned, + * obtained with gpiod_get_array(), + * @bits: bitmap of values to assign + * + * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status + * into account. + * + * This function is to be called from contexts that can sleep. + */ +void gpiod_set_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits) +{ + might_sleep_if(extra_checks); + if (!desc_array) + return; + gpiod_set_array_bitmap_complex(false, true, desc_array, bits); +} +EXPORT_SYMBOL_GPL(gpiod_set_array_bitmap_cansleep); + /** * gpiod_add_lookup_table() - register GPIO device consumers * @table: table of consumers to register diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 862ee027a02f..1eabce4fc6c5 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -106,35 +106,49 @@ int gpiod_direction_output_raw(struct gpio_desc *desc, int value); int gpiod_get_value(const struct gpio_desc *desc); int gpiod_get_array_value(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +int gpiod_get_array_bitmap(struct gpio_descs *desc_array, unsigned long *bits); void gpiod_set_value(struct gpio_desc *desc, int value); void gpiod_set_array_value(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +void gpiod_set_array_bitmap(struct gpio_descs *desc_array, unsigned long *bits); int gpiod_get_raw_value(const struct gpio_desc *desc); int gpiod_get_raw_array_value(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +int gpiod_get_raw_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits); void gpiod_set_raw_value(struct gpio_desc *desc, int value); int gpiod_set_raw_array_value(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +int gpiod_set_raw_array_bitmap(struct gpio_descs *desc_array, + unsigned long *bits); /* Value get/set from sleeping context */ int gpiod_get_value_cansleep(const struct gpio_desc *desc); int gpiod_get_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +int gpiod_get_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits); void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); void gpiod_set_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +void gpiod_set_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits); int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); int gpiod_get_raw_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +int gpiod_get_raw_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits); void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); int gpiod_set_raw_array_value_cansleep(unsigned int array_size, struct gpio_desc **desc_array, int *value_array); +int gpiod_set_raw_array_bitmap_cansleep(struct gpio_descs *desc_array, + unsigned long *bits); int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); From patchwork Mon Aug 6 22:29:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE63E13AC for ; Mon, 6 Aug 2018 22:32:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A58128FC1 for ; Mon, 6 Aug 2018 22:32:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D6AE29001; Mon, 6 Aug 2018 22:32:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 392EA28FC1 for ; Mon, 6 Aug 2018 22:32:50 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=1NY4vuPNNs9udc384uzuJWGz3LGb4sLFJ5JETvDEPkY=; b=QZ5aCCpSHDQrYugwWAbKDqttru +xQ+Xm77TQNjTayhR3nPYPB+RgFFQihf1kKaVpl+SIHVxSR9ja4gOtUl4MlYknuV/sot/Oz4L49+D lfACX6OzgeIJh4rsILCgIiAj6kJ1MGc5RNUo3eWiAXnye/m7Ig/nu8TBwjH8EmOU01WR/dKWAM8kg OElmaAWSSl0gscSz41bYI+NTSj1AiRZW4IriQCwRUl2mJRaWBlCWmxdjZH84Z0jtRVfNoblDYNnXN 2DbHUehgU3Y7ccTCiq05GkUgPGt9ajk6sw9AivdRtPIqPQfm9FG2Ap8BFR9KPcdXct4LsMhXxLIqC GJ4Mbq7A==; 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 1fmo3S-00028V-5R; Mon, 06 Aug 2018 22:32:46 +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 1fmo0a-0005TF-GT; Mon, 06 Aug 2018 22:30:02 +0000 Received: by mail-lf1-x141.google.com with SMTP id f135-v6so10187075lfg.10; Mon, 06 Aug 2018 15:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FDaMkIad0o9QzNTv2EARYdjQpGULA5HnpcmySlWm3i8=; b=O2N6qSTD6wcYUO5uf/sAtdsjHk+jMRgROxM64BeLFfqEax+Sd2rSsUJXBLoACFBcfU vpNekW03thHx+TO+4dBbmDjf2ARNzjZJ8OwQ2JmymgK+1PhoIzxi4XFh9k23tXNkeVvg R/uUcHgx02mbIEzP04Oerc0v2PIDWffK6wANRL7q1ngph2ViEoL9LEDoA7W496FeGGWy fDEOFe7qBJJOAxK5zUlkF+1u2agqRzLDQjvJ1yRepsL8yKJFWV99oaF+DF47sTpWYxgX BhOrFttIAwOnfZYjZuWzM/h2xNhw20WJknDy/Yd3cYox7qeKVDQ+D6qNwpfoF+0FY7d4 Dgug== 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=FDaMkIad0o9QzNTv2EARYdjQpGULA5HnpcmySlWm3i8=; b=ABJTfWoyWvSxjaj6VCgZ/tH8WhOPrX0kj3zyPN+Ng7xfajq4NjfK2lz088eZw6OVJi u5FRc4XYEBYh2SDaJ7MOK9eqOjltTn0fSv70YGJ0CFPzkANayqwt6ZbQ/+VoV4yiklmX AOsugpW5W4VMsCdbLJgYoGbDHjhpAlMyAk6JmoclGJMSnjE5nuovB6MaNqgXPMieZvAJ pprzlJEOgGFcgWLrem45yugmTFWzMXOemd3eADqyy0KpxXvKxgbSk5vVhdiGnfMnQegJ ijWerimbHwzYuDso0cTP6BeMYg5kO9WJIy7+kxQjeiMVTrzsWlA0eF5s5YnDBDhPyQbh 2WzA== X-Gm-Message-State: AOUpUlEG77Kzu7V+sAaRfgrHQjIuwR9RPH9aArn2V6Injn/mWlVO/Lum RwrK+yCuLVfuc8wIgllOZ8k= X-Google-Smtp-Source: AAOMgpciX3+0nE/8mArhut1MLp5m3pxfDitwVhtDsHuy0YeZFQlZ9DyC70LgedcTWPE5Cjl89pXqDA== X-Received: by 2002:a19:b24e:: with SMTP id b75-v6mr11741465lff.11.1533594583186; Mon, 06 Aug 2018 15:29:43 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:42 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 11/12] mtd: rawnand: ams-delta: Use GPIO API bitmap extension Date: Tue, 7 Aug 2018 00:29:17 +0200 Message-Id: <20180806222918.12644-12-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152949_010493_9D250FA0 X-CRM114-Status: GOOD ( 13.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Try to address the driver performance issues by replacing traditional get/set array function calls with their bitmap based equivalents. As long as fast bitmap processing path is not implemented in the new API extension, performance of the driver remains unchanged. Signed-off-by: Janusz Krzysztofik --- drivers/mtd/nand/raw/ams-delta.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 30c461138195..7b08b2c441d3 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -78,15 +78,9 @@ static void ams_delta_write_commit(struct ams_delta_nand *priv) static void ams_delta_write_next_byte(struct ams_delta_nand *priv, u_char byte) { - struct gpio_descs *data_gpiods = priv->data_gpiods; unsigned long bits = byte; - int i, value_array[data_gpiods->ndescs]; - - for (i = 0; i < data_gpiods->ndescs; i++) - value_array[i] = test_bit(i, &bits); - gpiod_set_raw_array_value(data_gpiods->ndescs, data_gpiods->desc, - value_array); + gpiod_set_raw_array_bitmap(priv->data_gpiods, &bits); ams_delta_write_commit(priv); } @@ -106,22 +100,15 @@ static void ams_delta_write_first_byte(struct ams_delta_nand *priv, u_char byte) static u_char ams_delta_read_next_byte(struct ams_delta_nand *priv) { - struct gpio_descs *data_gpiods = priv->data_gpiods; - unsigned long bits = 0; - int i, value_array[data_gpiods->ndescs]; + unsigned long bits; gpiod_set_value(priv->gpiod_nre, 0); ndelay(40); - gpiod_get_raw_array_value(data_gpiods->ndescs, data_gpiods->desc, - value_array); + gpiod_get_raw_array_bitmap(priv->data_gpiods, &bits); gpiod_set_value(priv->gpiod_nre, 1); - for (i = 0; i < data_gpiods->ndescs; i++) - if (value_array[i]) - __set_bit(i, &bits); - return bits; } From patchwork Mon Aug 6 22:29:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4842C13AC for ; Mon, 6 Aug 2018 22:40:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 323D729A7B for ; Mon, 6 Aug 2018 22:40:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 250FD29A91; Mon, 6 Aug 2018 22:40:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5A0829A7B for ; Mon, 6 Aug 2018 22:40:39 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=LvpIMVNbrb0npfQDu2oNJ4/DO41jdsjN3PoQgystWoc=; b=akpSGAj6LZK1Hx7zltbIZgPN10 JGT7il7QhuRk/sIvh3lvaEdMGnUwgCNkpqLhOFG/FVgax6tdRw/SSqq4eZgiDyG1RQCrvPjX92Wlx UphgFCAGhyHNvtOke7br0PKxVs6NHTCPvVRRQQcIPjyfD8oNIqP4p7mIjaQVzErwYd5JHCYeKFRqG lS+O5iOm9GOHSJZIv7hqpfzWp6mwJ9NdLssKGtST0uc1fh8SpaA1G51CM/w31PO6N3SG1y/eBqLZZ y8X2QkA+zjWLrOE3eEPQ9gFfUfpDAhfYghxXGAcQsasMiJ+9iVRfDP0fMfdx/XIN5PC4J8ECrseXb j1JpKsJg==; 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 1fmoAz-0001Lq-EM; Mon, 06 Aug 2018 22:40:33 +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 1fmo0Y-0005UC-Qu; Mon, 06 Aug 2018 22:29:55 +0000 Received: by mail-lf1-x142.google.com with SMTP id y200-v6so10196921lfd.7; Mon, 06 Aug 2018 15:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UZjTLX7QnQr/t1695VcV1KTsYiUTLZK2WnrZPxW0nQ0=; b=f4TupVyGulWb3GeTA5wNIXDgA28jrcBpoND1Ko4n43chjDMerygFxt+GgpBmhCWCEh K/A8/d6es6eXkmxlKoHfZjx30fvveGPjnB182ekcFQetalYPOaF4T9hu0nUk85K7igRD pFaf34gyE0Zk2i1ShroXnPSN5wopTGpVpI1c/n9zik+LN0rqjfs7uR3Gro5ITP9UccJk gxvw9AxP+3OeRFlgDcpoSvLkaHLUAWI/ABqKHR/WspP52lLK5uBZn4q3a4MufOHAaCYx pZWK2+kUNIZ1qoXXJfb7/ohkBoX7If/OVQRjuGQrfmXfv5c61AbP5/BLb6/0Yc4wYlwU kEYA== 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=UZjTLX7QnQr/t1695VcV1KTsYiUTLZK2WnrZPxW0nQ0=; b=LSzeC+613z5xhRugtzI0fegvYRIPDJinO54GASqfKaJS7ZbsIzLNFq8aGxHuOqEXjt oOYSKgPUnCODYK8WKXCP7uTF+nyXU9tkgpNCjPm2HmpBit1t720G6+stYrH+QzeqS6SO P9qYM62RANX8sULuWi44pSXSBKErx6QIiHn8oG5LhWqqxdfqfFQMo4mbgkeErwy+743P XOqYSTFAGdvtugyw8u6XUb/DLB1bE/qYP5K2oh43+ZoYkxd56YtZdyo4U2p4juP8uYVB 6/sUEpl1kaVqXeibFWgPOTl0Ib/wmziK7EIWkjvwpKKApjPlc0JeR/OpNCDUwd8U8Cum Z4HQ== X-Gm-Message-State: AOUpUlElXPIKn3ZG4UAbONQ8V8zsQLIUjeEoqB07jYTWBr+beZEkd+cd f1XSPdvZkuy0pNVBKBMpiuA= X-Google-Smtp-Source: AAOMgpdOVignCZnEeCBAFO3oZT9ssWE7eymuQTN++pgaa4W5/B4vcnak1+wEbM2FXkRJkCqWvtg9Vw== X-Received: by 2002:a19:5a56:: with SMTP id o83-v6mr11909803lfb.50.1533594584634; Mon, 06 Aug 2018 15:29:44 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:44 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 12/12] gpiolib: Add fast processing path to bitmap API functions Date: Tue, 7 Aug 2018 00:29:18 +0200 Message-Id: <20180806222918.12644-13-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152947_311908_253BDB98 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Certain GPIO descriptor arrays returned by gpio_get_array() may contain information on a single GPIO chip driving array member pins in hardware order. In such cases, bitmaps of values can be passed directly to the chip callback functions without wasting time on iterations. Add respective code to gpiod_get/set_array_bitmap_complex() functions. Signed-off-by: Janusz Krzysztofik --- Documentation/driver-api/gpio/consumer.rst | 6 ++++++ drivers/gpio/gpiolib.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst index bec4eab3b87c..b82f134dc352 100644 --- a/Documentation/driver-api/gpio/consumer.rst +++ b/Documentation/driver-api/gpio/consumer.rst @@ -409,6 +409,12 @@ descriptor arrays, only those of type struct gpio_descs returned by gpiod_get_array() and its variants. Supported array size is limited to the size of the bitmap, i.e., sizeof(unsigned long). +If the .chip member of the array structure, filled in by gpiod_get_array() in +certain circumstances, contains a valid GPIO chip descriptor, the raw variants +of the functions can take fast processing paths, passing bitmap arguments +directly to the chip callback functions. That allows for utilization of GPIO +banks as data I/O ports without much loss of performance. + GPIOs mapped to IRQs -------------------- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5b541364dee0..bf95f2964bc5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2846,6 +2846,12 @@ int gpiod_get_array_bitmap_complex(bool raw, bool can_sleep, if (array->ndescs > sizeof(*bits)) return -EINVAL; + if (raw && !IS_ERR_OR_NULL(array->chip)) { + unsigned long mask = (1ULL << array->ndescs) - 1; + + return gpio_chip_get_multiple(array->chip, &mask, bits); + } + i = gpiod_get_array_value_complex(raw, can_sleep, array->ndescs, array->desc, value_array); if (i) @@ -3156,6 +3162,14 @@ int gpiod_set_array_bitmap_complex(bool raw, bool can_sleep, if (array->ndescs > sizeof(*bits)) return -EINVAL; + if (raw && !IS_ERR_OR_NULL(array->chip)) { + unsigned long mask = (1ULL << array->ndescs) - 1; + + gpio_chip_set_multiple(array->chip, &mask, bits); + + return 0; + } + for (i = 0; i < array->ndescs; i++) value_array[i] = test_bit(i, bits);