Lines Matching full:this

36  * Clear the bit and poll it cleared.  This is usually called with
70 * the next hard reset. This case occurs in the NAND boot mode. When the board
73 * You will see a DMA timeout in this case. The bug has been fixed
76 * To avoid this bug, just add a new parameter `just_enable` for
121 static int __gpmi_enable_clk(struct gpmi_nand_data *this, bool v) in __gpmi_enable_clk() argument
128 clk = this->resources.clock[i]; in __gpmi_enable_clk()
144 clk_disable_unprepare(this->resources.clock[i - 1]); in __gpmi_enable_clk()
148 static int gpmi_init(struct gpmi_nand_data *this) in gpmi_init() argument
150 struct resources *r = &this->resources; in gpmi_init()
153 ret = pm_runtime_resume_and_get(this->dev); in gpmi_init()
165 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in gpmi_init()
191 pm_runtime_mark_last_busy(this->dev); in gpmi_init()
192 pm_runtime_put_autosuspend(this->dev); in gpmi_init()
196 /* This function is very useful. It is called only when the bug occur. */
197 static void gpmi_dump_info(struct gpmi_nand_data *this) in gpmi_dump_info() argument
199 struct resources *r = &this->resources; in gpmi_dump_info()
200 struct bch_geometry *geo = &this->bch_geometry; in gpmi_dump_info()
204 dev_err(this->dev, "Show GPMI registers :\n"); in gpmi_dump_info()
207 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
211 dev_err(this->dev, "Show BCH registers :\n"); in gpmi_dump_info()
214 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
216 dev_err(this->dev, "BCH Geometry :\n" in gpmi_dump_info()
243 static bool gpmi_check_ecc(struct gpmi_nand_data *this) in gpmi_check_ecc() argument
245 struct nand_chip *chip = &this->nand; in gpmi_check_ecc()
246 struct bch_geometry *geo = &this->bch_geometry; in gpmi_check_ecc()
254 if (GPMI_IS_MXS(this)) { in gpmi_check_ecc()
260 if (geo->ecc_strength > this->devdata->bch_max_ecc_strength) in gpmi_check_ecc()
270 static bool bbm_in_data_chunk(struct gpmi_nand_data *this, in bbm_in_data_chunk() argument
273 struct bch_geometry *geo = &this->bch_geometry; in bbm_in_data_chunk()
274 struct nand_chip *chip = &this->nand; in bbm_in_data_chunk()
279 dev_err(this->dev, in bbm_in_data_chunk()
294 dev_dbg(this->dev, "Set ecc to %d and bbm in chunk %d\n", in bbm_in_data_chunk()
306 * We may have available oob space in this case.
308 static int set_geometry_by_ecc_info(struct gpmi_nand_data *this, in set_geometry_by_ecc_info() argument
312 struct bch_geometry *geo = &this->bch_geometry; in set_geometry_by_ecc_info()
313 struct nand_chip *chip = &this->nand; in set_geometry_by_ecc_info()
325 dev_err(this->dev, in set_geometry_by_ecc_info()
334 if (!gpmi_check_ecc(this)) in set_geometry_by_ecc_info()
339 dev_err(this->dev, in set_geometry_by_ecc_info()
407 if (!this->swap_block_mark) in set_geometry_by_ecc_info()
438 static inline int get_ecc_strength(struct gpmi_nand_data *this) in get_ecc_strength() argument
440 struct bch_geometry *geo = &this->bch_geometry; in get_ecc_strength()
441 struct mtd_info *mtd = nand_to_mtd(&this->nand); in get_ecc_strength()
451 static int set_geometry_for_large_oob(struct gpmi_nand_data *this) in set_geometry_for_large_oob() argument
453 struct bch_geometry *geo = &this->bch_geometry; in set_geometry_for_large_oob()
454 struct nand_chip *chip = &this->nand; in set_geometry_for_large_oob()
469 /* check if platform can support this nand */ in set_geometry_for_large_oob()
470 if (!gpmi_check_ecc(this)) { in set_geometry_for_large_oob()
471 dev_err(this->dev, in set_geometry_for_large_oob()
483 max_ecc = min(get_ecc_strength(this), in set_geometry_for_large_oob()
484 this->devdata->bch_max_ecc_strength); in set_geometry_for_large_oob()
492 if (bbm_in_data_chunk(this, &bbm_chunk)) in set_geometry_for_large_oob()
504 /* check if oob can afford this extra ecc chunk */ in set_geometry_for_large_oob()
507 dev_err(this->dev, "unsupported NAND chip with new layout\n"); in set_geometry_for_large_oob()
533 if (!this->swap_block_mark) in set_geometry_for_large_oob()
546 dev_dbg(this->dev, "BCH Geometry :\n" in set_geometry_for_large_oob()
579 static int legacy_set_geometry(struct gpmi_nand_data *this) in legacy_set_geometry() argument
581 struct bch_geometry *geo = &this->bch_geometry; in legacy_set_geometry()
582 struct mtd_info *mtd = nand_to_mtd(&this->nand); in legacy_set_geometry()
609 geo->ecc_strength = get_ecc_strength(this); in legacy_set_geometry()
610 if (!gpmi_check_ecc(this)) { in legacy_set_geometry()
611 dev_err(this->dev, in legacy_set_geometry()
615 this->devdata->bch_max_ecc_strength); in legacy_set_geometry()
635 if (!this->swap_block_mark) in legacy_set_geometry()
693 static int common_nfc_set_geometry(struct gpmi_nand_data *this) in common_nfc_set_geometry() argument
695 struct nand_chip *chip = &this->nand; in common_nfc_set_geometry()
696 struct mtd_info *mtd = nand_to_mtd(&this->nand); in common_nfc_set_geometry()
702 use_minimun_ecc = of_property_read_bool(this->dev->of_node, in common_nfc_set_geometry()
708 dev_dbg(this->dev, "use legacy bch geometry\n"); in common_nfc_set_geometry()
709 err = legacy_set_geometry(this); in common_nfc_set_geometry()
716 dev_dbg(this->dev, "use large oob bch geometry\n"); in common_nfc_set_geometry()
717 err = set_geometry_for_large_oob(this); in common_nfc_set_geometry()
723 dev_dbg(this->dev, "use minimum ecc bch geometry\n"); in common_nfc_set_geometry()
724 err = set_geometry_by_ecc_info(this, requirements->strength, in common_nfc_set_geometry()
727 dev_err(this->dev, "none of the bch geometry setting works\n"); in common_nfc_set_geometry()
733 static int bch_set_geometry(struct gpmi_nand_data *this) in bch_set_geometry() argument
735 struct resources *r = &this->resources; in bch_set_geometry()
738 ret = common_nfc_set_geometry(this); in bch_set_geometry()
742 ret = pm_runtime_resume_and_get(this->dev); in bch_set_geometry()
748 * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this in bch_set_geometry()
752 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in bch_set_geometry()
761 pm_runtime_mark_last_busy(this->dev); in bch_set_geometry()
762 pm_runtime_put_autosuspend(this->dev); in bch_set_geometry()
841 static int gpmi_nfc_compute_timings(struct gpmi_nand_data *this, in gpmi_nfc_compute_timings() argument
844 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_compute_timings()
845 struct resources *r = &this->resources; in gpmi_nfc_compute_timings()
846 unsigned int dll_threshold_ps = this->devdata->max_chain_delay; in gpmi_nfc_compute_timings()
876 dev_err(this->dev, "clock setting: expected %ld, got %ld\n", in gpmi_nfc_compute_timings()
926 static int gpmi_nfc_apply_timings(struct gpmi_nand_data *this) in gpmi_nfc_apply_timings() argument
928 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_apply_timings()
929 struct resources *r = &this->resources; in gpmi_nfc_apply_timings()
938 if (GPMI_IS_MX6Q(this) || GPMI_IS_MX6SX(this)) in gpmi_nfc_apply_timings()
943 dev_err(this->dev, "cannot set clock rate to %lu Hz: %d\n", hw->clk_rate, ret); in gpmi_nfc_apply_timings()
947 if (GPMI_IS_MX6Q(this) || GPMI_IS_MX6SX(this)) { in gpmi_nfc_apply_timings()
977 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_setup_interface() local
987 if (sdr->tRC_min <= 25000 && !this->devdata->support_edo_timing) in gpmi_setup_interface()
990 /* Stop here if this call was just a check */ in gpmi_setup_interface()
995 ret = gpmi_nfc_compute_timings(this, sdr); in gpmi_setup_interface()
999 this->hw.must_apply_timings = true; in gpmi_setup_interface()
1005 static void gpmi_clear_bch(struct gpmi_nand_data *this) in gpmi_clear_bch() argument
1007 struct resources *r = &this->resources; in gpmi_clear_bch()
1011 static struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) in get_dma_chan() argument
1014 return this->dma_chans[0]; in get_dma_chan()
1017 /* This will be called after the DMA operation is finished. */
1020 struct gpmi_nand_data *this = param; in dma_irq_callback() local
1021 struct completion *dma_c = &this->dma_done; in dma_irq_callback()
1028 struct gpmi_nand_data *this = cookie; in bch_irq() local
1030 gpmi_clear_bch(this); in bch_irq()
1031 complete(&this->bch_done); in bch_irq()
1035 static int gpmi_raw_len_to_len(struct gpmi_nand_data *this, int raw_len) in gpmi_raw_len_to_len() argument
1041 if (this->bch) in gpmi_raw_len_to_len()
1042 return ALIGN_DOWN(raw_len, this->bch_geometry.eccn_chunk_size); in gpmi_raw_len_to_len()
1048 static bool prepare_data_dma(struct gpmi_nand_data *this, const void *buf, in prepare_data_dma() argument
1053 int len = gpmi_raw_len_to_len(this, raw_len); in prepare_data_dma()
1058 ret = dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
1067 sg_init_one(sgl, this->data_buffer_dma, len); in prepare_data_dma()
1069 if (dr == DMA_TO_DEVICE && buf != this->data_buffer_dma) in prepare_data_dma()
1070 memcpy(this->data_buffer_dma, buf, len); in prepare_data_dma()
1072 dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
1094 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_ecc() local
1095 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_ecc()
1110 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_free() local
1111 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_free()
1199 static int acquire_register_block(struct gpmi_nand_data *this, in acquire_register_block() argument
1202 struct platform_device *pdev = this->pdev; in acquire_register_block()
1203 struct resources *res = &this->resources; in acquire_register_block()
1215 dev_err(this->dev, "unknown resource name : %s\n", res_name); in acquire_register_block()
1220 static int acquire_bch_irq(struct gpmi_nand_data *this, irq_handler_t irq_h) in acquire_bch_irq() argument
1222 struct platform_device *pdev = this->pdev; in acquire_bch_irq()
1230 err = devm_request_irq(this->dev, err, irq_h, 0, res_name, this); in acquire_bch_irq()
1232 dev_err(this->dev, "error requesting BCH IRQ\n"); in acquire_bch_irq()
1237 static void release_dma_channels(struct gpmi_nand_data *this) in release_dma_channels() argument
1241 if (this->dma_chans[i]) { in release_dma_channels()
1242 dma_release_channel(this->dma_chans[i]); in release_dma_channels()
1243 this->dma_chans[i] = NULL; in release_dma_channels()
1247 static int acquire_dma_channels(struct gpmi_nand_data *this) in acquire_dma_channels() argument
1249 struct platform_device *pdev = this->pdev; in acquire_dma_channels()
1256 ret = dev_err_probe(this->dev, PTR_ERR(dma_chan), in acquire_dma_channels()
1258 release_dma_channels(this); in acquire_dma_channels()
1260 this->dma_chans[0] = dma_chan; in acquire_dma_channels()
1266 static int gpmi_get_clks(struct gpmi_nand_data *this) in gpmi_get_clks() argument
1268 struct resources *r = &this->resources; in gpmi_get_clks()
1272 for (i = 0; i < this->devdata->clks_count; i++) { in gpmi_get_clks()
1273 clk = devm_clk_get(this->dev, this->devdata->clks[i]); in gpmi_get_clks()
1285 dev_dbg(this->dev, "failed in finding the clocks.\n"); in gpmi_get_clks()
1289 static int acquire_resources(struct gpmi_nand_data *this) in acquire_resources() argument
1293 ret = acquire_register_block(this, GPMI_NAND_GPMI_REGS_ADDR_RES_NAME); in acquire_resources()
1297 ret = acquire_register_block(this, GPMI_NAND_BCH_REGS_ADDR_RES_NAME); in acquire_resources()
1301 ret = acquire_bch_irq(this, bch_irq); in acquire_resources()
1305 ret = acquire_dma_channels(this); in acquire_resources()
1309 ret = gpmi_get_clks(this); in acquire_resources()
1315 release_dma_channels(this); in acquire_resources()
1320 static void release_resources(struct gpmi_nand_data *this) in release_resources() argument
1322 release_dma_channels(this); in release_resources()
1325 static void gpmi_free_dma_buffer(struct gpmi_nand_data *this) in gpmi_free_dma_buffer() argument
1327 struct device *dev = this->dev; in gpmi_free_dma_buffer()
1328 struct bch_geometry *geo = &this->bch_geometry; in gpmi_free_dma_buffer()
1330 if (this->auxiliary_virt && virt_addr_valid(this->auxiliary_virt)) in gpmi_free_dma_buffer()
1332 this->auxiliary_virt, in gpmi_free_dma_buffer()
1333 this->auxiliary_phys); in gpmi_free_dma_buffer()
1334 kfree(this->data_buffer_dma); in gpmi_free_dma_buffer()
1335 kfree(this->raw_buffer); in gpmi_free_dma_buffer()
1337 this->data_buffer_dma = NULL; in gpmi_free_dma_buffer()
1338 this->raw_buffer = NULL; in gpmi_free_dma_buffer()
1342 static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this) in gpmi_alloc_dma_buffer() argument
1344 struct bch_geometry *geo = &this->bch_geometry; in gpmi_alloc_dma_buffer()
1345 struct device *dev = this->dev; in gpmi_alloc_dma_buffer()
1346 struct mtd_info *mtd = nand_to_mtd(&this->nand); in gpmi_alloc_dma_buffer()
1356 this->data_buffer_dma = kzalloc(mtd->writesize ?: PAGE_SIZE, in gpmi_alloc_dma_buffer()
1358 if (this->data_buffer_dma == NULL) in gpmi_alloc_dma_buffer()
1361 this->auxiliary_virt = dma_alloc_coherent(dev, geo->auxiliary_size, in gpmi_alloc_dma_buffer()
1362 &this->auxiliary_phys, GFP_DMA); in gpmi_alloc_dma_buffer()
1363 if (!this->auxiliary_virt) in gpmi_alloc_dma_buffer()
1366 this->raw_buffer = kzalloc((mtd->writesize ?: PAGE_SIZE) + mtd->oobsize, GFP_KERNEL); in gpmi_alloc_dma_buffer()
1367 if (!this->raw_buffer) in gpmi_alloc_dma_buffer()
1373 gpmi_free_dma_buffer(this); in gpmi_alloc_dma_buffer()
1382 static void block_mark_swapping(struct gpmi_nand_data *this, in block_mark_swapping() argument
1385 struct bch_geometry *nfc_geo = &this->bch_geometry; in block_mark_swapping()
1393 if (!this->swap_block_mark) in block_mark_swapping()
1428 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_count_bitflips() local
1429 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_count_bitflips()
1436 status = this->auxiliary_virt + ALIGN(meta, 4); in gpmi_count_bitflips()
1444 u8 *eccbuf = this->raw_buffer; in gpmi_count_bitflips()
1477 * nothing was written into this subpage the ECC is in gpmi_count_bitflips()
1479 * at this point that we are reading an erased page and in gpmi_count_bitflips()
1481 * ecc_strength bitflips. If this is a page with random in gpmi_count_bitflips()
1482 * data, we exceed this number of bitflips and have a in gpmi_count_bitflips()
1491 this->auxiliary_virt, in gpmi_count_bitflips()
1521 static void gpmi_bch_layout_std(struct gpmi_nand_data *this) in gpmi_bch_layout_std() argument
1523 struct bch_geometry *geo = &this->bch_geometry; in gpmi_bch_layout_std()
1529 this->bch_flashlayout0 = in gpmi_bch_layout_std()
1532 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_bch_layout_std()
1533 BF_BCH_FLASH0LAYOUT0_GF(gf_len, this) | in gpmi_bch_layout_std()
1534 BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block0_size, this); in gpmi_bch_layout_std()
1536 this->bch_flashlayout1 = in gpmi_bch_layout_std()
1538 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_bch_layout_std()
1539 BF_BCH_FLASH0LAYOUT1_GF(gf_len, this) | in gpmi_bch_layout_std()
1540 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(blockn_size, this); in gpmi_bch_layout_std()
1546 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page() local
1548 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_page()
1552 gpmi_bch_layout_std(this); in gpmi_ecc_read_page()
1553 this->bch = true; in gpmi_ecc_read_page()
1564 block_mark_swapping(this, buf, this->auxiliary_virt); in gpmi_ecc_read_page()
1578 chip->oob_poi[0] = ((uint8_t *)this->auxiliary_virt)[0]; in gpmi_ecc_read_page()
1588 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_subpage() local
1589 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_subpage()
1606 if (this->swap_block_mark) { in gpmi_ecc_read_subpage()
1609 * If this chunk is in the range of [first, last], in gpmi_ecc_read_subpage()
1616 dev_dbg(this->dev, in gpmi_ecc_read_subpage()
1654 this->bch_flashlayout0 = BF_BCH_FLASH0LAYOUT0_NBLOCKS( in gpmi_ecc_read_subpage()
1657 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_ecc_read_subpage()
1658 BF_BCH_FLASH0LAYOUT0_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1660 0 : geo->ecc0_chunk_size), this); in gpmi_ecc_read_subpage()
1662 this->bch_flashlayout1 = BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size) | in gpmi_ecc_read_subpage()
1663 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_ecc_read_subpage()
1664 BF_BCH_FLASH0LAYOUT1_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1665 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(geo->eccn_chunk_size, this); in gpmi_ecc_read_subpage()
1667 this->bch = true; in gpmi_ecc_read_subpage()
1673 dev_dbg(this->dev, "page:%d(%d:%d)%d, chunk:(%d:%d), BCH PG size:%d\n", in gpmi_ecc_read_subpage()
1685 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page() local
1686 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page()
1688 dev_dbg(this->dev, "ecc write page.\n"); in gpmi_ecc_write_page()
1690 gpmi_bch_layout_std(this); in gpmi_ecc_write_page()
1691 this->bch = true; in gpmi_ecc_write_page()
1693 memcpy(this->auxiliary_virt, chip->oob_poi, nfc_geo->auxiliary_size); in gpmi_ecc_write_page()
1695 if (this->swap_block_mark) { in gpmi_ecc_write_page()
1700 memcpy(this->data_buffer_dma, buf, mtd->writesize); in gpmi_ecc_write_page()
1701 buf = this->data_buffer_dma; in gpmi_ecc_write_page()
1702 block_mark_swapping(this, this->data_buffer_dma, in gpmi_ecc_write_page()
1703 this->auxiliary_virt); in gpmi_ecc_write_page()
1710 * There are several places in this driver where we have to handle the OOB and
1711 * block marks. This is the function where things are the most complicated, so
1712 * this is where we try to explain it all. All the other places refer back to
1729 * are OOB. This gives the caller a way to see the actual, physical bytes
1733 * What we do for this specific read operation depends on two questions:
1772 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_oob() local
1789 if (GPMI_IS_MX23(this)) { in gpmi_ecc_read_oob()
1817 * This function reads a NAND page without involving the ECC engine (no HW
1832 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page_raw() local
1833 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_read_page_raw()
1836 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_read_page_raw()
1853 * See the layout description for a detailed explanation on why this in gpmi_ecc_read_page_raw()
1856 if (this->swap_block_mark) in gpmi_ecc_read_page_raw()
1860 * Copy the metadata section into the oob buffer (this section is in gpmi_ecc_read_page_raw()
1902 * This function writes a NAND page without involving the ECC engine (no HW
1917 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page_raw() local
1918 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page_raw()
1921 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_write_page_raw()
1974 * See the layout description for a detailed explanation on why this in gpmi_ecc_write_page_raw()
1977 if (this->swap_block_mark) in gpmi_ecc_write_page_raw()
1997 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_block_markbad() local
2005 column = !GPMI_IS_MX23(this) ? mtd->writesize : 0; in gpmi_block_markbad()
2008 block_mark = this->data_buffer_dma; in gpmi_block_markbad()
2021 static int nand_boot_set_geometry(struct gpmi_nand_data *this) in nand_boot_set_geometry() argument
2023 struct boot_rom_geometry *geometry = &this->rom_geometry; in nand_boot_set_geometry()
2028 * In principle, we should be reading this from the OTP bits, since in nand_boot_set_geometry()
2038 * In principle, we should be reading this from the OTP bits, since in nand_boot_set_geometry()
2048 static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) in mx23_check_transcription_stamp() argument
2050 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_check_transcription_stamp()
2051 struct device *dev = this->dev; in mx23_check_transcription_stamp()
2052 struct nand_chip *chip = &this->nand; in mx23_check_transcription_stamp()
2103 static int mx23_write_transcription_stamp(struct gpmi_nand_data *this) in mx23_write_transcription_stamp() argument
2105 struct device *dev = this->dev; in mx23_write_transcription_stamp()
2106 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_write_transcription_stamp()
2107 struct nand_chip *chip = &this->nand; in mx23_write_transcription_stamp()
2139 /* Erase this block. */ in mx23_write_transcription_stamp()
2169 static int mx23_boot_init(struct gpmi_nand_data *this) in mx23_boot_init() argument
2171 struct device *dev = this->dev; in mx23_boot_init()
2172 struct nand_chip *chip = &this->nand; in mx23_boot_init()
2188 if (mx23_check_transcription_stamp(this)) in mx23_boot_init()
2206 * Compute the chip, page and byte addresses for this block's in mx23_boot_init()
2224 * again, but this time the result will be a mark in the in mx23_boot_init()
2238 mx23_write_transcription_stamp(this); in mx23_boot_init()
2242 static int nand_boot_init(struct gpmi_nand_data *this) in nand_boot_init() argument
2244 nand_boot_set_geometry(this); in nand_boot_init()
2246 /* This is ROM arch-specific initilization before the BBT scanning. */ in nand_boot_init()
2247 if (GPMI_IS_MX23(this)) in nand_boot_init()
2248 return mx23_boot_init(this); in nand_boot_init()
2252 static int gpmi_set_geometry(struct gpmi_nand_data *this) in gpmi_set_geometry() argument
2257 gpmi_free_dma_buffer(this); in gpmi_set_geometry()
2260 ret = bch_set_geometry(this); in gpmi_set_geometry()
2262 dev_err(this->dev, "Error setting BCH geometry : %d\n", ret); in gpmi_set_geometry()
2267 return gpmi_alloc_dma_buffer(this); in gpmi_set_geometry()
2270 static int gpmi_init_last(struct gpmi_nand_data *this) in gpmi_init_last() argument
2272 struct nand_chip *chip = &this->nand; in gpmi_init_last()
2275 struct bch_geometry *bch_geo = &this->bch_geometry; in gpmi_init_last()
2279 ret = gpmi_set_geometry(this); in gpmi_init_last()
2302 if (GPMI_IS_MX6(this) && in gpmi_init_last()
2313 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nand_attach_chip() local
2319 if (of_property_read_bool(this->dev->of_node, in gpmi_nand_attach_chip()
2321 this->swap_block_mark = false; in gpmi_nand_attach_chip()
2323 dev_dbg(this->dev, "Blockmark swapping %s\n", in gpmi_nand_attach_chip()
2324 str_enabled_disabled(this->swap_block_mark)); in gpmi_nand_attach_chip()
2326 ret = gpmi_init_last(this); in gpmi_nand_attach_chip()
2335 static struct gpmi_transfer *get_next_transfer(struct gpmi_nand_data *this) in get_next_transfer() argument
2337 struct gpmi_transfer *transfer = &this->transfers[this->ntransfers]; in get_next_transfer()
2339 this->ntransfers++; in get_next_transfer()
2341 if (this->ntransfers == GPMI_MAX_TRANSFERS) in get_next_transfer()
2348 struct gpmi_nand_data *this, u8 cmd, const u8 *addr, int naddr) in gpmi_chain_command() argument
2350 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_command()
2353 int chip = this->nand.cur_cs; in gpmi_chain_command()
2359 | BF_GPMI_CTRL0_CS(chip, this) in gpmi_chain_command()
2360 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_command()
2371 transfer = get_next_transfer(this); in gpmi_chain_command()
2380 dma_map_sg(this->dev, &transfer->sgl, 1, DMA_TO_DEVICE); in gpmi_chain_command()
2390 struct gpmi_nand_data *this) in gpmi_chain_wait_ready() argument
2392 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_wait_ready()
2397 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_wait_ready()
2398 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_wait_ready()
2408 struct gpmi_nand_data *this, void *buf, int raw_len, bool *direct) in gpmi_chain_data_read() argument
2411 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_read()
2415 transfer = get_next_transfer(this); in gpmi_chain_data_read()
2421 *direct = prepare_data_dma(this, buf, raw_len, &transfer->sgl, in gpmi_chain_data_read()
2426 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_read()
2427 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_read()
2431 if (this->bch) { in gpmi_chain_data_read()
2438 pio[5] = this->auxiliary_phys; in gpmi_chain_data_read()
2446 if (!this->bch) in gpmi_chain_data_read()
2455 struct gpmi_nand_data *this, const void *buf, int raw_len) in gpmi_chain_data_write() argument
2457 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_write()
2462 transfer = get_next_transfer(this); in gpmi_chain_data_write()
2468 prepare_data_dma(this, buf, raw_len, &transfer->sgl, DMA_TO_DEVICE); in gpmi_chain_data_write()
2472 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_write()
2473 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_write()
2477 if (this->bch) { in gpmi_chain_data_write()
2484 pio[5] = this->auxiliary_phys; in gpmi_chain_data_write()
2489 (this->bch ? MXS_DMA_CTRL_WAIT4END : 0)); in gpmi_chain_data_write()
2493 if (!this->bch) in gpmi_chain_data_write()
2506 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nfc_exec_op() local
2519 this->ntransfers = 0; in gpmi_nfc_exec_op()
2521 this->transfers[i].direction = DMA_NONE; in gpmi_nfc_exec_op()
2523 ret = pm_runtime_resume_and_get(this->dev); in gpmi_nfc_exec_op()
2528 * This driver currently supports only one NAND chip. Plus, dies share in gpmi_nfc_exec_op()
2533 if (this->hw.must_apply_timings) { in gpmi_nfc_exec_op()
2534 this->hw.must_apply_timings = false; in gpmi_nfc_exec_op()
2535 ret = gpmi_nfc_apply_timings(this); in gpmi_nfc_exec_op()
2540 dev_dbg(this->dev, "%s: %d instructions\n", __func__, op->ninstrs); in gpmi_nfc_exec_op()
2549 desc = gpmi_chain_wait_ready(this); in gpmi_nfc_exec_op()
2555 * When this command has an address cycle chain it in gpmi_nfc_exec_op()
2562 desc = gpmi_chain_command(this, cmd, NULL, 0); in gpmi_nfc_exec_op()
2566 desc = gpmi_chain_command(this, cmd, instr->ctx.addr.addrs, in gpmi_nfc_exec_op()
2574 desc = gpmi_chain_data_write(this, buf_write, buf_len); in gpmi_nfc_exec_op()
2584 desc = gpmi_chain_data_read(this, buf_read, buf_len, in gpmi_nfc_exec_op()
2595 dev_dbg(this->dev, "%s setup done\n", __func__); in gpmi_nfc_exec_op()
2598 dev_err(this->dev, "Multiple data instructions not supported\n"); in gpmi_nfc_exec_op()
2603 if (this->bch) { in gpmi_nfc_exec_op()
2604 writel(this->bch_flashlayout0, in gpmi_nfc_exec_op()
2605 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT0); in gpmi_nfc_exec_op()
2606 writel(this->bch_flashlayout1, in gpmi_nfc_exec_op()
2607 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT1); in gpmi_nfc_exec_op()
2611 desc->callback_param = this; in gpmi_nfc_exec_op()
2612 dma_completion = &this->dma_done; in gpmi_nfc_exec_op()
2617 if (this->bch && buf_read) { in gpmi_nfc_exec_op()
2619 this->resources.bch_regs + HW_BCH_CTRL_SET); in gpmi_nfc_exec_op()
2620 bch_completion = &this->bch_done; in gpmi_nfc_exec_op()
2625 dma_async_issue_pending(get_dma_chan(this)); in gpmi_nfc_exec_op()
2629 dev_err(this->dev, "DMA timeout, last DMA\n"); in gpmi_nfc_exec_op()
2630 gpmi_dump_info(this); in gpmi_nfc_exec_op()
2635 if (this->bch && buf_read) { in gpmi_nfc_exec_op()
2638 dev_err(this->dev, "BCH timeout, last DMA\n"); in gpmi_nfc_exec_op()
2639 gpmi_dump_info(this); in gpmi_nfc_exec_op()
2646 this->resources.bch_regs + HW_BCH_CTRL_CLR); in gpmi_nfc_exec_op()
2647 gpmi_clear_bch(this); in gpmi_nfc_exec_op()
2652 for (i = 0; i < this->ntransfers; i++) { in gpmi_nfc_exec_op()
2653 struct gpmi_transfer *transfer = &this->transfers[i]; in gpmi_nfc_exec_op()
2656 dma_unmap_sg(this->dev, &transfer->sgl, 1, in gpmi_nfc_exec_op()
2661 memcpy(buf_read, this->data_buffer_dma, in gpmi_nfc_exec_op()
2662 gpmi_raw_len_to_len(this, buf_len)); in gpmi_nfc_exec_op()
2664 this->bch = false; in gpmi_nfc_exec_op()
2667 pm_runtime_mark_last_busy(this->dev); in gpmi_nfc_exec_op()
2668 pm_runtime_put_autosuspend(this->dev); in gpmi_nfc_exec_op()
2679 static int gpmi_nand_init(struct gpmi_nand_data *this) in gpmi_nand_init() argument
2681 struct nand_chip *chip = &this->nand; in gpmi_nand_init()
2687 mtd->dev.parent = this->dev; in gpmi_nand_init()
2690 nand_set_controller_data(chip, this); in gpmi_nand_init()
2691 nand_set_flash_node(chip, this->pdev->dev.of_node); in gpmi_nand_init()
2697 this->swap_block_mark = !GPMI_IS_MX23(this); in gpmi_nand_init()
2703 this->bch_geometry.payload_size = 1024; in gpmi_nand_init()
2704 this->bch_geometry.auxiliary_size = 128; in gpmi_nand_init()
2705 ret = gpmi_alloc_dma_buffer(this); in gpmi_nand_init()
2709 nand_controller_init(&this->base); in gpmi_nand_init()
2710 this->base.ops = &gpmi_nand_controller_ops; in gpmi_nand_init()
2711 chip->controller = &this->base; in gpmi_nand_init()
2713 ret = nand_scan(chip, GPMI_IS_MX6(this) ? 2 : 1); in gpmi_nand_init()
2717 ret = nand_boot_init(this); in gpmi_nand_init()
2732 gpmi_free_dma_buffer(this); in gpmi_nand_init()
2749 struct gpmi_nand_data *this; in gpmi_nand_probe() local
2752 this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL); in gpmi_nand_probe()
2753 if (!this) in gpmi_nand_probe()
2756 this->devdata = of_device_get_match_data(&pdev->dev); in gpmi_nand_probe()
2757 platform_set_drvdata(pdev, this); in gpmi_nand_probe()
2758 this->pdev = pdev; in gpmi_nand_probe()
2759 this->dev = &pdev->dev; in gpmi_nand_probe()
2761 ret = acquire_resources(this); in gpmi_nand_probe()
2769 ret = gpmi_init(this); in gpmi_nand_probe()
2773 ret = gpmi_nand_init(this); in gpmi_nand_probe()
2777 dev_info(this->dev, "driver registered.\n"); in gpmi_nand_probe()
2784 release_resources(this); in gpmi_nand_probe()
2792 struct gpmi_nand_data *this = platform_get_drvdata(pdev); in gpmi_nand_remove() local
2793 struct nand_chip *chip = &this->nand; in gpmi_nand_remove()
2799 gpmi_free_dma_buffer(this); in gpmi_nand_remove()
2800 release_resources(this); in gpmi_nand_remove()
2817 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_pm_resume() local
2822 dev_err(this->dev, "Error in resume %d\n", ret); in gpmi_pm_resume()
2829 ret = gpmi_init(this); in gpmi_pm_resume()
2831 dev_err(this->dev, "Error setting GPMI : %d\n", ret); in gpmi_pm_resume()
2836 if (this->hw.clk_rate) in gpmi_pm_resume()
2837 this->hw.must_apply_timings = true; in gpmi_pm_resume()
2840 ret = bch_set_geometry(this); in gpmi_pm_resume()
2842 dev_err(this->dev, "Error setting BCH : %d\n", ret); in gpmi_pm_resume()
2854 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_suspend() local
2856 gpmi_disable_clk(this); in gpmi_runtime_suspend()
2863 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_resume() local
2866 ret = gpmi_enable_clk(this); in gpmi_runtime_resume()