Skip to content

Commit 1d46f1a

Browse files
committed
Merge tag 'nand/for-6.2' into mtd/next
Raw NAND core changes: * Drop obsolete dependencies on COMPILE_TEST * MAINTAINERS: rectify entry for MESON NAND controller bindings * Drop EXPORT_SYMBOL_GPL for nanddev_erase() Raw NAND driver changes: * marvell: Enable NFC/DEVBUS arbiter * gpmi: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync * mpc5121: Replace NO_IRQ by 0 * lpc32xx_{slc,mlc}: - Switch to using pm_ptr() - Switch to using gpiod API * lpc32xx_mlc: Switch to using pm_ptr() * cadence: Support 64-bit slave dma interface * rockchip: Describe rk3128-nfc in the bindings * brcmnand: Update interrupts description in the bindings SPI-NAND driver changes: * winbond: - Add Winbond W25N02KV flash support - Fix flash identification Fix merge conflict with mtd tree regarding the brcm bindings. Signed-off-by: Miquel Raynal <[email protected]>
2 parents 2399401 + 6408cc0 commit 1d46f1a

File tree

13 files changed

+203
-85
lines changed

13 files changed

+203
-85
lines changed

Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ properties:
8686
minItems: 1
8787
items:
8888
- description: NAND CTLRDY interrupt
89-
- description: FLASH_DMA_DONE if flash DMA is available
90-
- description: FLASH_EDU_DONE if EDU is available
89+
- description: FLASH_DMA_DONE (if flash DMA is available) or FLASH_EDU_DONE (if EDU is available)
9190

9291
interrupt-names:
9392
minItems: 1
9493
items:
9594
- const: nand_ctlrdy
96-
- const: flash_dma_done
97-
- const: flash_edu_done
95+
- enum:
96+
- flash_dma_done
97+
- flash_edu_done
9898

9999
clocks:
100100
maxItems: 1
@@ -173,6 +173,13 @@ allOf:
173173
- const: nand
174174
- const: iproc-idm
175175
- const: iproc-ext
176+
- if:
177+
properties:
178+
interrupts:
179+
minItems: 2
180+
then:
181+
required:
182+
- interrupt-names
176183

177184
unevaluatedProperties: false
178185

@@ -190,6 +197,7 @@ examples:
190197
reg-names = "nand", "flash-dma";
191198
interrupt-parent = <&hif_intr2_intc>;
192199
interrupts = <24>, <4>;
200+
interrupt-names = "nand_ctlrdy", "flash_dma_done";
193201
194202
#address-cells = <1>;
195203
#size-cells = <0>;

Documentation/devicetree/bindings/mtd/rockchip,nand-controller.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ properties:
1919
- const: rockchip,rk2928-nfc
2020
- const: rockchip,rv1108-nfc
2121
- items:
22-
- const: rockchip,rk3036-nfc
22+
- enum:
23+
- rockchip,rk3036-nfc
24+
- rockchip,rk3128-nfc
2325
- const: rockchip,rk2928-nfc
2426
- items:
2527
- const: rockchip,rk3308-nfc

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13382,7 +13382,7 @@ MESON NAND CONTROLLER DRIVER FOR AMLOGIC SOCS
1338213382
M: Liang Yang <[email protected]>
1338313383
1338413384
S: Maintained
13385-
F: Documentation/devicetree/bindings/mtd/amlogic,meson-nand.txt
13385+
F: Documentation/devicetree/bindings/mtd/amlogic,meson-nand.yaml
1338613386
F: drivers/mtd/nand/raw/meson_*
1338713387

1338813388
MESON VIDEO DECODER DRIVER FOR AMLOGIC SOCS

