Lines Matching +full:cdr +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Handles the M-Systems DiskOnChip G3 chip
32 * As no specification is available from M-Systems/Sandisk, this drivers lacks
34 * - IPL write
40 * - a 1 byte Hamming code stored in the OOB for each page
41 * - a 7 bytes BCH code stored in the OOB for each page
43 * - BCH is in GF(2^14)
44 * - BCH is over data of 520 bytes (512 page + 7 page_info bytes
46 * - BCH can correct up to 4 bits (t = 4)
47 * - BCH syndroms are calculated in hardware, and checked in hardware as well
53 MODULE_PARM_DESC(reliable_mode, "Set the docg3 mode (0=normal MLC, 1=fast, "
54 "2=reliable) : MLC normal operations are in normal mode");
60 return -ERANGE; in docg3_ooblayout_ecc()
62 /* byte 7 is Hamming ECC, byte 8-14 are BCH ECC */ in docg3_ooblayout_ecc()
63 oobregion->offset = 7; in docg3_ooblayout_ecc()
64 oobregion->length = 8; in docg3_ooblayout_ecc()
73 return -ERANGE; in docg3_ooblayout_free()
77 oobregion->offset = 0; in docg3_ooblayout_free()
78 oobregion->length = 7; in docg3_ooblayout_free()
80 oobregion->offset = 15; in docg3_ooblayout_free()
81 oobregion->length = 1; in docg3_ooblayout_free()
94 u8 val = readb(docg3->cascade->base + reg); in doc_readb()
102 u16 val = readw(docg3->cascade->base + reg); in doc_readw()
110 writeb(val, docg3->cascade->base + reg); in doc_writeb()
116 writew(val, docg3->cascade->base + reg); in doc_writew()
158 * doc_delay - delay docg3 operations
200 } while (!doc_is_ready(docg3) && maxWaitCycles--); in doc_wait_ready()
205 return -EIO; in doc_wait_ready()
218 doc_dbg("doc_reset_seq() -> isReady=%s\n", ret ? "false" : "true"); in doc_reset_seq()
223 * doc_read_data_area - Read data from data area
234 int i, cdr, len4; in doc_read_data_area() local
239 cdr = len & 0x1; in doc_read_data_area()
240 len4 = len - cdr; in doc_read_data_area()
253 if (cdr) { in doc_read_data_area()
258 for (i = 0; i < cdr; i++) { in doc_read_data_area()
269 * doc_write_data_area - Write data into data area
278 int i, cdr, len4; in doc_write_data_area() local
283 cdr = len & 0x3; in doc_write_data_area()
284 len4 = len - cdr; in doc_write_data_area()
294 for (i = 0; i < cdr; i++) { in doc_write_data_area()
303 * doc_set_reliable_mode - Sets the flash to normal or reliable data mode
306 * The reliable data mode is a bit slower than the fast mode, but less errors
307 * occur. Entering the reliable mode cannot be done without entering the fast
308 * mode first.
310 * In reliable mode, pages 2*n and 2*n+1 are clones. Writing to page 0 of blocks
321 doc_dbg("doc_set_reliable_mode(%s)\n", strmode[docg3->reliable]); in doc_set_reliable_mode()
322 switch (docg3->reliable) { in doc_set_reliable_mode()
335 doc_err("doc_set_reliable_mode(): invalid mode\n"); in doc_set_reliable_mode()
342 * doc_set_asic_mode - Set the ASIC mode
344 * @mode: the mode
347 * - RESET: all registers are zeroed
348 * - NORMAL: receives and handles commands
349 * - POWERDOWN: minimal poweruse, flash parts shut off
351 static void doc_set_asic_mode(struct docg3 *docg3, u8 mode) in doc_set_asic_mode() argument
358 mode |= DOC_ASICMODE_MDWREN; in doc_set_asic_mode()
359 doc_dbg("doc_set_asic_mode(%02x)\n", mode); in doc_set_asic_mode()
360 doc_writeb(docg3, mode, DOC_ASICMODE); in doc_set_asic_mode()
361 doc_writeb(docg3, ~mode, DOC_ASICMODECONFIRM); in doc_set_asic_mode()
366 * doc_set_device_id - Sets the devices id for cascaded G3 chips
387 * doc_set_extra_page_mode - Change flash page layout
393 * mode must be input to the flash ASIC.
395 * Returns 0 if no error occurred, -EIO else.
408 return -EIO; in doc_set_extra_page_mode()
414 * doc_setup_addr_sector - Setup blocks/page/ofs address for one plane
428 * doc_setup_writeaddr_sector - Setup blocks/page/ofs address for one plane
445 * doc_read_seek - Set both flash planes to the specified block, page for reading
495 * doc_write_seek - Set both flash planes to the specified block, page for writing
548 * doc_read_page_ecc_init - Initialize hardware ECC engine
555 * Return 0 if succeeded, -EIO on error
569 * doc_write_page_ecc_init - Initialize hardware BCH ECC engine
576 * Return 0 if succeeded, -EIO on error
590 * doc_ecc_disable - Disable Hamming and BCH ECC hardware calculator
603 * doc_hamming_ecc_init - Initialize hardware Hamming ECC engine
621 * doc_ecc_bch_fix_data - Fix if need be read data from flash
640 * Returns number of fixed bits (0, 1, 2, 3, 4) or -EBADMSG if too many bit
650 numerrs = bch_decode(docg3->cascade->bch, NULL, in doc_ecc_bch_fix_data()
653 BUG_ON(numerrs == -EINVAL); in doc_ecc_bch_fix_data()
658 errorpos[i] = (errorpos[i] & ~7) | (7 - (errorpos[i] & 7)); in doc_ecc_bch_fix_data()
670 * doc_read_page_prepare - Prepares reading data from a flash page
678 * - tell ASIC to map the flash pages
679 * - tell ASIC to be in read mode
690 * - one read of 512 bytes at offset 0
691 * - one read of 512 bytes at offset 512 + 16
693 * Returns 0 if successful, -EIO if a read error occurred.
705 return -EINVAL; in doc_read_page_prepare()
707 doc_set_device_id(docg3, docg3->device_id); in doc_read_page_prepare()
724 offset -= 2 * DOC_LAYOUT_PAGE_SIZE; in doc_read_page_prepare()
735 return -EIO; in doc_read_page_prepare()
739 * doc_read_page_getbytes - Reads bytes from a prepared page
758 doc_read_data_area(docg3, buf ? buf + 1 : buf, len - 1, 0); in doc_read_page_getbytes()
767 * doc_write_page_putbytes - Writes bytes into a prepared page
781 * doc_get_bch_hw_ecc - Get hardware calculated BCH ECC
794 * doc_page_finish - Ends reading/writing of a flash page
804 * doc_read_page_finish - Ends reading of a flash page
818 * calc_block_sector - Calculate blocks, pages and ofs.
825 * @reliable: 0 if docg3 in normal mode, 1 if docg3 in fast mode, 2 if docg3 in
826 * reliable mode.
828 * The calculation is based on the reliable/normal mode. In normal mode, the 64
829 * pages of a block are available. In reliable mode, as pages 2*n and 2*n+1 are
855 * doc_read_oob - Read out of band bytes from flash
863 * Returns 0 if read successful, of -EIO, -EINVAL if an error occurred
868 struct docg3 *docg3 = mtd->priv; in doc_read_oob()
870 u8 *oobbuf = ops->oobbuf; in doc_read_oob()
871 u8 *buf = ops->datbuf; in doc_read_oob()
878 len = ops->len; in doc_read_oob()
882 ooblen = ops->ooblen; in doc_read_oob()
886 if (oobbuf && ops->mode == MTD_OPS_PLACE_OOB) in doc_read_oob()
887 oobbuf += ops->ooboffs; in doc_read_oob()
889 doc_dbg("doc_read_oob(from=%lld, mode=%d, data=(%p:%zu), oob=(%p:%zu))\n", in doc_read_oob()
890 from, ops->mode, buf, len, oobbuf, ooblen); in doc_read_oob()
892 return -EINVAL; in doc_read_oob()
894 ops->oobretlen = 0; in doc_read_oob()
895 ops->retlen = 0; in doc_read_oob()
898 mutex_lock(&docg3->cascade->lock); in doc_read_oob()
899 old_stats = mtd->ecc_stats; in doc_read_oob()
901 calc_block_sector(from - skip, &block0, &block1, &page, &ofs, in doc_read_oob()
902 docg3->reliable); in doc_read_oob()
903 nbdata = min_t(size_t, len, DOC_LAYOUT_PAGE_SIZE - skip); in doc_read_oob()
918 DOC_LAYOUT_PAGE_SIZE - nbdata - skip, in doc_read_oob()
923 doc_read_page_getbytes(docg3, DOC_LAYOUT_OOB_SIZE - nboob, in doc_read_oob()
930 doc_dbg("OOB - INFO: %*phC\n", 7, oobbuf); in doc_read_oob()
931 doc_dbg("OOB - HAMMING: %02x\n", oobbuf[7]); in doc_read_oob()
932 doc_dbg("OOB - BCH_ECC: %*phC\n", 7, oobbuf + 8); in doc_read_oob()
933 doc_dbg("OOB - UNUSED: %02x\n", oobbuf[15]); in doc_read_oob()
938 ret = -EIO; in doc_read_oob()
945 (ops->mode != MTD_OPS_RAW) && in doc_read_oob()
949 mtd->ecc_stats.failed++; in doc_read_oob()
950 ret = -EBADMSG; in doc_read_oob()
953 mtd->ecc_stats.corrected += ret; in doc_read_oob()
960 ops->retlen += nbdata; in doc_read_oob()
961 ops->oobretlen += nboob; in doc_read_oob()
964 len -= nbdata; in doc_read_oob()
965 ooblen -= nboob; in doc_read_oob()
971 if (ops->stats) { in doc_read_oob()
972 ops->stats->uncorrectable_errors += in doc_read_oob()
973 mtd->ecc_stats.failed - old_stats.failed; in doc_read_oob()
974 ops->stats->corrected_bitflips += in doc_read_oob()
975 mtd->ecc_stats.corrected - old_stats.corrected; in doc_read_oob()
977 mutex_unlock(&docg3->cascade->lock); in doc_read_oob()
988 u_char *buf = docg3->bbt; in doc_reload_bbt()
990 nbpages = DIV_ROUND_UP(docg3->max_block + 1, 8 * DOC_LAYOUT_PAGE_SIZE); in doc_reload_bbt()
1007 * doc_block_isbad - Checks whether a block is good or not
1015 struct docg3 *docg3 = mtd->priv; in doc_block_isbad()
1019 docg3->reliable); in doc_block_isbad()
1025 if (block1 > docg3->max_block) in doc_block_isbad()
1026 return -EINVAL; in doc_block_isbad()
1028 is_good = docg3->bbt[block0 >> 3] & (1 << (block0 & 0x7)); in doc_block_isbad()
1034 * doc_get_erase_count - Get block erase count
1041 * Returns The number of erases, or -EINVAL or -EIO on error.
1051 return -EINVAL;
1052 calc_block_sector(from, &block0, &block1, &page, &ofs, docg3->reliable);
1053 if (block1 > docg3->max_block)
1054 return -EINVAL;
1066 return -EIO;
1077 * doc_get_op_status - get erase/write operation status
1098 * doc_write_erase_wait_status - wait for write or erase completion
1104 * Returns 0 if erase successful, -EIO if erase/write issue, -ETIMEOUT if
1115 ret = -EAGAIN; in doc_write_erase_wait_status()
1123 ret = -EIO; in doc_write_erase_wait_status()
1132 * doc_erase_block - Erase a couple of blocks
1139 * Returns 0 if erase successful, -EIO if erase issue, -ETIMEOUT if chip not
1149 return -EIO; in doc_erase_block()
1167 return -EIO; in doc_erase_block()
1174 * doc_erase - Erase a portion of the chip
1181 * Returns 0 if erase successful, -EINVAL if addressing error, -EIO if erase
1186 struct docg3 *docg3 = mtd->priv; in doc_erase()
1190 doc_dbg("doc_erase(from=%lld, len=%lld\n", info->addr, info->len); in doc_erase()
1192 calc_block_sector(info->addr + info->len, &block0, &block1, &page, in doc_erase()
1193 &ofs, docg3->reliable); in doc_erase()
1194 if (info->addr + info->len > mtd->size || page || ofs) in doc_erase()
1195 return -EINVAL; in doc_erase()
1197 calc_block_sector(info->addr, &block0, &block1, &page, &ofs, in doc_erase()
1198 docg3->reliable); in doc_erase()
1199 mutex_lock(&docg3->cascade->lock); in doc_erase()
1200 doc_set_device_id(docg3, docg3->device_id); in doc_erase()
1202 for (len = info->len; !ret && len > 0; len -= mtd->erasesize) { in doc_erase()
1207 mutex_unlock(&docg3->cascade->lock); in doc_erase()
1213 * doc_write_page - Write a single page to the chip
1221 * BCH computations. If 1, only bytes 0-7 and byte 15 are taken,
1229 * Returns 0 if write successful, -EIO if write error, -EAGAIN if timeout
1238 calc_block_sector(to, &block0, &block1, &page, &ofs, docg3->reliable); in doc_write_page()
1240 doc_set_device_id(docg3, docg3->device_id); in doc_write_page()
1292 * doc_guess_autoecc - Guess autoecc mode from mbd_oob_ops
1295 * Returns 0 or 1 if success, -EINVAL if invalid oob mode
1301 switch (ops->mode) { in doc_guess_autoecc()
1310 autoecc = -EINVAL; in doc_guess_autoecc()
1316 * doc_fill_autooob - Fill a 16 bytes OOB from 8 non-ECC bytes
1318 * @oobsrc: the source 8 bytes non-ECC OOB buffer
1328 * doc_backup_oob - Backup OOB into docg3 structure
1342 * Returns 0 if success, -EINVAL if ops content invalid
1347 int ooblen = ops->ooblen, autoecc; in doc_backup_oob()
1350 return -EINVAL; in doc_backup_oob()
1355 docg3->oob_write_ofs = to; in doc_backup_oob()
1356 docg3->oob_autoecc = autoecc; in doc_backup_oob()
1357 if (ops->mode == MTD_OPS_AUTO_OOB) { in doc_backup_oob()
1358 doc_fill_autooob(docg3->oob_write_buf, ops->oobbuf); in doc_backup_oob()
1359 ops->oobretlen = 8; in doc_backup_oob()
1361 memcpy(docg3->oob_write_buf, ops->oobbuf, DOC_LAYOUT_OOB_SIZE); in doc_backup_oob()
1362 ops->oobretlen = DOC_LAYOUT_OOB_SIZE; in doc_backup_oob()
1368 * doc_write_oob - Write out of band bytes to flash
1385 struct docg3 *docg3 = mtd->priv; in doc_write_oob()
1387 u8 *oobbuf = ops->oobbuf; in doc_write_oob()
1388 u8 *buf = ops->datbuf; in doc_write_oob()
1393 len = ops->len; in doc_write_oob()
1397 ooblen = ops->ooblen; in doc_write_oob()
1401 if (oobbuf && ops->mode == MTD_OPS_PLACE_OOB) in doc_write_oob()
1402 oobbuf += ops->ooboffs; in doc_write_oob()
1404 doc_dbg("doc_write_oob(from=%lld, mode=%d, data=(%p:%zu), oob=(%p:%zu))\n", in doc_write_oob()
1405 ofs, ops->mode, buf, len, oobbuf, ooblen); in doc_write_oob()
1406 switch (ops->mode) { in doc_write_oob()
1409 oobdelta = mtd->oobsize; in doc_write_oob()
1412 oobdelta = mtd->oobavail; in doc_write_oob()
1415 return -EINVAL; in doc_write_oob()
1419 return -EINVAL; in doc_write_oob()
1422 return -EINVAL; in doc_write_oob()
1424 ops->oobretlen = 0; in doc_write_oob()
1425 ops->retlen = 0; in doc_write_oob()
1428 return -EINVAL; in doc_write_oob()
1436 mutex_lock(&docg3->cascade->lock); in doc_write_oob()
1439 if (ofs == docg3->oob_write_ofs) in doc_write_oob()
1440 memcpy(oob, docg3->oob_write_buf, DOC_LAYOUT_OOB_SIZE); in doc_write_oob()
1441 else if (ooblen > 0 && ops->mode == MTD_OPS_AUTO_OOB) in doc_write_oob()
1448 len -= DOC_LAYOUT_PAGE_SIZE; in doc_write_oob()
1452 ooblen -= oobdelta; in doc_write_oob()
1453 ops->oobretlen += oobdelta; in doc_write_oob()
1455 ops->retlen += DOC_LAYOUT_PAGE_SIZE; in doc_write_oob()
1459 mutex_unlock(&docg3->cascade->lock); in doc_write_oob()
1469 floor = attr->attr.name[1] - '0'; in sysfs_dev2docg3()
1473 return docg3_floors[floor]->priv; in sysfs_dev2docg3()
1482 mutex_lock(&docg3->cascade->lock); in dps0_is_key_locked()
1483 doc_set_device_id(docg3, docg3->device_id); in dps0_is_key_locked()
1486 mutex_unlock(&docg3->cascade->lock); in dps0_is_key_locked()
1497 mutex_lock(&docg3->cascade->lock); in dps1_is_key_locked()
1498 doc_set_device_id(docg3, docg3->device_id); in dps1_is_key_locked()
1501 mutex_unlock(&docg3->cascade->lock); in dps1_is_key_locked()
1514 return -EINVAL; in dps0_insert_key()
1516 mutex_lock(&docg3->cascade->lock); in dps0_insert_key()
1517 doc_set_device_id(docg3, docg3->device_id); in dps0_insert_key()
1521 mutex_unlock(&docg3->cascade->lock); in dps0_insert_key()
1533 return -EINVAL; in dps1_insert_key()
1535 mutex_lock(&docg3->cascade->lock); in dps1_insert_key()
1536 doc_set_device_id(docg3, docg3->device_id); in dps1_insert_key()
1540 mutex_unlock(&docg3->cascade->lock); in dps1_insert_key()
1558 struct device *dev = &pdev->dev; in doc_register_sysfs()
1564 floor < DOC_MAX_NBFLOORS && cascade->floors[floor]; in doc_register_sysfs()
1577 while (--i >= 0) in doc_register_sysfs()
1580 } while (--floor >= 0); in doc_register_sysfs()
1588 struct device *dev = &pdev->dev; in doc_unregister_sysfs()
1591 for (floor = 0; floor < DOC_MAX_NBFLOORS && cascade->floors[floor]; in doc_unregister_sysfs()
1602 struct docg3 *docg3 = s->private; in flashcontrol_show()
1606 mutex_lock(&docg3->cascade->lock); in flashcontrol_show()
1608 mutex_unlock(&docg3->cascade->lock); in flashcontrol_show()
1612 fctrl & DOC_CTRL_VIOLATION ? "protocol violation" : "-", in flashcontrol_show()
1614 fctrl & DOC_CTRL_PROTECTION_ERROR ? "protection error" : "-", in flashcontrol_show()
1615 fctrl & DOC_CTRL_SEQUENCE_ERROR ? "sequence error" : "-", in flashcontrol_show()
1624 struct docg3 *docg3 = s->private; in asic_mode_show()
1626 int pctrl, mode; in asic_mode_show() local
1628 mutex_lock(&docg3->cascade->lock); in asic_mode_show()
1630 mode = pctrl & 0x03; in asic_mode_show()
1631 mutex_unlock(&docg3->cascade->lock); in asic_mode_show()
1634 "%04x : RAM_WE=%d,RSTIN_RESET=%d,BDETCT_RESET=%d,WRITE_ENABLE=%d,POWERDOWN=%d,MODE=%d%d (", in asic_mode_show()
1641 mode >> 1, mode & 0x1); in asic_mode_show()
1643 switch (mode) { in asic_mode_show()
1661 struct docg3 *docg3 = s->private; in device_id_show()
1664 mutex_lock(&docg3->cascade->lock); in device_id_show()
1666 mutex_unlock(&docg3->cascade->lock); in device_id_show()
1675 struct docg3 *docg3 = s->private; in protection_show()
1678 mutex_lock(&docg3->cascade->lock); in protection_show()
1686 mutex_unlock(&docg3->cascade->lock); in protection_show()
1707 …seq_printf(s, "DPS0 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%… in protection_show()
1714 …seq_printf(s, "DPS1 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%… in protection_show()
1727 struct dentry *root = floor->dbg.dfs_dir; in doc_dbg_register()
1728 struct docg3 *docg3 = floor->priv; in doc_dbg_register()
1733 dev_warn(floor->dev.parent, in doc_dbg_register()
1749 * doc_set_driver_info - Fill the mtd_info structure and docg3 structure
1755 struct docg3 *docg3 = mtd->priv; in doc_set_driver_info()
1759 docg3->if_cfg = (cfg & DOC_CONF_IF_CFG ? 1 : 0); in doc_set_driver_info()
1760 docg3->reliable = reliable_mode; in doc_set_driver_info()
1764 mtd->name = devm_kasprintf(docg3->dev, GFP_KERNEL, "docg3.%d", in doc_set_driver_info()
1765 docg3->device_id); in doc_set_driver_info()
1766 if (!mtd->name) in doc_set_driver_info()
1767 return -ENOMEM; in doc_set_driver_info()
1768 docg3->max_block = 2047; in doc_set_driver_info()
1771 mtd->type = MTD_NANDFLASH; in doc_set_driver_info()
1772 mtd->flags = MTD_CAP_NANDFLASH; in doc_set_driver_info()
1773 mtd->size = (docg3->max_block + 1) * DOC_LAYOUT_BLOCK_SIZE; in doc_set_driver_info()
1774 if (docg3->reliable == 2) in doc_set_driver_info()
1775 mtd->size /= 2; in doc_set_driver_info()
1776 mtd->erasesize = DOC_LAYOUT_BLOCK_SIZE * DOC_LAYOUT_NBPLANES; in doc_set_driver_info()
1777 if (docg3->reliable == 2) in doc_set_driver_info()
1778 mtd->erasesize /= 2; in doc_set_driver_info()
1779 mtd->writebufsize = mtd->writesize = DOC_LAYOUT_PAGE_SIZE; in doc_set_driver_info()
1780 mtd->oobsize = DOC_LAYOUT_OOB_SIZE; in doc_set_driver_info()
1781 mtd->_erase = doc_erase; in doc_set_driver_info()
1782 mtd->_read_oob = doc_read_oob; in doc_set_driver_info()
1783 mtd->_write_oob = doc_write_oob; in doc_set_driver_info()
1784 mtd->_block_isbad = doc_block_isbad; in doc_set_driver_info()
1786 mtd->oobavail = 8; in doc_set_driver_info()
1787 mtd->ecc_strength = DOC_ECC_BCH_T; in doc_set_driver_info()
1793 * doc_probe_device - Check if a device is available
1812 ret = -ENOMEM; in doc_probe_device()
1819 mtd->priv = docg3; in doc_probe_device()
1820 mtd->dev.parent = dev; in doc_probe_device()
1821 bbt_nbpages = DIV_ROUND_UP(docg3->max_block + 1, in doc_probe_device()
1823 docg3->bbt = kcalloc(DOC_LAYOUT_PAGE_SIZE, bbt_nbpages, GFP_KERNEL); in doc_probe_device()
1824 if (!docg3->bbt) in doc_probe_device()
1827 docg3->dev = dev; in doc_probe_device()
1828 docg3->device_id = floor; in doc_probe_device()
1829 docg3->cascade = cascade; in doc_probe_device()
1830 doc_set_device_id(docg3, docg3->device_id); in doc_probe_device()
1846 docg3->cascade->base, floor); in doc_probe_device()
1862 kfree(docg3->bbt); in doc_probe_device()
1872 * doc_release_device - Release a docg3 floor
1877 struct docg3 *docg3 = mtd->priv; in doc_release_device()
1880 kfree(docg3->bbt); in doc_release_device()
1886 * docg3_resume - Awakens docg3 floor
1899 docg3_floors = cascade->floors; in docg3_resume()
1901 docg3 = mtd->priv; in docg3_resume()
1910 * docg3_suspend - Put in low power mode the docg3 floor
1916 * Returns 0 if suspend succeeded, -EIO if chip refused suspend
1927 docg3_floors = cascade->floors; in docg3_suspend()
1932 docg3 = mtd->priv; in docg3_suspend()
1951 return -EIO; in docg3_suspend()
1956 docg3 = mtd->priv; in docg3_suspend()
1962 * docg3_probe - Probe the IO space for a DiskOnChip G3 chip
1968 * Returns 0 on success, -ENOMEM, -ENXIO on error
1972 struct device *dev = &pdev->dev; in docg3_probe()
1979 ret = -ENXIO; in docg3_probe()
1986 ret = -ENOMEM; in docg3_probe()
1987 base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE); in docg3_probe()
1997 cascade->base = base; in docg3_probe()
1998 mutex_init(&cascade->lock); in docg3_probe()
1999 cascade->bch = bch_init(DOC_ECC_BCH_M, DOC_ECC_BCH_T, in docg3_probe()
2001 if (!cascade->bch) in docg3_probe()
2016 cascade->floors[floor] = mtd; in docg3_probe()
2022 doc_dbg_register(cascade->floors[floor]); in docg3_probe()
2033 ret = -ENODEV; in docg3_probe()
2036 bch_free(cascade->bch); in docg3_probe()
2038 if (cascade->floors[floor]) in docg3_probe()
2039 doc_release_device(cascade->floors[floor]); in docg3_probe()
2044 * docg3_release - Release the driver
2052 struct docg3 *docg3 = cascade->floors[0]->priv; in docg3_release()
2057 if (cascade->floors[floor]) in docg3_release()
2058 doc_release_device(cascade->floors[floor]); in docg3_release()
2060 bch_free(docg3->cascade->bch); in docg3_release()
2065 { .compatible = "m-systems,diskonchip-g3" },