Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1100694imm; Wed, 18 Jul 2018 16:58:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd0jDYM/ZYWHxiAVFK2JlILIHr8gVO0sP8Y9eLaKtmHyBMWM36Vjtaa+vc+mOpNByoEyeKv X-Received: by 2002:a17:902:8697:: with SMTP id g23-v6mr7851819plo.292.1531958299559; Wed, 18 Jul 2018 16:58:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531958299; cv=none; d=google.com; s=arc-20160816; b=c2snyn9wfC6pdghEcAvJZk15kaK3/VY1nOOfUZpjET/vZvwn02RM65cUDlQg+CAyVf VxiVp3Za5DD1sjnkIp3l5BWDZ2VWv8NMP4Z4IZvl6kpmXK2sNyQQKeEMrdLBQqbNWR2r 4d2FhMtIhlS+/+Z/o8eSEkbQFIUOtVKNFHTxiUInvXXNxxz51HLZDiV9ef9AFb8YN1Tr toTDa4Vjw2NtdwCQQy45/7DmW2NP+xQkKHv1rOWqDUKsBJ1HsWKYmE7YHT91z0kcW+Js dTIJANdaMQbb4rhLDnsskFu+hVPx+canqYFZ2GBPuOavUtJ9uw8gI0qTLRNhYSZ29Qls rzIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7UpVQKmbNqgcoYX7beG5QsOge6J6prdHCDj6n9vqTZM=; b=fNYDoib1MUeUul6d+0LjkOGriPj7tBWxEf+QZpdEf4nzw95Q0S3mzyUuwt+a4DAu1+ yxbHBiWqBnBog5l331TooHZGrj2KxEAf1Xvc+Vb3B412l66Mq8lv+Dno0pM55iBAYne0 v00F8Hr46s4BdsERzQQ3U2+3IJXDWLRccFYhqghAn+FjTi9SwAkMv0w19P+KPmBoQRor LB2d6H4njRFVZ14dEWq50RqU067TOCQ+kcoJaxntesyZid+bLC0kjDCZLa3PQQqJFJ6S qkW+jUvv/dwljFusVPTgY3gD0A0MQD15WkfofRVgdMlkEWDigDXIt9jE/YDQFKtQ464r X3rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sPwlnCuf; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1-v6si4082824pli.76.2018.07.18.16.58.04; Wed, 18 Jul 2018 16:58:19 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sPwlnCuf; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731108AbeGSAhS (ORCPT + 99 others); Wed, 18 Jul 2018 20:37:18 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:36768 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730813AbeGSAhR (ORCPT ); Wed, 18 Jul 2018 20:37:17 -0400 Received: by mail-lf0-f67.google.com with SMTP id b22-v6so4704783lfa.3; Wed, 18 Jul 2018 16:56:57 -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=S/tAIoIoaHjwyZ6Vurt+JklYAr8AC/f2R08+4YTjUNEjMH/L2MS6hT8mb+NjwSA/h9 dcby0cvEtdOlnmyzh0CSraJUxC8kLQ/nzH4k3m9CdbBKKRAF5z0hKrJaBIOv5AGFG8kC 8YqoPjaqwZoIEa3kbepK78AxwfxOzBiYV/BAHw9fd9+JkYvCLjc6PJlFDwiel3BARJYr +kzBwos9H/zOXlYEbHGmflYlABRU6CZZFZBKlLDSjmGOiJm9U6l2rFqt+6UFB1tvr3xf F+WUHSPhD/CgNQrzrkYUZzF1AR6ZklCtVi8J6qTdr822RL3ZjqZZrDwBVBQmA/XGkQ/s 9lqw== X-Gm-Message-State: AOUpUlHISs3r7XZmMkESA+OKHelMMMJTexbJTNtGvcaVyQu6Hz0YM5ZS Mz0yeerdPI4Sj3WaBglvAVg= 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 Cc: 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 , Janusz Krzysztofik 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.16.4