drivers/mtd/nand/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ EXPORT_SYMBOL_GPL(nanddev_isreserved);
126126
*
127127
* Return: 0 in case of success, a negative error code otherwise.
128128
*/
129-
int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos)
129+
static int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos)
130130
{
131131
if (nanddev_isbad(nand, pos) || nanddev_isreserved(nand, pos)) {
132132
pr_warn("attempt to erase a bad/reserved block @%llx\n",
@@ -136,7 +136,6 @@ int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos)
136136

137137
return nand->ops->erase(nand, pos);
138138
}
139-
EXPORT_SYMBOL_GPL(nanddev_erase);
140139

141140
/**
142141
* nanddev_mtd_erase() - Generic mtd->_erase() implementation for NAND devices

drivers/mtd/nand/raw/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ config MTD_NAND_PLATFORM
415415

416416
config MTD_NAND_CADENCE
417417
tristate "Support Cadence NAND (HPNFC) controller"
418-
depends on (OF || COMPILE_TEST) && HAS_IOMEM
418+
depends on OF && HAS_IOMEM
419419
help
420420
Enable the driver for NAND flash on platforms using a Cadence NAND
421421
controller.
@@ -430,7 +430,7 @@ config MTD_NAND_ARASAN
430430

431431
config MTD_NAND_INTEL_LGM
432432
tristate "Support for NAND controller on Intel LGM SoC"
433-
depends on OF || COMPILE_TEST
433+
depends on OF
434434
depends on HAS_IOMEM
435435
help
436436
Enables support for NAND Flash chips on Intel's LGM SoC.
@@ -450,7 +450,7 @@ config MTD_NAND_ROCKCHIP
450450

451451
config MTD_NAND_PL35X
452452
tristate "ARM PL35X NAND controller"
453-
depends on OF || COMPILE_TEST
453+
depends on OF
454454
depends on PL353_SMC
455455
help
456456
Enables support for PrimeCell SMC PL351 and PL353 NAND

drivers/mtd/nand/raw/cadence-nand-controller.c

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,14 @@ static int cadence_nand_hw_init(struct cdns_nand_ctrl *cdns_ctrl)
11841184
if (cadence_nand_read_bch_caps(cdns_ctrl))
11851185
return -EIO;
11861186

1187+
#ifndef CONFIG_64BIT
1188+
if (cdns_ctrl->caps2.data_dma_width == 8) {
1189+
dev_err(cdns_ctrl->dev,
1190+
"cannot access 64-bit dma on !64-bit architectures");
1191+
return -EIO;
1192+
}
1193+
#endif
1194+
11871195
/*
11881196
* Set IO width access to 8.
11891197
* It is because during SW device discovering width access
@@ -1882,17 +1890,36 @@ static int cadence_nand_read_buf(struct cdns_nand_ctrl *cdns_ctrl,
18821890
return status;
18831891

18841892
if (!cdns_ctrl->caps1->has_dma) {
1885-
int len_in_words = len >> 2;
1893+
u8 data_dma_width = cdns_ctrl->caps2.data_dma_width;
1894+
1895+
int len_in_words = (data_dma_width == 4) ? len >> 2 : len >> 3;
18861896

18871897
/* read alingment data */
1888-
ioread32_rep(cdns_ctrl->io.virt, buf, len_in_words);
1898+
if (data_dma_width == 4)
1899+
ioread32_rep(cdns_ctrl->io.virt, buf, len_in_words);
1900+
#ifdef CONFIG_64BIT
1901+
else
1902+
readsq(cdns_ctrl->io.virt, buf, len_in_words);
1903+
#endif
1904+
18891905
if (sdma_size > len) {
1906+
int read_bytes = (data_dma_width == 4) ?
1907+
len_in_words << 2 : len_in_words << 3;
1908+
18901909
/* read rest data from slave DMA interface if any */
1891-
ioread32_rep(cdns_ctrl->io.virt, cdns_ctrl->buf,
1892-
sdma_size / 4 - len_in_words);
1910+
if (data_dma_width == 4)
1911+
ioread32_rep(cdns_ctrl->io.virt,
1912+
cdns_ctrl->buf,
1913+
sdma_size / 4 - len_in_words);
1914+
#ifdef CONFIG_64BIT
1915+
else
1916+
readsq(cdns_ctrl->io.virt, cdns_ctrl->buf,
1917+
sdma_size / 8 - len_in_words);
1918+
#endif
1919+
18931920
/* copy rest of data */
1894-
memcpy(buf + (len_in_words << 2), cdns_ctrl->buf,
1895-
len - (len_in_words << 2));
1921+
memcpy(buf + read_bytes, cdns_ctrl->buf,
1922+
len - read_bytes);
18961923
}
18971924
return 0;
18981925
}
@@ -1936,16 +1963,35 @@ static int cadence_nand_write_buf(struct cdns_nand_ctrl *cdns_ctrl,
19361963
return status;
19371964

19381965
if (!cdns_ctrl->caps1->has_dma) {
1939-
int len_in_words = len >> 2;
1966+
u8 data_dma_width = cdns_ctrl->caps2.data_dma_width;
1967+
1968+
int len_in_words = (data_dma_width == 4) ? len >> 2 : len >> 3;
1969+
1970+
if (data_dma_width == 4)
1971+
iowrite32_rep(cdns_ctrl->io.virt, buf, len_in_words);
1972+
#ifdef CONFIG_64BIT
1973+
else
1974+
writesq(cdns_ctrl->io.virt, buf, len_in_words);
1975+
#endif
19401976

1941-
iowrite32_rep(cdns_ctrl->io.virt, buf, len_in_words);
19421977
if (sdma_size > len) {
1978+
int written_bytes = (data_dma_width == 4) ?
1979+
len_in_words << 2 : len_in_words << 3;
1980+
19431981
/* copy rest of data */
1944-
memcpy(cdns_ctrl->buf, buf + (len_in_words << 2),
1945-
len - (len_in_words << 2));
1982+
memcpy(cdns_ctrl->buf, buf + written_bytes,
1983+
len - written_bytes);
1984+
19461985
/* write all expected by nand controller data */
1947-
iowrite32_rep(cdns_ctrl->io.virt, cdns_ctrl->buf,
1948-
sdma_size / 4 - len_in_words);
1986+
if (data_dma_width == 4)
1987+
iowrite32_rep(cdns_ctrl->io.virt,
1988+
cdns_ctrl->buf,
1989+
sdma_size / 4 - len_in_words);
1990+
#ifdef CONFIG_64BIT
1991+
else
1992+
writesq(cdns_ctrl->io.virt, cdns_ctrl->buf,
1993+
sdma_size / 8 - len_in_words);
1994+
#endif
19491995
}
19501996

19511997
return 0;

drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,9 @@ static int gpmi_init(struct gpmi_nand_data *this)
148148
struct resources *r = &this->resources;
149149
int ret;
150150

151-
ret = pm_runtime_get_sync(this->dev);
152-
if (ret < 0) {
153-
pm_runtime_put_noidle(this->dev);
151+
ret = pm_runtime_resume_and_get(this->dev);
152+
if (ret < 0)
154153
return ret;
155-
}
156154

157155
ret = gpmi_reset_block(r->gpmi_regs, false);
158156
if (ret)
@@ -2504,11 +2502,9 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip,
25042502
for (i = 0; i < GPMI_MAX_TRANSFERS; i++)
25052503
this->transfers[i].direction = DMA_NONE;
25062504

2507-
ret = pm_runtime_get_sync(this->dev);
2508-
if (ret < 0) {
2509-
pm_runtime_put_noidle(this->dev);
2505+
ret = pm_runtime_resume_and_get(this->dev);
2506+
if (ret < 0)
25102507
return ret;
2511-
}
25122508

25132509
/*
25142510
* This driver currently supports only one NAND chip. Plus, dies share

drivers/mtd/nand/raw/lpc32xx_mlc.c

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <linux/completion.h>
2626
#include <linux/interrupt.h>
2727
#include <linux/of.h>
28-
#include <linux/of_gpio.h>
28+
#include <linux/gpio/consumer.h>
2929
#include <linux/mtd/lpc32xx_mlc.h>
3030
#include <linux/io.h>
3131
#include <linux/mm.h>
@@ -122,7 +122,6 @@ struct lpc32xx_nand_cfg_mlc {
122122
uint32_t rd_low;
123123
uint32_t wr_high;
124124
uint32_t wr_low;
125-
int wp_gpio;
126125
struct mtd_partition *parts;
127126
unsigned num_parts;
128127
};
@@ -177,6 +176,7 @@ struct lpc32xx_nand_host {
177176
struct nand_chip nand_chip;
178177
struct lpc32xx_mlc_platform_data *pdata;
179178
struct clk *clk;
179+
struct gpio_desc *wp_gpio;
180180
void __iomem *io_base;
181181
int irq;
182182
struct lpc32xx_nand_cfg_mlc *ncfg;
@@ -370,17 +370,17 @@ static int lpc32xx_waitfunc(struct nand_chip *chip)
370370
*/
371371
static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host)
372372
{
373-
if (gpio_is_valid(host->ncfg->wp_gpio))
374-
gpio_set_value(host->ncfg->wp_gpio, 0);
373+
if (host->wp_gpio)
374+
gpiod_set_value_cansleep(host->wp_gpio, 1);
375375
}
376376

377377
/*
378378
* Disable NAND write protect
379379
*/
380380
static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host)
381381
{
382-
if (gpio_is_valid(host->ncfg->wp_gpio))
383-
gpio_set_value(host->ncfg->wp_gpio, 1);
382+
if (host->wp_gpio)
383+
gpiod_set_value_cansleep(host->wp_gpio, 0);
384384
}
385385

