From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:40:42
In preparation for merging the driver with "gpio-nand", as suggested by
Boris Brezillon and others, drop Amstrad Delta specific bits or replace
them with more generic ones.
The series starts with v2 of a patch that adds write protection on boot,
originally submitted as a part of the driver GPIO migratiton series but
not merged, with comments received at that time from Boris Brezillon now
hopefully addressed.
The series also contains v4 of a previously discussed patch that drops
Amstrad Delta specific partition table info from the driver, now
provided by the board file via platform data, with an OF fix added in v2
now excluded to a separate patch.
Remaining patches are new submissions.
Janusz Krzysztofik (14):
mtd: rawnand: ams-delta: Write protect device during probe
mtd: rawnand: ams-delta: Use struct gpio_nand_platdata
ARM: OMAP1: ams-delta: Provide board specific partition info
mtd: rawnand: ams-delta: Drop board specific partition info
mtd: rawnand: ams-delta: Enable OF partition info support
mtd: rawnand: ams-delta: Push inversion handling to gpiolib
mtd: rawnand: ams-delta: Don't hardcode read/write pulse widths
mtd: rawnand: ams-delta: Make read pulses optional
mtd: rawnand: ams-delta: Handle more GPIO pins as optional
mtd: rawnand: ams-delta: Add module device tables
mtd: rawnand: ams-delta: Support custom driver initialisation
mtd: rawnand: ams-delta: Drop useless local variable
mtd: rawnand: ams-delta: Make the driver custom I/O ready
mtd: rawnand: ams-delta: Rename structures and functions to gpio_nand*
arch/arm/mach-omap1/board-ams-delta.c | 47 ++++-
drivers/mtd/nand/raw/ams-delta.c | 237 +++++++++++++++++---------
2 files changed, 198 insertions(+), 86 deletions(-)
--
2.24.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:40:25
Initialise NWP GPIO pin as asserted to protect the device from hazard
during setup of other GPIO pins.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
v2: release write protection before calling nand_scan()
drivers/mtd/nand/raw/ams-delta.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
@@ -251,8 +251,8 @@ static int ams_delta_init(struct platform_device *pdev)platform_set_drvdata(pdev,priv);-/* Set chip enabled, but */-priv->gpiod_nwp=devm_gpiod_get(&pdev->dev,"nwp",GPIOD_OUT_HIGH);+/* Set chip enabled but write protected */+priv->gpiod_nwp=devm_gpiod_get(&pdev->dev,"nwp",GPIOD_OUT_LOW);if(IS_ERR(priv->gpiod_nwp)){err=PTR_ERR(priv->gpiod_nwp);dev_err(&pdev->dev,"NWP GPIO request failed (%d)\n",err);
@@ -309,6 +309,17 @@ static int ams_delta_init(struct platform_device *pdev)nand_controller_init(&priv->base);this->controller=&priv->base;+/*+*FIXME:Weshouldreleasewriteprotectiononlyafternand_scan()to+*beonthesafesidebutwecan'tdothatuntilwehaveagenericway+*toassert/deassertWPfromthecore.Evenifthecoreshouldn't+*writethingsinthenand_scan()path,itshouldhavecontrolonthis+*pinjustincaseweeverneedtodisablewriteprotectionduring+*chipdetection/initialization.+*/+/* Release write protection */+gpiod_set_value(priv->gpiod_nwp,1);+/* Scan to find existence of the device */err=nand_scan(this,1);if(err)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:41:27
In order to be able to move the hardcoded Amstrad Delta partition info
from the driver code to the board file, reuse gpio_nand_platdata
structure owned by "gpio-nand" driver and try to obtain information
on device partitions from device platform data.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:42:03
Now as the Amstrad Delta NAND driver supports fetching information on
MTD partitions from device platform data, add partition info to the
NAND device configuration.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
arch/arm/mach-omap1/board-ams-delta.c | 35 +++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:42:33
Now as we support fetching partition info from device platform data and
the Amstrad Delta board file provides that info, drop it from the
driver code.
v2: rebase on top of gpio_nand_platdata extension
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
Changelog:
v4: rebase on top of gpio_nand_platdata driver/board extensions,
- drop no longer required command line parser related bits,
- adjust commit description,
- move OF fix to a separate patch.
v3: add information on the requirement for passing partition info via
kernel command line to the board Kconfig entry help text.
v2: fix a typo poitned out by Aaro - thanks!,
- fix device_node not passed to OF parser via mtd_info,
- commit message reworded and reformatted a bit for better
readability.
drivers/mtd/nand/raw/ams-delta.c | 29 ++---------------------------
1 file changed, 2 insertions(+), 27 deletions(-)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:42:52
Provide MTD layer with device OF node info required by OF partition
parser.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 1 +
1 file changed, 1 insertion(+)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:43:09
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
[off-list ref], 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(-)
@@ -303,7 +303,7 @@ static int ams_delta_init(struct platform_device *pdev)*chipdetection/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);
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:43:38
Allow platforms to omit NRE pin from device configuration by requesting
that pin as optional. In that case, also don't apply read pulse width
from chip SDR timings. There should be no need for further code
adjustments as gpiolib can handle NULL GPIO descriptor pointers.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:45:20
In preparation for extending the driver with custom I/O support, try to
obtain device specific initialisation routine from a matching device
table entry and run it as an additional step of device probe.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 11 +++++++++++
1 file changed, 11 insertions(+)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:45:42
In preparation for merging the driver with "gpio-nand", introduce
module device tables where new device models can be accommodated as
soon as respective support is added.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:45:52
In order to make the driver more useful on platforms other than Amstrad
Delta, allow GPIO descriptor pointers of possibly non-critical NWP and
NCE pins to be initialised as NULL.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:46:05
For consistency with adjacent code patterns used in the driver probe
function, store data GPIO array pointer directly in a respective field
of the driver private structure instead of storing it intermediately
in a local variable for error checking.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
@@ -230,7 +230,6 @@ static int ams_delta_init(struct platform_device *pdev)structams_delta_nand*priv;structnand_chip*this;structmtd_info*mtd;-structgpio_descs*data_gpiods;int(*probe)(structplatform_device*pdev,structams_delta_nand*priv);interr=0;
@@ -312,13 +311,12 @@ static int ams_delta_init(struct platform_device *pdev)}/* 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);returnerr;}-priv->data_gpiods=data_gpiods;priv->data_in=true;if(pdev->id_entry)
--
2.24.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:46:15
In order to be merged with "gpio-nand", the driver must support custom
(non-GPIO) I/O accessors.
Allow platforms to omit data GPIO port as well as NWE pin info from
device setup. For the driver to still work on such platform, custom
I/O accessors as well as a custom probe function which initialises the
driver private structure with those accessors must be added to the
driver.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
@@ -311,13 +315,24 @@ static int ams_delta_init(struct platform_device *pdev)}/* Request array of data pins, initialize them as input */-priv->data_gpiods=devm_gpiod_get_array(&pdev->dev,"data",GPIOD_IN);+priv->data_gpiods=devm_gpiod_get_array_optional(&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);returnerr;}-priv->data_in=true;+if(priv->data_gpiods){+if(!priv->gpiod_nwe){+dev_err(&pdev->dev,+"mandatory NWE pin not provided by platform\n");+return-ENODEV;+}++priv->io_read=ams_delta_io_read;+priv->io_write=ams_delta_io_write;+priv->data_in=true;+}if(pdev->id_entry)probe=(void*)pdev->id_entry->driver_data;
@@ -328,6 +343,11 @@ static int ams_delta_init(struct platform_device *pdev)if(err)returnerr;+if(!priv->io_read||!priv->io_write){+dev_err(&pdev->dev,"incomplete device configuration\n");+return-ENODEV;+}+/* Initialize the NAND controller object embedded in ams_delta_nand. */priv->base.ops=&ams_delta_ops;nand_controller_init(&priv->base);
--
2.24.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 00:46:56
Another step in preparation for merging the driver with "gpio-nand".
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/mtd/nand/raw/ams-delta.c | 86 ++++++++++++++++----------------
1 file changed, 42 insertions(+), 44 deletions(-)
@@ -188,15 +186,15 @@ static int ams_delta_exec_op(struct nand_chip *this,break;}-ams_delta_ctrl_cs(priv,0);+gpio_nand_ctrl_cs(priv,0);returnret;}-staticintams_delta_setup_data_interface(structnand_chip*this,intcsline,+staticintgpio_nand_setup_data_interface(structnand_chip*this,intcsline,conststructnand_data_interface*cf){-structams_delta_nand*priv=nand_get_controller_data(this);+structgpio_nand*priv=nand_get_controller_data(this);conststructnand_sdr_timings*sdr=nand_get_sdr_timings(cf);structdevice*dev=&nand_to_mtd(this)->dev;
@@ -217,23 +215,23 @@ static int ams_delta_setup_data_interface(struct nand_chip *this, int csline,return0;}-staticconststructnand_controller_opsams_delta_ops={-.exec_op=ams_delta_exec_op,-.setup_data_interface=ams_delta_setup_data_interface,+staticconststructnand_controller_opsgpio_nand_ops={+.exec_op=gpio_nand_exec_op,+.setup_data_interface=gpio_nand_setup_data_interface,};/**Maininitializationroutine*/-staticintams_delta_init(structplatform_device*pdev)+staticintgpio_nand_probe(structplatform_device*pdev){structgpio_nand_platdata*pdata=dev_get_platdata(&pdev->dev);conststructmtd_partition*partitions=NULL;intnum_partitions=0;-structams_delta_nand*priv;+structgpio_nand*priv;structnand_chip*this;structmtd_info*mtd;-int(*probe)(structplatform_device*pdev,structams_delta_nand*priv);+int(*probe)(structplatform_device*pdev,structgpio_nand*priv);interr=0;if(pdata){
@@ -242,7 +240,7 @@ static int ams_delta_init(struct platform_device *pdev)}/* Allocate memory for MTD device structure and private data */-priv=devm_kzalloc(&pdev->dev,sizeof(structams_delta_nand),+priv=devm_kzalloc(&pdev->dev,sizeof(structgpio_nand),GFP_KERNEL);if(!priv)return-ENOMEM;
@@ -329,8 +327,8 @@ static int ams_delta_init(struct platform_device *pdev)return-ENODEV;}-priv->io_read=ams_delta_io_read;-priv->io_write=ams_delta_io_write;+priv->io_read=gpio_nand_io_read;+priv->io_write=gpio_nand_io_write;priv->data_in=true;}
@@ -348,8 +346,8 @@ static int ams_delta_init(struct platform_device *pdev)return-ENODEV;}-/* Initialize the NAND controller object embedded in ams_delta_nand. */-priv->base.ops=&ams_delta_ops;+/* Initialize the NAND controller object embedded in gpio_nand. */+priv->base.ops=&gpio_nand_ops;nand_controller_init(&priv->base);this->controller=&priv->base;
From: Tony Lindgren <tony@atomide.com> Date: 2020-02-12 14:52:11
* Janusz Krzysztofik [off-list ref] [200212 00:41]:
Now as the Amstrad Delta NAND driver supports fetching information on
MTD partitions from device platform data, add partition info to the
NAND device configuration.
Fine if you want hardcoded partition info :) Not sure if the partition
info coming from bootloader is any better either.. Ideally there would
be a partition table somewhere on the device like we have for disks..
Anyways, this is best merged together with the mtd patches so:
Acked-by: Tony Lindgren <tony@atomide.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Janusz Krzysztofik <jmkrzyszt@gmail.com> Date: 2020-02-12 18:26:07
Hi Tony,
On Wednesday, February 12, 2020 3:51:54 P.M. CET Tony Lindgren wrote:
* Janusz Krzysztofik [off-list ref] [200212 00:41]:
quoted
Now as the Amstrad Delta NAND driver supports fetching information on
MTD partitions from device platform data, add partition info to the
NAND device configuration.
Fine if you want hardcoded partition info :) Not sure if the partition
info coming from bootloader is any better either.. Ideally there would
be a partition table somewhere on the device like we have for disks..
Yeah, but Amstrad didn't provide anything like that, and we may want to get
convenient access to factory content of the flash. We might use command line
for that, though nobody seemed to really like my previous proposal to use
command line partition info exclusively.
Anyways, this is best merged together with the mtd patches so:
Acked-by: Tony Lindgren <tony@atomide.com>
Thanks for your A-b:. BTW, patch 06/14 also touches the board file and would
require your acceptance before being merged via mtd, so could you please have
a look?
Thanks,
Janusz
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Tony Lindgren <tony@atomide.com> Date: 2020-02-12 18:28:24
* Janusz Krzysztofik [off-list ref] [200212 00:41]:
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
[off-list ref], thanks!
From: Tony Lindgren <tony@atomide.com> Date: 2020-02-12 18:28:45
* Janusz Krzysztofik [off-list ref] [200212 18:26]:
Thanks for your A-b:. BTW, patch 06/14 also touches the board file and would
require your acceptance before being merged via mtd, so could you please have
a look?
On Wed, 2020-02-12 at 00:39:28 UTC, Janusz Krzysztofik wrote:
In order to be merged with "gpio-nand", the driver must support custom
(non-GPIO) I/O accessors.
Allow platforms to omit data GPIO port as well as NWE pin info from
device setup. For the driver to still work on such platform, custom
I/O accessors as well as a custom probe function which initialises the
driver private structure with those accessors must be added to the
driver.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:27 UTC, Janusz Krzysztofik wrote:
For consistency with adjacent code patterns used in the driver probe
function, store data GPIO array pointer directly in a respective field
of the driver private structure instead of storing it intermediately
in a local variable for error checking.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:26 UTC, Janusz Krzysztofik wrote:
In preparation for extending the driver with custom I/O support, try to
obtain device specific initialisation routine from a matching device
table entry and run it as an additional step of device probe.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:25 UTC, Janusz Krzysztofik wrote:
In preparation for merging the driver with "gpio-nand", introduce
module device tables where new device models can be accommodated as
soon as respective support is added.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:24 UTC, Janusz Krzysztofik wrote:
In order to make the driver more useful on platforms other than Amstrad
Delta, allow GPIO descriptor pointers of possibly non-critical NWP and
NCE pins to be initialised as NULL.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:23 UTC, Janusz Krzysztofik wrote:
Allow platforms to omit NRE pin from device configuration by requesting
that pin as optional. In that case, also don't apply read pulse width
from chip SDR timings. There should be no need for further code
adjustments as gpiolib can handle NULL GPIO descriptor pointers.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:22 UTC, Janusz Krzysztofik wrote:
Instead of forcing Amstrad Delta specific read/write pulse widths, use
variables initialised from respective fields of chip SDR timings.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:21 UTC, Janusz Krzysztofik wrote:
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
[off-list ref], thanks!
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>
On Wed, 2020-02-12 at 00:39:19 UTC, Janusz Krzysztofik wrote:
Now as we support fetching partition info from device platform data and
the Amstrad Delta board file provides that info, drop it from the
driver code.
v2: rebase on top of gpio_nand_platdata extension
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:18 UTC, Janusz Krzysztofik wrote:
Now as the Amstrad Delta NAND driver supports fetching information on
MTD partitions from device platform data, add partition info to the
NAND device configuration.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>
On Wed, 2020-02-12 at 00:39:17 UTC, Janusz Krzysztofik wrote:
In order to be able to move the hardcoded Amstrad Delta partition info
from the driver code to the board file, reuse gpio_nand_platdata
structure owned by "gpio-nand" driver and try to obtain information
on device partitions from device platform data.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
On Wed, 2020-02-12 at 00:39:16 UTC, Janusz Krzysztofik wrote:
Initialise NWP GPIO pin as asserted to protect the device from hazard
during setup of other GPIO pins.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>