mtd: nand: omap_gpmc: Make ready/busy pins configurable
Subsystems (2)
PATCH 1/1 mtd: nand: omap_gpmc: Make ready/busy pins configurable
Commit fb384c4720ca7496775d6578f184bf628db73456 introduced the use of WAIT0 pin for determining whether the NAND is ready or not. This only works if all NAND chips are connected to WAIT0. If some chips are connected to the other available pin WAIT1, nand_wait() does not really wait and prints a WARN_ON message.
This patch allows the board to provide configuration of which chip is connected to which WAITx signal. For example, one can define in include/configs/foo.h:
#define CONFIG_NAND_OMAP_GPMC_WSCFG 0,0,1,1
This would mean that chips using to CS0 and 1 are connected to WAIT0 and chips with CS2 and 3 are connected to WAIT1.
--- drivers/mtd/nand/omap_gpmc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/mtd/nand/omap_gpmc.c +11 -2
@@ -36,7 +36,8 @@ static __maybe_unused struct nand_ecclayout omap_ecclayout;struct omap_nand_info {struct bch_control *control;enum omap_ecc ecc_scheme; -int cs; +uint8_t cs; +uint8_t ws;/* wait status pin (0,1) */ };/* We are wasting a bit of memory but al least we are safe */
@@ -76,7 +77,9 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,/* Check wait pin as dev ready indicator */ static int omap_dev_ready (struct mtd_info *mtd) { -return gpmc_cfg->status & (1 <<8 ); + registerstruct nand_chip *this = mtd->priv; +struct omap_nand_info *info = this->priv; +return gpmc_cfg->status & (1 << (8 + info->ws)); }/*
@@ -853,6 +856,12 @@ int board_nand_init(struct nand_chip *nand) nand->IO_ADDR_W = (void __iomem *)&gpmc_cfg->cs[cs].nand_cmd; omap_nand_info[cs].control =NULL ; omap_nand_info[cs].cs = cs; +#if !defined(CONFIG_NAND_OMAP_GPMC_WSCFG ) + omap_nand_info[cs].ws =0 ; +#else +int8_t ws[CONFIG_SYS_MAX_NAND_DEVICE ] = {CONFIG_NAND_OMAP_GPMC_WSCFG }; + omap_nand_info[cs].ws = ws[cs]; +#endif nand->priv = &omap_nand_info[cs]; nand->cmd_ctrl = omap_nand_hwcontrol; nand->options |=NAND_NO_PADDING |NAND_CACHEPRG ;
Signature · 1 line
2.1.4
PATCH 1/1 mtd: nand: omap_gpmc: Make ready/busy pins configurable
Quoted 49 lines · Michal Sojka
Commit
fb384c4720ca7496775d6578f184bf628db73456introduced the use of WAIT0 pin for determining whether the NAND is ready or not. This only works if all NAND chips are connected to WAIT0. If some chips are connected to the other available pin WAIT1,nand_wait()does not really wait and prints aWARN_ONmessage.This patch allows the board to provide configuration of which chip is connected to which WAITx signal. For example, one can define in
include/configs/foo.h:#define CONFIG_NAND_OMAP_GPMC_WSCFG 0,0,1,1This would mean that chips using to CS0 and 1 are connected to WAIT0 and chips with CS2 and 3 are connected to WAIT1.
Signed-off-by Michal Sojka <[email protected]>Cc Tom Rini <[email protected]>Cc Stefan Roese <[email protected]>--- drivers/mtd/nand/omap_gpmc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/mtd/nand/omap_gpmc.c +5
-2@@ -36,7 +36,8 @@ static __maybe_unused struct nand_ecclayout omap_ecclayout;struct omap_nand_info {struct bch_control *control;enum omap_ecc ecc_scheme; -int cs; +uint8_t cs; +uint8_t ws;/* wait status pin (0,1) */ };/* We are wasting a bit of memory but al least we are safe */ @@ -76,7 +77,9 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,/* Check wait pin as dev ready indicator */ static int omap_dev_ready (struct mtd_info *mtd) { -return gpmc_cfg->status & (1 <<8 ); + registerstruct nand_chip *this = mtd->priv; +struct omap_nand_info *info = this->priv; +return gpmc_cfg->status & (1 << (8 + info->ws)); }/*
drivers/mtd/nand/omap_gpmc.c int board_nand_init(struct nand_chip *nand) · line 862
Quoted 7 lines
drivers/mtd/nand/omap_gpmc.c +4
-0@@ -853,6 +856,12 @@ int board_nand_init(struct nand_chip *nand) nand->IO_ADDR_W = (void __iomem *)&gpmc_cfg->cs[cs].nand_cmd; omap_nand_info[cs].control =NULL ; omap_nand_info[cs].cs = cs; +#if !defined(CONFIG_NAND_OMAP_GPMC_WSCFG ) + omap_nand_info[cs].ws =0 ; +#else +int8_t ws[CONFIG_SYS_MAX_NAND_DEVICE ] = {CONFIG_NAND_OMAP_GPMC_WSCFG };
Doesn't this declaration trigger a compilation warning?
drivers/mtd/nand/omap_gpmc.c int board_nand_init(struct nand_chip *nand) · line 864
Quoted 2 lines
drivers/mtd/nand/omap_gpmc.c +2
-0+ omap_nand_info[cs].ws = ws[cs]; +#endif
I've attached a new version of this patch. It removed the ifdef from the code. Please take a look at it and let me know what you think.
Thanks,
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mtd-nand-omap_gpmc-Make-ready-busy-pins-configurable.patch
Type: text/x-diff
Size: 2666 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150211/a0390e77/attachment.patch>
PATCH 1/1 mtd: nand: omap_gpmc: Make ready/busy pins configurable
Hi Stefan,
Quoted 48 lines · Stefan Roese
Quoted 47 lines · Michal Sojka
Commit
fb384c4720ca7496775d6578f184bf628db73456introduced the use of WAIT0 pin for determining whether the NAND is ready or not. This only works if all NAND chips are connected to WAIT0. If some chips are connected to the other available pin WAIT1,nand_wait()does not really wait and prints aWARN_ONmessage.This patch allows the board to provide configuration of which chip is connected to which WAITx signal. For example, one can define in
include/configs/foo.h:#define CONFIG_NAND_OMAP_GPMC_WSCFG 0,0,1,1This would mean that chips using to CS0 and 1 are connected to WAIT0 and chips with CS2 and 3 are connected to WAIT1.
Signed-off-by Michal Sojka <[email protected]>Cc Tom Rini <[email protected]>Cc Stefan Roese <[email protected]>--- drivers/mtd/nand/omap_gpmc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/mtd/nand/omap_gpmc.c +5
-2@@ -36,7 +36,8 @@ static __maybe_unused struct nand_ecclayout omap_ecclayout;struct omap_nand_info {struct bch_control *control;enum omap_ecc ecc_scheme; -int cs; +uint8_t cs; +uint8_t ws;/* wait status pin (0,1) */ };/* We are wasting a bit of memory but al least we are safe */ @@ -76,7 +77,9 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,/* Check wait pin as dev ready indicator */ static int omap_dev_ready (struct mtd_info *mtd) { -return gpmc_cfg->status & (1 <<8 ); + registerstruct nand_chip *this = mtd->priv; +struct omap_nand_info *info = this->priv; +return gpmc_cfg->status & (1 << (8 + info->ws)); }
Quoted 11 lines
drivers/mtd/nand/omap_gpmc.c int board_nand_init(struct nand_chip *nand) · line 862
Quoted 9 lines
drivers/mtd/nand/omap_gpmc.c +4
-0/* @@ -853,6 +856,12 @@ int board_nand_init(struct nand_chip *nand) nand->IO_ADDR_W = (void __iomem *)&gpmc_cfg->cs[cs].nand_cmd; omap_nand_info[cs].control =NULL ; omap_nand_info[cs].cs = cs; +#if !defined(CONFIG_NAND_OMAP_GPMC_WSCFG ) + omap_nand_info[cs].ws =0 ; +#else +int8_t ws[CONFIG_SYS_MAX_NAND_DEVICE ] = {CONFIG_NAND_OMAP_GPMC_WSCFG };Doesn't this declaration trigger a compilation warning?
Not with gcc-4.8.3 that we use.
Quoted 5 lines
drivers/mtd/nand/omap_gpmc.c int board_nand_init(struct nand_chip *nand) · line 864
Quoted 2 lines
drivers/mtd/nand/omap_gpmc.c +2
-0+ omap_nand_info[cs].ws = ws[cs]; +#endif I've attached a new version of this patch. It removed the ifdef from the code. Please take a look at it and let me know what you think.
Yes, it's better and it works for us. Just one point - what about making the variable const as in the patch below?
Thanks,
-Michal
-------------8<------------------
Commit fb384c4720ca7496775d6578f184bf628db73456 introduced the use of WAIT0 pin for determining whether the NAND is ready or not. This only works if all NAND chips are connected to WAIT0. If some chips are connected to the other available pin WAIT1, nand_wait() does not really wait and prints a WARN_ON message.
This patch allows the board to provide configuration of which chip is connected to which WAITx signal. For example, one can define in include/configs/foo.h:
#define CONFIG_NAND_OMAP_GPMC_WSCFG 0,0,1,1
This would mean that chips using to CS0 and 1 are connected to WAIT0 and chips with CS2 and 3 are connected to WAIT1.
--- drivers/mtd/nand/omap_gpmc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/mtd/nand/omap_gpmc.c +14 -2
@@ -30,13 +30,22 @@ static u8 bch8_polynomial[] = {0xef, 0x51, 0x2e, 0x09, 0xed, 0x93, 0x9a, 0xc2,static uint8_t cs_next;static __maybe_unused struct nand_ecclayout omap_ecclayout; +#if defined(CONFIG_NAND_OMAP_GPMC_WSCFG ) +static const int8_t wscfg[CONFIG_SYS_MAX_NAND_DEVICE ] = + {CONFIG_NAND_OMAP_GPMC_WSCFG }; +#else +/* wscfg is preset to zero since its a static variable */ +static const int8_t wscfg[CONFIG_SYS_MAX_NAND_DEVICE ]; +#endif +/* * Driver configurations */ struct omap_nand_info {struct bch_control *control;enum omap_ecc ecc_scheme; -int cs; +uint8_t cs; +uint8_t ws;/* wait status pin (0,1) */ };/* We are wasting a bit of memory but al least we are safe */
@@ -76,7 +85,9 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,/* Check wait pin as dev ready indicator */ static int omap_dev_ready (struct mtd_info *mtd) { -return gpmc_cfg->status & (1 <<8 ); + registerstruct nand_chip *this = mtd->priv; +struct omap_nand_info *info = this->priv; +return gpmc_cfg->status & (1 << (8 + info->ws)); }/*
@@ -853,6 +864,7 @@ int board_nand_init(struct nand_chip *nand) nand->IO_ADDR_W = (void __iomem *)&gpmc_cfg->cs[cs].nand_cmd; omap_nand_info[cs].control =NULL ; omap_nand_info[cs].cs = cs; + omap_nand_info[cs].ws = wscfg[cs]; nand->priv = &omap_nand_info[cs]; nand->cmd_ctrl = omap_nand_hwcontrol; nand->options |=NAND_NO_PADDING |NAND_CACHEPRG ;
Signature · 1 line
2.1.4
PATCH 1/1 mtd: nand: omap_gpmc: Make ready/busy pins configurable
Hi Michal,
On 17.02.2015 14:52, Michal Sojka wrote:
<snip>
Quoted 8 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ omap_nand_info[cs].ws = ws[cs]; +#endifI've attached a new version of this patch. It removed the ifdef from the code. Please take a look at it and let me know what you think.
Yes, it's better and it works for us. Just one point - what about making the variable const as in the patch below?
Even better. Please submit it as a regular patch (v2) and my:
Thanks,
Stefan