From patchwork Wed Jul 18 23:57: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: 10533477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2AC2B6020A for ; Wed, 18 Jul 2018 23:57:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 187BC29924 for ; Wed, 18 Jul 2018 23:57:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CE5529930; Wed, 18 Jul 2018 23:57: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=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 9C75D2992B for ; Wed, 18 Jul 2018 23:57:42 +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=tGgrKiJj9s8Jva/N1h0qrlFc7J3kn/g7HZwl8YtUi1w=; b=CxRK5vYwXRbj2G8PiCm7nNTFG5 79Ts+u/WrVJ11EynbBLoK3zgSW331YDTLOcgveAu9H/dedoTF7yMkrdcGNx38qaV+29us4qPoLQo+ 00Wa2VTCpmzmVR8YiXTIUgi8I394/+F5oTtYlTQi4dwkikPBnJAsG4MtlUojMQ0rIqy54kTZdhgHQ st+qgC1XChI0RZqGM1KZZNd+nSoWluIJURRtE7p1YdMBlP3hKHr42tT1GYwtPdDJOQsbt8H5Y/ox9 1/m2PeLeAM8vht/t4Dm8uuCtKxnW/Mk4Pbd40WC4oz1BU2kaWFCL/7OavQLn97Z7Atv13bdJxysgw LiD3C7Cg==; 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 1ffwK8-0006UR-CM; Wed, 18 Jul 2018 23:57:36 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffwJa-0005mt-BM; Wed, 18 Jul 2018 23:57:03 +0000 Received: by mail-lf0-x244.google.com with SMTP id u14-v6so4705562lfu.0; Wed, 18 Jul 2018 16:56:58 -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=7UpVQKmbNqgcoYX7beG5QsOge6J6prdHCDj6n9vqTZM=; b=sPwlnCuf03EeIomuZl/nufBkir6j6bl5mxtOPupoxRmP6bLExqbnQsBW91SxU/HawO VVEGvQqiWU7qSYVYd5t/5F0UJs+AvWl9vfOhMOw6TBLRWP48F1Dx0QZ7pK56Qa+qd23A QT4+hIU/Zi1CsD1SVP5ddaJyPxtE7HNO9OSBMdh7hQMEhVBx6hWxIOivd84EgqKo3npq 3NbofxiCXupZLDwYU2DcUwNOuYpxxlX6w5MKi4tXe5TOqM0kqUDPMXeRnNnoxz42vehq 4DbZQ5XlFU+qxUVS+Jnfpzff+2B2POqw9a/3npneREuRpEMw+2byDikDhOpo+IFzSuvK dgIg== 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=7UpVQKmbNqgcoYX7beG5QsOge6J6prdHCDj6n9vqTZM=; b=BbUI6V7Sx0IfqdcIH1dFMeNtVXCQ3yvNxsosg+KHDEF3yrplG5oX+A6wYZ235/cAZX duKLzfCT+jF9OT+O3q22fJBqmdDbq/pK17wFgA0n+oMcat1jQLxaefBfEP7ypNp5Jc8Z bsh5+SID/el/SSQ6ECsGmlyGYGzVtKRYseBq8cVERhHwRDAcqc11BUIrCSubdTpulz4k Qu+nvGdezu7ZoJezAWV7jyFGqpDNJ3bxJirl1m5bU9bDCN5PEdKGMvTiCYqYYmjpMoAC g9IbmlABJG7evZLAjman/fFJ/vWaCLMy7BUrijEo7VtcIHTyrrjClcUUSJ8uDnXZXcFy KB6w== X-Gm-Message-State: AOUpUlHBZemHy8c6XHdK3F5hOl8y80xX2LScYemsfrvwXcpbYey+kGll nYjH9cNokyWuUmbuflPfO4Y= X-Google-Smtp-Source: AAOMgpdbtSiftXIk6ZWvWrBkBY16OasqkjudQFzoX/3IplArXFK63OCbkh8yrSXhIN6KViYM+ewWkA== X-Received: by 2002:a19:1586:: with SMTP id 6-v6mr4910327lfv.51.1531958216950; Wed, 18 Jul 2018 16:56:56 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h7-v6sm826584ljk.27.2018.07.18.16.56.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 16:56:56 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Miquel Raynal Subject: [RFC PATCH 5/8] mtd: rawnand: ams-delta: Request data port GPIO resource Date: Thu, 19 Jul 2018 01:57:07 +0200 Message-Id: <20180718235710.18242-6-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180718235710.18242-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180718_165702_403958_6152C9EF X-CRM114-Status: GOOD ( 18.17 ) 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: Grygorii Strashko , Kevin Hilman , Tony Lindgren , Richard Weinberger , Linus Walleij , Aaro Koskinen , Artem Bityutskiy , linux-kernel@vger.kernel.org, Marek Vasut , linux-omap@vger.kernel.org, Janusz Krzysztofik , linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, Santosh Shilimkar , 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, 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 ++++++++ 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);