Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1354177imm; Wed, 18 Jul 2018 23:30:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfYpV++UJ4gfLpldGFqD20aY3h1ZtmfAFqku/k8IaBlzpFNgwDVjKlK9Xb3jft96nTTwKhb X-Received: by 2002:a17:902:7894:: with SMTP id q20-v6mr5908091pll.3.1531981804758; Wed, 18 Jul 2018 23:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531981804; cv=none; d=google.com; s=arc-20160816; b=q0pHZ1mRFgW3kXrPBSAKJjuNzcAmN12V2t7k/xwDbZk+aFtzRq5nx8Vr7atozgV3Qw klXfKV58v1+FlP/s4GEk8lBTeVUFBaSYWFBQMwp69Ca7UOVBWuYXBJGTYya0vD2SzcKH pR5CfIwY6oF8Bj4kF3lVRS3imKHpjBp6pR3jqMBd9jh+G5rwQk90/Uzwxs3Rjn/lOxu9 lz4tbRJ33DaMOvn+l4YYpodcHosUmynoDBPtGBmBNgcpvO+iIlu/57MQ3d6n3xhQNS8g e8cI1B/VX6rJQOj28WBD4MUGcEDNftOo/WTqy7lbU7jh/Li19nZjQ6UgNxFEulShdWCI S3XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=oSsdgvtvizNdAnL4FTYkBslEzwvhp7tbB6YOV9p4Tq0=; b=rtTPpZuxVpx+q/Uyp5pFcHWcn8t/yaUNjt9zdCaijZ7LQPHs/3TYoqxMkcrHsigYuL 2bgN4/YQMUrqov9VDEeiYEcOtj4yV4mAysb067OTIQs12HaOc8najtjmAwWb3+rE8SqI IDBM/qW7CdtJIerJhj3bsfuLfugqk+mosFhCHK5vi/4IgvtO8HE5Q/Npul+jv7psSR6T 702M0uBDXL/wDwTppYJWfCV8ZE3pkXh3fI6Ep/mRCH+MwCjzvIwnDe2eRBQD+4/qBBQp ynpWUEaLfCRosN2Vm04prbJB9j3mQKSxM/51WbdnKfan1nqUtDQPA6imjK5oKIBaac9l a8Sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si4815465pgu.636.2018.07.18.23.29.50; Wed, 18 Jul 2018 23:30:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbeGSHKK (ORCPT + 99 others); Thu, 19 Jul 2018 03:10:10 -0400 Received: from mail.bootlin.com ([62.4.15.54]:51404 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbeGSHKJ (ORCPT ); Thu, 19 Jul 2018 03:10:09 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id D5D0120766; Thu, 19 Jul 2018 08:28:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (unknown [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 7F0DB206F3; Thu, 19 Jul 2018 08:28:36 +0200 (CEST) Date: Thu, 19 Jul 2018 08:28:34 +0200 From: Boris Brezillon To: Janusz Krzysztofik Cc: Miquel Raynal , Tony Lindgren , Aaro Koskinen , Grygorii Strashko , Santosh Shilimkar , Kevin Hilman , Linus Walleij , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Bityutskiy Subject: Re: [RFC PATCH 5/8] mtd: rawnand: ams-delta: Request data port GPIO resource Message-ID: <20180719082834.32827212@bbrezillon> In-Reply-To: <20180718235710.18242-6-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180718235710.18242-6-jmkrzyszt@gmail.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Jul 2018 01:57:07 +0200 Janusz Krzysztofik wrote: > 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, we can already > obtain exclusive access to the port by requesting an array of its GPIO > descriptors. For that to work on Amstrad Delta, respective GPIO lookup > table entries are added to the board init file. > > Signed-off-by: Janusz Krzysztofik > --- > arch/arm/mach-omap1/board-ams-delta.c | 11 ++++++++++- > drivers/mtd/nand/raw/ams-delta.c | 8 ++++++++ Can we split that in 2 patches: one adding data entries to the lookup table, and another one patching the driver to request the gpiod array. > 2 files changed, 18 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), > { }, > }, > }; > diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c > index d7e4c9dbef67..ad62c0245458 100644 > --- a/drivers/mtd/nand/raw/ams-delta.c > +++ b/drivers/mtd/nand/raw/ams-delta.c > @@ -189,6 +189,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) > @@ -289,6 +290,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 output and set low */ > + data_gpiods = devm_gpiod_get_array(&pdev->dev, "data", GPIOD_OUT_LOW); > + 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);