From: Janusz Krzysztofik <jmkrzyszt@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Tony Lindgren <tony@atomide.com>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
linux-mtd@lists.infradead.org,
Janusz Krzysztofik <jmkrzyszt@gmail.com>
Subject: [RFC PATCH 06/14] mtd: rawnand: ams-delta: Push inversion handling to gpiolib
Date: Wed, 12 Feb 2020 01:39:21 +0100 [thread overview]
Message-ID: <20200212003929.6682-7-jmkrzyszt@gmail.com> (raw)
In-Reply-To: <20200212003929.6682-1-jmkrzyszt@gmail.com>
Let platforms take care of declaring correct GPIO pin polarity so we
can just ask a GPIO line to be asserted or deasserted and gpiolib deals
with the rest depending on how the platform is configured.
Inspired by similar changes to regulator drivers by Linus Walleij
<linus.walleij@linaro.org>, thanks!
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
arch/arm/mach-omap1/board-ams-delta.c | 12 ++++++++----
drivers/mtd/nand/raw/ams-delta.c | 22 +++++++++++-----------
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index f4d2ef97099e..8d32894ecd2e 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -341,10 +341,14 @@ static struct gpiod_lookup_table ams_delta_nand_gpio_table = {
.table = {
GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy",
0),
- GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce", 0),
- GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre", 0),
- GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp", 0),
- GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe", 0),
+ GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce",
+ GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre",
+ GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp",
+ GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe",
+ GPIO_ACTIVE_LOW),
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),
diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c
index fb96f6a3b0b3..c7aeb940accd 100644
--- a/drivers/mtd/nand/raw/ams-delta.c
+++ b/drivers/mtd/nand/raw/ams-delta.c
@@ -44,9 +44,9 @@ struct ams_delta_nand {
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);
+ ndelay(40);
+ gpiod_set_value(priv->gpiod_nwe, 0);
}
static void ams_delta_io_write(struct ams_delta_nand *priv, u8 byte)
@@ -81,13 +81,13 @@ static u8 ams_delta_io_read(struct ams_delta_nand *priv)
struct gpio_descs *data_gpiods = priv->data_gpiods;
DECLARE_BITMAP(values, BITS_PER_TYPE(res)) = { 0, };
- gpiod_set_value(priv->gpiod_nre, 0);
+ gpiod_set_value(priv->gpiod_nre, 1);
ndelay(40);
gpiod_get_raw_array_value(data_gpiods->ndescs, data_gpiods->desc,
data_gpiods->info, values);
- gpiod_set_value(priv->gpiod_nre, 1);
+ gpiod_set_value(priv->gpiod_nre, 0);
res = values[0];
return res;
@@ -129,7 +129,7 @@ static void ams_delta_read_buf(struct ams_delta_nand *priv, u8 *buf, int len)
static void ams_delta_ctrl_cs(struct ams_delta_nand *priv, bool assert)
{
- gpiod_set_value(priv->gpiod_nce, assert ? 0 : 1);
+ gpiod_set_value(priv->gpiod_nce, assert);
}
static int ams_delta_exec_op(struct nand_chip *this,
@@ -237,28 +237,28 @@ static int ams_delta_init(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
/* Set chip enabled but write protected */
- priv->gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_LOW);
+ 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);
return err;
}
- priv->gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_HIGH);
+ priv->gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_LOW);
if (IS_ERR(priv->gpiod_nce)) {
err = PTR_ERR(priv->gpiod_nce);
dev_err(&pdev->dev, "NCE GPIO request failed (%d)\n", err);
return err;
}
- priv->gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_HIGH);
+ priv->gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_LOW);
if (IS_ERR(priv->gpiod_nre)) {
err = PTR_ERR(priv->gpiod_nre);
dev_err(&pdev->dev, "NRE GPIO request failed (%d)\n", err);
return err;
}
- priv->gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_HIGH);
+ priv->gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_LOW);
if (IS_ERR(priv->gpiod_nwe)) {
err = PTR_ERR(priv->gpiod_nwe);
dev_err(&pdev->dev, "NWE GPIO request failed (%d)\n", err);
@@ -303,7 +303,7 @@ static int ams_delta_init(struct platform_device *pdev)
* chip detection/initialization.
*/
/* Release write protection */
- gpiod_set_value(priv->gpiod_nwp, 1);
+ gpiod_set_value(priv->gpiod_nwp, 0);
/* Scan to find existence of the device */
err = nand_scan(this, 1);
@@ -332,7 +332,7 @@ static int ams_delta_cleanup(struct platform_device *pdev)
struct mtd_info *mtd = nand_to_mtd(&priv->nand_chip);
/* Apply write protection */
- gpiod_set_value(priv->gpiod_nwp, 0);
+ gpiod_set_value(priv->gpiod_nwp, 1);
/* Unregister device */
nand_release(mtd_to_nand(mtd));
--
2.24.1
next prev parent reply other threads:[~2020-02-12 0:40 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 0:39 [RFC PATCH 00/14] mtd: rawnand: ams-delta: Prepare for merging Janusz Krzysztofik
2020-02-12 0:39 ` [RFC PATCH 01/14 v2] mtd: rawnand: ams-delta: Write protect device during probe Janusz Krzysztofik
2020-03-10 18:33 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 02/14] mtd: rawnand: ams-delta: Use struct gpio_nand_platdata Janusz Krzysztofik
2020-03-10 18:33 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 03/14] ARM: OMAP1: ams-delta: Provide board specific partition info Janusz Krzysztofik
2020-02-12 14:51 ` Tony Lindgren
2020-02-12 18:25 ` Janusz Krzysztofik
2020-02-12 18:28 ` Tony Lindgren
2020-03-10 18:33 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 04/14 v4] mtd: rawnand: ams-delta: Drop " Janusz Krzysztofik
2020-03-10 18:33 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 05/14] mtd: rawnand: ams-delta: Enable OF partition info support Janusz Krzysztofik
2020-03-10 18:33 ` Miquel Raynal
2020-02-12 0:39 ` Janusz Krzysztofik [this message]
2020-02-12 18:28 ` [RFC PATCH 06/14] mtd: rawnand: ams-delta: Push inversion handling to gpiolib Tony Lindgren
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 07/14] mtd: rawnand: ams-delta: Don't hardcode read/write pulse widths Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 08/14] mtd: rawnand: ams-delta: Make read pulses optional Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 09/14] mtd: rawnand: ams-delta: Handle more GPIO pins as optional Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 10/14] mtd: rawnand: ams-delta: Add module device tables Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 11/14] mtd: rawnand: ams-delta: Support custom driver initialisation Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 12/14] mtd: rawnand: ams-delta: Drop useless local variable Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 13/14] mtd: rawnand: ams-delta: Make the driver custom I/O ready Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
2020-02-12 0:39 ` [RFC PATCH 14/14] mtd: rawnand: ams-delta: Rename structures and functions to gpio_nand* Janusz Krzysztofik
2020-03-10 18:32 ` Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200212003929.6682-7-jmkrzyszt@gmail.com \
--to=jmkrzyszt@gmail.com \
--cc=aaro.koskinen@iki.fi \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=tony@atomide.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).