mtd: rawnand: sunxi: Random cleanups + exec_op
v2 cover mtd: rawnand: sunxi: Random cleanups + exec_op
Hello,
This series converts the sunxi NAND controller driver to exec_op and cleans a few things up.
Regards,
Boris
Changes in v2:
- Add patch 6 and 7 which were missing in v1
Boris Brezillon (7):
mtd: rawnand: sunxi: Use a consistent name for sunxi_nand_chip objects
mtd: rawnand: sunxi: Use struct_size()
mtd: rawnand: sunxi: Name nand_chip objects consistently
mtd: rawnand: sunxi: Stop passing mtd_info objects around
mtd: rawnand: sunxi: Add an SPDX tag
mtd: rawnand: sunxi: Migrate to ->exec_op()
mtd: rawnand: sunxi: Fix kernel doc headers
drivers/mtd/nand/raw/sunxi_nand.c | 714 ++++++++++++++++-------------- 1 file changed, 371 insertions(+), 343 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/7 mtd: rawnand: sunxi: Use a consistent name for sunxi_nand_chip objects
sunxi_nand_chip objects are sometimes called chip and other times called sunxi_nand. Make that consistent and name all occurrences sunxi_nand.
--- drivers/mtd/nand/raw/sunxi_nand.c | 56 ++++++++++++++++--------------- 1 file changed, 29 insertions(+), 27 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +29 -27
@@ -1471,8 +1471,8 @@ static int _sunxi_nand_lookup_timing(const s32 *lut, int lut_size, u32 duration,static int sunxi_nfc_setup_data_interface (struct nand_chip *nand,int csline,const struct nand_data_interface *conf) { -struct sunxi_nand_chip *chip =to_sunxi_nand (nand); -struct sunxi_nfc *nfc =to_sunxi_nfc (chip->nand.controller); +struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand); +struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller);const struct nand_sdr_timings *timings;u32 min_clk_period =0 ;s32 tWB, tADL, tWHR, tRHW, tCAD;
@@ -1591,7 +1591,7 @@ static int sunxi_nfc_setup_data_interface(struct nand_chip *nand, int csline, tCAD =0x7 ;/* TODO: A83 has some more bits for CDQSS, CS, CLHZ, CCS, WC */ - chip->timing_cfg =NFC_TIMING_CFG (tWB, tADL, tWHR, tRHW, tCAD); + sunxi_nand->timing_cfg =NFC_TIMING_CFG (tWB, tADL, tWHR, tRHW, tCAD);/* Convert min_clk_period from picoseconds to nanoseconds */ min_clk_period =DIV_ROUND_UP (min_clk_period,1000 );
@@ -1602,10 +1602,11 @@ static int sunxi_nfc_setup_data_interface(struct nand_chip *nand, int csline,* This new formula was verified with a scope and validated by * Allwinner engineers. */ - chip->clk_rate =NSEC_PER_SEC / min_clk_period; - real_clk_rate =clk_round_rate (nfc->mod_clk, chip->clk_rate); + sunxi_nand->clk_rate =NSEC_PER_SEC / min_clk_period; + real_clk_rate =clk_round_rate (nfc->mod_clk, sunxi_nand->clk_rate);if (real_clk_rate <=0 ) { -dev_err (nfc->dev,"Unable to round clk %lu\n" , chip->clk_rate); +dev_err (nfc->dev,"Unable to round clk %lu\n" , + sunxi_nand->clk_rate);return -EINVAL ; }
@@ -1615,8 +1616,8 @@ static int sunxi_nfc_setup_data_interface(struct nand_chip *nand, int csline,* 30 ns. */ min_clk_period =NSEC_PER_SEC / real_clk_rate; - chip->timing_ctl = ((min_clk_period *2 ) <30 ) ? -NFC_TIMING_CTL_EDO :0 ; + sunxi_nand->timing_ctl = ((min_clk_period *2 ) <30 ) ? +NFC_TIMING_CTL_EDO :0 ;return 0 ; }
@@ -1853,7 +1854,7 @@ static const struct nand_controller_ops sunxi_nand_controller_ops = {static int sunxi_nand_chip_init (struct device *dev,struct sunxi_nfc *nfc,struct device_node *np) { -struct sunxi_nand_chip *chip; +struct sunxi_nand_chip *sunxi_nand;struct mtd_info *mtd;struct nand_chip *nand;int nsels;
@@ -1870,17 +1871,17 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,return -EINVAL ; } - chip =devm_kzalloc (dev, -sizeof (*chip) + - (nsels *sizeof (struct sunxi_nand_chip_sel )), -GFP_KERNEL ); -if (!chip) { + sunxi_nand =devm_kzalloc (dev, +sizeof (*sunxi_nand) + + (nsels *sizeof (struct sunxi_nand_chip_sel )), +GFP_KERNEL ); +if (!sunxi_nand) {dev_err (dev,"could not allocate chip\n" );return -ENOMEM ; } - chip->nsels = nsels; - chip->selected =-1 ; + sunxi_nand->nsels = nsels; + sunxi_nand->selected =-1 ;for (i =0 ; i < nsels; i++) { ret =of_property_read_u32_index (np,"reg" , i, &tmp);
@@ -1902,16 +1903,16 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,return -EINVAL ; } - chip->sels[i].cs = tmp; + sunxi_nand->sels[i].cs = tmp;if (!of_property_read_u32_index (np,"allwinner,rb" , i, &tmp) && tmp <2 ) - chip->sels[i].rb = tmp; + sunxi_nand->sels[i].rb = tmp;else - chip->sels[i].rb =-1 ; + sunxi_nand->sels[i].rb =-1 ; } - nand = &chip->nand; + nand = &sunxi_nand->nand;/* Default tR value specified in the ONFI spec (chapter 4.15.1) */ nand->legacy.chip_delay =200 ; nand->controller = &nfc->controller;
@@ -1943,7 +1944,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,return ret; } -list_add_tail (&chip->node, &nfc->chips); +list_add_tail (&sunxi_nand->node, &nfc->chips);return 0 ; }
@@ -1973,14 +1974,15 @@ static int sunxi_nand_chips_init(struct device *dev, struct sunxi_nfc *nfc)static void sunxi_nand_chips_cleanup (struct sunxi_nfc *nfc) { -struct sunxi_nand_chip *chip; +struct sunxi_nand_chip *sunxi_nand;while (!list_empty (&nfc->chips)) { - chip = list_first_entry(&nfc->chips, struct sunxi_nand_chip, - node); -nand_release (&chip->nand); -sunxi_nand_ecc_cleanup (&chip->nand.ecc); -list_del (&chip->node); + sunxi_nand =list_first_entry (&nfc->chips, + struct sunxi_nand_chip, + node); +nand_release (&sunxi_nand->nand); +sunxi_nand_ecc_cleanup (&sunxi_nand->nand.ecc); +list_del (&sunxi_nand->node); } }
Signature · 1 line
2.17.1
PATCH v2 2/7 mtd: rawnand: sunxi: Use struct_size()
In reply to Boris BrezillonUse struct_size() to calculate sunxi_nand object size.
--- drivers/mtd/nand/raw/sunxi_nand.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +1 -3
@@ -1871,9 +1871,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,return -EINVAL ; } - sunxi_nand =devm_kzalloc (dev, -sizeof (*sunxi_nand) + - (nsels *sizeof (struct sunxi_nand_chip_sel )), + sunxi_nand =devm_kzalloc (dev,struct_size (sunxi_nand, sels, nsels),GFP_KERNEL );if (!sunxi_nand) {dev_err (dev,"could not allocate chip\n" );
Signature · 1 line
2.17.1
PATCH v2 3/7 mtd: rawnand: sunxi: Name nand_chip objects consistently
In reply to Boris Brezillonnand_chip objects are sometimes called chip and sometimes nand. Rename all of them into nand to make things consistent.
--- drivers/mtd/nand/raw/sunxi_nand.c | 103 +++++++++++++++--------------- 1 file changed, 51 insertions(+), 52 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +51 -52
@@ -1185,16 +1185,16 @@ static void sunxi_nfc_hw_ecc_write_extra_oob(struct mtd_info *mtd, *cur_off = mtd->oobsize + mtd->writesize; } -static int sunxi_nfc_hw_ecc_read_page (struct nand_chip *chip,uint8_t *buf, +static int sunxi_nfc_hw_ecc_read_page (struct nand_chip *nand,uint8_t *buf,int oob_required,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); -struct nand_ecc_ctrl *ecc = &chip->ecc; +struct mtd_info *mtd =nand_to_mtd (nand); +struct nand_ecc_ctrl *ecc = &nand->ecc;unsigned int max_bitflips =0 ;int ret, i, cur_off =0 ;bool raw_mode = false; -nand_read_page_op (chip, page,0 ,NULL ,0 ); +nand_read_page_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (mtd);
@@ -1202,7 +1202,7 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *chip, uint8_t *buf,int data_off = i * ecc->size;int oob_off = i * (ecc->bytes +4 );u8 *data = buf + data_off; -u8 *oob = chip->oob_poi + oob_off; +u8 *oob = nand->oob_poi + oob_off; ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob, oob_off + mtd->writesize,
@@ -1215,7 +1215,7 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *chip, uint8_t *buf, }if (oob_required) -sunxi_nfc_hw_ecc_read_extra_oob (mtd, chip->oob_poi, &cur_off, +sunxi_nfc_hw_ecc_read_extra_oob (mtd, nand->oob_poi, &cur_off, !raw_mode, page);sunxi_nfc_hw_ecc_disable (mtd);
@@ -1223,33 +1223,33 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *chip, uint8_t *buf,return max_bitflips; } -static int sunxi_nfc_hw_ecc_read_page_dma (struct nand_chip *chip,u8 *buf, +static int sunxi_nfc_hw_ecc_read_page_dma (struct nand_chip *nand,u8 *buf,int oob_required,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); +struct mtd_info *mtd =nand_to_mtd (nand);int ret; -nand_read_page_op (chip, page,0 ,NULL ,0 ); +nand_read_page_op (nand, page,0 ,NULL ,0 ); ret =sunxi_nfc_hw_ecc_read_chunks_dma (mtd, buf, oob_required, page, - chip->ecc.steps); + nand->ecc.steps);if (ret >=0 )return ret;/* Fallback to PIO mode */ -return sunxi_nfc_hw_ecc_read_page (chip, buf, oob_required, page); +return sunxi_nfc_hw_ecc_read_page (nand, buf, oob_required, page); } -static int sunxi_nfc_hw_ecc_read_subpage (struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_read_subpage (struct nand_chip *nand,u32 data_offs,u32 readlen,u8 *bufpoi,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); -struct nand_ecc_ctrl *ecc = &chip->ecc; +struct mtd_info *mtd =nand_to_mtd (nand); +struct nand_ecc_ctrl *ecc = &nand->ecc;int ret, i, cur_off =0 ;unsigned int max_bitflips =0 ; -nand_read_page_op (chip, page,0 ,NULL ,0 ); +nand_read_page_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (mtd);
@@ -1258,7 +1258,7 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct nand_chip *chip,int data_off = i * ecc->size;int oob_off = i * (ecc->bytes +4 );u8 *data = bufpoi + data_off; -u8 *oob = chip->oob_poi + oob_off; +u8 *oob = nand->oob_poi + oob_off; ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, oob,
@@ -1274,34 +1274,34 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct nand_chip *chip,return max_bitflips; } -static int sunxi_nfc_hw_ecc_read_subpage_dma (struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_read_subpage_dma (struct nand_chip *nand,u32 data_offs,u32 readlen,u8 *buf,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); -int nchunks =DIV_ROUND_UP (data_offs + readlen, chip->ecc.size); +struct mtd_info *mtd =nand_to_mtd (nand); +int nchunks =DIV_ROUND_UP (data_offs + readlen, nand->ecc.size);int ret; -nand_read_page_op (chip, page,0 ,NULL ,0 ); +nand_read_page_op (nand, page,0 ,NULL ,0 ); ret =sunxi_nfc_hw_ecc_read_chunks_dma (mtd, buf, false, page, nchunks);if (ret >=0 )return ret;/* Fallback to PIO mode */ -return sunxi_nfc_hw_ecc_read_subpage (chip, data_offs, readlen, +return sunxi_nfc_hw_ecc_read_subpage (nand, data_offs, readlen, buf, page); } -static int sunxi_nfc_hw_ecc_write_page (struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_write_page (struct nand_chip *nand,const uint8_t *buf,int oob_required,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); -struct nand_ecc_ctrl *ecc = &chip->ecc; +struct mtd_info *mtd =nand_to_mtd (nand); +struct nand_ecc_ctrl *ecc = &nand->ecc;int ret, i, cur_off =0 ; -nand_prog_page_begin_op (chip, page,0 ,NULL ,0 ); +nand_prog_page_begin_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (mtd);
@@ -1309,7 +1309,7 @@ static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *chip,int data_off = i * ecc->size;int oob_off = i * (ecc->bytes +4 );const u8 *data = buf + data_off; -const u8 *oob = chip->oob_poi + oob_off; +const u8 *oob = nand->oob_poi + oob_off; ret = sunxi_nfc_hw_ecc_write_chunk(mtd, data, data_off, oob, oob_off + mtd->writesize,
@@ -1318,25 +1318,25 @@ static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *chip,return ret; } -if (oob_required || (chip->options &NAND_NEED_SCRAMBLING )) -sunxi_nfc_hw_ecc_write_extra_oob (mtd, chip->oob_poi, +if (oob_required || (nand->options &NAND_NEED_SCRAMBLING )) +sunxi_nfc_hw_ecc_write_extra_oob (mtd, nand->oob_poi, &cur_off, page);sunxi_nfc_hw_ecc_disable (mtd); -return nand_prog_page_end_op (chip); +return nand_prog_page_end_op (nand); } -static int sunxi_nfc_hw_ecc_write_subpage (struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_write_subpage (struct nand_chip *nand,u32 data_offs,u32 data_len,const u8 *buf,int oob_required,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); -struct nand_ecc_ctrl *ecc = &chip->ecc; +struct mtd_info *mtd =nand_to_mtd (nand); +struct nand_ecc_ctrl *ecc = &nand->ecc;int ret, i, cur_off =0 ; -nand_prog_page_begin_op (chip, page,0 ,NULL ,0 ); +nand_prog_page_begin_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (mtd);
@@ -1345,7 +1345,7 @@ static int sunxi_nfc_hw_ecc_write_subpage(struct nand_chip *chip,int data_off = i * ecc->size;int oob_off = i * (ecc->bytes +4 );const u8 *data = buf + data_off; -const u8 *oob = chip->oob_poi + oob_off; +const u8 *oob = nand->oob_poi + oob_off; ret = sunxi_nfc_hw_ecc_write_chunk(mtd, data, data_off, oob, oob_off + mtd->writesize,
@@ -1356,16 +1356,15 @@ static int sunxi_nfc_hw_ecc_write_subpage(struct nand_chip *chip,sunxi_nfc_hw_ecc_disable (mtd); -return nand_prog_page_end_op (chip); +return nand_prog_page_end_op (nand); } -static int sunxi_nfc_hw_ecc_write_page_dma (struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_write_page_dma (struct nand_chip *nand,const u8 *buf,int oob_required,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct nand_ecc_ctrl *ecc = &nand->ecc;struct scatterlist sg;
@@ -1386,7 +1385,7 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *chip,sunxi_nfc_hw_ecc_set_prot_oob_bytes (mtd, oob, i, !i, page); } -nand_prog_page_begin_op (chip, page,0 ,NULL ,0 ); +nand_prog_page_begin_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (mtd);sunxi_nfc_randomizer_config (mtd, page, false);
@@ -1413,38 +1412,38 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *chip,if (ret)return ret; -if (oob_required || (chip->options &NAND_NEED_SCRAMBLING )) +if (oob_required || (nand->options &NAND_NEED_SCRAMBLING ))/* TODO: use DMA to transfer extra OOB bytes ? */ -sunxi_nfc_hw_ecc_write_extra_oob (mtd, chip->oob_poi, +sunxi_nfc_hw_ecc_write_extra_oob (mtd, nand->oob_poi,NULL , page); -return nand_prog_page_end_op (chip); +return nand_prog_page_end_op (nand); pio_fallback: -return sunxi_nfc_hw_ecc_write_page (chip, buf, oob_required, page); +return sunxi_nfc_hw_ecc_write_page (nand, buf, oob_required, page); } -static int sunxi_nfc_hw_ecc_read_oob (struct nand_chip *chip,int page) +static int sunxi_nfc_hw_ecc_read_oob (struct nand_chip *nand,int page) { - chip->pagebuf =-1 ; + nand->pagebuf =-1 ; -return chip->ecc.read_page (chip, chip->data_buf,1 , page); +return nand->ecc.read_page (nand, nand->data_buf,1 , page); } -static int sunxi_nfc_hw_ecc_write_oob (struct nand_chip *chip,int page) +static int sunxi_nfc_hw_ecc_write_oob (struct nand_chip *nand,int page) { -struct mtd_info *mtd =nand_to_mtd (chip); +struct mtd_info *mtd =nand_to_mtd (nand);int ret; - chip->pagebuf =-1 ; + nand->pagebuf =-1 ; -memset (chip->data_buf,0xff , mtd->writesize); - ret = chip->ecc.write_page (chip, chip->data_buf,1 , page); +memset (nand->data_buf,0xff , mtd->writesize); + ret = nand->ecc.write_page (nand, nand->data_buf,1 , page);if (ret)return ret;/* Send command to program the OOB data */ -return nand_prog_page_end_op (chip); +return nand_prog_page_end_op (nand); }static const s32 tWB_lut[] = {6 ,12 ,16 ,20 };
Signature · 1 line
2.17.1
PATCH v2 4/7 mtd: rawnand: sunxi: Stop passing mtd_info objects around
In reply to Boris BrezillonReplace them by nand_chip pointers.
--- drivers/mtd/nand/raw/sunxi_nand.c | 204 ++++++++++++++---------------- 1 file changed, 94 insertions(+), 110 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +94 -110
@@ -339,13 +339,11 @@ static int sunxi_nfc_rst(struct sunxi_nfc *nfc)return ret; } -static int sunxi_nfc_dma_op_prepare (struct mtd_info *mtd,const void *buf, +static int sunxi_nfc_dma_op_prepare (struct sunxi_nfc *nfc,const void *buf,int chunksize,int nchunks,enum dma_data_direction ddir,struct scatterlist *sg) { -struct nand_chip *nand =mtd_to_nand (mtd); -struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct dma_async_tx_descriptor *dmad;enum dma_transfer_direction tdir;dma_cookie_t dmat;
@@ -388,13 +386,10 @@ static int sunxi_nfc_dma_op_prepare(struct mtd_info *mtd, const void *buf,return ret; } -static void sunxi_nfc_dma_op_cleanup (struct mtd_info *mtd, +static void sunxi_nfc_dma_op_cleanup (struct sunxi_nfc *nfc,enum dma_data_direction ddir,struct scatterlist *sg) { -struct nand_chip *nand =mtd_to_nand (mtd); -struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller); -dma_unmap_sg (nfc->dev, sg,1 , ddir);writel (readl (nfc->regs +NFC_REG_CTL ) & ~NFC_RAM_METHOD , nfc->regs +NFC_REG_CTL );
@@ -684,8 +679,10 @@ static u16 sunxi_nfc_randomizer_step(u16 state, int count)return state; } -static u16 sunxi_nfc_randomizer_state (struct mtd_info *mtd,int page,bool ecc) +static u16 sunxi_nfc_randomizer_state (struct nand_chip *nand,int page, +bool ecc) { +struct mtd_info *mtd =nand_to_mtd (nand);const u16 *seeds = sunxi_nfc_randomizer_page_seeds;int mod =mtd_div_by_ws (mtd->erasesize, mtd);
@@ -702,10 +699,9 @@ static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc)return seeds[page % mod]; } -static void sunxi_nfc_randomizer_config (struct mtd_info *mtd, -int page,bool ecc) +static void sunxi_nfc_randomizer_config (struct nand_chip *nand,int page, +bool ecc) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);u32 ecc_ctl =readl (nfc->regs +NFC_REG_ECC_CTL );u16 state;
@@ -714,14 +710,13 @@ static void sunxi_nfc_randomizer_config(struct mtd_info *mtd,return ; ecc_ctl =readl (nfc->regs +NFC_REG_ECC_CTL ); - state =sunxi_nfc_randomizer_state (mtd, page, ecc); + state =sunxi_nfc_randomizer_state (nand, page, ecc); ecc_ctl =readl (nfc->regs +NFC_REG_ECC_CTL ) & ~NFC_RANDOM_SEED_MSK ;writel (ecc_ctl |NFC_RANDOM_SEED (state), nfc->regs +NFC_REG_ECC_CTL ); } -static void sunxi_nfc_randomizer_enable (struct mtd_info *mtd) +static void sunxi_nfc_randomizer_enable (struct nand_chip *nand) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);if (!(nand->options &NAND_NEED_SCRAMBLING ))
@@ -731,9 +726,8 @@ static void sunxi_nfc_randomizer_enable(struct mtd_info *mtd) nfc->regs + NFC_REG_ECC_CTL); } -static void sunxi_nfc_randomizer_disable (struct mtd_info *mtd) +static void sunxi_nfc_randomizer_disable (struct nand_chip *nand) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);if (!(nand->options &NAND_NEED_SCRAMBLING ))
@@ -743,36 +737,35 @@ static void sunxi_nfc_randomizer_disable(struct mtd_info *mtd) nfc->regs + NFC_REG_ECC_CTL); } -static void sunxi_nfc_randomize_bbm (struct mtd_info *mtd,int page,u8 *bbm) +static void sunxi_nfc_randomize_bbm (struct nand_chip *nand,int page,u8 *bbm) { -u16 state =sunxi_nfc_randomizer_state (mtd, page, true); +u16 state =sunxi_nfc_randomizer_state (nand, page, true); bbm[0 ] ^= state; bbm[1 ] ^=sunxi_nfc_randomizer_step (state,8 ); } -static void sunxi_nfc_randomizer_write_buf (struct mtd_info *mtd, +static void sunxi_nfc_randomizer_write_buf (struct nand_chip *nand,const uint8_t *buf,int len,bool ecc,int page) { -sunxi_nfc_randomizer_config (mtd, page, ecc); -sunxi_nfc_randomizer_enable (mtd); -sunxi_nfc_write_buf (mtd_to_nand (mtd), buf, len); -sunxi_nfc_randomizer_disable (mtd); +sunxi_nfc_randomizer_config (nand, page, ecc); +sunxi_nfc_randomizer_enable (nand); +sunxi_nfc_write_buf (nand, buf, len); +sunxi_nfc_randomizer_disable (nand); } -static void sunxi_nfc_randomizer_read_buf (struct mtd_info *mtd,uint8_t *buf, +static void sunxi_nfc_randomizer_read_buf (struct nand_chip *nand,uint8_t *buf,int len,bool ecc,int page) { -sunxi_nfc_randomizer_config (mtd, page, ecc); -sunxi_nfc_randomizer_enable (mtd); -sunxi_nfc_read_buf (mtd_to_nand (mtd), buf, len); -sunxi_nfc_randomizer_disable (mtd); +sunxi_nfc_randomizer_config (nand, page, ecc); +sunxi_nfc_randomizer_enable (nand); +sunxi_nfc_read_buf (nand, buf, len); +sunxi_nfc_randomizer_disable (nand); } -static void sunxi_nfc_hw_ecc_enable (struct mtd_info *mtd) +static void sunxi_nfc_hw_ecc_enable (struct nand_chip *nand) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct sunxi_nand_hw_ecc *data = nand->ecc.priv;u32 ecc_ctl;
@@ -789,9 +782,8 @@ static void sunxi_nfc_hw_ecc_enable(struct mtd_info *mtd)writel (ecc_ctl, nfc->regs +NFC_REG_ECC_CTL ); } -static void sunxi_nfc_hw_ecc_disable (struct mtd_info *mtd) +static void sunxi_nfc_hw_ecc_disable (struct nand_chip *nand) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller); writel(readl(nfc->regs + NFC_REG_ECC_CTL) & ~NFC_ECC_EN,
@@ -811,10 +803,9 @@ static inline u32 sunxi_nfc_buf_to_user_data(const u8 *buf)return buf[0 ] | (buf[1 ] <<8 ) | (buf[2 ] <<16 ) | (buf[3 ] <<24 ); } -static void sunxi_nfc_hw_ecc_get_prot_oob_bytes (struct mtd_info *mtd,u8 *oob, +static void sunxi_nfc_hw_ecc_get_prot_oob_bytes (struct nand_chip *nand,u8 *oob,int step,bool bbm,int page) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller); sunxi_nfc_user_data_to_buf(readl(nfc->regs + NFC_REG_USER_DATA(step)),
@@ -822,21 +813,20 @@ static void sunxi_nfc_hw_ecc_get_prot_oob_bytes(struct mtd_info *mtd, u8 *oob,/* De-randomize the Bad Block Marker. */ if (bbm && (nand->options &NAND_NEED_SCRAMBLING )) -sunxi_nfc_randomize_bbm (mtd, page, oob); +sunxi_nfc_randomize_bbm (nand, page, oob); } -static void sunxi_nfc_hw_ecc_set_prot_oob_bytes (struct mtd_info *mtd, +static void sunxi_nfc_hw_ecc_set_prot_oob_bytes (struct nand_chip *nand,const u8 *oob,int step,bool bbm,int page) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);u8 user_data[4 ];/* Randomize the Bad Block Marker. */ if (bbm && (nand->options &NAND_NEED_SCRAMBLING )) {memcpy (user_data, oob,sizeof (user_data)); -sunxi_nfc_randomize_bbm (mtd, page, user_data); +sunxi_nfc_randomize_bbm (nand, page, user_data); oob = user_data; }
@@ -844,9 +834,11 @@ static void sunxi_nfc_hw_ecc_set_prot_oob_bytes(struct mtd_info *mtd, nfc->regs + NFC_REG_USER_DATA(step)); } -static void sunxi_nfc_hw_ecc_update_stats (struct mtd_info *mtd, +static void sunxi_nfc_hw_ecc_update_stats (struct nand_chip *nand,unsigned int *max_bitflips,int ret) { +struct mtd_info *mtd =nand_to_mtd (nand); +if (ret <0 ) { mtd->ecc_stats.failed++; }else {
@@ -855,10 +847,9 @@ static void sunxi_nfc_hw_ecc_update_stats(struct mtd_info *mtd, } } -static int sunxi_nfc_hw_ecc_correct (struct mtd_info *mtd,u8 *data,u8 *oob, +static int sunxi_nfc_hw_ecc_correct (struct nand_chip *nand,u8 *data,u8 *oob,int step,u32 status,bool *erased) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct nand_ecc_ctrl *ecc = &nand->ecc;u32 tmp;
@@ -892,14 +883,13 @@ static int sunxi_nfc_hw_ecc_correct(struct mtd_info *mtd, u8 *data, u8 *oob,return NFC_ECC_ERR_CNT (step, tmp); } -static int sunxi_nfc_hw_ecc_read_chunk (struct mtd_info *mtd, +static int sunxi_nfc_hw_ecc_read_chunk (struct nand_chip *nand,u8 *data,int data_off,u8 *oob,int oob_off,int *cur_off,unsigned int *max_bitflips,bool bbm,bool oob_required,int page) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct nand_ecc_ctrl *ecc = &nand->ecc;int raw_mode =0 ;
@@ -909,7 +899,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,if (*cur_off != data_off)nand_change_read_column_op (nand, data_off,NULL ,0 , false); -sunxi_nfc_randomizer_read_buf (mtd,NULL , ecc->size, false, page); +sunxi_nfc_randomizer_read_buf (nand,NULL , ecc->size, false, page);if (data_off + ecc->size != oob_off)nand_change_read_column_op (nand, oob_off,NULL ,0 , false);
@@ -918,18 +908,18 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,if (ret)return ret; -sunxi_nfc_randomizer_enable (mtd); +sunxi_nfc_randomizer_enable (nand);writel (NFC_DATA_TRANS |NFC_DATA_SWAP_METHOD |NFC_ECC_OP , nfc->regs +NFC_REG_CMD ); ret =sunxi_nfc_wait_events (nfc,NFC_CMD_INT_FLAG , false,0 ); -sunxi_nfc_randomizer_disable (mtd); +sunxi_nfc_randomizer_disable (nand);if (ret)return ret; *cur_off = oob_off + ecc->bytes +4 ; - ret =sunxi_nfc_hw_ecc_correct (mtd, data, oob_required ? oob :NULL ,0 , + ret =sunxi_nfc_hw_ecc_correct (nand, data, oob_required ? oob :NULL ,0 ,readl (nfc->regs +NFC_REG_ECC_ST ), &erased);if (erased)
@@ -961,24 +951,24 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,if (oob_required) {nand_change_read_column_op (nand, oob_off,NULL ,0 , false); -sunxi_nfc_randomizer_read_buf (mtd, oob, ecc->bytes +4 , +sunxi_nfc_randomizer_read_buf (nand, oob, ecc->bytes +4 , true, page); -sunxi_nfc_hw_ecc_get_prot_oob_bytes (mtd, oob,0 , +sunxi_nfc_hw_ecc_get_prot_oob_bytes (nand, oob,0 , bbm, page); } } -sunxi_nfc_hw_ecc_update_stats (mtd, max_bitflips, ret); +sunxi_nfc_hw_ecc_update_stats (nand, max_bitflips, ret);return raw_mode; } -static void sunxi_nfc_hw_ecc_read_extra_oob (struct mtd_info *mtd, +static void sunxi_nfc_hw_ecc_read_extra_oob (struct nand_chip *nand,u8 *oob,int *cur_off,bool randomize,int page) { -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct nand_ecc_ctrl *ecc = &nand->ecc;int offset = ((ecc->bytes +4 ) * ecc->steps);int len = mtd->oobsize - offset;
@@ -993,20 +983,20 @@ static void sunxi_nfc_hw_ecc_read_extra_oob(struct mtd_info *mtd,if (!randomize)sunxi_nfc_read_buf (nand, oob + offset, len);else -sunxi_nfc_randomizer_read_buf (mtd, oob + offset, len, +sunxi_nfc_randomizer_read_buf (nand, oob + offset, len, false, page);if (cur_off) *cur_off = mtd->oobsize + mtd->writesize; } -static int sunxi_nfc_hw_ecc_read_chunks_dma (struct mtd_info *mtd,uint8_t *buf, +static int sunxi_nfc_hw_ecc_read_chunks_dma (struct nand_chip *nand,uint8_t *buf,int oob_required,int page,int nchunks) { -struct nand_chip *nand =mtd_to_nand (mtd);bool randomized = nand->options &NAND_NEED_SCRAMBLING ;struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller); +struct mtd_info *mtd =nand_to_mtd (nand);struct nand_ecc_ctrl *ecc = &nand->ecc;unsigned int max_bitflips =0 ;int ret, i, raw_mode =0 ;
@@ -1017,14 +1007,14 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct mtd_info *mtd, uint8_t *buf,if (ret)return ret; - ret =sunxi_nfc_dma_op_prepare (mtd, buf, ecc->size, nchunks, + ret =sunxi_nfc_dma_op_prepare (nfc, buf, ecc->size, nchunks,DMA_FROM_DEVICE , &sg);if (ret)return ret; -sunxi_nfc_hw_ecc_enable (mtd); -sunxi_nfc_randomizer_config (mtd, page, false); -sunxi_nfc_randomizer_enable (mtd); +sunxi_nfc_hw_ecc_enable (nand); +sunxi_nfc_randomizer_config (nand, page, false); +sunxi_nfc_randomizer_enable (nand);writel ((NAND_CMD_RNDOUTSTART <<16 ) | (NAND_CMD_RNDOUT <<8 ) |NAND_CMD_READSTART , nfc->regs +NFC_REG_RCMD_SET );
@@ -1038,10 +1028,10 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct mtd_info *mtd, uint8_t *buf,if (ret)dmaengine_terminate_all (nfc->dmac); -sunxi_nfc_randomizer_disable (mtd); -sunxi_nfc_hw_ecc_disable (mtd); +sunxi_nfc_randomizer_disable (nand); +sunxi_nfc_hw_ecc_disable (nand); -sunxi_nfc_dma_op_cleanup (mtd,DMA_FROM_DEVICE , &sg); +sunxi_nfc_dma_op_cleanup (nfc,DMA_FROM_DEVICE , &sg);if (ret)return ret;
@@ -1055,7 +1045,7 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct mtd_info *mtd, uint8_t *buf,u8 *oob = nand->oob_poi + oob_off;bool erased; - ret =sunxi_nfc_hw_ecc_correct (mtd, randomized ? data :NULL , + ret =sunxi_nfc_hw_ecc_correct (nand, randomized ? data :NULL , oob_required ? oob :NULL , i, status, &erased);
@@ -1069,14 +1059,14 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct mtd_info *mtd, uint8_t *buf, mtd->writesize + oob_off, oob, ecc->bytes + 4, false); -sunxi_nfc_hw_ecc_get_prot_oob_bytes (mtd, oob, i, +sunxi_nfc_hw_ecc_get_prot_oob_bytes (nand, oob, i, !i, page); }if (erased) raw_mode =1 ; -sunxi_nfc_hw_ecc_update_stats (mtd, &max_bitflips, ret); +sunxi_nfc_hw_ecc_update_stats (nand, &max_bitflips, ret); }if (status &NFC_ECC_ERR_MSK ) {
@@ -1111,25 +1101,24 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct mtd_info *mtd, uint8_t *buf,if (ret >=0 ) raw_mode =1 ; -sunxi_nfc_hw_ecc_update_stats (mtd, &max_bitflips, ret); +sunxi_nfc_hw_ecc_update_stats (nand, &max_bitflips, ret); } }if (oob_required) -sunxi_nfc_hw_ecc_read_extra_oob (mtd, nand->oob_poi, +sunxi_nfc_hw_ecc_read_extra_oob (nand, nand->oob_poi,NULL , !raw_mode, page);return max_bitflips; } -static int sunxi_nfc_hw_ecc_write_chunk (struct mtd_info *mtd, +static int sunxi_nfc_hw_ecc_write_chunk (struct nand_chip *nand,const u8 *data,int data_off,const u8 *oob,int oob_off,int *cur_off,bool bbm,int page) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct nand_ecc_ctrl *ecc = &nand->ecc;int ret;
@@ -1137,7 +1126,7 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd,if (data_off != *cur_off)nand_change_write_column_op (nand, data_off,NULL ,0 , false); -sunxi_nfc_randomizer_write_buf (mtd, data, ecc->size, false, page); +sunxi_nfc_randomizer_write_buf (nand, data, ecc->size, false, page);if (data_off + ecc->size != oob_off)nand_change_write_column_op (nand, oob_off,NULL ,0 , false);
@@ -1146,15 +1135,15 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd,if (ret)return ret; -sunxi_nfc_randomizer_enable (mtd); -sunxi_nfc_hw_ecc_set_prot_oob_bytes (mtd, oob,0 , bbm, page); +sunxi_nfc_randomizer_enable (nand); +sunxi_nfc_hw_ecc_set_prot_oob_bytes (nand, oob,0 , bbm, page);writel (NFC_DATA_TRANS |NFC_DATA_SWAP_METHOD |NFC_ACCESS_DIR |NFC_ECC_OP , nfc->regs +NFC_REG_CMD ); ret =sunxi_nfc_wait_events (nfc,NFC_CMD_INT_FLAG , false,0 ); -sunxi_nfc_randomizer_disable (mtd); +sunxi_nfc_randomizer_disable (nand);if (ret)return ret;
@@ -1163,11 +1152,11 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd,return 0 ; } -static void sunxi_nfc_hw_ecc_write_extra_oob (struct mtd_info *mtd, +static void sunxi_nfc_hw_ecc_write_extra_oob (struct nand_chip *nand,u8 *oob,int *cur_off,int page) { -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct nand_ecc_ctrl *ecc = &nand->ecc;int offset = ((ecc->bytes +4 ) * ecc->steps);int len = mtd->oobsize - offset;
@@ -1179,7 +1168,7 @@ static void sunxi_nfc_hw_ecc_write_extra_oob(struct mtd_info *mtd,nand_change_write_column_op (nand, offset + mtd->writesize,NULL ,0 , false); -sunxi_nfc_randomizer_write_buf (mtd, oob + offset, len, false, page); +sunxi_nfc_randomizer_write_buf (nand, oob + offset, len, false, page);if (cur_off) *cur_off = mtd->oobsize + mtd->writesize;
@@ -1196,7 +1185,7 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *nand, uint8_t *buf,nand_read_page_op (nand, page,0 ,NULL ,0 ); -sunxi_nfc_hw_ecc_enable (mtd); +sunxi_nfc_hw_ecc_enable (nand);for (i =0 ; i < ecc->steps; i++) {int data_off = i * ecc->size;
@@ -1204,7 +1193,7 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *nand, uint8_t *buf,u8 *data = buf + data_off;u8 *oob = nand->oob_poi + oob_off; - ret =sunxi_nfc_hw_ecc_read_chunk (mtd, data, data_off, oob, + ret =sunxi_nfc_hw_ecc_read_chunk (nand, data, data_off, oob, oob_off + mtd->writesize, &cur_off, &max_bitflips, !i, oob_required, page);
@@ -1215,10 +1204,10 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *nand, uint8_t *buf, }if (oob_required) -sunxi_nfc_hw_ecc_read_extra_oob (mtd, nand->oob_poi, &cur_off, +sunxi_nfc_hw_ecc_read_extra_oob (nand, nand->oob_poi, &cur_off, !raw_mode, page); -sunxi_nfc_hw_ecc_disable (mtd); +sunxi_nfc_hw_ecc_disable (nand);return max_bitflips; }
@@ -1226,12 +1215,11 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *nand, uint8_t *buf,static int sunxi_nfc_hw_ecc_read_page_dma (struct nand_chip *nand,u8 *buf,int oob_required,int page) { -struct mtd_info *mtd =nand_to_mtd (nand);int ret;nand_read_page_op (nand, page,0 ,NULL ,0 ); - ret =sunxi_nfc_hw_ecc_read_chunks_dma (mtd, buf, oob_required, page, + ret =sunxi_nfc_hw_ecc_read_chunks_dma (nand, buf, oob_required, page, nand->ecc.steps);if (ret >=0 )return ret;
@@ -1251,7 +1239,7 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct nand_chip *nand,nand_read_page_op (nand, page,0 ,NULL ,0 ); -sunxi_nfc_hw_ecc_enable (mtd); +sunxi_nfc_hw_ecc_enable (nand);for (i = data_offs / ecc->size; i <DIV_ROUND_UP (data_offs + readlen, ecc->size); i++) {
@@ -1260,7 +1248,7 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct nand_chip *nand,u8 *data = bufpoi + data_off;u8 *oob = nand->oob_poi + oob_off; - ret = sunxi_nfc_hw_ecc_read_chunk(mtd, data, data_off, + ret = sunxi_nfc_hw_ecc_read_chunk(nand, data, data_off, oob, oob_off + mtd->writesize, &cur_off, &max_bitflips, !i,
@@ -1269,7 +1257,7 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct nand_chip *nand,return ret; } -sunxi_nfc_hw_ecc_disable (mtd); +sunxi_nfc_hw_ecc_disable (nand);return max_bitflips; }
@@ -1278,13 +1266,12 @@ static int sunxi_nfc_hw_ecc_read_subpage_dma(struct nand_chip *nand, u32 data_offs, u32 readlen, u8 *buf, int page) { - struct mtd_info *mtd = nand_to_mtd(nand); int nchunks = DIV_ROUND_UP(data_offs + readlen, nand->ecc.size);int ret;nand_read_page_op (nand, page,0 ,NULL ,0 ); - ret =sunxi_nfc_hw_ecc_read_chunks_dma (mtd, buf, false, page, nchunks); + ret =sunxi_nfc_hw_ecc_read_chunks_dma (nand, buf, false, page, nchunks);if (ret >=0 )return ret;
@@ -1303,7 +1290,7 @@ static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *nand,nand_prog_page_begin_op (nand, page,0 ,NULL ,0 ); -sunxi_nfc_hw_ecc_enable (mtd); +sunxi_nfc_hw_ecc_enable (nand);for (i =0 ; i < ecc->steps; i++) {int data_off = i * ecc->size;
@@ -1311,7 +1298,7 @@ static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *nand,const u8 *data = buf + data_off;const u8 *oob = nand->oob_poi + oob_off; - ret =sunxi_nfc_hw_ecc_write_chunk (mtd, data, data_off, oob, + ret =sunxi_nfc_hw_ecc_write_chunk (nand, data, data_off, oob, oob_off + mtd->writesize, &cur_off, !i, page);if (ret)
@@ -1319,10 +1306,10 @@ static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *nand, }if (oob_required || (nand->options &NAND_NEED_SCRAMBLING )) -sunxi_nfc_hw_ecc_write_extra_oob (mtd, nand->oob_poi, +sunxi_nfc_hw_ecc_write_extra_oob (nand, nand->oob_poi, &cur_off, page); -sunxi_nfc_hw_ecc_disable (mtd); +sunxi_nfc_hw_ecc_disable (nand);return nand_prog_page_end_op (nand); }
@@ -1338,7 +1325,7 @@ static int sunxi_nfc_hw_ecc_write_subpage(struct nand_chip *nand,nand_prog_page_begin_op (nand, page,0 ,NULL ,0 ); -sunxi_nfc_hw_ecc_enable (mtd); +sunxi_nfc_hw_ecc_enable (nand);for (i = data_offs / ecc->size; i <DIV_ROUND_UP (data_offs + data_len, ecc->size); i++) {
@@ -1347,14 +1334,14 @@ static int sunxi_nfc_hw_ecc_write_subpage(struct nand_chip *nand,const u8 *data = buf + data_off;const u8 *oob = nand->oob_poi + oob_off; - ret =sunxi_nfc_hw_ecc_write_chunk (mtd, data, data_off, oob, + ret =sunxi_nfc_hw_ecc_write_chunk (nand, data, data_off, oob, oob_off + mtd->writesize, &cur_off, !i, page);if (ret)return ret; } -sunxi_nfc_hw_ecc_disable (mtd); +sunxi_nfc_hw_ecc_disable (nand);return nand_prog_page_end_op (nand); }
@@ -1364,7 +1351,6 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand, int oob_required, int page) { -struct mtd_info *mtd =nand_to_mtd (nand);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct nand_ecc_ctrl *ecc = &nand->ecc;struct scatterlist sg;
@@ -1374,7 +1360,7 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,if (ret)return ret; - ret =sunxi_nfc_dma_op_prepare (mtd, buf, ecc->size, ecc->steps, + ret =sunxi_nfc_dma_op_prepare (nfc, buf, ecc->size, ecc->steps,DMA_TO_DEVICE , &sg);if (ret) goto pio_fallback;
@@ -1382,14 +1368,14 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,for (i =0 ; i < ecc->steps; i++) {const u8 *oob = nand->oob_poi + (i * (ecc->bytes +4 )); -sunxi_nfc_hw_ecc_set_prot_oob_bytes (mtd, oob, i, !i, page); +sunxi_nfc_hw_ecc_set_prot_oob_bytes (nand, oob, i, !i, page); }nand_prog_page_begin_op (nand, page,0 ,NULL ,0 ); -sunxi_nfc_hw_ecc_enable (mtd); -sunxi_nfc_randomizer_config (mtd, page, false); -sunxi_nfc_randomizer_enable (mtd); +sunxi_nfc_hw_ecc_enable (nand); +sunxi_nfc_randomizer_config (nand, page, false); +sunxi_nfc_randomizer_enable (nand);writel ((NAND_CMD_RNDIN <<8 ) |NAND_CMD_PAGEPROG , nfc->regs +NFC_REG_RCMD_SET );
@@ -1404,17 +1390,17 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,if (ret)dmaengine_terminate_all (nfc->dmac); -sunxi_nfc_randomizer_disable (mtd); -sunxi_nfc_hw_ecc_disable (mtd); +sunxi_nfc_randomizer_disable (nand); +sunxi_nfc_hw_ecc_disable (nand); -sunxi_nfc_dma_op_cleanup (mtd,DMA_TO_DEVICE , &sg); +sunxi_nfc_dma_op_cleanup (nfc,DMA_TO_DEVICE , &sg);if (ret)return ret;if (oob_required || (nand->options &NAND_NEED_SCRAMBLING ))/* TODO: use DMA to transfer extra OOB bytes ? */ -sunxi_nfc_hw_ecc_write_extra_oob (mtd, nand->oob_poi, +sunxi_nfc_hw_ecc_write_extra_oob (nand, nand->oob_poi,NULL , page);return nand_prog_page_end_op (nand);
@@ -1677,14 +1663,13 @@ static void sunxi_nand_hw_ecc_ctrl_cleanup(struct nand_ecc_ctrl *ecc)kfree (ecc->priv); } -static int sunxi_nand_hw_ecc_ctrl_init (struct mtd_info *mtd, +static int sunxi_nand_hw_ecc_ctrl_init (struct nand_chip *nand,struct nand_ecc_ctrl *ecc,struct device_node *np) {static const u8 strengths[] = {16 ,24 ,28 ,32 ,40 ,48 ,56 ,60 ,64 }; -struct nand_chip *nand =mtd_to_nand (mtd); -struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand); -struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller); +struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller); +struct mtd_info *mtd =nand_to_mtd (nand);struct sunxi_nand_hw_ecc *data;int nsectors;int ret;
@@ -1808,7 +1793,6 @@ static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc)static int sunxi_nand_attach_chip (struct nand_chip *nand) { -struct mtd_info *mtd =nand_to_mtd (nand);struct nand_ecc_ctrl *ecc = &nand->ecc;struct device_node *np =nand_get_flash_node (nand);int ret;
@@ -1831,7 +1815,7 @@ static int sunxi_nand_attach_chip(struct nand_chip *nand)switch (ecc->mode) {case NAND_ECC_HW : - ret =sunxi_nand_hw_ecc_ctrl_init (mtd, ecc, np); + ret =sunxi_nand_hw_ecc_ctrl_init (nand, ecc, np);if (ret)return ret;break ;
Signature · 1 line
2.17.1
PATCH v2 5/7 mtd: rawnand: sunxi: Add an SPDX tag
In reply to Boris BrezillonReplace the license text by an SPDX tag and fix MODULE_LICENSE() to match GPL-2.0+.
--- drivers/mtd/nand/raw/sunxi_nand.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +2 -11
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2013 Boris BREZILLON <[email protected]> *
@@ -10,16 +11,6 @@* * Copyright (C) 2013 Dmitriy B. <[email protected]> * Copyright (C) 2013 Sergey Lapin <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #include <linux/dma-mapping.h>
@@ -2107,7 +2098,7 @@ static struct platform_driver sunxi_nfc_driver = { };module_platform_driver (sunxi_nfc_driver); -MODULE_LICENSE ("GPL v2" ); +MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Boris BREZILLON" );MODULE_DESCRIPTION ("Allwinner NAND Flash Controller driver" );MODULE_ALIAS ("platform:sunxi_nand" );
Signature · 1 line
2.17.1
PATCH v2 6/7 mtd: rawnand: sunxi: Migrate to ->exec_op()
In reply to Boris BrezillonAnd get rif of all legacy hooks and unused fields.
--- drivers/mtd/nand/raw/sunxi_nand.c | 294 ++++++++++++++++++------------ 1 file changed, 174 insertions(+), 120 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +174 -120
@@ -183,7 +183,6 @@ struct sunxi_nand_hw_ecc {* @mtd: base MTD structure * @clk_rate: clk_rate required for this NAND chip * @timing_cfg TIMING_CFG register value for this NAND chip -* @selected: current active CS * @nsels: number of CS lines required by the NAND chip * @sels: array of CS lines descriptions */
@@ -193,11 +192,6 @@ struct sunxi_nand_chip {unsigned long clk_rate;u32 timing_cfg;u32 timing_ctl; -int selected; -int addr_cycles; -u32 addr[2 ]; -int cmd_cycles; -u8 cmd[2 ];int nsels;struct sunxi_nand_chip_sel sels[0 ]; };
@@ -386,26 +380,7 @@ static void sunxi_nfc_dma_op_cleanup(struct sunxi_nfc *nfc, nfc->regs + NFC_REG_CTL); } -static int sunxi_nfc_dev_ready (struct nand_chip *nand) -{ -struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand); -struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller); -u32 mask; - -if (sunxi_nand->selected <0 ) -return 0 ; - -if (sunxi_nand->sels[sunxi_nand->selected].rb <0 ) { -dev_err (nfc->dev,"cannot check R/B NAND status!\n" ); -return 0 ; - } - - mask =NFC_RB_STATE (sunxi_nand->sels[sunxi_nand->selected].rb); - -return !!(readl (nfc->regs +NFC_REG_ST ) & mask); -} - -static void sunxi_nfc_select_chip (struct nand_chip *nand,int chip) +static void sunxi_nfc_select_chip (struct nand_chip *nand,unsigned int cs) {struct mtd_info *mtd =nand_to_mtd (nand);struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand);
@@ -413,40 +388,27 @@ static void sunxi_nfc_select_chip(struct nand_chip *nand, int chip)struct sunxi_nand_chip_sel *sel;u32 ctl; -if (chip >0 && chip >= sunxi_nand->nsels) -return ; - -if (chip == sunxi_nand->selected) +if (cs >0 && cs >= sunxi_nand->nsels)return ; ctl =readl (nfc->regs +NFC_REG_CTL ) & ~(NFC_PAGE_SHIFT_MSK |NFC_CE_SEL_MSK |NFC_RB_SEL_MSK |NFC_EN ); -if (chip >=0 ) { - sel = &sunxi_nand->sels[chip]; + sel = &sunxi_nand->sels[cs]; + ctl |=NFC_CE_SEL (sel->cs) |NFC_EN |NFC_PAGE_SHIFT (nand->page_shift); +if (sel->rb >=0 ) + ctl |=NFC_RB_SEL (sel->rb); - ctl |=NFC_CE_SEL (sel->cs) |NFC_EN | -NFC_PAGE_SHIFT (nand->page_shift); -if (sel->rb <0 ) { - nand->legacy.dev_ready =NULL ; - }else { - nand->legacy.dev_ready = sunxi_nfc_dev_ready; - ctl |=NFC_RB_SEL (sel->rb); - } +writel (mtd->writesize, nfc->regs +NFC_REG_SPARE_AREA ); -writel (mtd->writesize, nfc->regs +NFC_REG_SPARE_AREA ); - -if (nfc->clk_rate != sunxi_nand->clk_rate) { -clk_set_rate (nfc->mod_clk, sunxi_nand->clk_rate); - nfc->clk_rate = sunxi_nand->clk_rate; - } +if (nfc->clk_rate != sunxi_nand->clk_rate) { +clk_set_rate (nfc->mod_clk, sunxi_nand->clk_rate); + nfc->clk_rate = sunxi_nand->clk_rate; }writel (sunxi_nand->timing_ctl, nfc->regs +NFC_REG_TIMING_CTL );writel (sunxi_nand->timing_cfg, nfc->regs +NFC_REG_TIMING_CFG );writel (ctl, nfc->regs +NFC_REG_CTL ); - - sunxi_nand->selected = chip; }static void sunxi_nfc_read_buf (struct nand_chip *nand,uint8_t *buf,int len)
@@ -523,71 +485,6 @@ static void sunxi_nfc_write_buf(struct nand_chip *nand, const uint8_t *buf, } } -static uint8_t sunxi_nfc_read_byte (struct nand_chip *nand) -{ -uint8_t ret =0 ; - -sunxi_nfc_read_buf (nand, &ret,1 ); - -return ret; -} - -static void sunxi_nfc_cmd_ctrl (struct nand_chip *nand,int dat, -unsigned int ctrl) -{ -struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand); -struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller); -int ret; - -if (dat ==NAND_CMD_NONE && (ctrl &NAND_NCE ) && - !(ctrl & (NAND_CLE |NAND_ALE ))) { -u32 cmd =0 ; - -if (!sunxi_nand->addr_cycles && !sunxi_nand->cmd_cycles) -return ; - -if (sunxi_nand->cmd_cycles--) - cmd |=NFC_SEND_CMD1 | sunxi_nand->cmd[0 ]; - -if (sunxi_nand->cmd_cycles--) { - cmd |=NFC_SEND_CMD2 ; -writel (sunxi_nand->cmd[1 ], - nfc->regs +NFC_REG_RCMD_SET ); - } - - sunxi_nand->cmd_cycles =0 ; - -if (sunxi_nand->addr_cycles) { - cmd |=NFC_SEND_ADR | -NFC_ADR_NUM (sunxi_nand->addr_cycles); -writel (sunxi_nand->addr[0 ], - nfc->regs +NFC_REG_ADDR_LOW ); - } - -if (sunxi_nand->addr_cycles >4 ) -writel (sunxi_nand->addr[1 ], - nfc->regs +NFC_REG_ADDR_HIGH ); - - ret =sunxi_nfc_wait_cmd_fifo_empty (nfc); -if (ret) -return ; - -writel (cmd, nfc->regs +NFC_REG_CMD ); - sunxi_nand->addr[0 ] =0 ; - sunxi_nand->addr[1 ] =0 ; - sunxi_nand->addr_cycles =0 ; -sunxi_nfc_wait_events (nfc,NFC_CMD_INT_FLAG , true,0 ); - } - -if (ctrl &NAND_CLE ) { - sunxi_nand->cmd[sunxi_nand->cmd_cycles++] = dat; - }else if (ctrl &NAND_ALE ) { - sunxi_nand->addr[sunxi_nand->addr_cycles /4 ] |= - dat << ((sunxi_nand->addr_cycles %4 ) *8 ); - sunxi_nand->addr_cycles++; - } -} -/* These seed values have been extracted from Allwinner's BSP */ static const u16 sunxi_nfc_randomizer_page_seeds[] = {0x2b75 ,0x0bd0 ,0x5ca3 ,0x62d1 ,0x1c93 ,0x07e9 ,0x2162 ,0x3a72 ,
@@ -1174,6 +1071,8 @@ static int sunxi_nfc_hw_ecc_read_page(struct nand_chip *nand, uint8_t *buf,int ret, i, cur_off =0 ;bool raw_mode = false; +sunxi_nfc_select_chip (nand, nand->cur_cs); +nand_read_page_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (nand);
@@ -1208,6 +1107,8 @@ static int sunxi_nfc_hw_ecc_read_page_dma(struct nand_chip *nand, u8 *buf, {int ret; +sunxi_nfc_select_chip (nand, nand->cur_cs); +nand_read_page_op (nand, page,0 ,NULL ,0 ); ret = sunxi_nfc_hw_ecc_read_chunks_dma(nand, buf, oob_required, page,
@@ -1228,6 +1129,8 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct nand_chip *nand,int ret, i, cur_off =0 ;unsigned int max_bitflips =0 ; +sunxi_nfc_select_chip (nand, nand->cur_cs); +nand_read_page_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (nand);
@@ -1260,6 +1163,8 @@ static int sunxi_nfc_hw_ecc_read_subpage_dma(struct nand_chip *nand,int nchunks =DIV_ROUND_UP (data_offs + readlen, nand->ecc.size);int ret; +sunxi_nfc_select_chip (nand, nand->cur_cs); +nand_read_page_op (nand, page,0 ,NULL ,0 ); ret =sunxi_nfc_hw_ecc_read_chunks_dma (nand, buf, false, page, nchunks);
@@ -1279,6 +1184,8 @@ static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *nand,struct nand_ecc_ctrl *ecc = &nand->ecc;int ret, i, cur_off =0 ; +sunxi_nfc_select_chip (nand, nand->cur_cs); +nand_prog_page_begin_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (nand);
@@ -1314,6 +1221,8 @@ static int sunxi_nfc_hw_ecc_write_subpage(struct nand_chip *nand,struct nand_ecc_ctrl *ecc = &nand->ecc;int ret, i, cur_off =0 ; +sunxi_nfc_select_chip (nand, nand->cur_cs); +nand_prog_page_begin_op (nand, page,0 ,NULL ,0 );sunxi_nfc_hw_ecc_enable (nand);
@@ -1347,6 +1256,8 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,struct scatterlist sg;int ret, i; +sunxi_nfc_select_chip (nand, nand->cur_cs); + ret =sunxi_nfc_wait_cmd_fifo_empty (nfc);if (ret)return ret;
@@ -1820,9 +1731,159 @@ static int sunxi_nand_attach_chip(struct nand_chip *nand)return 0 ; } +static int sunxi_nfc_exec_subop (struct nand_chip *nand, +const struct nand_subop *subop) +{ +struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller); +u32 cmd =0 , extcmd =0 , cnt =0 , addrs[2 ] = { }; +unsigned int i, j, remaining, start; +void *inbuf =NULL ; +int ret; + +for (i =0 ; i < subop->ninstrs; i++) { +const struct nand_op_instr *instr = &subop->instrs[i]; + +switch (instr->type) { +case NAND_OP_CMD_INSTR : +if (cmd &NFC_SEND_CMD1 ) { +if (WARN_ON (cmd &NFC_SEND_CMD2 )) +return -EINVAL ; + + cmd |=NFC_SEND_CMD2 ; + extcmd |= instr->ctx.cmd.opcode; + }else { + cmd |=NFC_SEND_CMD1 | +NFC_CMD (instr->ctx.cmd.opcode); + } +break ; + +case NAND_OP_ADDR_INSTR : + remaining =nand_subop_get_num_addr_cyc (subop, i); + start =nand_subop_get_addr_start_off (subop, i); +for (j =0 ; j <8 && j + start < remaining; j++) { +u32 addr = instr->ctx.addr.addrs[j + start]; + + addrs[j /4 ] |= addr << (j %4 ) *8 ; + } + +if (j) + cmd |=NFC_SEND_ADR |NFC_ADR_NUM (j); + +break ; + +case NAND_OP_DATA_IN_INSTR : +case NAND_OP_DATA_OUT_INSTR : + start =nand_subop_get_data_start_off (subop, i); + remaining =nand_subop_get_data_len (subop, i); + cnt =min_t (u32, remaining,NFC_SRAM_SIZE ); + cmd |=NFC_DATA_TRANS |NFC_DATA_SWAP_METHOD ; + +if (instr->type ==NAND_OP_DATA_OUT_INSTR ) { + cmd |=NFC_ACCESS_DIR ; +memcpy_toio (nfc->regs +NFC_RAM0_BASE , + instr->ctx.data.buf.out + start, + cnt); + }else { + inbuf = instr->ctx.data.buf.in + start; + } + +break ; + +case NAND_OP_WAITRDY_INSTR : + cmd |=NFC_WAIT_FLAG ; +break ; + } + } + + ret =sunxi_nfc_wait_cmd_fifo_empty (nfc); +if (ret) +return ret; + +if (cmd &NFC_SEND_ADR ) { +writel (addrs[0 ], nfc->regs +NFC_REG_ADDR_LOW ); +writel (addrs[1 ], nfc->regs +NFC_REG_ADDR_HIGH ); + } + +if (cmd &NFC_SEND_CMD2 ) +writel (extcmd, + nfc->regs + + (cmd &NFC_ACCESS_DIR ? +NFC_REG_WCMD_SET :NFC_REG_RCMD_SET )); + +if (cmd &NFC_DATA_TRANS ) +writel (cnt, nfc->regs +NFC_REG_CNT ); + +writel (cmd, nfc->regs +NFC_REG_CMD ); + + ret =sunxi_nfc_wait_events (nfc,NFC_CMD_INT_FLAG , + !(cmd &NFC_WAIT_FLAG ) && cnt <64 , +0 ); +if (ret) +return ret; + +if (inbuf) +memcpy_fromio (inbuf, nfc->regs +NFC_RAM0_BASE , cnt); + +return 0 ; +} + +static int sunxi_nfc_soft_waitrdy (struct nand_chip *nand, +const struct nand_subop *subop) +{ +return nand_soft_waitrdy (nand, + subop->instrs[0 ].ctx.waitrdy.timeout_ms); +} + +static const struct nand_op_parser sunxi_nfc_op_parser =NAND_OP_PARSER ( +NAND_OP_PARSER_PATTERN (sunxi_nfc_exec_subop, +NAND_OP_PARSER_PAT_CMD_ELEM (true), +NAND_OP_PARSER_PAT_ADDR_ELEM (true,8 ), +NAND_OP_PARSER_PAT_CMD_ELEM (true), +NAND_OP_PARSER_PAT_WAITRDY_ELEM (true), +NAND_OP_PARSER_PAT_DATA_IN_ELEM (true,1024 )), +NAND_OP_PARSER_PATTERN (sunxi_nfc_exec_subop, +NAND_OP_PARSER_PAT_CMD_ELEM (true), +NAND_OP_PARSER_PAT_ADDR_ELEM (true,8 ), +NAND_OP_PARSER_PAT_DATA_OUT_ELEM (true,1024 ), +NAND_OP_PARSER_PAT_CMD_ELEM (true), + NAND_OP_PARSER_PAT_WAITRDY_ELEM(true)), +); + +static const struct nand_op_parser sunxi_nfc_norb_op_parser =NAND_OP_PARSER ( +NAND_OP_PARSER_PATTERN (sunxi_nfc_exec_subop, +NAND_OP_PARSER_PAT_CMD_ELEM (true), +NAND_OP_PARSER_PAT_ADDR_ELEM (true,8 ), +NAND_OP_PARSER_PAT_CMD_ELEM (true), +NAND_OP_PARSER_PAT_DATA_IN_ELEM (true,1024 )), +NAND_OP_PARSER_PATTERN (sunxi_nfc_exec_subop, +NAND_OP_PARSER_PAT_CMD_ELEM (true), +NAND_OP_PARSER_PAT_ADDR_ELEM (true,8 ), +NAND_OP_PARSER_PAT_DATA_OUT_ELEM (true,1024 ), +NAND_OP_PARSER_PAT_CMD_ELEM (true)), +NAND_OP_PARSER_PATTERN (sunxi_nfc_soft_waitrdy, + NAND_OP_PARSER_PAT_WAITRDY_ELEM(false)), +); + +static int sunxi_nfc_exec_op (struct nand_chip *nand, +const struct nand_operation *op,bool check_only) +{ +struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand); +const struct nand_op_parser *parser; + +sunxi_nfc_select_chip (nand, op->cs); + +if (sunxi_nand->sels[op->cs].rb >=0 ) + parser = &sunxi_nfc_op_parser; +else + parser = &sunxi_nfc_norb_op_parser; + +return nand_op_parser_exec_op (nand, parser, op, check_only); +} +static const struct nand_controller_ops sunxi_nand_controller_ops = { .attach_chip = sunxi_nand_attach_chip, .setup_data_interface = sunxi_nfc_setup_data_interface, + .exec_op = sunxi_nfc_exec_op, }; static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
@@ -1853,7 +1914,6 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, } sunxi_nand->nsels = nsels; - sunxi_nand->selected =-1 ;for (i =0 ; i < nsels; i++) { ret =of_property_read_u32_index (np,"reg" , i, &tmp);
@@ -1886,7 +1946,6 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, nand = &sunxi_nand->nand;/* Default tR value specified in the ONFI spec (chapter 4.15.1) */ - nand->legacy.chip_delay =200 ; nand->controller = &nfc->controller; nand->controller->ops = &sunxi_nand_controller_ops;
@@ -1896,11 +1955,6 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,*/ nand->ecc.mode =NAND_ECC_HW ;nand_set_flash_node (nand, np); - nand->legacy.select_chip = sunxi_nfc_select_chip; - nand->legacy.cmd_ctrl = sunxi_nfc_cmd_ctrl; - nand->legacy.read_buf = sunxi_nfc_read_buf; - nand->legacy.write_buf = sunxi_nfc_write_buf; - nand->legacy.read_byte = sunxi_nfc_read_byte; mtd =nand_to_mtd (nand); mtd->dev.parent = dev;
Signature · 1 line
2.17.1
PATCH v2 7/7 mtd: rawnand: sunxi: Fix kernel doc headers
In reply to Boris BrezillonFix the struct description and use standard kernel-doc header format (even if the file is not parsed by the doc generator).
We also replace tabs by a single space.
--- drivers/mtd/nand/raw/sunxi_nand.c | 60 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +30 -30
@@ -154,37 +154,36 @@#define NFC_MAX_CS 7 -/* -* Chip Select structure: stores information related to NAND Chip Select +/** +* struct sunxi_nand_chip_sel - stores information related to NAND Chip Select * -* @cs: the NAND CS id used to communicate with a NAND Chip -* @rb: the Ready/Busy pin ID. -1 means no R/B pin connected to the -* NFC +* @cs: the NAND CS id used to communicate with a NAND Chip +* @rb: the Ready/Busy pin ID. -1 means no R/B pin connected to the NFC */ struct sunxi_nand_chip_sel {u8 cs;s8 rb; }; -/* -* sunxi HW ECC infos: stores information related to HW ECC support +/** +* struct sunxi_nand_hw_ecc - stores information related to HW ECC support * -* @mode: the sunxi ECC mode field deduced from ECC requirements +* @mode: the sunxi ECC mode field deduced from ECC requirements */ struct sunxi_nand_hw_ecc {int mode; }; -/* -* NAND chip structure: stores NAND chip device related information +/** +* struct sunxi_nand_chip - stores NAND chip device related information * -* @node: used to store NAND chips into a list -* @nand: base NAND chip structure -* @mtd: base MTD structure -* @clk_rate: clk_rate required for this NAND chip -* @timing_cfg TIMING_CFG register value for this NAND chip -* @nsels: number of CS lines required by the NAND chip -* @sels: array of CS lines descriptions +* @node: used to store NAND chips into a list +* @nand: base NAND chip structure +* @clk_rate: clk_rate required for this NAND chip +* @timing_cfg: TIMING_CFG register value for this NAND chip +* @timing_ctl: TIMING_CTL register value for this NAND chip +* @nsels: number of CS lines required by the NAND chip +* @sels: array of CS lines descriptions */ struct sunxi_nand_chip {struct list_head node;
@@ -201,20 +200,21 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(struct nand_chip *nand) return container_of(nand, struct sunxi_nand_chip, nand); } -/* -* NAND Controller structure: stores sunxi NAND controller information +/** +* struct sunxi_nfc - stores sunxi NAND controller information * -* @controller: base controller structure -* @dev: parent device (used to print error messages) -* @regs: NAND controller registers -* @ahb_clk: NAND Controller AHB clock -* @mod_clk: NAND Controller mod clock -* @assigned_cs: bitmask describing already assigned CS lines -* @clk_rate: NAND controller current clock rate -* @chips: a list containing all the NAND chips attached to -* this NAND controller -* @complete: a completion object used to wait for NAND -* controller events +* @controller: base controller structure +* @dev: parent device (used to print error messages) +* @regs: NAND controller registers +* @ahb_clk: NAND controller AHB clock +* @mod_clk: NAND controller mod clock +* @reset: NAND controller reset line +* @assigned_cs: bitmask describing already assigned CS lines +* @clk_rate: NAND controller current clock rate +* @chips: a list containing all the NAND chips attached to this NAND +* controller +* @complete: a completion object used to wait for NAND controller events +* @dmac: the DMA channel attached to the NAND controller */ struct sunxi_nfc {struct nand_controller controller;
Signature · 1 line
2.17.1
Miquel Raynal
maintainerHi Boris,
Boris Brezillon <[email protected]> wrote on Sat, 15 Dec 2018 09:24:30 +0100:
Quoted 5 lines
Hello,
This series converts the sunxi NAND controller driver to
exec_opand cleans a few things up.
Series applied on nand/next.
Thanks,
Miquèl