386386
static void lpc32xx_dma_complete_func(void *completion)
@@ -636,8 +636,6 @@ static struct lpc32xx_nand_cfg_mlc *lpc32xx_parse_dt(struct device *dev)
636636
return NULL;
637637
}
638638

639-
ncfg->wp_gpio = of_get_named_gpio(np, "gpios", 0);
640-
641639
return ncfg;
642640
}
643641

@@ -713,14 +711,18 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
713711
"Missing or bad NAND config from device tree\n");
714712
return -ENOENT;
715713
}
716-
if (host->ncfg->wp_gpio == -EPROBE_DEFER)
717-
return -EPROBE_DEFER;
718-
if (gpio_is_valid(host->ncfg->wp_gpio) &&
719-
gpio_request(host->ncfg->wp_gpio, "NAND WP")) {
720-
dev_err(&pdev->dev, "GPIO not available\n");
721-
return -EBUSY;
714+
715+
/* Start with WP disabled, if available */
716+
host->wp_gpio = gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
717+
res = PTR_ERR_OR_ZERO(host->wp_gpio);
718+
if (res) {
719+
if (res != -EPROBE_DEFER)
720+
dev_err(&pdev->dev, "WP GPIO is not available: %d\n",
721+
res);
722+
return res;
722723
}
723-
lpc32xx_wp_disable(host);
724+
725+
gpiod_set_consumer_name(host->wp_gpio, "NAND WP");
724726

725727
host->pdata = dev_get_platdata(&pdev->dev);
726728

@@ -817,7 +819,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
817819
clk_put(host->clk);
818820
free_gpio:
819821
lpc32xx_wp_enable(host);
820-
gpio_free(host->ncfg->wp_gpio);
822+
gpiod_put(host->wp_gpio);
821823

822824
return res;
823825
}
@@ -843,12 +845,11 @@ static int lpc32xx_nand_remove(struct platform_device *pdev)
843845
clk_put(host->clk);
844846

