• Home
  • Raw
  • Download

Lines Matching refs:this

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()
151 ret = pm_runtime_get_sync(this->dev); in gpmi_init()
153 pm_runtime_put_noidle(this->dev); in gpmi_init()
165 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in gpmi_init()
189 pm_runtime_mark_last_busy(this->dev); in gpmi_init()
190 pm_runtime_put_autosuspend(this->dev); in gpmi_init()
195 static void gpmi_dump_info(struct gpmi_nand_data *this) in gpmi_dump_info() argument
197 struct resources *r = &this->resources; in gpmi_dump_info()
198 struct bch_geometry *geo = &this->bch_geometry; in gpmi_dump_info()
202 dev_err(this->dev, "Show GPMI registers :\n"); in gpmi_dump_info()
205 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
209 dev_err(this->dev, "Show BCH registers :\n"); in gpmi_dump_info()
212 dev_err(this->dev, "offset 0x%.3x : 0x%.8x\n", i * 0x10, reg); in gpmi_dump_info()
214 dev_err(this->dev, "BCH Geometry :\n" in gpmi_dump_info()
239 static inline bool gpmi_check_ecc(struct gpmi_nand_data *this) in gpmi_check_ecc() argument
241 struct bch_geometry *geo = &this->bch_geometry; in gpmi_check_ecc()
244 if (GPMI_IS_MXS(this)) { in gpmi_check_ecc()
249 return geo->ecc_strength <= this->devdata->bch_max_ecc_strength; in gpmi_check_ecc()
258 static int set_geometry_by_ecc_info(struct gpmi_nand_data *this, in set_geometry_by_ecc_info() argument
262 struct bch_geometry *geo = &this->bch_geometry; in set_geometry_by_ecc_info()
263 struct nand_chip *chip = &this->nand; in set_geometry_by_ecc_info()
275 dev_err(this->dev, in set_geometry_by_ecc_info()
283 if (!gpmi_check_ecc(this)) in set_geometry_by_ecc_info()
288 dev_err(this->dev, in set_geometry_by_ecc_info()
356 if (!this->swap_block_mark) in set_geometry_by_ecc_info()
387 static inline int get_ecc_strength(struct gpmi_nand_data *this) in get_ecc_strength() argument
389 struct bch_geometry *geo = &this->bch_geometry; in get_ecc_strength()
390 struct mtd_info *mtd = nand_to_mtd(&this->nand); in get_ecc_strength()
400 static int legacy_set_geometry(struct gpmi_nand_data *this) in legacy_set_geometry() argument
402 struct bch_geometry *geo = &this->bch_geometry; in legacy_set_geometry()
403 struct mtd_info *mtd = nand_to_mtd(&this->nand); in legacy_set_geometry()
428 geo->ecc_strength = get_ecc_strength(this); in legacy_set_geometry()
429 if (!gpmi_check_ecc(this)) { in legacy_set_geometry()
430 dev_err(this->dev, in legacy_set_geometry()
434 this->devdata->bch_max_ecc_strength); in legacy_set_geometry()
454 if (!this->swap_block_mark) in legacy_set_geometry()
512 static int common_nfc_set_geometry(struct gpmi_nand_data *this) in common_nfc_set_geometry() argument
514 struct nand_chip *chip = &this->nand; in common_nfc_set_geometry()
519 return set_geometry_by_ecc_info(this, chip->ecc.strength, in common_nfc_set_geometry()
522 if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) in common_nfc_set_geometry()
523 || legacy_set_geometry(this)) { in common_nfc_set_geometry()
527 return set_geometry_by_ecc_info(this, in common_nfc_set_geometry()
536 static int bch_set_geometry(struct gpmi_nand_data *this) in bch_set_geometry() argument
538 struct resources *r = &this->resources; in bch_set_geometry()
541 ret = common_nfc_set_geometry(this); in bch_set_geometry()
545 ret = pm_runtime_get_sync(this->dev); in bch_set_geometry()
547 pm_runtime_put_autosuspend(this->dev); in bch_set_geometry()
556 ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MXS(this)); in bch_set_geometry()
565 pm_runtime_mark_last_busy(this->dev); in bch_set_geometry()
566 pm_runtime_put_autosuspend(this->dev); in bch_set_geometry()
645 static void gpmi_nfc_compute_timings(struct gpmi_nand_data *this, in gpmi_nfc_compute_timings() argument
648 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_compute_timings()
649 struct resources *r = &this->resources; in gpmi_nfc_compute_timings()
650 unsigned int dll_threshold_ps = this->devdata->max_chain_delay; in gpmi_nfc_compute_timings()
719 static int gpmi_nfc_apply_timings(struct gpmi_nand_data *this) in gpmi_nfc_apply_timings() argument
721 struct gpmi_nfc_hardware_timing *hw = &this->hw; in gpmi_nfc_apply_timings()
722 struct resources *r = &this->resources; in gpmi_nfc_apply_timings()
731 if (GPMI_IS_MX6Q(this) || GPMI_IS_MX6SX(this)) in gpmi_nfc_apply_timings()
736 dev_err(this->dev, "cannot set clock rate to %lu Hz: %d\n", hw->clk_rate, ret); in gpmi_nfc_apply_timings()
740 if (GPMI_IS_MX6Q(this) || GPMI_IS_MX6SX(this)) { in gpmi_nfc_apply_timings()
770 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_setup_interface() local
779 if (sdr->tRC_min <= 25000 && !GPMI_IS_MX6(this)) in gpmi_setup_interface()
787 gpmi_nfc_compute_timings(this, sdr); in gpmi_setup_interface()
789 this->hw.must_apply_timings = true; in gpmi_setup_interface()
795 static void gpmi_clear_bch(struct gpmi_nand_data *this) in gpmi_clear_bch() argument
797 struct resources *r = &this->resources; in gpmi_clear_bch()
801 static struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) in get_dma_chan() argument
804 return this->dma_chans[0]; in get_dma_chan()
810 struct gpmi_nand_data *this = param; in dma_irq_callback() local
811 struct completion *dma_c = &this->dma_done; in dma_irq_callback()
818 struct gpmi_nand_data *this = cookie; in bch_irq() local
820 gpmi_clear_bch(this); in bch_irq()
821 complete(&this->bch_done); in bch_irq()
825 static int gpmi_raw_len_to_len(struct gpmi_nand_data *this, int raw_len) in gpmi_raw_len_to_len() argument
831 if (this->bch) in gpmi_raw_len_to_len()
832 return ALIGN_DOWN(raw_len, this->bch_geometry.ecc_chunk_size); in gpmi_raw_len_to_len()
838 static bool prepare_data_dma(struct gpmi_nand_data *this, const void *buf, in prepare_data_dma() argument
843 int len = gpmi_raw_len_to_len(this, raw_len); in prepare_data_dma()
848 ret = dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
857 sg_init_one(sgl, this->data_buffer_dma, len); in prepare_data_dma()
859 if (dr == DMA_TO_DEVICE && buf != this->data_buffer_dma) in prepare_data_dma()
860 memcpy(this->data_buffer_dma, buf, len); in prepare_data_dma()
862 dma_map_sg(this->dev, sgl, 1, dr); in prepare_data_dma()
884 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_ecc() local
885 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_ecc()
900 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ooblayout_free() local
901 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ooblayout_free()
972 static int acquire_register_block(struct gpmi_nand_data *this, in acquire_register_block() argument
975 struct platform_device *pdev = this->pdev; in acquire_register_block()
976 struct resources *res = &this->resources; in acquire_register_block()
990 dev_err(this->dev, "unknown resource name : %s\n", res_name); in acquire_register_block()
995 static int acquire_bch_irq(struct gpmi_nand_data *this, irq_handler_t irq_h) in acquire_bch_irq() argument
997 struct platform_device *pdev = this->pdev; in acquire_bch_irq()
1004 dev_err(this->dev, "Can't get resource for %s\n", res_name); in acquire_bch_irq()
1008 err = devm_request_irq(this->dev, r->start, irq_h, 0, res_name, this); in acquire_bch_irq()
1010 dev_err(this->dev, "error requesting BCH IRQ\n"); in acquire_bch_irq()
1015 static void release_dma_channels(struct gpmi_nand_data *this) in release_dma_channels() argument
1019 if (this->dma_chans[i]) { in release_dma_channels()
1020 dma_release_channel(this->dma_chans[i]); in release_dma_channels()
1021 this->dma_chans[i] = NULL; in release_dma_channels()
1025 static int acquire_dma_channels(struct gpmi_nand_data *this) in acquire_dma_channels() argument
1027 struct platform_device *pdev = this->pdev; in acquire_dma_channels()
1034 ret = dev_err_probe(this->dev, PTR_ERR(dma_chan), in acquire_dma_channels()
1036 release_dma_channels(this); in acquire_dma_channels()
1038 this->dma_chans[0] = dma_chan; in acquire_dma_channels()
1044 static int gpmi_get_clks(struct gpmi_nand_data *this) in gpmi_get_clks() argument
1046 struct resources *r = &this->resources; in gpmi_get_clks()
1050 for (i = 0; i < this->devdata->clks_count; i++) { in gpmi_get_clks()
1051 clk = devm_clk_get(this->dev, this->devdata->clks[i]); in gpmi_get_clks()
1063 dev_dbg(this->dev, "failed in finding the clocks.\n"); in gpmi_get_clks()
1067 static int acquire_resources(struct gpmi_nand_data *this) in acquire_resources() argument
1071 ret = acquire_register_block(this, GPMI_NAND_GPMI_REGS_ADDR_RES_NAME); in acquire_resources()
1075 ret = acquire_register_block(this, GPMI_NAND_BCH_REGS_ADDR_RES_NAME); in acquire_resources()
1079 ret = acquire_bch_irq(this, bch_irq); in acquire_resources()
1083 ret = acquire_dma_channels(this); in acquire_resources()
1087 ret = gpmi_get_clks(this); in acquire_resources()
1093 release_dma_channels(this); in acquire_resources()
1098 static void release_resources(struct gpmi_nand_data *this) in release_resources() argument
1100 release_dma_channels(this); in release_resources()
1103 static void gpmi_free_dma_buffer(struct gpmi_nand_data *this) in gpmi_free_dma_buffer() argument
1105 struct device *dev = this->dev; in gpmi_free_dma_buffer()
1106 struct bch_geometry *geo = &this->bch_geometry; in gpmi_free_dma_buffer()
1108 if (this->auxiliary_virt && virt_addr_valid(this->auxiliary_virt)) in gpmi_free_dma_buffer()
1110 this->auxiliary_virt, in gpmi_free_dma_buffer()
1111 this->auxiliary_phys); in gpmi_free_dma_buffer()
1112 kfree(this->data_buffer_dma); in gpmi_free_dma_buffer()
1113 kfree(this->raw_buffer); in gpmi_free_dma_buffer()
1115 this->data_buffer_dma = NULL; in gpmi_free_dma_buffer()
1116 this->raw_buffer = NULL; in gpmi_free_dma_buffer()
1120 static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this) in gpmi_alloc_dma_buffer() argument
1122 struct bch_geometry *geo = &this->bch_geometry; in gpmi_alloc_dma_buffer()
1123 struct device *dev = this->dev; in gpmi_alloc_dma_buffer()
1124 struct mtd_info *mtd = nand_to_mtd(&this->nand); in gpmi_alloc_dma_buffer()
1134 this->data_buffer_dma = kzalloc(mtd->writesize ?: PAGE_SIZE, in gpmi_alloc_dma_buffer()
1136 if (this->data_buffer_dma == NULL) in gpmi_alloc_dma_buffer()
1139 this->auxiliary_virt = dma_alloc_coherent(dev, geo->auxiliary_size, in gpmi_alloc_dma_buffer()
1140 &this->auxiliary_phys, GFP_DMA); in gpmi_alloc_dma_buffer()
1141 if (!this->auxiliary_virt) in gpmi_alloc_dma_buffer()
1144 this->raw_buffer = kzalloc((mtd->writesize ?: PAGE_SIZE) + mtd->oobsize, GFP_KERNEL); in gpmi_alloc_dma_buffer()
1145 if (!this->raw_buffer) in gpmi_alloc_dma_buffer()
1151 gpmi_free_dma_buffer(this); in gpmi_alloc_dma_buffer()
1160 static void block_mark_swapping(struct gpmi_nand_data *this, in block_mark_swapping() argument
1163 struct bch_geometry *nfc_geo = &this->bch_geometry; in block_mark_swapping()
1171 if (!this->swap_block_mark) in block_mark_swapping()
1206 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_count_bitflips() local
1207 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_count_bitflips()
1214 status = this->auxiliary_virt + ALIGN(meta, 4); in gpmi_count_bitflips()
1222 u8 *eccbuf = this->raw_buffer; in gpmi_count_bitflips()
1269 this->auxiliary_virt, in gpmi_count_bitflips()
1299 static void gpmi_bch_layout_std(struct gpmi_nand_data *this) in gpmi_bch_layout_std() argument
1301 struct bch_geometry *geo = &this->bch_geometry; in gpmi_bch_layout_std()
1306 this->bch_flashlayout0 = in gpmi_bch_layout_std()
1309 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_bch_layout_std()
1310 BF_BCH_FLASH0LAYOUT0_GF(gf_len, this) | in gpmi_bch_layout_std()
1311 BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this); in gpmi_bch_layout_std()
1313 this->bch_flashlayout1 = in gpmi_bch_layout_std()
1315 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_bch_layout_std()
1316 BF_BCH_FLASH0LAYOUT1_GF(gf_len, this) | in gpmi_bch_layout_std()
1317 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this); in gpmi_bch_layout_std()
1323 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page() local
1325 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_page()
1329 gpmi_bch_layout_std(this); in gpmi_ecc_read_page()
1330 this->bch = true; in gpmi_ecc_read_page()
1341 block_mark_swapping(this, buf, this->auxiliary_virt); in gpmi_ecc_read_page()
1355 chip->oob_poi[0] = ((uint8_t *)this->auxiliary_virt)[0]; in gpmi_ecc_read_page()
1365 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_subpage() local
1366 struct bch_geometry *geo = &this->bch_geometry; in gpmi_ecc_read_subpage()
1383 if (this->swap_block_mark) { in gpmi_ecc_read_subpage()
1393 dev_dbg(this->dev, in gpmi_ecc_read_subpage()
1413 this->bch_flashlayout0 = BF_BCH_FLASH0LAYOUT0_NBLOCKS(n - 1) | in gpmi_ecc_read_subpage()
1415 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | in gpmi_ecc_read_subpage()
1416 BF_BCH_FLASH0LAYOUT0_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1417 BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(geo->ecc_chunk_size, this); in gpmi_ecc_read_subpage()
1419 this->bch_flashlayout1 = BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size) | in gpmi_ecc_read_subpage()
1420 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | in gpmi_ecc_read_subpage()
1421 BF_BCH_FLASH0LAYOUT1_GF(geo->gf_len, this) | in gpmi_ecc_read_subpage()
1422 BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(geo->ecc_chunk_size, this); in gpmi_ecc_read_subpage()
1424 this->bch = true; in gpmi_ecc_read_subpage()
1430 dev_dbg(this->dev, "page:%d(%d:%d)%d, chunk:(%d:%d), BCH PG size:%d\n", in gpmi_ecc_read_subpage()
1442 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page() local
1443 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page()
1446 dev_dbg(this->dev, "ecc write page.\n"); in gpmi_ecc_write_page()
1448 gpmi_bch_layout_std(this); in gpmi_ecc_write_page()
1449 this->bch = true; in gpmi_ecc_write_page()
1451 memcpy(this->auxiliary_virt, chip->oob_poi, nfc_geo->auxiliary_size); in gpmi_ecc_write_page()
1453 if (this->swap_block_mark) { in gpmi_ecc_write_page()
1458 memcpy(this->data_buffer_dma, buf, mtd->writesize); in gpmi_ecc_write_page()
1459 buf = this->data_buffer_dma; in gpmi_ecc_write_page()
1460 block_mark_swapping(this, this->data_buffer_dma, in gpmi_ecc_write_page()
1461 this->auxiliary_virt); in gpmi_ecc_write_page()
1532 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_oob() local
1549 if (GPMI_IS_MX23(this)) { in gpmi_ecc_read_oob()
1592 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_read_page_raw() local
1593 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_read_page_raw()
1596 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_read_page_raw()
1616 if (this->swap_block_mark) in gpmi_ecc_read_page_raw()
1677 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_ecc_write_page_raw() local
1678 struct bch_geometry *nfc_geo = &this->bch_geometry; in gpmi_ecc_write_page_raw()
1681 u8 *tmp_buf = this->raw_buffer; in gpmi_ecc_write_page_raw()
1737 if (this->swap_block_mark) in gpmi_ecc_write_page_raw()
1757 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_block_markbad() local
1765 column = !GPMI_IS_MX23(this) ? mtd->writesize : 0; in gpmi_block_markbad()
1768 block_mark = this->data_buffer_dma; in gpmi_block_markbad()
1781 static int nand_boot_set_geometry(struct gpmi_nand_data *this) in nand_boot_set_geometry() argument
1783 struct boot_rom_geometry *geometry = &this->rom_geometry; in nand_boot_set_geometry()
1808 static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) in mx23_check_transcription_stamp() argument
1810 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_check_transcription_stamp()
1811 struct device *dev = this->dev; in mx23_check_transcription_stamp()
1812 struct nand_chip *chip = &this->nand; in mx23_check_transcription_stamp()
1863 static int mx23_write_transcription_stamp(struct gpmi_nand_data *this) in mx23_write_transcription_stamp() argument
1865 struct device *dev = this->dev; in mx23_write_transcription_stamp()
1866 struct boot_rom_geometry *rom_geo = &this->rom_geometry; in mx23_write_transcription_stamp()
1867 struct nand_chip *chip = &this->nand; in mx23_write_transcription_stamp()
1929 static int mx23_boot_init(struct gpmi_nand_data *this) in mx23_boot_init() argument
1931 struct device *dev = this->dev; in mx23_boot_init()
1932 struct nand_chip *chip = &this->nand; in mx23_boot_init()
1948 if (mx23_check_transcription_stamp(this)) in mx23_boot_init()
1998 mx23_write_transcription_stamp(this); in mx23_boot_init()
2002 static int nand_boot_init(struct gpmi_nand_data *this) in nand_boot_init() argument
2004 nand_boot_set_geometry(this); in nand_boot_init()
2007 if (GPMI_IS_MX23(this)) in nand_boot_init()
2008 return mx23_boot_init(this); in nand_boot_init()
2012 static int gpmi_set_geometry(struct gpmi_nand_data *this) in gpmi_set_geometry() argument
2017 gpmi_free_dma_buffer(this); in gpmi_set_geometry()
2020 ret = bch_set_geometry(this); in gpmi_set_geometry()
2022 dev_err(this->dev, "Error setting BCH geometry : %d\n", ret); in gpmi_set_geometry()
2027 return gpmi_alloc_dma_buffer(this); in gpmi_set_geometry()
2030 static int gpmi_init_last(struct gpmi_nand_data *this) in gpmi_init_last() argument
2032 struct nand_chip *chip = &this->nand; in gpmi_init_last()
2035 struct bch_geometry *bch_geo = &this->bch_geometry; in gpmi_init_last()
2039 ret = gpmi_set_geometry(this); in gpmi_init_last()
2062 if (GPMI_IS_MX6(this) && in gpmi_init_last()
2073 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nand_attach_chip() local
2079 if (of_property_read_bool(this->dev->of_node, in gpmi_nand_attach_chip()
2081 this->swap_block_mark = false; in gpmi_nand_attach_chip()
2083 dev_dbg(this->dev, "Blockmark swapping %sabled\n", in gpmi_nand_attach_chip()
2084 this->swap_block_mark ? "en" : "dis"); in gpmi_nand_attach_chip()
2086 ret = gpmi_init_last(this); in gpmi_nand_attach_chip()
2095 static struct gpmi_transfer *get_next_transfer(struct gpmi_nand_data *this) in get_next_transfer() argument
2097 struct gpmi_transfer *transfer = &this->transfers[this->ntransfers]; in get_next_transfer()
2099 this->ntransfers++; in get_next_transfer()
2101 if (this->ntransfers == GPMI_MAX_TRANSFERS) in get_next_transfer()
2108 struct gpmi_nand_data *this, u8 cmd, const u8 *addr, int naddr) in gpmi_chain_command() argument
2110 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_command()
2113 int chip = this->nand.cur_cs; in gpmi_chain_command()
2119 | BF_GPMI_CTRL0_CS(chip, this) in gpmi_chain_command()
2120 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_command()
2131 transfer = get_next_transfer(this); in gpmi_chain_command()
2140 dma_map_sg(this->dev, &transfer->sgl, 1, DMA_TO_DEVICE); in gpmi_chain_command()
2150 struct gpmi_nand_data *this) in gpmi_chain_wait_ready() argument
2152 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_wait_ready()
2157 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_wait_ready()
2158 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_wait_ready()
2168 struct gpmi_nand_data *this, void *buf, int raw_len, bool *direct) in gpmi_chain_data_read() argument
2171 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_read()
2175 transfer = get_next_transfer(this); in gpmi_chain_data_read()
2181 *direct = prepare_data_dma(this, buf, raw_len, &transfer->sgl, in gpmi_chain_data_read()
2186 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_read()
2187 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_read()
2191 if (this->bch) { in gpmi_chain_data_read()
2198 pio[5] = this->auxiliary_phys; in gpmi_chain_data_read()
2206 if (!this->bch) in gpmi_chain_data_read()
2215 struct gpmi_nand_data *this, const void *buf, int raw_len) in gpmi_chain_data_write() argument
2217 struct dma_chan *channel = get_dma_chan(this); in gpmi_chain_data_write()
2222 transfer = get_next_transfer(this); in gpmi_chain_data_write()
2228 prepare_data_dma(this, buf, raw_len, &transfer->sgl, DMA_TO_DEVICE); in gpmi_chain_data_write()
2232 | BF_GPMI_CTRL0_CS(this->nand.cur_cs, this) in gpmi_chain_data_write()
2233 | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) in gpmi_chain_data_write()
2237 if (this->bch) { in gpmi_chain_data_write()
2244 pio[5] = this->auxiliary_phys; in gpmi_chain_data_write()
2249 (this->bch ? MXS_DMA_CTRL_WAIT4END : 0)); in gpmi_chain_data_write()
2253 if (!this->bch) in gpmi_chain_data_write()
2266 struct gpmi_nand_data *this = nand_get_controller_data(chip); in gpmi_nfc_exec_op() local
2279 this->ntransfers = 0; in gpmi_nfc_exec_op()
2281 this->transfers[i].direction = DMA_NONE; in gpmi_nfc_exec_op()
2283 ret = pm_runtime_get_sync(this->dev); in gpmi_nfc_exec_op()
2285 pm_runtime_put_noidle(this->dev); in gpmi_nfc_exec_op()
2295 if (this->hw.must_apply_timings) { in gpmi_nfc_exec_op()
2296 this->hw.must_apply_timings = false; in gpmi_nfc_exec_op()
2297 ret = gpmi_nfc_apply_timings(this); in gpmi_nfc_exec_op()
2302 dev_dbg(this->dev, "%s: %d instructions\n", __func__, op->ninstrs); in gpmi_nfc_exec_op()
2311 desc = gpmi_chain_wait_ready(this); in gpmi_nfc_exec_op()
2324 desc = gpmi_chain_command(this, cmd, NULL, 0); in gpmi_nfc_exec_op()
2328 desc = gpmi_chain_command(this, cmd, instr->ctx.addr.addrs, in gpmi_nfc_exec_op()
2336 desc = gpmi_chain_data_write(this, buf_write, buf_len); in gpmi_nfc_exec_op()
2346 desc = gpmi_chain_data_read(this, buf_read, buf_len, in gpmi_nfc_exec_op()
2357 dev_dbg(this->dev, "%s setup done\n", __func__); in gpmi_nfc_exec_op()
2360 dev_err(this->dev, "Multiple data instructions not supported\n"); in gpmi_nfc_exec_op()
2365 if (this->bch) { in gpmi_nfc_exec_op()
2366 writel(this->bch_flashlayout0, in gpmi_nfc_exec_op()
2367 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT0); in gpmi_nfc_exec_op()
2368 writel(this->bch_flashlayout1, in gpmi_nfc_exec_op()
2369 this->resources.bch_regs + HW_BCH_FLASH0LAYOUT1); in gpmi_nfc_exec_op()
2373 desc->callback_param = this; in gpmi_nfc_exec_op()
2374 dma_completion = &this->dma_done; in gpmi_nfc_exec_op()
2379 if (this->bch && buf_read) { in gpmi_nfc_exec_op()
2381 this->resources.bch_regs + HW_BCH_CTRL_SET); in gpmi_nfc_exec_op()
2382 bch_completion = &this->bch_done; in gpmi_nfc_exec_op()
2387 dma_async_issue_pending(get_dma_chan(this)); in gpmi_nfc_exec_op()
2391 dev_err(this->dev, "DMA timeout, last DMA\n"); in gpmi_nfc_exec_op()
2392 gpmi_dump_info(this); in gpmi_nfc_exec_op()
2397 if (this->bch && buf_read) { in gpmi_nfc_exec_op()
2400 dev_err(this->dev, "BCH timeout, last DMA\n"); in gpmi_nfc_exec_op()
2401 gpmi_dump_info(this); in gpmi_nfc_exec_op()
2408 this->resources.bch_regs + HW_BCH_CTRL_CLR); in gpmi_nfc_exec_op()
2409 gpmi_clear_bch(this); in gpmi_nfc_exec_op()
2414 for (i = 0; i < this->ntransfers; i++) { in gpmi_nfc_exec_op()
2415 struct gpmi_transfer *transfer = &this->transfers[i]; in gpmi_nfc_exec_op()
2418 dma_unmap_sg(this->dev, &transfer->sgl, 1, in gpmi_nfc_exec_op()
2423 memcpy(buf_read, this->data_buffer_dma, in gpmi_nfc_exec_op()
2424 gpmi_raw_len_to_len(this, buf_len)); in gpmi_nfc_exec_op()
2426 this->bch = false; in gpmi_nfc_exec_op()
2429 pm_runtime_mark_last_busy(this->dev); in gpmi_nfc_exec_op()
2430 pm_runtime_put_autosuspend(this->dev); in gpmi_nfc_exec_op()
2441 static int gpmi_nand_init(struct gpmi_nand_data *this) in gpmi_nand_init() argument
2443 struct nand_chip *chip = &this->nand; in gpmi_nand_init()
2449 mtd->dev.parent = this->dev; in gpmi_nand_init()
2452 nand_set_controller_data(chip, this); in gpmi_nand_init()
2453 nand_set_flash_node(chip, this->pdev->dev.of_node); in gpmi_nand_init()
2459 this->swap_block_mark = !GPMI_IS_MX23(this); in gpmi_nand_init()
2465 this->bch_geometry.payload_size = 1024; in gpmi_nand_init()
2466 this->bch_geometry.auxiliary_size = 128; in gpmi_nand_init()
2467 ret = gpmi_alloc_dma_buffer(this); in gpmi_nand_init()
2471 nand_controller_init(&this->base); in gpmi_nand_init()
2472 this->base.ops = &gpmi_nand_controller_ops; in gpmi_nand_init()
2473 chip->controller = &this->base; in gpmi_nand_init()
2475 ret = nand_scan(chip, GPMI_IS_MX6(this) ? 2 : 1); in gpmi_nand_init()
2479 ret = nand_boot_init(this); in gpmi_nand_init()
2494 gpmi_free_dma_buffer(this); in gpmi_nand_init()
2520 struct gpmi_nand_data *this; in gpmi_nand_probe() local
2524 this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL); in gpmi_nand_probe()
2525 if (!this) in gpmi_nand_probe()
2530 this->devdata = of_id->data; in gpmi_nand_probe()
2536 platform_set_drvdata(pdev, this); in gpmi_nand_probe()
2537 this->pdev = pdev; in gpmi_nand_probe()
2538 this->dev = &pdev->dev; in gpmi_nand_probe()
2540 ret = acquire_resources(this); in gpmi_nand_probe()
2544 ret = __gpmi_enable_clk(this, true); in gpmi_nand_probe()
2554 ret = gpmi_init(this); in gpmi_nand_probe()
2558 ret = gpmi_nand_init(this); in gpmi_nand_probe()
2565 dev_info(this->dev, "driver registered.\n"); in gpmi_nand_probe()
2572 release_resources(this); in gpmi_nand_probe()
2580 struct gpmi_nand_data *this = platform_get_drvdata(pdev); in gpmi_nand_remove() local
2581 struct nand_chip *chip = &this->nand; in gpmi_nand_remove()
2590 gpmi_free_dma_buffer(this); in gpmi_nand_remove()
2591 release_resources(this); in gpmi_nand_remove()
2598 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_pm_suspend() local
2600 release_dma_channels(this); in gpmi_pm_suspend()
2606 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_pm_resume() local
2609 ret = acquire_dma_channels(this); in gpmi_pm_resume()
2614 ret = gpmi_init(this); in gpmi_pm_resume()
2616 dev_err(this->dev, "Error setting GPMI : %d\n", ret); in gpmi_pm_resume()
2621 if (this->hw.clk_rate) in gpmi_pm_resume()
2622 this->hw.must_apply_timings = true; in gpmi_pm_resume()
2625 ret = bch_set_geometry(this); in gpmi_pm_resume()
2627 dev_err(this->dev, "Error setting BCH : %d\n", ret); in gpmi_pm_resume()
2637 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_suspend() local
2639 return __gpmi_enable_clk(this, false); in gpmi_runtime_suspend()
2644 struct gpmi_nand_data *this = dev_get_drvdata(dev); in gpmi_runtime_resume() local
2646 return __gpmi_enable_clk(this, true); in gpmi_runtime_resume()