Lines Matching full:this
35 * Clear the bit and poll it cleared. This is usually called with
69 * the next hard reset. This case occurs in the NAND boot mode. When the board
72 * You will see a DMA timeout in this case. The bug has been fixed
75 * To avoid this bug, just add a new parameter `just_enable` for
120 static int __gpmi_enable_clk(struct gpmi_nand_data *this, bool v) in __gpmi_enable_clk() argument
127 clk = this->resources.clock[i]; in __gpmi_enable_clk()
143 clk_disable_unprepare(this->resources.clock[i - 1]); in __gpmi_enable_clk()
147 static int gpmi_init(struct gpmi_nand_data *this) in gpmi_init() argument
149 struct resources *r = &this->resources; in gpmi_init()
152 ret = pm_runtime_resume_and_get(this->dev); in gpmi_init()
164 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in gpmi_init()
190 pm_runtime_mark_last_busy(this->dev); in gpmi_init()
191 pm_runtime_put_autosuspend(this->dev); in gpmi_init()
195 /* This function is very useful. It is called only when the bug occur. */
196 static void gpmi_dump_info(struct gpmi_nand_data *this) in gpmi_dump_info() argument
198 struct resources *r = &this->resources; in gpmi_dump_info()
199 struct bch_geometry *geo = &this->bch_geometry; in gpmi_dump_info()
203 dev_err(this->dev, "Show GPMI registers :\n"); in gpmi_dump_info()
206 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
210 dev_err(this->dev, "Show BCH registers :\n"); in gpmi_dump_info()
213 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
215 dev_err(this->dev, "BCH Geometry :\n" in gpmi_dump_info()
242 static bool gpmi_check_ecc(struct gpmi_nand_data *this) in gpmi_check_ecc() argument
244 struct nand_chip *chip = &this->nand; in gpmi_check_ecc()
245 struct bch_geometry *geo = &this->bch_geometry; in gpmi_check_ecc()
253 if (GPMI_IS_MXS(this)) { in gpmi_check_ecc()
259 if (geo->ecc_strength > this->devdata->bch_max_ecc_strength) in gpmi_check_ecc()
269 static bool bbm_in_data_chunk(struct gpmi_nand_data *this, in bbm_in_data_chunk() argument
272 struct bch_geometry *geo = &this->bch_geometry; in bbm_in_data_chunk()
273 struct nand_chip *chip = &this->nand; in bbm_in_data_chunk()
278 dev_err(this->dev, in bbm_in_data_chunk()
293 dev_dbg(this->dev, "Set ecc to %d and bbm in chunk %d\n", in bbm_in_data_chunk()
305 * We may have available oob space in this case.
307 static int set_geometry_by_ecc_info(struct gpmi_nand_data *this, in set_geometry_by_ecc_info() argument
311 struct bch_geometry *geo = &this->bch_geometry; in set_geometry_by_ecc_info()
312 struct nand_chip *chip = &this->nand; in set_geometry_by_ecc_info()
324 dev_err(this->dev, in set_geometry_by_ecc_info()
333 if (!gpmi_check_ecc(this)) in set_geometry_by_ecc_info()
338 dev_err(this->dev, in set_geometry_by_ecc_info()
406 if (!this->swap_block_mark) in set_geometry_by_ecc_info()
437 static inline int get_ecc_strength(struct gpmi_nand_data *this) in get_ecc_strength() argument
439 struct bch_geometry *geo = &this->bch_geometry; in get_ecc_strength()
440 struct mtd_info *mtd = nand_to_mtd(&this->nand); in get_ecc_strength()
450 static int set_geometry_for_large_oob(struct gpmi_nand_data *this) in set_geometry_for_large_oob() argument
452 struct bch_geometry *geo = &this->bch_geometry; in set_geometry_for_large_oob()
453 struct nand_chip *chip = &this->nand; in set_geometry_for_large_oob()
468 /* check if platform can support this nand */ in set_geometry_for_large_oob()
469 if (!gpmi_check_ecc(this)) { in set_geometry_for_large_oob()
470 dev_err(this->dev, in set_geometry_for_large_oob()
482 max_ecc = min(get_ecc_strength(this), in set_geometry_for_large_oob()
483 this->devdata->bch_max_ecc_strength); in set_geometry_for_large_oob()
491 if (bbm_in_data_chunk(this, &bbm_chunk)) in set_geometry_for_large_oob()
503 /* check if oob can afford this extra ecc chunk */ in set_geometry_for_large_oob()
506 dev_err(this->dev, "unsupported NAND chip with new layout\n"); in set_geometry_for_large_oob()
532 if (!this->swap_block_mark) in set_geometry_for_large_oob()
545 dev_dbg(this->dev, "BCH Geometry :\n" in set_geometry_for_large_oob()
578 static int legacy_set_geometry(struct gpmi_nand_data *this) in legacy_set_geometry() argument
580 struct bch_geometry *geo = &this->bch_geometry; in legacy_set_geometry()
581 struct mtd_info *mtd = nand_to_mtd(&this->nand); in legacy_set_geometry()
608 geo->ecc_strength = get_ecc_strength(this); in legacy_set_geometry()
609 if (!gpmi_check_ecc(this)) { in legacy_set_geometry()
610 dev_err(this->dev, in legacy_set_geometry()
614 this->devdata->bch_max_ecc_strength); in legacy_set_geometry()
634 if (!this->swap_block_mark) in legacy_set_geometry()
692 static int common_nfc_set_geometry(struct gpmi_nand_data *this) in common_nfc_set_geometry() argument
694 struct nand_chip *chip = &this->nand; in common_nfc_set_geometry()
695 struct mtd_info *mtd = nand_to_mtd(&this->nand); in common_nfc_set_geometry()
701 use_minimun_ecc = of_property_read_bool(this->dev->of_node, in common_nfc_set_geometry()
707 dev_dbg(this->dev, "use legacy bch geometry\n"); in common_nfc_set_geometry()
708 err = legacy_set_geometry(this); in common_nfc_set_geometry()
715 dev_dbg(this->dev, "use large oob bch geometry\n"); in common_nfc_set_geometry()
716 err = set_geometry_for_large_oob(this); in common_nfc_set_geometry()
722 dev_dbg(this->dev, "use minimum ecc bch geometry\n"); in common_nfc_set_geometry()
723 err = set_geometry_by_ecc_info(this, requirements->strength, in common_nfc_set_geometry()
726 dev_err(this->dev, "none of the bch geometry setting works\n"); in common_nfc_set_geometry()
732 static int bch_set_geometry(struct gpmi_nand_data *this) in bch_set_geometry() argument
734 struct resources *r = &this->resources; in bch_set_geometry()
737 ret = common_nfc_set_geometry(this); in bch_set_geometry()
741 ret = pm_runtime_resume_and_get(this->dev); in bch_set_geometry()
747 * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this in bch_set_geometry()
751 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in bch_set_geometry()
760 pm_runtime_mark_last_busy(this->dev); in bch_set_geometry()
761 pm_runtime_put_autosuspend(this->dev); in bch_set_geometry()
840 static int gpmi_nfc_compute_timings(struct gpmi_nand_data *this, in gpmi_nfc_compute_timings() argument
843 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_compute_timings()
844 struct resources *r = &this->resources; in gpmi_nfc_compute_timings()
845 unsigned int dll_threshold_ps = this->devdata->max_chain_delay; in gpmi_nfc_compute_timings()
875 dev_err(this->dev, "clock setting: expected %ld, got %ld\n", in gpmi_nfc_compute_timings()
925 static int gpmi_nfc_apply_timings(struct gpmi_nand_data *this) in gpmi_nfc_apply_timings() argument
927 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_apply_timings()
928 struct resources *r = &this->resources; in gpmi_nfc_apply_timings()
937 if (GPMI_IS_MX6Q(this) || GPMI_IS_MX6SX(this)) in gpmi_nfc_apply_timings()
942 dev_err(this->dev, "cannot set clock rate to %lu Hz: %d\n", hw->clk_rate, ret); in gpmi_nfc_apply_timings()
946 if (GPMI_IS_MX6Q(this) || GPMI_IS_MX6SX(this)) { in gpmi_nfc_apply_timings()
976 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_setup_interface() local
986 if (sdr->tRC_min <= 25000 && !this->devdata->support_edo_timing) in gpmi_setup_interface()
989 /* Stop here if this call was just a check */ in gpmi_setup_interface()
994 ret = gpmi_nfc_compute_timings(this, sdr); in gpmi_setup_interface()
998 this->hw.must_apply_timings = true; in gpmi_setup_interface()
1004 static void gpmi_clear_bch(struct gpmi_nand_data *this) in gpmi_clear_bch() argument
1006 struct resources *r = &this->resources; in gpmi_clear_bch()
1010 static struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) in get_dma_chan() argument
1013 return this->dma_chans[0]; in get_dma_chan()
1016 /* This will be called after the DMA operation is finished. */
1019 struct gpmi_nand_data *this = param; in dma_irq_callback() local
1020 struct completion *dma_c = &this->dma_done; in dma_irq_callback()
1027 struct gpmi_nand_data *this = cookie; in bch_irq() local
1029 gpmi_clear_bch(this); in bch_irq()
1030 complete(&this->bch_done); in bch_irq()
1034 static int gpmi_raw_len_to_len(struct gpmi_nand_data *this, int raw_len) in gpmi_raw_len_to_len() argument
1040 if (this->bch) in gpmi_raw_len_to_len()
1041 return ALIGN_DOWN(raw_len, this->bch_geometry.eccn_chunk_size); in gpmi_raw_len_to_len()
1047 static bool prepare_data_dma(struct gpmi_nand_data *this, const void *buf, in prepare_data_dma() argument
1052 int len = gpmi_raw_len_to_len(this, raw_len); in prepare_data_dma()
1057 ret = dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
1066 sg_init_one(sgl, this->data_buffer_dma, len); in prepare_data_dma()
1068 if (dr == DMA_TO_DEVICE && buf != this->data_buffer_dma) in prepare_data_dma()
1069 memcpy(this->data_buffer_dma, buf, len); in prepare_data_dma()
1071 dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
1093 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_ecc() local
1094 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_ecc()
1109 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_free() local
1110 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_free()
1198 static int acquire_register_block(struct gpmi_nand_data *this, in acquire_register_block() argument
1201 struct platform_device *pdev = this->pdev; in acquire_register_block()
1202 struct resources *res = &this->resources; in acquire_register_block()
1214 dev_err(this->dev, "unknown resource name : %s\n", res_name); in acquire_register_block()
1219 static int acquire_bch_irq(struct gpmi_nand_data *this, irq_handler_t irq_h) in acquire_bch_irq() argument
1221 struct platform_device *pdev = this->pdev; in acquire_bch_irq()
1229 err = devm_request_irq(this->dev, err, irq_h, 0, res_name, this); in acquire_bch_irq()
1231 dev_err(this->dev, "error requesting BCH IRQ\n"); in acquire_bch_irq()
1236 static void release_dma_channels(struct gpmi_nand_data *this) in release_dma_channels() argument
1240 if (this->dma_chans[i]) { in release_dma_channels()
1241 dma_release_channel(this->dma_chans[i]); in release_dma_channels()
1242 this->dma_chans[i] = NULL; in release_dma_channels()
1246 static int acquire_dma_channels(struct gpmi_nand_data *this) in acquire_dma_channels() argument
1248 struct platform_device *pdev = this->pdev; in acquire_dma_channels()
1255 ret = dev_err_probe(this->dev, PTR_ERR(dma_chan), in acquire_dma_channels()
1257 release_dma_channels(this); in acquire_dma_channels()
1259 this->dma_chans[0] = dma_chan; in acquire_dma_channels()
1265 static int gpmi_get_clks(struct gpmi_nand_data *this) in gpmi_get_clks() argument
1267 struct resources *r = &this->resources; in gpmi_get_clks()
1271 for (i = 0; i < this->devdata->clks_count; i++) { in gpmi_get_clks()
1272 clk = devm_clk_get(this->dev, this->devdata->clks[i]); in gpmi_get_clks()
1284 dev_dbg(this->dev, "failed in finding the clocks.\n"); in gpmi_get_clks()
1288 static int acquire_resources(struct gpmi_nand_data *this) in acquire_resources() argument
1292 ret = acquire_register_block(this, GPMI_NAND_GPMI_REGS_ADDR_RES_NAME); in acquire_resources()
1296 ret = acquire_register_block(this, GPMI_NAND_BCH_REGS_ADDR_RES_NAME); in acquire_resources()
1300 ret = acquire_bch_irq(this, bch_irq); in acquire_resources()
1304 ret = acquire_dma_channels(this); in acquire_resources()
1308 ret = gpmi_get_clks(this); in acquire_resources()
1314 release_dma_channels(this); in acquire_resources()
1319 static void release_resources(struct gpmi_nand_data *this) in release_resources() argument
1321 release_dma_channels(this); in release_resources()
1324 static void gpmi_free_dma_buffer(struct gpmi_nand_data *this) in gpmi_free_dma_buffer() argument
1326 struct device *dev = this->dev; in gpmi_free_dma_buffer()
1327 struct bch_geometry *geo = &this->bch_geometry; in gpmi_free_dma_buffer()
1329 if (this->auxiliary_virt && virt_addr_valid(this->auxiliary_virt)) in gpmi_free_dma_buffer()
1331 this->auxiliary_virt, in gpmi_free_dma_buffer()
1332 this->auxiliary_phys); in gpmi_free_dma_buffer()
1333 kfree(this->data_buffer_dma); in gpmi_free_dma_buffer()
1334 kfree(this->raw_buffer); in gpmi_free_dma_buffer()
1336 this->data_buffer_dma = NULL; in gpmi_free_dma_buffer()
1337 this->raw_buffer = NULL; in gpmi_free_dma_buffer()
1341 static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this) in gpmi_alloc_dma_buffer() argument
1343 struct bch_geometry *geo = &this->bch_geometry; in gpmi_alloc_dma_buffer()
1344 struct device *dev = this->dev; in gpmi_alloc_dma_buffer()
1345 struct mtd_info *mtd = nand_to_mtd(&this->nand); in gpmi_alloc_dma_buffer()
1355 this->data_buffer_dma = kzalloc(mtd->writesize ?: PAGE_SIZE, in gpmi_alloc_dma_buffer()
1357 if (this->data_buffer_dma == NULL) in gpmi_alloc_dma_buffer()
1360 this->auxiliary_virt = dma_alloc_coherent(dev, geo->auxiliary_size, in gpmi_alloc_dma_buffer()
1361 &this->auxiliary_phys, GFP_DMA); in gpmi_alloc_dma_buffer()
1362 if (!this->auxiliary_virt) in gpmi_alloc_dma_buffer()
1365 this->raw_buffer = kzalloc((mtd->writesize ?: PAGE_SIZE) + mtd->oobsize, GFP_KERNEL); in gpmi_alloc_dma_buffer()
1366 if (!this->raw_buffer) in gpmi_alloc_dma_buffer()
1372 gpmi_free_dma_buffer(this); in gpmi_alloc_dma_buffer()
1381 static void block_mark_swapping(struct gpmi_nand_data *this, in block_mark_swapping() argument
1384 struct bch_geometry *nfc_geo = &this->bch_geometry; in block_mark_swapping()
1392 if (!this->swap_block_mark) in block_mark_swapping()
1427 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_count_bitflips() local
1428 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_count_bitflips()
1435 status = this->auxiliary_virt + ALIGN(meta, 4); in gpmi_count_bitflips()
1443 u8 *eccbuf = this->raw_buffer; in gpmi_count_bitflips()
1476 * nothing was written into this subpage the ECC is in gpmi_count_bitflips()
1478 * at this point that we are reading an erased page and in gpmi_count_bitflips()
1480 * ecc_strength bitflips. If this is a page with random in gpmi_count_bitflips()
1481 * data, we exceed this number of bitflips and have a in gpmi_count_bitflips()
1490 this->auxiliary_virt, in gpmi_count_bitflips()
1520 static void gpmi_bch_layout_std(struct gpmi_nand_data *this) in gpmi_bch_layout_std() argument
1522 struct bch_geometry *geo = &this->bch_geometry; in gpmi_bch_layout_std()
1528 this->bch_flashlayout0 = in gpmi_bch_layout_std()
1531 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_bch_layout_std()
1532 BF_BCH_FLASH0LAYOUT0_GF(gf_len, this) | in gpmi_bch_layout_std()
1533 BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block0_size, this); in gpmi_bch_layout_std()
1535 this->bch_flashlayout1 = in gpmi_bch_layout_std()
1537 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_bch_layout_std()
1538 BF_BCH_FLASH0LAYOUT1_GF(gf_len, this) | in gpmi_bch_layout_std()
1539 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(blockn_size, this); in gpmi_bch_layout_std()
1545 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page() local
1547 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_page()
1551 gpmi_bch_layout_std(this); in gpmi_ecc_read_page()
1552 this->bch = true; in gpmi_ecc_read_page()
1563 block_mark_swapping(this, buf, this->auxiliary_virt); in gpmi_ecc_read_page()
1577 chip->oob_poi[0] = ((uint8_t *)this->auxiliary_virt)[0]; in gpmi_ecc_read_page()
1587 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_subpage() local
1588 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_subpage()
1605 if (this->swap_block_mark) { in gpmi_ecc_read_subpage()
1608 * If this chunk is in the range of [first, last], in gpmi_ecc_read_subpage()
1615 dev_dbg(this->dev, in gpmi_ecc_read_subpage()
1653 this->bch_flashlayout0 = BF_BCH_FLASH0LAYOUT0_NBLOCKS( in gpmi_ecc_read_subpage()
1656 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_ecc_read_subpage()
1657 BF_BCH_FLASH0LAYOUT0_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1659 0 : geo->ecc0_chunk_size), this); in gpmi_ecc_read_subpage()
1661 this->bch_flashlayout1 = BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size) | in gpmi_ecc_read_subpage()
1662 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_ecc_read_subpage()
1663 BF_BCH_FLASH0LAYOUT1_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1664 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(geo->eccn_chunk_size, this); in gpmi_ecc_read_subpage()
1666 this->bch = true; in gpmi_ecc_read_subpage()
1672 dev_dbg(this->dev, "page:%d(%d:%d)%d, chunk:(%d:%d), BCH PG size:%d\n", in gpmi_ecc_read_subpage()
1684 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page() local
1685 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page()
1687 dev_dbg(this->dev, "ecc write page.\n"); in gpmi_ecc_write_page()
1689 gpmi_bch_layout_std(this); in gpmi_ecc_write_page()
1690 this->bch = true; in gpmi_ecc_write_page()
1692 memcpy(this->auxiliary_virt, chip->oob_poi, nfc_geo->auxiliary_size); in gpmi_ecc_write_page()
1694 if (this->swap_block_mark) { in gpmi_ecc_write_page()
1699 memcpy(this->data_buffer_dma, buf, mtd->writesize); in gpmi_ecc_write_page()
1700 buf = this->data_buffer_dma; in gpmi_ecc_write_page()
1701 block_mark_swapping(this, this->data_buffer_dma, in gpmi_ecc_write_page()
1702 this->auxiliary_virt); in gpmi_ecc_write_page()
1709 * There are several places in this driver where we have to handle the OOB and
1710 * block marks. This is the function where things are the most complicated, so
1711 * this is where we try to explain it all. All the other places refer back to
1728 * are OOB. This gives the caller a way to see the actual, physical bytes
1732 * What we do for this specific read operation depends on two questions:
1771 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_oob() local
1788 if (GPMI_IS_MX23(this)) { in gpmi_ecc_read_oob()
1816 * This function reads a NAND page without involving the ECC engine (no HW
1831 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page_raw() local
1832 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_read_page_raw()
1835 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_read_page_raw()
1852 * See the layout description for a detailed explanation on why this in gpmi_ecc_read_page_raw()
1855 if (this->swap_block_mark) in gpmi_ecc_read_page_raw()
1859 * Copy the metadata section into the oob buffer (this section is in gpmi_ecc_read_page_raw()
1901 * This function writes a NAND page without involving the ECC engine (no HW
1916 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page_raw() local
1917 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page_raw()
1920 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_write_page_raw()
1973 * See the layout description for a detailed explanation on why this in gpmi_ecc_write_page_raw()
1976 if (this->swap_block_mark) in gpmi_ecc_write_page_raw()
1996 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_block_markbad() local
2004 column = !GPMI_IS_MX23(this) ? mtd->writesize : 0; in gpmi_block_markbad()
2007 block_mark = this->data_buffer_dma; in gpmi_block_markbad()
2020 static int nand_boot_set_geometry(struct gpmi_nand_data *this) in nand_boot_set_geometry() argument
2022 struct boot_rom_geometry *geometry = &this->rom_geometry; in nand_boot_set_geometry()
2027 * In principle, we should be reading this from the OTP bits, since in nand_boot_set_geometry()
2037 * In principle, we should be reading this from the OTP bits, since in nand_boot_set_geometry()
2047 static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) in mx23_check_transcription_stamp() argument
2049 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_check_transcription_stamp()
2050 struct device *dev = this->dev; in mx23_check_transcription_stamp()
2051 struct nand_chip *chip = &this->nand; in mx23_check_transcription_stamp()
2102 static int mx23_write_transcription_stamp(struct gpmi_nand_data *this) in mx23_write_transcription_stamp() argument
2104 struct device *dev = this->dev; in mx23_write_transcription_stamp()
2105 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_write_transcription_stamp()
2106 struct nand_chip *chip = &this->nand; in mx23_write_transcription_stamp()
2138 /* Erase this block. */ in mx23_write_transcription_stamp()
2168 static int mx23_boot_init(struct gpmi_nand_data *this) in mx23_boot_init() argument
2170 struct device *dev = this->dev; in mx23_boot_init()
2171 struct nand_chip *chip = &this->nand; in mx23_boot_init()
2187 if (mx23_check_transcription_stamp(this)) in mx23_boot_init()
2205 * Compute the chip, page and byte addresses for this block's in mx23_boot_init()
2223 * again, but this time the result will be a mark in the in mx23_boot_init()
2237 mx23_write_transcription_stamp(this); in mx23_boot_init()
2241 static int nand_boot_init(struct gpmi_nand_data *this) in nand_boot_init() argument
2243 nand_boot_set_geometry(this); in nand_boot_init()
2245 /* This is ROM arch-specific initilization before the BBT scanning. */ in nand_boot_init()
2246 if (GPMI_IS_MX23(this)) in nand_boot_init()
2247 return mx23_boot_init(this); in nand_boot_init()
2251 static int gpmi_set_geometry(struct gpmi_nand_data *this) in gpmi_set_geometry() argument
2256 gpmi_free_dma_buffer(this); in gpmi_set_geometry()
2259 ret = bch_set_geometry(this); in gpmi_set_geometry()
2261 dev_err(this->dev, "Error setting BCH geometry : %d\n", ret); in gpmi_set_geometry()
2266 return gpmi_alloc_dma_buffer(this); in gpmi_set_geometry()
2269 static int gpmi_init_last(struct gpmi_nand_data *this) in gpmi_init_last() argument
2271 struct nand_chip *chip = &this->nand; in gpmi_init_last()
2274 struct bch_geometry *bch_geo = &this->bch_geometry; in gpmi_init_last()
2278 ret = gpmi_set_geometry(this); in gpmi_init_last()
2301 if (GPMI_IS_MX6(this) && in gpmi_init_last()
2312 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nand_attach_chip() local
2318 if (of_property_read_bool(this->dev->of_node, in gpmi_nand_attach_chip()
2320 this->swap_block_mark = false; in gpmi_nand_attach_chip()
2322 dev_dbg(this->dev, "Blockmark swapping %sabled\n", in gpmi_nand_attach_chip()
2323 this->swap_block_mark ? "en" : "dis"); in gpmi_nand_attach_chip()
2325 ret = gpmi_init_last(this); in gpmi_nand_attach_chip()
2334 static struct gpmi_transfer *get_next_transfer(struct gpmi_nand_data *this) in get_next_transfer() argument
2336 struct gpmi_transfer *transfer = &this->transfers[this->ntransfers]; in get_next_transfer()
2338 this->ntransfers++; in get_next_transfer()
2340 if (this->ntransfers == GPMI_MAX_TRANSFERS) in get_next_transfer()
2347 struct gpmi_nand_data *this, u8 cmd, const u8 *addr, int naddr) in gpmi_chain_command() argument
2349 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_command()
2352 int chip = this->nand.cur_cs; in gpmi_chain_command()
2358 | BF_GPMI_CTRL0_CS(chip, this) in gpmi_chain_command()
2359 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_command()
2370 transfer = get_next_transfer(this); in gpmi_chain_command()
2379 dma_map_sg(this->dev, &transfer->sgl, 1, DMA_TO_DEVICE); in gpmi_chain_command()
2389 struct gpmi_nand_data *this) in gpmi_chain_wait_ready() argument
2391 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_wait_ready()
2396 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_wait_ready()
2397 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_wait_ready()
2407 struct gpmi_nand_data *this, void *buf, int raw_len, bool *direct) in gpmi_chain_data_read() argument
2410 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_read()
2414 transfer = get_next_transfer(this); in gpmi_chain_data_read()
2420 *direct = prepare_data_dma(this, buf, raw_len, &transfer->sgl, in gpmi_chain_data_read()
2425 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_read()
2426 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_read()
2430 if (this->bch) { in gpmi_chain_data_read()
2437 pio[5] = this->auxiliary_phys; in gpmi_chain_data_read()
2445 if (!this->bch) in gpmi_chain_data_read()
2454 struct gpmi_nand_data *this, const void *buf, int raw_len) in gpmi_chain_data_write() argument
2456 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_write()
2461 transfer = get_next_transfer(this); in gpmi_chain_data_write()
2467 prepare_data_dma(this, buf, raw_len, &transfer->sgl, DMA_TO_DEVICE); in gpmi_chain_data_write()
2471 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_write()
2472 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_write()
2476 if (this->bch) { in gpmi_chain_data_write()
2483 pio[5] = this->auxiliary_phys; in gpmi_chain_data_write()
2488 (this->bch ? MXS_DMA_CTRL_WAIT4END : 0)); in gpmi_chain_data_write()
2492 if (!this->bch) in gpmi_chain_data_write()
2505 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nfc_exec_op() local
2518 this->ntransfers = 0; in gpmi_nfc_exec_op()
2520 this->transfers[i].direction = DMA_NONE; in gpmi_nfc_exec_op()
2522 ret = pm_runtime_resume_and_get(this->dev); in gpmi_nfc_exec_op()
2527 * This driver currently supports only one NAND chip. Plus, dies share in gpmi_nfc_exec_op()
2532 if (this->hw.must_apply_timings) { in gpmi_nfc_exec_op()
2533 this->hw.must_apply_timings = false; in gpmi_nfc_exec_op()
2534 ret = gpmi_nfc_apply_timings(this); in gpmi_nfc_exec_op()
2539 dev_dbg(this->dev, "%s: %d instructions\n", __func__, op->ninstrs); in gpmi_nfc_exec_op()
2548 desc = gpmi_chain_wait_ready(this); in gpmi_nfc_exec_op()
2554 * When this command has an address cycle chain it in gpmi_nfc_exec_op()
2561 desc = gpmi_chain_command(this, cmd, NULL, 0); in gpmi_nfc_exec_op()
2565 desc = gpmi_chain_command(this, cmd, instr->ctx.addr.addrs, in gpmi_nfc_exec_op()
2573 desc = gpmi_chain_data_write(this, buf_write, buf_len); in gpmi_nfc_exec_op()
2583 desc = gpmi_chain_data_read(this, buf_read, buf_len, in gpmi_nfc_exec_op()
2594 dev_dbg(this->dev, "%s setup done\n", __func__); in gpmi_nfc_exec_op()
2597 dev_err(this->dev, "Multiple data instructions not supported\n"); in gpmi_nfc_exec_op()
2602 if (this->bch) { in gpmi_nfc_exec_op()
2603 writel(this->bch_flashlayout0, in gpmi_nfc_exec_op()
2604 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT0); in gpmi_nfc_exec_op()
2605 writel(this->bch_flashlayout1, in gpmi_nfc_exec_op()
2606 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT1); in gpmi_nfc_exec_op()
2610 desc->callback_param = this; in gpmi_nfc_exec_op()
2611 dma_completion = &this->dma_done; in gpmi_nfc_exec_op()
2616 if (this->bch && buf_read) { in gpmi_nfc_exec_op()
2618 this->resources.bch_regs + HW_BCH_CTRL_SET); in gpmi_nfc_exec_op()
2619 bch_completion = &this->bch_done; in gpmi_nfc_exec_op()
2624 dma_async_issue_pending(get_dma_chan(this)); in gpmi_nfc_exec_op()
2628 dev_err(this->dev, "DMA timeout, last DMA\n"); in gpmi_nfc_exec_op()
2629 gpmi_dump_info(this); in gpmi_nfc_exec_op()
2634 if (this->bch && buf_read) { in gpmi_nfc_exec_op()
2637 dev_err(this->dev, "BCH timeout, last DMA\n"); in gpmi_nfc_exec_op()
2638 gpmi_dump_info(this); in gpmi_nfc_exec_op()
2645 this->resources.bch_regs + HW_BCH_CTRL_CLR); in gpmi_nfc_exec_op()
2646 gpmi_clear_bch(this); in gpmi_nfc_exec_op()
2651 for (i = 0; i < this->ntransfers; i++) { in gpmi_nfc_exec_op()
2652 struct gpmi_transfer *transfer = &this->transfers[i]; in gpmi_nfc_exec_op()
2655 dma_unmap_sg(this->dev, &transfer->sgl, 1, in gpmi_nfc_exec_op()
2660 memcpy(buf_read, this->data_buffer_dma, in gpmi_nfc_exec_op()
2661 gpmi_raw_len_to_len(this, buf_len)); in gpmi_nfc_exec_op()
2663 this->bch = false; in gpmi_nfc_exec_op()
2666 pm_runtime_mark_last_busy(this->dev); in gpmi_nfc_exec_op()
2667 pm_runtime_put_autosuspend(this->dev); in gpmi_nfc_exec_op()
2678 static int gpmi_nand_init(struct gpmi_nand_data *this) in gpmi_nand_init() argument
2680 struct nand_chip *chip = &this->nand; in gpmi_nand_init()
2686 mtd->dev.parent = this->dev; in gpmi_nand_init()
2689 nand_set_controller_data(chip, this); in gpmi_nand_init()
2690 nand_set_flash_node(chip, this->pdev->dev.of_node); in gpmi_nand_init()
2696 this->swap_block_mark = !GPMI_IS_MX23(this); in gpmi_nand_init()
2702 this->bch_geometry.payload_size = 1024; in gpmi_nand_init()
2703 this->bch_geometry.auxiliary_size = 128; in gpmi_nand_init()
2704 ret = gpmi_alloc_dma_buffer(this); in gpmi_nand_init()
2708 nand_controller_init(&this->base); in gpmi_nand_init()
2709 this->base.ops = &gpmi_nand_controller_ops; in gpmi_nand_init()
2710 chip->controller = &this->base; in gpmi_nand_init()
2712 ret = nand_scan(chip, GPMI_IS_MX6(this) ? 2 : 1); in gpmi_nand_init()
2716 ret = nand_boot_init(this); in gpmi_nand_init()
2731 gpmi_free_dma_buffer(this); in gpmi_nand_init()
2748 struct gpmi_nand_data *this; in gpmi_nand_probe() local
2751 this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL); in gpmi_nand_probe()
2752 if (!this) in gpmi_nand_probe()
2755 this->devdata = of_device_get_match_data(&pdev->dev); in gpmi_nand_probe()
2756 platform_set_drvdata(pdev, this); in gpmi_nand_probe()
2757 this->pdev = pdev; in gpmi_nand_probe()
2758 this->dev = &pdev->dev; in gpmi_nand_probe()
2760 ret = acquire_resources(this); in gpmi_nand_probe()
2768 ret = gpmi_init(this); in gpmi_nand_probe()
2772 ret = gpmi_nand_init(this); in gpmi_nand_probe()
2776 dev_info(this->dev, "driver registered.\n"); in gpmi_nand_probe()
2783 release_resources(this); in gpmi_nand_probe()
2791 struct gpmi_nand_data *this = platform_get_drvdata(pdev); in gpmi_nand_remove() local
2792 struct nand_chip *chip = &this->nand; in gpmi_nand_remove()
2798 gpmi_free_dma_buffer(this); in gpmi_nand_remove()
2799 release_resources(this); in gpmi_nand_remove()
2816 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_pm_resume() local
2821 dev_err(this->dev, "Error in resume %d\n", ret); in gpmi_pm_resume()
2828 ret = gpmi_init(this); in gpmi_pm_resume()
2830 dev_err(this->dev, "Error setting GPMI : %d\n", ret); in gpmi_pm_resume()
2835 if (this->hw.clk_rate) in gpmi_pm_resume()
2836 this->hw.must_apply_timings = true; in gpmi_pm_resume()
2839 ret = bch_set_geometry(this); in gpmi_pm_resume()
2841 dev_err(this->dev, "Error setting BCH : %d\n", ret); in gpmi_pm_resume()
2853 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_suspend() local
2855 gpmi_disable_clk(this); in gpmi_runtime_suspend()
2862 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_resume() local
2865 ret = gpmi_enable_clk(this); in gpmi_runtime_resume()