845847
lpc32xx_wp_enable(host);
846-
gpio_free(host->ncfg->wp_gpio);
848+
gpiod_put(host->wp_gpio);
847849

848850
return 0;
849851
}
850852

851-
#ifdef CONFIG_PM
852853
static int lpc32xx_nand_resume(struct platform_device *pdev)
853854
{
854855
struct lpc32xx_nand_host *host = platform_get_drvdata(pdev);
@@ -880,11 +881,6 @@ static int lpc32xx_nand_suspend(struct platform_device *pdev, pm_message_t pm)
880881
return 0;
881882
}
882883

883-
#else
884-
#define lpc32xx_nand_resume NULL
885-
#define lpc32xx_nand_suspend NULL
886-
#endif
887-
888884
static const struct of_device_id lpc32xx_nand_match[] = {
889885
{ .compatible = "nxp,lpc3220-mlc" },
890886
{ /* sentinel */ },
@@ -894,8 +890,8 @@ MODULE_DEVICE_TABLE(of, lpc32xx_nand_match);
894890
static struct platform_driver lpc32xx_nand_driver = {
895891
.probe = lpc32xx_nand_probe,
896892
.remove = lpc32xx_nand_remove,
897-
.resume = lpc32xx_nand_resume,
898-
.suspend = lpc32xx_nand_suspend,
893+
.resume = pm_ptr(lpc32xx_nand_resume),
894+
.suspend = pm_ptr(lpc32xx_nand_suspend),
899895
.driver = {
900896
.name = DRV_NAME,
901897
.of_match_table = lpc32xx_nand_match,

0 commit comments

Comments
 (0)