Add support for nuvoton ma35 nand controller
Subsystems (5)
v2 cover Add support for nuvoton ma35 nand controller
This patch series adds the mtd nand driver for the nuvoton ma35 ARMv8 SoC. It includes DT binding documentation and the ma35 mtd nand driver.
v2:
- Update nuvoton,ma35d1-nand.yaml
- Adjust the order and remove any unnecessary items.
- Add 'nand-ecc-step-size' and 'nand-ecc-strength' to the required list.
- Update ma35d1 mtd nand driver
- Fix coding style.
- Use 'devm_clk_get' instead of 'of_clk_get'.
- Use 'dev_err_probe' instead of 'dev_err'.
- Remove 'pr_info' and 'of_match_ptr'.
- Remove 'module_init' and 'module_exit'.
Hui-Ping Chen (2):
dt-bindings: mtd: nuvoton,ma35d1-nand: add new bindings
mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC
.../bindings/mtd/nuvoton,ma35d1-nand.yaml | 93 ++ drivers/mtd/nand/raw/Kconfig | 8 + drivers/mtd/nand/raw/Makefile | 1 + drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c | 1070 +++++++++++++++++ 4 files changed, 1172 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/nuvoton,ma35d1-nand.yaml create mode 100644 drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c
Signature · 1 line
2.25.1
PATCH v2 1/2 dt-bindings: mtd: nuvoton,ma35d1-nand: add new bindings
Add dt-bindings for the Nuvoton MA35 SoC NAND Controller.
--- .../bindings/mtd/nuvoton,ma35d1-nand.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/nuvoton,ma35d1-nand.yaml
Documentation/devicetree/bindings/mtd/nuvoton,ma35d1-nand.yaml new file +93 -0
@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/nuvoton,ma35d1-nand.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 NAND Flash Interface (NFI) Controller + +maintainers: + - Hui-Ping Chen <[email protected]> + +allOf: + - $ref: nand-controller.yaml# + +properties: + compatible: + enum: + - nuvoton,ma35d1-nand + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + +patternProperties: + "^nand@[a-f0-9]$": + type: object + $ref: raw-nand-chip.yaml + properties: + nand-ecc-step-size: + enum: [512, 1024] + + nand-ecc-strength: + enum: [8, 12, 24] + + required: + - nand-ecc-step-size + - nand-ecc-strength + + unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + - clocks + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + nand-controller@401A0000 { + compatible = "nuvoton,ma35d1-nand"; + reg = <0x0 0x401A0000 0x0 0x1000>; + interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk NAND_GATE>; + #address-cells = <1>; + #size-cells = <0>; + + nand@0 { + reg = <0>; + + nand-on-flash-bbt; + nand-ecc-step-size = <512>; + nand-ecc-strength = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + uboot@0 { + label = "nand-uboot"; + read-only; + reg = <0x0 0x300000>; + }; + }; + }; + }; + }; + +...
Signature · 1 line
2.25.1
Re: [PATCH v2 1/2] dt-bindings: mtd: nuvoton,ma35d1-nand: add new bindings
Quoted 8 lines · Hui-Ping Chen
Add dt-bindings for the Nuvoton MA35 SoC NAND Controller.
Signed-off-by Hui-Ping Chen <[email protected]>--- .../bindings/mtd/nuvoton,ma35d1-nand.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/nuvoton,ma35d1-nand.yaml
Best regards,
Krzysztof
PATCH v2 2/2 mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC
In reply to Hui-Ping ChenNuvoton MA35 SoCs NAND Flash Interface Controller supports 2KB, 4KB and 8KB page size, and up to 8-bit, 12-bit, and 24-bit hardware ECC calculation circuit to protect data communication.
--- drivers/mtd/nand/raw/Kconfig | 8 + drivers/mtd/nand/raw/Makefile | 1 + drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c | 1070 ++++++++++++++++++++ 3 files changed, 1079 insertions(+) create mode 100644 drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c
drivers/mtd/nand/raw/Kconfig +8 -0
@@ -448,6 +448,14 @@ config MTD_NAND_RENESAS Enables support for the NAND controller found on Renesas R-Car Gen3 and RZ/N1 SoC families. +config MTD_NAND_NVT_MA35 + tristate "Nuvoton MA35 SoC NAND controller" + depends on ARCH_MA35 || COMPILE_TEST + depends on OF + help + Enables support for the NAND controller found on + the Nuvoton MA35 series SoCs. + comment "Misc" config MTD_SM_COMMON
drivers/mtd/nand/raw/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_MTD_NAND_INTEL_LGM) += intel-nand-controller.o obj-$(CONFIG_MTD_NAND_ROCKCHIP) += rockchip-nand-controller.o obj-$(CONFIG_MTD_NAND_PL35X) += pl35x-nand-controller.o obj-$(CONFIG_MTD_NAND_RENESAS) += renesas-nand-controller.o +obj-$(CONFIG_MTD_NAND_NVT_MA35) += nuvoton_ma35d1_nand.o nand-objs := nand_base.o nand_legacy.o nand_bbt.o nand_timings.o nand_ids.o nand-objs += nand_onfi.o
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +1070 -0
1,070 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC
Quoted 6 lines · Hui-Ping Chen
Nuvoton MA35 SoCs NAND Flash Interface Controller supports 2KB, 4KB and 8KB page size, and up to 8-bit, 12-bit, and 24-bit hardware ECC calculation circuit to protect data communication.
Signed-off-by Hui-Ping Chen <[email protected]>
...
Quoted 82 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +82
-0+static int ma35_nand_probe (struct platform_device *pdev) +{ +struct ma35_nand_info *nand; +struct nand_chip *chip; +struct mtd_info *mtd; +int retval =0 ; + + nand =devm_kzalloc (&pdev->dev,sizeof (*nand),GFP_KERNEL ); +if (!nand) +return -ENOMEM ; + +nand_controller_init (&nand->controller); + + nand->regs =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (nand->regs)) +return PTR_ERR (nand->regs); + + nand->dev = &pdev->dev; + chip = &nand->chip; + mtd =nand_to_mtd (chip); +nand_set_controller_data (chip, nand); +nand_set_flash_node (chip, pdev->dev.of_node); + + mtd->priv = chip; + mtd->owner =THIS_MODULE ; + mtd->dev.parent = &pdev->dev; + + nand->clk =devm_clk_get (&pdev->dev,"nand_gate" ); +if (IS_ERR (nand->clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (nand->clk), +"failed to find nand clock\n" ); + + retval =clk_prepare_enable (nand->clk); +if (retval <0 ) { +dev_err (&pdev->dev,"failed to enable clock\n" ); + retval = -ENXIO ; + } + + nand->chip.controller = &nand->controller; + + chip->legacy.cmdfunc = ma35_nand_command; + chip->legacy.waitfunc = ma35_waitfunc; + chip->legacy.read_byte = ma35_nand_read_byte; + chip->legacy.select_chip = ma35_nand_select_chip; + chip->legacy.read_buf = ma35_read_buf_dma; + chip->legacy.write_buf = ma35_write_buf_dma; + chip->legacy.dev_ready = ma35_nand_devready; + chip->legacy.chip_delay =25 ;/* us */ + +/* Read OOB data first, then HW read page */ + chip->ecc.hwctl = ma35_nand_enable_hwecc; + chip->ecc.calculate = ma35_nand_calculate_ecc; + chip->ecc.correct = ma35_nand_correct_data; + chip->ecc.write_page = ma35_nand_write_page_hwecc; + chip->ecc.read_page = ma35_nand_read_page_hwecc_oob_first; + chip->ecc.read_oob = ma35_nand_read_oob_hwecc; + chip->options |= (NAND_NO_SUBPAGE_WRITE |NAND_USES_DMA ); + +ma35_nand_initialize (nand); +platform_set_drvdata (pdev, nand); + + nand->controller.ops = &ma35_nand_controller_ops; + + nand->irq =platform_get_irq (pdev,0 ); +if (nand->irq <0 ) +return dev_err_probe (&pdev->dev, nand->irq, +"failed to get platform irq\n" ); + +if (request_irq (nand->irq, ma35_nand_irq,IRQF_TRIGGER_HIGH ,"ma35d1-nand" , nand)) { +dev_err (&pdev->dev,"Error requesting NAND IRQ\n" ); +return -ENXIO ; + } + + retval =nand_scan (chip,1 ); +if (retval) +return retval; + +if (mtd_device_register (mtd, nand->parts, nand->nr_parts)) { +nand_cleanup (chip); +devm_kfree (&pdev->dev, nand); +return retval; + }
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1001
Quoted 10 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +10
-0+ +return retval; +} + +static void ma35_nand_remove (struct platform_device *pdev) +{ +struct ma35_nand_info *nand =platform_get_drvdata (pdev); +struct nand_chip *chip = &nand->chip; +int ret; +
Where do you release IRQ handler?
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1008
Quoted 7 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +7
-0+ ret =mtd_device_unregister (nand_to_mtd (chip)); +WARN_ON (ret); +nand_cleanup (chip); + +clk_disable_unprepare (nand->clk); + +kfree (nand);
NAK, you never tested your code.
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1009
Quoted 1 line
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +1
-0+platform_set_drvdata (pdev,NULL );
Why? Drop.
Quoted 36 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +36
-0+} + +/* PM Support */ +#ifdef CONFIG_PM +static int ma35_nand_suspend (struct platform_device *pdev,pm_message_t pm) +{ +struct ma35_nand_info *nand =platform_get_drvdata (pdev); +unsigned long timeo = jiffies +HZ /2 ; + +/* wait DMAC to ready */ +while (1 ) { +if ((readl (nand->regs +MA35_NFI_REG_DMACTL ) &DMA_BUSY ) ==0 ) +break ; +if (time_after (jiffies, timeo)) +return -ETIMEDOUT ; + } + +clk_disable (nand->clk); + +return 0 ; +} + +static int ma35_nand_resume (struct platform_device *pdev) +{ +struct ma35_nand_info *nand =platform_get_drvdata (pdev); + +clk_enable (nand->clk); +ma35_nand_hwecc_init (nand); +ma35_nand_dmac_init (nand); + +return 0 ; +} + +#else +#define ma35_nand_suspend NULL +#define ma35_nand_resume NULL
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1055
Quoted 10 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +10
-0+#endif + +static const struct of_device_id ma35_nfi_of_match[] = { + { .compatible ="nuvoton,ma35d1-nand" }, + {}, +}; +MODULE_DEVICE_TABLE (of, ma35_nfi_of_match); + +static struct platform_driver ma35_nand_driver = { + .driver = {
Messed indentation.
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1057
Quoted 2 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +2
-0+ .name = "ma35d1-nand", + .owner = THIS_MODULE,
Drop. Please do not upstream some 10 year old code... Use recent code as template, not 10yo stuff...
Best regards,
Krzysztof
Re: [PATCH v2 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC
Dear Krzysztof,
Thank you for your reply.
Quoted 94 lines · Krzysztof Kozlowski
Quoted 6 lines · Hui-Ping Chen
Nuvoton MA35 SoCs NAND Flash Interface Controller supports 2KB, 4KB and 8KB page size, and up to 8-bit, 12-bit, and 24-bit hardware ECC calculation circuit to protect data communication.
Signed-off-by Hui-Ping Chen <[email protected]>...
Quoted 85 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +85
-0+static int ma35_nand_probe (struct platform_device *pdev) +{ +struct ma35_nand_info *nand; +struct nand_chip *chip; +struct mtd_info *mtd; +int retval =0 ; + + nand =devm_kzalloc (&pdev->dev,sizeof (*nand),GFP_KERNEL ); +if (!nand) +return -ENOMEM ; + +nand_controller_init (&nand->controller); + + nand->regs =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (nand->regs)) +return PTR_ERR (nand->regs); + + nand->dev = &pdev->dev; + chip = &nand->chip; + mtd =nand_to_mtd (chip); +nand_set_controller_data (chip, nand); +nand_set_flash_node (chip, pdev->dev.of_node); + + mtd->priv = chip; + mtd->owner =THIS_MODULE ; + mtd->dev.parent = &pdev->dev; + + nand->clk =devm_clk_get (&pdev->dev,"nand_gate" ); +if (IS_ERR (nand->clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (nand->clk), +"failed to find nand clock\n" ); + + retval =clk_prepare_enable (nand->clk); +if (retval <0 ) { +dev_err (&pdev->dev,"failed to enable clock\n" ); + retval = -ENXIO ; + } + + nand->chip.controller = &nand->controller; + + chip->legacy.cmdfunc = ma35_nand_command; + chip->legacy.waitfunc = ma35_waitfunc; + chip->legacy.read_byte = ma35_nand_read_byte; + chip->legacy.select_chip = ma35_nand_select_chip; + chip->legacy.read_buf = ma35_read_buf_dma; + chip->legacy.write_buf = ma35_write_buf_dma; + chip->legacy.dev_ready = ma35_nand_devready; + chip->legacy.chip_delay =25 ;/* us */ + +/* Read OOB data first, then HW read page */ + chip->ecc.hwctl = ma35_nand_enable_hwecc; + chip->ecc.calculate = ma35_nand_calculate_ecc; + chip->ecc.correct = ma35_nand_correct_data; + chip->ecc.write_page = ma35_nand_write_page_hwecc; + chip->ecc.read_page = ma35_nand_read_page_hwecc_oob_first; + chip->ecc.read_oob = ma35_nand_read_oob_hwecc; + chip->options |= (NAND_NO_SUBPAGE_WRITE |NAND_USES_DMA ); + +ma35_nand_initialize (nand); +platform_set_drvdata (pdev, nand); + + nand->controller.ops = &ma35_nand_controller_ops; + + nand->irq =platform_get_irq (pdev,0 ); +if (nand->irq <0 ) +return dev_err_probe (&pdev->dev, nand->irq, +"failed to get platform irq\n" ); + +if (request_irq (nand->irq, ma35_nand_irq,IRQF_TRIGGER_HIGH ,"ma35d1-nand" , nand)) { +dev_err (&pdev->dev,"Error requesting NAND IRQ\n" ); +return -ENXIO ; + } + + retval =nand_scan (chip,1 ); +if (retval) +return retval; + +if (mtd_device_register (mtd, nand->parts, nand->nr_parts)) { +nand_cleanup (chip); +devm_kfree (&pdev->dev, nand); +return retval; + } + +return retval; +}
Quoted 8 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1001
Quoted 7 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +7
-0+ +static void ma35_nand_remove (struct platform_device *pdev) +{ +struct ma35_nand_info *nand =platform_get_drvdata (pdev); +struct nand_chip *chip = &nand->chip; +int ret; +Where do you release IRQ handler?
I will add a release IRQ handler to this function.
Quoted 8 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1008
Quoted 7 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +7
-0+ ret =mtd_device_unregister (nand_to_mtd (chip)); +WARN_ON (ret); +nand_cleanup (chip); + +clk_disable_unprepare (nand->clk); + +kfree (nand);NAK, you never tested your code.
I will strengthen the testing of this function.
Quoted 2 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1009
Quoted 1 line
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +1
-0+platform_set_drvdata (pdev,NULL );Why? Drop.
I will remove it.
Quoted 39 lines
Quoted 39 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +39
-0+} + +/* PM Support */ +#ifdef CONFIG_PM +static int ma35_nand_suspend (struct platform_device *pdev,pm_message_t pm) +{ +struct ma35_nand_info *nand =platform_get_drvdata (pdev); +unsigned long timeo = jiffies +HZ /2 ; + +/* wait DMAC to ready */ +while (1 ) { +if ((readl (nand->regs +MA35_NFI_REG_DMACTL ) &DMA_BUSY ) ==0 ) +break ; +if (time_after (jiffies, timeo)) +return -ETIMEDOUT ; + } + +clk_disable (nand->clk); + +return 0 ; +} + +static int ma35_nand_resume (struct platform_device *pdev) +{ +struct ma35_nand_info *nand =platform_get_drvdata (pdev); + +clk_enable (nand->clk); +ma35_nand_hwecc_init (nand); +ma35_nand_dmac_init (nand); + +return 0 ; +} + +#else +#define ma35_nand_suspend NULL +#define ma35_nand_resume NULL +#endif + +static const struct of_device_id ma35_nfi_of_match[] = {
Quoted 8 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1055
Quoted 7 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +7
-0+ { .compatible = "nuvoton,ma35d1-nand" }, + {}, +}; +MODULE_DEVICE_TABLE (of, ma35_nfi_of_match); + +static struct platform_driver ma35_nand_driver = { + .driver = {Messed indentation.
I will fix it.
Quoted 4 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c line 1057
Quoted 2 lines
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c new file +2
-0+ .name = "ma35d1-nand", + .owner = THIS_MODULE,Drop. Please do not upstream some 10 year old code... Use recent code as template, not 10yo stuff...
I will refer to the new driver implementation.
Quoted 2 lines
Best regards,
Krzysztof
Best regards,
Hui-Ping Chen
kernel test robot
build botRe: [PATCH v2 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC
In reply to Hui-Ping Chenkernel test robot noticed the following build warnings:
Hi Hui-Ping,
kernel test robot noticed the following build warnings:
[auto build test WARNING on mtd/nand/next]
[also build test WARNING on linus/master v6.11-rc4 next-20240820] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Hui-Ping-Chen/dt-bindings-mtd-nuvoton-ma35d1-nand-add-new-bindings/20240819-172155 base: https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next patch link: https://lore.kernel.org/r/20240819092037.110260-3-hpchen0nvt%40gmail.com patch subject: [PATCH v2 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC config: parisc-randconfig-r123-20240820 (https://download.01.org/0day-ci/archive/20240820/[email protected]/config) compiler: hppa-linux-gcc (GCC) 14.1.0 reproduce: (https://download.01.org/0day-ci/archive/20240820/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:231:20: sparse: sparse: cast removes address space '__iomem' of expression
>> drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:736:20: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [usertype] *ptr @@ got unsigned char [noderef] [usertype] __iomem * @@ drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:736:20: sparse: expected unsigned char [usertype] *ptr drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:736:20: sparse: got unsigned char [noderef] [usertype] __iomem * >> drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:764:22: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected char *ptr @@ got char [noderef] __iomem * @@
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:764:22: sparse: expected char *ptr
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:764:22: sparse: got char [noderef] __iomem *
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:803:22: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected char *ptr @@ got char [noderef] __iomem * @@
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:803:22: sparse: expected char *ptr
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:803:22: sparse: got char [noderef] __iomem *
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [usertype] *ptr @@ got unsigned char [noderef] [usertype] __iomem * @@
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: expected unsigned char [usertype] *ptr
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: got unsigned char [noderef] [usertype] __iomem *
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [usertype] *ptr @@ got unsigned char [noderef] [usertype] __iomem * @@
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: expected unsigned char [usertype] *ptr
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: got unsigned char [noderef] [usertype] __iomem *
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [usertype] *ptr @@ got unsigned char [noderef] [usertype] __iomem * @@
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: expected unsigned char [usertype] *ptr
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: got unsigned char [noderef] [usertype] __iomem *
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [usertype] *ptr @@ got unsigned char [noderef] [usertype] __iomem * @@
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: expected unsigned char [usertype] *ptr
drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c:506:28: sparse: got unsigned char [noderef] [usertype] __iomem *
vim +736 drivers/mtd/nand/raw/nuvoton_ma35d1_nand.c
731
732 static int ma35_nand_write_page_hwecc(struct nand_chip *chip, const u8 *buf,
733 int oob_required, int page)
734 {
735 struct ma35_nand_info *nand = nand_get_controller_data(chip);
> 736 u8 *ptr = (u8 __iomem *)(nand->regs + MA35_NFI_REG_NANDRA0);
737 struct mtd_info *mtd = nand_to_mtd(chip);
738 u8 *ecc_calc = chip->ecc.calc_buf;
739
740 memset((void *)ptr, 0xFF, mtd->oobsize);
741 memcpy((void *)ptr, (void *)chip->oob_poi, mtd->oobsize - chip->ecc.total);
742
743 ma35_nand_command(chip, NAND_CMD_SEQIN, 0, page);
744 ma35_nand_dma_transfer(chip, buf, mtd->writesize, 0x1);
745 ma35_nand_command(chip, NAND_CMD_PAGEPROG, -1, -1);
746 ma35_waitfunc(chip);
747
748 /* Copy parity code in NANDRA to calc */
749 memcpy((void *)ecc_calc,
750 (void *)(ptr + (mtd->oobsize - chip->ecc.total)),
751 chip->ecc.total);
752
753 /* Copy parity code in calc to oob_poi */
754 memcpy((void *)(chip->oob_poi + (mtd->oobsize - chip->ecc.total)),
755 (void *)ecc_calc, chip->ecc.total);
756
757 return 0;
758 }
759
760 static int ma35_nand_read_page_hwecc_oob_first(struct nand_chip *chip, u8 *buf,
761 int oob_required, int page)
762 {
763 struct ma35_nand_info *nand = nand_get_controller_data(chip);
> 764 char *ptr = (char __iomem *)(nand->regs + MA35_NFI_REG_NANDRA0); 765 struct mtd_info *mtd = nand_to_mtd(chip);
766
767 /* 1. read the OOB area */
768 ma35_nand_command(chip, NAND_CMD_READOOB, 0, page);
769 ma35_nand_read_buf(chip, chip->oob_poi, mtd->oobsize);
770
771 /* 2. copy OOB data to NANDRA for page read */
772 memcpy((void *)ptr, (void *)chip->oob_poi, mtd->oobsize);
773
774 if ((*(ptr+2) != 0) && (*(ptr+3) != 0))
775 memset((void *)buf, 0xff, mtd->writesize);
776 else {
777 /* 3. read data from nand */
778 ma35_nand_command(chip, NAND_CMD_READ0, 0, page);
779 ma35_nand_dma_transfer(chip, buf, mtd->writesize, 0x0);
780
781 /* 4. restore OOB data from SMRA */
782 memcpy((void *)chip->oob_poi, (void *)ptr, mtd->oobsize);
783 }
784
785 return 0;
786 }
787
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki