Lines Matching full:this

34  * Clear the bit and poll it cleared.  This is usually called with
68 * the next hard reset. This case occurs in the NAND boot mode. When the board
71 * You will see a DMA timeout in this case. The bug has been fixed
74 * To avoid this bug, just add a new parameter `just_enable` for
119 static int __gpmi_enable_clk(struct gpmi_nand_data *this, bool v) in __gpmi_enable_clk() argument
126 clk = this->resources.clock[i]; in __gpmi_enable_clk()
142 clk_disable_unprepare(this->resources.clock[i - 1]); in __gpmi_enable_clk()
146 static int gpmi_init(struct gpmi_nand_data *this) in gpmi_init() argument
148 struct resources *r = &this->resources; in gpmi_init()
159 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in gpmi_init()
187 /* This function is very useful. It is called only when the bug occur. */
188 static void gpmi_dump_info(struct gpmi_nand_data *this) in gpmi_dump_info() argument
190 struct resources *r = &this->resources; in gpmi_dump_info()
191 struct bch_geometry *geo = &this->bch_geometry; in gpmi_dump_info()
195 dev_err(this->dev, "Show GPMI registers :\n"); in gpmi_dump_info()
198 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
202 dev_err(this->dev, "Show BCH registers :\n"); in gpmi_dump_info()
205 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
207 dev_err(this->dev, "BCH Geometry :\n" in gpmi_dump_info()
232 static inline bool gpmi_check_ecc(struct gpmi_nand_data *this) in gpmi_check_ecc() argument
234 struct bch_geometry *geo = &this->bch_geometry; in gpmi_check_ecc()
237 if (GPMI_IS_MXS(this)) { in gpmi_check_ecc()
242 return geo->ecc_strength <= this->devdata->bch_max_ecc_strength; in gpmi_check_ecc()
249 * We may have available oob space in this case.
251 static int set_geometry_by_ecc_info(struct gpmi_nand_data *this, in set_geometry_by_ecc_info() argument
255 struct bch_geometry *geo = &this->bch_geometry; in set_geometry_by_ecc_info()
256 struct nand_chip *chip = &this->nand; in set_geometry_by_ecc_info()
268 dev_err(this->dev, in set_geometry_by_ecc_info()
276 if (!gpmi_check_ecc(this)) in set_geometry_by_ecc_info()
281 dev_err(this->dev, in set_geometry_by_ecc_info()
349 if (!this->swap_block_mark) in set_geometry_by_ecc_info()
380 static inline int get_ecc_strength(struct gpmi_nand_data *this) in get_ecc_strength() argument
382 struct bch_geometry *geo = &this->bch_geometry; in get_ecc_strength()
383 struct mtd_info *mtd = nand_to_mtd(&this->nand); in get_ecc_strength()
393 static int legacy_set_geometry(struct gpmi_nand_data *this) in legacy_set_geometry() argument
395 struct bch_geometry *geo = &this->bch_geometry; in legacy_set_geometry()
396 struct mtd_info *mtd = nand_to_mtd(&this->nand); in legacy_set_geometry()
421 geo->ecc_strength = get_ecc_strength(this); in legacy_set_geometry()
422 if (!gpmi_check_ecc(this)) { in legacy_set_geometry()
423 dev_err(this->dev, in legacy_set_geometry()
427 this->devdata->bch_max_ecc_strength); in legacy_set_geometry()
447 if (!this->swap_block_mark) in legacy_set_geometry()
505 static int common_nfc_set_geometry(struct gpmi_nand_data *this) in common_nfc_set_geometry() argument
507 struct nand_chip *chip = &this->nand; in common_nfc_set_geometry()
510 return set_geometry_by_ecc_info(this, chip->ecc.strength, in common_nfc_set_geometry()
513 if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) in common_nfc_set_geometry()
514 || legacy_set_geometry(this)) { in common_nfc_set_geometry()
519 return set_geometry_by_ecc_info(this, in common_nfc_set_geometry()
528 static int bch_set_geometry(struct gpmi_nand_data *this) in bch_set_geometry() argument
530 struct resources *r = &this->resources; in bch_set_geometry()
533 ret = common_nfc_set_geometry(this); in bch_set_geometry()
537 ret = pm_runtime_get_sync(this->dev); in bch_set_geometry()
542 * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this in bch_set_geometry()
546 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in bch_set_geometry()
555 pm_runtime_mark_last_busy(this->dev); in bch_set_geometry()
556 pm_runtime_put_autosuspend(this->dev); in bch_set_geometry()
635 static void gpmi_nfc_compute_timings(struct gpmi_nand_data *this, in gpmi_nfc_compute_timings() argument
638 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_compute_timings()
639 unsigned int dll_threshold_ps = this->devdata->max_chain_delay; in gpmi_nfc_compute_timings()
704 static void gpmi_nfc_apply_timings(struct gpmi_nand_data *this) in gpmi_nfc_apply_timings() argument
706 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_apply_timings()
707 struct resources *r = &this->resources; in gpmi_nfc_apply_timings()
735 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_setup_data_interface() local
744 if (sdr->tRC_min <= 25000 && !GPMI_IS_MX6(this)) in gpmi_setup_data_interface()
747 /* Stop here if this call was just a check */ in gpmi_setup_data_interface()
752 gpmi_nfc_compute_timings(this, sdr); in gpmi_setup_data_interface()
754 this->hw.must_apply_timings = true; in gpmi_setup_data_interface()
760 static void gpmi_clear_bch(struct gpmi_nand_data *this) in gpmi_clear_bch() argument
762 struct resources *r = &this->resources; in gpmi_clear_bch()
766 static struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) in get_dma_chan() argument
769 return this->dma_chans[0]; in get_dma_chan()
772 /* This will be called after the DMA operation is finished. */
775 struct gpmi_nand_data *this = param; in dma_irq_callback() local
776 struct completion *dma_c = &this->dma_done; in dma_irq_callback()
783 struct gpmi_nand_data *this = cookie; in bch_irq() local
785 gpmi_clear_bch(this); in bch_irq()
786 complete(&this->bch_done); in bch_irq()
790 static int gpmi_raw_len_to_len(struct gpmi_nand_data *this, int raw_len) in gpmi_raw_len_to_len() argument
796 if (this->bch) in gpmi_raw_len_to_len()
797 return ALIGN_DOWN(raw_len, this->bch_geometry.ecc_chunk_size); in gpmi_raw_len_to_len()
803 static bool prepare_data_dma(struct gpmi_nand_data *this, const void *buf, in prepare_data_dma() argument
808 int len = gpmi_raw_len_to_len(this, raw_len); in prepare_data_dma()
813 ret = dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
822 sg_init_one(sgl, this->data_buffer_dma, len); in prepare_data_dma()
824 if (dr == DMA_TO_DEVICE && buf != this->data_buffer_dma) in prepare_data_dma()
825 memcpy(this->data_buffer_dma, buf, len); in prepare_data_dma()
827 dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
840 * This functions copies bits from one memory region to another, and is used by
1001 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_ecc() local
1002 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_ecc()
1017 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_free() local
1018 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_free()
1089 static int acquire_register_block(struct gpmi_nand_data *this, in acquire_register_block() argument
1092 struct platform_device *pdev = this->pdev; in acquire_register_block()
1093 struct resources *res = &this->resources; in acquire_register_block()
1107 dev_err(this->dev, "unknown resource name : %s\n", res_name); in acquire_register_block()
1112 static int acquire_bch_irq(struct gpmi_nand_data *this, irq_handler_t irq_h) in acquire_bch_irq() argument
1114 struct platform_device *pdev = this->pdev; in acquire_bch_irq()
1121 dev_err(this->dev, "Can't get resource for %s\n", res_name); in acquire_bch_irq()
1125 err = devm_request_irq(this->dev, r->start, irq_h, 0, res_name, this); in acquire_bch_irq()
1127 dev_err(this->dev, "error requesting BCH IRQ\n"); in acquire_bch_irq()
1132 static void release_dma_channels(struct gpmi_nand_data *this) in release_dma_channels() argument
1136 if (this->dma_chans[i]) { in release_dma_channels()
1137 dma_release_channel(this->dma_chans[i]); in release_dma_channels()
1138 this->dma_chans[i] = NULL; in release_dma_channels()
1142 static int acquire_dma_channels(struct gpmi_nand_data *this) in acquire_dma_channels() argument
1144 struct platform_device *pdev = this->pdev; in acquire_dma_channels()
1150 dev_err(this->dev, "Failed to request DMA channel.\n"); in acquire_dma_channels()
1154 this->dma_chans[0] = dma_chan; in acquire_dma_channels()
1158 release_dma_channels(this); in acquire_dma_channels()
1162 static int gpmi_get_clks(struct gpmi_nand_data *this) in gpmi_get_clks() argument
1164 struct resources *r = &this->resources; in gpmi_get_clks()
1168 for (i = 0; i < this->devdata->clks_count; i++) { in gpmi_get_clks()
1169 clk = devm_clk_get(this->dev, this->devdata->clks[i]); in gpmi_get_clks()
1178 if (GPMI_IS_MX6(this)) in gpmi_get_clks()
1190 dev_dbg(this->dev, "failed in finding the clocks.\n"); in gpmi_get_clks()
1194 static int acquire_resources(struct gpmi_nand_data *this) in acquire_resources() argument
1198 ret = acquire_register_block(this, GPMI_NAND_GPMI_REGS_ADDR_RES_NAME); in acquire_resources()
1202 ret = acquire_register_block(this, GPMI_NAND_BCH_REGS_ADDR_RES_NAME); in acquire_resources()
1206 ret = acquire_bch_irq(this, bch_irq); in acquire_resources()
1210 ret = acquire_dma_channels(this); in acquire_resources()
1214 ret = gpmi_get_clks(this); in acquire_resources()
1220 release_dma_channels(this); in acquire_resources()
1225 static void release_resources(struct gpmi_nand_data *this) in release_resources() argument
1227 release_dma_channels(this); in release_resources()
1230 static void gpmi_free_dma_buffer(struct gpmi_nand_data *this) in gpmi_free_dma_buffer() argument
1232 struct device *dev = this->dev; in gpmi_free_dma_buffer()
1233 struct bch_geometry *geo = &this->bch_geometry; in gpmi_free_dma_buffer()
1235 if (this->auxiliary_virt && virt_addr_valid(this->auxiliary_virt)) in gpmi_free_dma_buffer()
1237 this->auxiliary_virt, in gpmi_free_dma_buffer()
1238 this->auxiliary_phys); in gpmi_free_dma_buffer()
1239 kfree(this->data_buffer_dma); in gpmi_free_dma_buffer()
1240 kfree(this->raw_buffer); in gpmi_free_dma_buffer()
1242 this->data_buffer_dma = NULL; in gpmi_free_dma_buffer()
1243 this->raw_buffer = NULL; in gpmi_free_dma_buffer()
1247 static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this) in gpmi_alloc_dma_buffer() argument
1249 struct bch_geometry *geo = &this->bch_geometry; in gpmi_alloc_dma_buffer()
1250 struct device *dev = this->dev; in gpmi_alloc_dma_buffer()
1251 struct mtd_info *mtd = nand_to_mtd(&this->nand); in gpmi_alloc_dma_buffer()
1261 this->data_buffer_dma = kzalloc(mtd->writesize ?: PAGE_SIZE, in gpmi_alloc_dma_buffer()
1263 if (this->data_buffer_dma == NULL) in gpmi_alloc_dma_buffer()
1266 this->auxiliary_virt = dma_alloc_coherent(dev, geo->auxiliary_size, in gpmi_alloc_dma_buffer()
1267 &this->auxiliary_phys, GFP_DMA); in gpmi_alloc_dma_buffer()
1268 if (!this->auxiliary_virt) in gpmi_alloc_dma_buffer()
1271 this->raw_buffer = kzalloc((mtd->writesize ?: PAGE_SIZE) + mtd->oobsize, GFP_KERNEL); in gpmi_alloc_dma_buffer()
1272 if (!this->raw_buffer) in gpmi_alloc_dma_buffer()
1278 gpmi_free_dma_buffer(this); in gpmi_alloc_dma_buffer()
1287 static void block_mark_swapping(struct gpmi_nand_data *this, in block_mark_swapping() argument
1290 struct bch_geometry *nfc_geo = &this->bch_geometry; in block_mark_swapping()
1298 if (!this->swap_block_mark) in block_mark_swapping()
1333 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_count_bitflips() local
1334 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_count_bitflips()
1341 status = this->auxiliary_virt + ALIGN(meta, 4); in gpmi_count_bitflips()
1349 u8 *eccbuf = this->raw_buffer; in gpmi_count_bitflips()
1382 * nothing was written into this subpage the ECC is in gpmi_count_bitflips()
1384 * at this point that we are reading an erased page and in gpmi_count_bitflips()
1386 * ecc_strength bitflips. If this is a page with random in gpmi_count_bitflips()
1387 * data, we exceed this number of bitflips and have a in gpmi_count_bitflips()
1396 this->auxiliary_virt, in gpmi_count_bitflips()
1426 static void gpmi_bch_layout_std(struct gpmi_nand_data *this) in gpmi_bch_layout_std() argument
1428 struct bch_geometry *geo = &this->bch_geometry; in gpmi_bch_layout_std()
1433 this->bch_flashlayout0 = in gpmi_bch_layout_std()
1436 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_bch_layout_std()
1437 BF_BCH_FLASH0LAYOUT0_GF(gf_len, this) | in gpmi_bch_layout_std()
1438 BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this); in gpmi_bch_layout_std()
1440 this->bch_flashlayout1 = in gpmi_bch_layout_std()
1442 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_bch_layout_std()
1443 BF_BCH_FLASH0LAYOUT1_GF(gf_len, this) | in gpmi_bch_layout_std()
1444 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this); in gpmi_bch_layout_std()
1450 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page() local
1452 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_page()
1456 gpmi_bch_layout_std(this); in gpmi_ecc_read_page()
1457 this->bch = true; in gpmi_ecc_read_page()
1468 block_mark_swapping(this, buf, this->auxiliary_virt); in gpmi_ecc_read_page()
1482 chip->oob_poi[0] = ((uint8_t *)this->auxiliary_virt)[0]; in gpmi_ecc_read_page()
1492 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_subpage() local
1493 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_subpage()
1510 if (this->swap_block_mark) { in gpmi_ecc_read_subpage()
1513 * If this chunk is in the range of [first, last], in gpmi_ecc_read_subpage()
1520 dev_dbg(this->dev, in gpmi_ecc_read_subpage()
1540 this->bch_flashlayout0 = BF_BCH_FLASH0LAYOUT0_NBLOCKS(n - 1) | in gpmi_ecc_read_subpage()
1542 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_ecc_read_subpage()
1543 BF_BCH_FLASH0LAYOUT0_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1544 BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(geo->ecc_chunk_size, this); in gpmi_ecc_read_subpage()
1546 this->bch_flashlayout1 = BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size) | in gpmi_ecc_read_subpage()
1547 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_ecc_read_subpage()
1548 BF_BCH_FLASH0LAYOUT1_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1549 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(geo->ecc_chunk_size, this); in gpmi_ecc_read_subpage()
1551 this->bch = true; in gpmi_ecc_read_subpage()
1557 dev_dbg(this->dev, "page:%d(%d:%d)%d, chunk:(%d:%d), BCH PG size:%d\n", in gpmi_ecc_read_subpage()
1569 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page() local
1570 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page()
1573 dev_dbg(this->dev, "ecc write page.\n"); in gpmi_ecc_write_page()
1575 gpmi_bch_layout_std(this); in gpmi_ecc_write_page()
1576 this->bch = true; in gpmi_ecc_write_page()
1578 memcpy(this->auxiliary_virt, chip->oob_poi, nfc_geo->auxiliary_size); in gpmi_ecc_write_page()
1580 if (this->swap_block_mark) { in gpmi_ecc_write_page()
1585 memcpy(this->data_buffer_dma, buf, mtd->writesize); in gpmi_ecc_write_page()
1586 buf = this->data_buffer_dma; in gpmi_ecc_write_page()
1587 block_mark_swapping(this, this->data_buffer_dma, in gpmi_ecc_write_page()
1588 this->auxiliary_virt); in gpmi_ecc_write_page()
1597 * There are several places in this driver where we have to handle the OOB and
1598 * block marks. This is the function where things are the most complicated, so
1599 * this is where we try to explain it all. All the other places refer back to
1616 * are OOB. This gives the caller a way to see the actual, physical bytes
1620 * What we do for this specific read operation depends on two questions:
1659 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_oob() local
1676 if (GPMI_IS_MX23(this)) { in gpmi_ecc_read_oob()
1704 * This function reads a NAND page without involving the ECC engine (no HW
1719 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page_raw() local
1720 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_read_page_raw()
1723 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_read_page_raw()
1740 * See the layout description for a detailed explanation on why this in gpmi_ecc_read_page_raw()
1743 if (this->swap_block_mark) in gpmi_ecc_read_page_raw()
1747 * Copy the metadata section into the oob buffer (this section is in gpmi_ecc_read_page_raw()
1791 * This function writes a NAND page without involving the ECC engine (no HW
1806 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page_raw() local
1807 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page_raw()
1810 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_write_page_raw()
1863 * See the layout description for a detailed explanation on why this in gpmi_ecc_write_page_raw()
1866 if (this->swap_block_mark) in gpmi_ecc_write_page_raw()
1886 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_block_markbad() local
1894 column = !GPMI_IS_MX23(this) ? mtd->writesize : 0; in gpmi_block_markbad()
1897 block_mark = this->data_buffer_dma; in gpmi_block_markbad()
1910 static int nand_boot_set_geometry(struct gpmi_nand_data *this) in nand_boot_set_geometry() argument
1912 struct boot_rom_geometry *geometry = &this->rom_geometry; in nand_boot_set_geometry()
1917 * In principle, we should be reading this from the OTP bits, since in nand_boot_set_geometry()
1927 * In principle, we should be reading this from the OTP bits, since in nand_boot_set_geometry()
1937 static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) in mx23_check_transcription_stamp() argument
1939 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_check_transcription_stamp()
1940 struct device *dev = this->dev; in mx23_check_transcription_stamp()
1941 struct nand_chip *chip = &this->nand; in mx23_check_transcription_stamp()
1992 static int mx23_write_transcription_stamp(struct gpmi_nand_data *this) in mx23_write_transcription_stamp() argument
1994 struct device *dev = this->dev; in mx23_write_transcription_stamp()
1995 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_write_transcription_stamp()
1996 struct nand_chip *chip = &this->nand; in mx23_write_transcription_stamp()
2028 /* Erase this block. */ in mx23_write_transcription_stamp()
2058 static int mx23_boot_init(struct gpmi_nand_data *this) in mx23_boot_init() argument
2060 struct device *dev = this->dev; in mx23_boot_init()
2061 struct nand_chip *chip = &this->nand; in mx23_boot_init()
2077 if (mx23_check_transcription_stamp(this)) in mx23_boot_init()
2095 * Compute the chip, page and byte addresses for this block's in mx23_boot_init()
2113 * again, but this time the result will be a mark in the in mx23_boot_init()
2127 mx23_write_transcription_stamp(this); in mx23_boot_init()
2131 static int nand_boot_init(struct gpmi_nand_data *this) in nand_boot_init() argument
2133 nand_boot_set_geometry(this); in nand_boot_init()
2135 /* This is ROM arch-specific initilization before the BBT scanning. */ in nand_boot_init()
2136 if (GPMI_IS_MX23(this)) in nand_boot_init()
2137 return mx23_boot_init(this); in nand_boot_init()
2141 static int gpmi_set_geometry(struct gpmi_nand_data *this) in gpmi_set_geometry() argument
2146 gpmi_free_dma_buffer(this); in gpmi_set_geometry()
2149 ret = bch_set_geometry(this); in gpmi_set_geometry()
2151 dev_err(this->dev, "Error setting BCH geometry : %d\n", ret); in gpmi_set_geometry()
2156 return gpmi_alloc_dma_buffer(this); in gpmi_set_geometry()
2159 static int gpmi_init_last(struct gpmi_nand_data *this) in gpmi_init_last() argument
2161 struct nand_chip *chip = &this->nand; in gpmi_init_last()
2164 struct bch_geometry *bch_geo = &this->bch_geometry; in gpmi_init_last()
2168 ret = gpmi_set_geometry(this); in gpmi_init_last()
2191 if (GPMI_IS_MX6(this) && in gpmi_init_last()
2202 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nand_attach_chip() local
2208 if (of_property_read_bool(this->dev->of_node, in gpmi_nand_attach_chip()
2210 this->swap_block_mark = false; in gpmi_nand_attach_chip()
2212 dev_dbg(this->dev, "Blockmark swapping %sabled\n", in gpmi_nand_attach_chip()
2213 this->swap_block_mark ? "en" : "dis"); in gpmi_nand_attach_chip()
2215 ret = gpmi_init_last(this); in gpmi_nand_attach_chip()
2224 static struct gpmi_transfer *get_next_transfer(struct gpmi_nand_data *this) in get_next_transfer() argument
2226 struct gpmi_transfer *transfer = &this->transfers[this->ntransfers]; in get_next_transfer()
2228 this->ntransfers++; in get_next_transfer()
2230 if (this->ntransfers == GPMI_MAX_TRANSFERS) in get_next_transfer()
2237 struct gpmi_nand_data *this, u8 cmd, const u8 *addr, int naddr) in gpmi_chain_command() argument
2239 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_command()
2242 int chip = this->nand.cur_cs; in gpmi_chain_command()
2248 | BF_GPMI_CTRL0_CS(chip, this) in gpmi_chain_command()
2249 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_command()
2260 transfer = get_next_transfer(this); in gpmi_chain_command()
2269 dma_map_sg(this->dev, &transfer->sgl, 1, DMA_TO_DEVICE); in gpmi_chain_command()
2279 struct gpmi_nand_data *this) in gpmi_chain_wait_ready() argument
2281 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_wait_ready()
2286 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_wait_ready()
2287 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_wait_ready()
2297 struct gpmi_nand_data *this, void *buf, int raw_len, bool *direct) in gpmi_chain_data_read() argument
2300 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_read()
2304 transfer = get_next_transfer(this); in gpmi_chain_data_read()
2310 *direct = prepare_data_dma(this, buf, raw_len, &transfer->sgl, in gpmi_chain_data_read()
2315 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_read()
2316 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_read()
2320 if (this->bch) { in gpmi_chain_data_read()
2327 pio[5] = this->auxiliary_phys; in gpmi_chain_data_read()
2335 if (!this->bch) in gpmi_chain_data_read()
2344 struct gpmi_nand_data *this, const void *buf, int raw_len) in gpmi_chain_data_write() argument
2346 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_write()
2351 transfer = get_next_transfer(this); in gpmi_chain_data_write()
2357 prepare_data_dma(this, buf, raw_len, &transfer->sgl, DMA_TO_DEVICE); in gpmi_chain_data_write()
2361 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_write()
2362 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_write()
2366 if (this->bch) { in gpmi_chain_data_write()
2373 pio[5] = this->auxiliary_phys; in gpmi_chain_data_write()
2378 (this->bch ? MXS_DMA_CTRL_WAIT4END : 0)); in gpmi_chain_data_write()
2382 if (!this->bch) in gpmi_chain_data_write()
2395 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nfc_exec_op() local
2405 this->ntransfers = 0; in gpmi_nfc_exec_op()
2407 this->transfers[i].direction = DMA_NONE; in gpmi_nfc_exec_op()
2409 ret = pm_runtime_get_sync(this->dev); in gpmi_nfc_exec_op()
2414 * This driver currently supports only one NAND chip. Plus, dies share in gpmi_nfc_exec_op()
2419 if (this->hw.must_apply_timings) { in gpmi_nfc_exec_op()
2420 this->hw.must_apply_timings = false; in gpmi_nfc_exec_op()
2421 gpmi_nfc_apply_timings(this); in gpmi_nfc_exec_op()
2424 dev_dbg(this->dev, "%s: %d instructions\n", __func__, op->ninstrs); in gpmi_nfc_exec_op()
2433 desc = gpmi_chain_wait_ready(this); in gpmi_nfc_exec_op()
2439 * When this command has an address cycle chain it in gpmi_nfc_exec_op()
2446 desc = gpmi_chain_command(this, cmd, NULL, 0); in gpmi_nfc_exec_op()
2450 desc = gpmi_chain_command(this, cmd, instr->ctx.addr.addrs, in gpmi_nfc_exec_op()
2458 desc = gpmi_chain_data_write(this, buf_write, buf_len); in gpmi_nfc_exec_op()
2468 desc = gpmi_chain_data_read(this, buf_read, buf_len, in gpmi_nfc_exec_op()
2479 dev_dbg(this->dev, "%s setup done\n", __func__); in gpmi_nfc_exec_op()
2482 dev_err(this->dev, "Multiple data instructions not supported\n"); in gpmi_nfc_exec_op()
2487 if (this->bch) { in gpmi_nfc_exec_op()
2488 writel(this->bch_flashlayout0, in gpmi_nfc_exec_op()
2489 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT0); in gpmi_nfc_exec_op()
2490 writel(this->bch_flashlayout1, in gpmi_nfc_exec_op()
2491 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT1); in gpmi_nfc_exec_op()
2494 if (this->bch && buf_read) { in gpmi_nfc_exec_op()
2496 this->resources.bch_regs + HW_BCH_CTRL_SET); in gpmi_nfc_exec_op()
2497 completion = &this->bch_done; in gpmi_nfc_exec_op()
2500 desc->callback_param = this; in gpmi_nfc_exec_op()
2501 completion = &this->dma_done; in gpmi_nfc_exec_op()
2507 dma_async_issue_pending(get_dma_chan(this)); in gpmi_nfc_exec_op()
2511 dev_err(this->dev, "DMA timeout, last DMA\n"); in gpmi_nfc_exec_op()
2512 gpmi_dump_info(this); in gpmi_nfc_exec_op()
2518 this->resources.bch_regs + HW_BCH_CTRL_CLR); in gpmi_nfc_exec_op()
2519 gpmi_clear_bch(this); in gpmi_nfc_exec_op()
2524 for (i = 0; i < this->ntransfers; i++) { in gpmi_nfc_exec_op()
2525 struct gpmi_transfer *transfer = &this->transfers[i]; in gpmi_nfc_exec_op()
2528 dma_unmap_sg(this->dev, &transfer->sgl, 1, in gpmi_nfc_exec_op()
2533 memcpy(buf_read, this->data_buffer_dma, in gpmi_nfc_exec_op()
2534 gpmi_raw_len_to_len(this, buf_len)); in gpmi_nfc_exec_op()
2536 this->bch = false; in gpmi_nfc_exec_op()
2538 pm_runtime_mark_last_busy(this->dev); in gpmi_nfc_exec_op()
2539 pm_runtime_put_autosuspend(this->dev); in gpmi_nfc_exec_op()
2550 static int gpmi_nand_init(struct gpmi_nand_data *this) in gpmi_nand_init() argument
2552 struct nand_chip *chip = &this->nand; in gpmi_nand_init()
2558 mtd->dev.parent = this->dev; in gpmi_nand_init()
2561 nand_set_controller_data(chip, this); in gpmi_nand_init()
2562 nand_set_flash_node(chip, this->pdev->dev.of_node); in gpmi_nand_init()
2568 this->swap_block_mark = !GPMI_IS_MX23(this); in gpmi_nand_init()
2574 this->bch_geometry.payload_size = 1024; in gpmi_nand_init()
2575 this->bch_geometry.auxiliary_size = 128; in gpmi_nand_init()
2576 ret = gpmi_alloc_dma_buffer(this); in gpmi_nand_init()
2580 nand_controller_init(&this->base); in gpmi_nand_init()
2581 this->base.ops = &gpmi_nand_controller_ops; in gpmi_nand_init()
2582 chip->controller = &this->base; in gpmi_nand_init()
2584 ret = nand_scan(chip, GPMI_IS_MX6(this) ? 2 : 1); in gpmi_nand_init()
2588 ret = nand_boot_init(this); in gpmi_nand_init()
2603 gpmi_free_dma_buffer(this); in gpmi_nand_init()
2629 struct gpmi_nand_data *this; in gpmi_nand_probe() local
2633 this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL); in gpmi_nand_probe()
2634 if (!this) in gpmi_nand_probe()
2639 this->devdata = of_id->data; in gpmi_nand_probe()
2645 platform_set_drvdata(pdev, this); in gpmi_nand_probe()
2646 this->pdev = pdev; in gpmi_nand_probe()
2647 this->dev = &pdev->dev; in gpmi_nand_probe()
2649 ret = acquire_resources(this); in gpmi_nand_probe()
2653 ret = __gpmi_enable_clk(this, true); in gpmi_nand_probe()
2663 ret = gpmi_init(this); in gpmi_nand_probe()
2667 ret = gpmi_nand_init(this); in gpmi_nand_probe()
2674 dev_info(this->dev, "driver registered.\n"); in gpmi_nand_probe()
2681 release_resources(this); in gpmi_nand_probe()
2689 struct gpmi_nand_data *this = platform_get_drvdata(pdev); in gpmi_nand_remove() local
2694 nand_release(&this->nand); in gpmi_nand_remove()
2695 gpmi_free_dma_buffer(this); in gpmi_nand_remove()
2696 release_resources(this); in gpmi_nand_remove()
2703 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_pm_suspend() local
2705 release_dma_channels(this); in gpmi_pm_suspend()
2711 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_pm_resume() local
2714 ret = acquire_dma_channels(this); in gpmi_pm_resume()
2719 ret = gpmi_init(this); in gpmi_pm_resume()
2721 dev_err(this->dev, "Error setting GPMI : %d\n", ret); in gpmi_pm_resume()
2726 ret = bch_set_geometry(this); in gpmi_pm_resume()
2728 dev_err(this->dev, "Error setting BCH : %d\n", ret); in gpmi_pm_resume()
2738 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_suspend() local
2740 return __gpmi_enable_clk(this, false); in gpmi_runtime_suspend()
2745 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_resume() local
2747 return __gpmi_enable_clk(this, true); in gpmi_runtime_resume()