| .. | .. |
|---|
| 136 | 136 | void (*irq_control)(struct mxc_nand_host *, int); |
|---|
| 137 | 137 | u32 (*get_ecc_status)(struct mxc_nand_host *); |
|---|
| 138 | 138 | const struct mtd_ooblayout_ops *ooblayout; |
|---|
| 139 | | - void (*select_chip)(struct mtd_info *mtd, int chip); |
|---|
| 140 | | - int (*setup_data_interface)(struct mtd_info *mtd, int csline, |
|---|
| 141 | | - const struct nand_data_interface *conf); |
|---|
| 139 | + void (*select_chip)(struct nand_chip *chip, int cs); |
|---|
| 140 | + int (*setup_interface)(struct nand_chip *chip, int csline, |
|---|
| 141 | + const struct nand_interface_config *conf); |
|---|
| 142 | 142 | void (*enable_hwecc)(struct nand_chip *chip, bool enable); |
|---|
| 143 | 143 | |
|---|
| 144 | 144 | /* |
|---|
| .. | .. |
|---|
| 669 | 669 | struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 670 | 670 | uint16_t config1; |
|---|
| 671 | 671 | |
|---|
| 672 | | - if (chip->ecc.mode != NAND_ECC_HW) |
|---|
| 672 | + if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST) |
|---|
| 673 | 673 | return; |
|---|
| 674 | 674 | |
|---|
| 675 | 675 | config1 = readw(NFC_V1_V2_CONFIG1); |
|---|
| .. | .. |
|---|
| 687 | 687 | struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 688 | 688 | uint32_t config2; |
|---|
| 689 | 689 | |
|---|
| 690 | | - if (chip->ecc.mode != NAND_ECC_HW) |
|---|
| 690 | + if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST) |
|---|
| 691 | 691 | return; |
|---|
| 692 | 692 | |
|---|
| 693 | 693 | config2 = readl(NFC_V3_CONFIG2); |
|---|
| .. | .. |
|---|
| 701 | 701 | } |
|---|
| 702 | 702 | |
|---|
| 703 | 703 | /* This functions is used by upper layer to checks if device is ready */ |
|---|
| 704 | | -static int mxc_nand_dev_ready(struct mtd_info *mtd) |
|---|
| 704 | +static int mxc_nand_dev_ready(struct nand_chip *chip) |
|---|
| 705 | 705 | { |
|---|
| 706 | 706 | /* |
|---|
| 707 | 707 | * NFC handles R/B internally. Therefore, this function |
|---|
| .. | .. |
|---|
| 816 | 816 | return max_bitflips; |
|---|
| 817 | 817 | } |
|---|
| 818 | 818 | |
|---|
| 819 | | -static int mxc_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 820 | | - uint8_t *buf, int oob_required, int page) |
|---|
| 819 | +static int mxc_nand_read_page(struct nand_chip *chip, uint8_t *buf, |
|---|
| 820 | + int oob_required, int page) |
|---|
| 821 | 821 | { |
|---|
| 822 | 822 | struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 823 | 823 | void *oob_buf; |
|---|
| .. | .. |
|---|
| 830 | 830 | return host->devtype_data->read_page(chip, buf, oob_buf, 1, page); |
|---|
| 831 | 831 | } |
|---|
| 832 | 832 | |
|---|
| 833 | | -static int mxc_nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 834 | | - uint8_t *buf, int oob_required, int page) |
|---|
| 833 | +static int mxc_nand_read_page_raw(struct nand_chip *chip, uint8_t *buf, |
|---|
| 834 | + int oob_required, int page) |
|---|
| 835 | 835 | { |
|---|
| 836 | 836 | struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 837 | 837 | void *oob_buf; |
|---|
| .. | .. |
|---|
| 844 | 844 | return host->devtype_data->read_page(chip, buf, oob_buf, 0, page); |
|---|
| 845 | 845 | } |
|---|
| 846 | 846 | |
|---|
| 847 | | -static int mxc_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 848 | | - int page) |
|---|
| 847 | +static int mxc_nand_read_oob(struct nand_chip *chip, int page) |
|---|
| 849 | 848 | { |
|---|
| 850 | 849 | struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 851 | 850 | |
|---|
| .. | .. |
|---|
| 874 | 873 | return 0; |
|---|
| 875 | 874 | } |
|---|
| 876 | 875 | |
|---|
| 877 | | -static int mxc_nand_write_page_ecc(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 878 | | - const uint8_t *buf, int oob_required, |
|---|
| 879 | | - int page) |
|---|
| 876 | +static int mxc_nand_write_page_ecc(struct nand_chip *chip, const uint8_t *buf, |
|---|
| 877 | + int oob_required, int page) |
|---|
| 880 | 878 | { |
|---|
| 881 | 879 | return mxc_nand_write_page(chip, buf, true, page); |
|---|
| 882 | 880 | } |
|---|
| 883 | 881 | |
|---|
| 884 | | -static int mxc_nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 885 | | - const uint8_t *buf, int oob_required, int page) |
|---|
| 882 | +static int mxc_nand_write_page_raw(struct nand_chip *chip, const uint8_t *buf, |
|---|
| 883 | + int oob_required, int page) |
|---|
| 886 | 884 | { |
|---|
| 887 | 885 | return mxc_nand_write_page(chip, buf, false, page); |
|---|
| 888 | 886 | } |
|---|
| 889 | 887 | |
|---|
| 890 | | -static int mxc_nand_write_oob(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 891 | | - int page) |
|---|
| 888 | +static int mxc_nand_write_oob(struct nand_chip *chip, int page) |
|---|
| 892 | 889 | { |
|---|
| 890 | + struct mtd_info *mtd = nand_to_mtd(chip); |
|---|
| 893 | 891 | struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 894 | 892 | |
|---|
| 895 | 893 | memset(host->data_buf, 0xff, mtd->writesize); |
|---|
| .. | .. |
|---|
| 897 | 895 | return mxc_nand_write_page(chip, host->data_buf, false, page); |
|---|
| 898 | 896 | } |
|---|
| 899 | 897 | |
|---|
| 900 | | -static u_char mxc_nand_read_byte(struct mtd_info *mtd) |
|---|
| 898 | +static u_char mxc_nand_read_byte(struct nand_chip *nand_chip) |
|---|
| 901 | 899 | { |
|---|
| 902 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 903 | 900 | struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 904 | 901 | uint8_t ret; |
|---|
| 905 | 902 | |
|---|
| .. | .. |
|---|
| 921 | 918 | return ret; |
|---|
| 922 | 919 | } |
|---|
| 923 | 920 | |
|---|
| 924 | | -static uint16_t mxc_nand_read_word(struct mtd_info *mtd) |
|---|
| 925 | | -{ |
|---|
| 926 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 927 | | - struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 928 | | - uint16_t ret; |
|---|
| 929 | | - |
|---|
| 930 | | - ret = *(uint16_t *)(host->data_buf + host->buf_start); |
|---|
| 931 | | - host->buf_start += 2; |
|---|
| 932 | | - |
|---|
| 933 | | - return ret; |
|---|
| 934 | | -} |
|---|
| 935 | | - |
|---|
| 936 | 921 | /* Write data of length len to buffer buf. The data to be |
|---|
| 937 | 922 | * written on NAND Flash is first copied to RAMbuffer. After the Data Input |
|---|
| 938 | 923 | * Operation by the NFC, the data is written to NAND Flash */ |
|---|
| 939 | | -static void mxc_nand_write_buf(struct mtd_info *mtd, |
|---|
| 940 | | - const u_char *buf, int len) |
|---|
| 924 | +static void mxc_nand_write_buf(struct nand_chip *nand_chip, const u_char *buf, |
|---|
| 925 | + int len) |
|---|
| 941 | 926 | { |
|---|
| 942 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 927 | + struct mtd_info *mtd = nand_to_mtd(nand_chip); |
|---|
| 943 | 928 | struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 944 | 929 | u16 col = host->buf_start; |
|---|
| 945 | 930 | int n = mtd->oobsize + mtd->writesize - col; |
|---|
| .. | .. |
|---|
| 955 | 940 | * Flash first the data output cycle is initiated by the NFC, which copies |
|---|
| 956 | 941 | * the data to RAMbuffer. This data of length len is then copied to buffer buf. |
|---|
| 957 | 942 | */ |
|---|
| 958 | | -static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) |
|---|
| 943 | +static void mxc_nand_read_buf(struct nand_chip *nand_chip, u_char *buf, |
|---|
| 944 | + int len) |
|---|
| 959 | 945 | { |
|---|
| 960 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 946 | + struct mtd_info *mtd = nand_to_mtd(nand_chip); |
|---|
| 961 | 947 | struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 962 | 948 | u16 col = host->buf_start; |
|---|
| 963 | 949 | int n = mtd->oobsize + mtd->writesize - col; |
|---|
| .. | .. |
|---|
| 971 | 957 | |
|---|
| 972 | 958 | /* This function is used by upper layer for select and |
|---|
| 973 | 959 | * deselect of the NAND chip */ |
|---|
| 974 | | -static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip) |
|---|
| 960 | +static void mxc_nand_select_chip_v1_v3(struct nand_chip *nand_chip, int chip) |
|---|
| 975 | 961 | { |
|---|
| 976 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 977 | 962 | struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 978 | 963 | |
|---|
| 979 | 964 | if (chip == -1) { |
|---|
| .. | .. |
|---|
| 992 | 977 | } |
|---|
| 993 | 978 | } |
|---|
| 994 | 979 | |
|---|
| 995 | | -static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip) |
|---|
| 980 | +static void mxc_nand_select_chip_v2(struct nand_chip *nand_chip, int chip) |
|---|
| 996 | 981 | { |
|---|
| 997 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 998 | 982 | struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 999 | 983 | |
|---|
| 1000 | 984 | if (chip == -1) { |
|---|
| .. | .. |
|---|
| 1133 | 1117 | struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 1134 | 1118 | uint16_t config1 = 0; |
|---|
| 1135 | 1119 | |
|---|
| 1136 | | - if (nand_chip->ecc.mode == NAND_ECC_HW && mtd->writesize) |
|---|
| 1120 | + if (nand_chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST && |
|---|
| 1121 | + mtd->writesize) |
|---|
| 1137 | 1122 | config1 |= NFC_V1_V2_CONFIG1_ECC_EN; |
|---|
| 1138 | 1123 | |
|---|
| 1139 | 1124 | if (!host->devtype_data->irqpending_quirk) |
|---|
| .. | .. |
|---|
| 1155 | 1140 | writew(0x4, NFC_V1_V2_WRPROT); |
|---|
| 1156 | 1141 | } |
|---|
| 1157 | 1142 | |
|---|
| 1158 | | -static int mxc_nand_v2_setup_data_interface(struct mtd_info *mtd, int csline, |
|---|
| 1159 | | - const struct nand_data_interface *conf) |
|---|
| 1143 | +static int mxc_nand_v2_setup_interface(struct nand_chip *chip, int csline, |
|---|
| 1144 | + const struct nand_interface_config *conf) |
|---|
| 1160 | 1145 | { |
|---|
| 1161 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 1162 | | - struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 1146 | + struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 1163 | 1147 | int tRC_min_ns, tRC_ps, ret; |
|---|
| 1164 | 1148 | unsigned long rate, rate_round; |
|---|
| 1165 | 1149 | const struct nand_sdr_timings *timings; |
|---|
| .. | .. |
|---|
| 1244 | 1228 | if (mtd->writesize) { |
|---|
| 1245 | 1229 | uint16_t pages_per_block = mtd->erasesize / mtd->writesize; |
|---|
| 1246 | 1230 | |
|---|
| 1247 | | - if (nand_chip->ecc.mode == NAND_ECC_HW) |
|---|
| 1231 | + if (nand_chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) |
|---|
| 1248 | 1232 | config1 |= NFC_V1_V2_CONFIG1_ECC_EN; |
|---|
| 1249 | 1233 | |
|---|
| 1250 | 1234 | host->eccsize = get_eccsize(mtd); |
|---|
| .. | .. |
|---|
| 1320 | 1304 | } |
|---|
| 1321 | 1305 | |
|---|
| 1322 | 1306 | if (mtd->writesize) { |
|---|
| 1323 | | - if (chip->ecc.mode == NAND_ECC_HW) |
|---|
| 1307 | + if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) |
|---|
| 1324 | 1308 | config2 |= NFC_V3_CONFIG2_ECC_EN; |
|---|
| 1325 | 1309 | |
|---|
| 1326 | 1310 | config2 |= NFC_V3_CONFIG2_PPB( |
|---|
| .. | .. |
|---|
| 1349 | 1333 | |
|---|
| 1350 | 1334 | /* Used by the upper layer to write command to NAND Flash for |
|---|
| 1351 | 1335 | * different operations to be carried out on NAND Flash */ |
|---|
| 1352 | | -static void mxc_nand_command(struct mtd_info *mtd, unsigned command, |
|---|
| 1353 | | - int column, int page_addr) |
|---|
| 1336 | +static void mxc_nand_command(struct nand_chip *nand_chip, unsigned command, |
|---|
| 1337 | + int column, int page_addr) |
|---|
| 1354 | 1338 | { |
|---|
| 1355 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 1339 | + struct mtd_info *mtd = nand_to_mtd(nand_chip); |
|---|
| 1356 | 1340 | struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 1357 | 1341 | |
|---|
| 1358 | 1342 | dev_dbg(host->dev, "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n", |
|---|
| .. | .. |
|---|
| 1409 | 1393 | } |
|---|
| 1410 | 1394 | } |
|---|
| 1411 | 1395 | |
|---|
| 1412 | | -static int mxc_nand_set_features(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 1413 | | - int addr, u8 *subfeature_param) |
|---|
| 1396 | +static int mxc_nand_set_features(struct nand_chip *chip, int addr, |
|---|
| 1397 | + u8 *subfeature_param) |
|---|
| 1414 | 1398 | { |
|---|
| 1415 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 1416 | | - struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 1399 | + struct mtd_info *mtd = nand_to_mtd(chip); |
|---|
| 1400 | + struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 1417 | 1401 | int i; |
|---|
| 1418 | 1402 | |
|---|
| 1419 | 1403 | host->buf_start = 0; |
|---|
| 1420 | 1404 | |
|---|
| 1421 | 1405 | for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i) |
|---|
| 1422 | | - chip->write_byte(mtd, subfeature_param[i]); |
|---|
| 1406 | + chip->legacy.write_byte(chip, subfeature_param[i]); |
|---|
| 1423 | 1407 | |
|---|
| 1424 | 1408 | memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize); |
|---|
| 1425 | 1409 | host->devtype_data->send_cmd(host, NAND_CMD_SET_FEATURES, false); |
|---|
| .. | .. |
|---|
| 1429 | 1413 | return 0; |
|---|
| 1430 | 1414 | } |
|---|
| 1431 | 1415 | |
|---|
| 1432 | | -static int mxc_nand_get_features(struct mtd_info *mtd, struct nand_chip *chip, |
|---|
| 1433 | | - int addr, u8 *subfeature_param) |
|---|
| 1416 | +static int mxc_nand_get_features(struct nand_chip *chip, int addr, |
|---|
| 1417 | + u8 *subfeature_param) |
|---|
| 1434 | 1418 | { |
|---|
| 1435 | | - struct nand_chip *nand_chip = mtd_to_nand(mtd); |
|---|
| 1436 | | - struct mxc_nand_host *host = nand_get_controller_data(nand_chip); |
|---|
| 1419 | + struct mtd_info *mtd = nand_to_mtd(chip); |
|---|
| 1420 | + struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 1437 | 1421 | int i; |
|---|
| 1438 | 1422 | |
|---|
| 1439 | 1423 | host->devtype_data->send_cmd(host, NAND_CMD_GET_FEATURES, false); |
|---|
| .. | .. |
|---|
| 1443 | 1427 | host->buf_start = 0; |
|---|
| 1444 | 1428 | |
|---|
| 1445 | 1429 | for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i) |
|---|
| 1446 | | - *subfeature_param++ = chip->read_byte(mtd); |
|---|
| 1430 | + *subfeature_param++ = chip->legacy.read_byte(chip); |
|---|
| 1447 | 1431 | |
|---|
| 1448 | 1432 | return 0; |
|---|
| 1449 | 1433 | } |
|---|
| 1450 | 1434 | |
|---|
| 1451 | 1435 | /* |
|---|
| 1452 | | - * The generic flash bbt decriptors overlap with our ecc |
|---|
| 1436 | + * The generic flash bbt descriptors overlap with our ecc |
|---|
| 1453 | 1437 | * hardware, so define some i.MX specific ones. |
|---|
| 1454 | 1438 | */ |
|---|
| 1455 | 1439 | static uint8_t bbt_pattern[] = { 'B', 'b', 't', '0' }; |
|---|
| .. | .. |
|---|
| 1538 | 1522 | .get_ecc_status = get_ecc_status_v2, |
|---|
| 1539 | 1523 | .ooblayout = &mxc_v2_ooblayout_ops, |
|---|
| 1540 | 1524 | .select_chip = mxc_nand_select_chip_v2, |
|---|
| 1541 | | - .setup_data_interface = mxc_nand_v2_setup_data_interface, |
|---|
| 1525 | + .setup_interface = mxc_nand_v2_setup_interface, |
|---|
| 1542 | 1526 | .enable_hwecc = mxc_nand_enable_hwecc_v1_v2, |
|---|
| 1543 | 1527 | .irqpending_quirk = 0, |
|---|
| 1544 | 1528 | .needs_ip = 0, |
|---|
| .. | .. |
|---|
| 1697 | 1681 | struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 1698 | 1682 | struct device *dev = mtd->dev.parent; |
|---|
| 1699 | 1683 | |
|---|
| 1700 | | - switch (chip->ecc.mode) { |
|---|
| 1701 | | - case NAND_ECC_HW: |
|---|
| 1684 | + chip->ecc.bytes = host->devtype_data->eccbytes; |
|---|
| 1685 | + host->eccsize = host->devtype_data->eccsize; |
|---|
| 1686 | + chip->ecc.size = 512; |
|---|
| 1687 | + mtd_set_ooblayout(mtd, host->devtype_data->ooblayout); |
|---|
| 1688 | + |
|---|
| 1689 | + switch (chip->ecc.engine_type) { |
|---|
| 1690 | + case NAND_ECC_ENGINE_TYPE_ON_HOST: |
|---|
| 1702 | 1691 | chip->ecc.read_page = mxc_nand_read_page; |
|---|
| 1703 | 1692 | chip->ecc.read_page_raw = mxc_nand_read_page_raw; |
|---|
| 1704 | 1693 | chip->ecc.read_oob = mxc_nand_read_oob; |
|---|
| .. | .. |
|---|
| 1707 | 1696 | chip->ecc.write_oob = mxc_nand_write_oob; |
|---|
| 1708 | 1697 | break; |
|---|
| 1709 | 1698 | |
|---|
| 1710 | | - case NAND_ECC_SOFT: |
|---|
| 1699 | + case NAND_ECC_ENGINE_TYPE_SOFT: |
|---|
| 1711 | 1700 | break; |
|---|
| 1712 | 1701 | |
|---|
| 1713 | 1702 | default: |
|---|
| .. | .. |
|---|
| 1745 | 1734 | */ |
|---|
| 1746 | 1735 | host->used_oobsize = min(mtd->oobsize, 218U); |
|---|
| 1747 | 1736 | |
|---|
| 1748 | | - if (chip->ecc.mode == NAND_ECC_HW) { |
|---|
| 1737 | + if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) { |
|---|
| 1749 | 1738 | if (is_imx21_nfc(host) || is_imx27_nfc(host)) |
|---|
| 1750 | 1739 | chip->ecc.strength = 1; |
|---|
| 1751 | 1740 | else |
|---|
| .. | .. |
|---|
| 1755 | 1744 | return 0; |
|---|
| 1756 | 1745 | } |
|---|
| 1757 | 1746 | |
|---|
| 1747 | +static int mxcnd_setup_interface(struct nand_chip *chip, int chipnr, |
|---|
| 1748 | + const struct nand_interface_config *conf) |
|---|
| 1749 | +{ |
|---|
| 1750 | + struct mxc_nand_host *host = nand_get_controller_data(chip); |
|---|
| 1751 | + |
|---|
| 1752 | + return host->devtype_data->setup_interface(chip, chipnr, conf); |
|---|
| 1753 | +} |
|---|
| 1754 | + |
|---|
| 1758 | 1755 | static const struct nand_controller_ops mxcnd_controller_ops = { |
|---|
| 1759 | 1756 | .attach_chip = mxcnd_attach_chip, |
|---|
| 1757 | + .setup_interface = mxcnd_setup_interface, |
|---|
| 1760 | 1758 | }; |
|---|
| 1761 | 1759 | |
|---|
| 1762 | 1760 | static int mxcnd_probe(struct platform_device *pdev) |
|---|
| .. | .. |
|---|
| 1786 | 1784 | mtd->name = DRIVER_NAME; |
|---|
| 1787 | 1785 | |
|---|
| 1788 | 1786 | /* 50 us command delay time */ |
|---|
| 1789 | | - this->chip_delay = 5; |
|---|
| 1787 | + this->legacy.chip_delay = 5; |
|---|
| 1790 | 1788 | |
|---|
| 1791 | 1789 | nand_set_controller_data(this, host); |
|---|
| 1792 | 1790 | nand_set_flash_node(this, pdev->dev.of_node), |
|---|
| 1793 | | - this->dev_ready = mxc_nand_dev_ready; |
|---|
| 1794 | | - this->cmdfunc = mxc_nand_command; |
|---|
| 1795 | | - this->read_byte = mxc_nand_read_byte; |
|---|
| 1796 | | - this->read_word = mxc_nand_read_word; |
|---|
| 1797 | | - this->write_buf = mxc_nand_write_buf; |
|---|
| 1798 | | - this->read_buf = mxc_nand_read_buf; |
|---|
| 1799 | | - this->set_features = mxc_nand_set_features; |
|---|
| 1800 | | - this->get_features = mxc_nand_get_features; |
|---|
| 1791 | + this->legacy.dev_ready = mxc_nand_dev_ready; |
|---|
| 1792 | + this->legacy.cmdfunc = mxc_nand_command; |
|---|
| 1793 | + this->legacy.read_byte = mxc_nand_read_byte; |
|---|
| 1794 | + this->legacy.write_buf = mxc_nand_write_buf; |
|---|
| 1795 | + this->legacy.read_buf = mxc_nand_read_buf; |
|---|
| 1796 | + this->legacy.set_features = mxc_nand_set_features; |
|---|
| 1797 | + this->legacy.get_features = mxc_nand_get_features; |
|---|
| 1801 | 1798 | |
|---|
| 1802 | 1799 | host->clk = devm_clk_get(&pdev->dev, NULL); |
|---|
| 1803 | 1800 | if (IS_ERR(host->clk)) |
|---|
| .. | .. |
|---|
| 1818 | 1815 | if (err < 0) |
|---|
| 1819 | 1816 | return err; |
|---|
| 1820 | 1817 | |
|---|
| 1821 | | - this->setup_data_interface = host->devtype_data->setup_data_interface; |
|---|
| 1818 | + if (!host->devtype_data->setup_interface) |
|---|
| 1819 | + this->options |= NAND_KEEP_TIMINGS; |
|---|
| 1822 | 1820 | |
|---|
| 1823 | 1821 | if (host->devtype_data->needs_ip) { |
|---|
| 1824 | 1822 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| .. | .. |
|---|
| 1843 | 1841 | if (host->devtype_data->axi_offset) |
|---|
| 1844 | 1842 | host->regs_axi = host->base + host->devtype_data->axi_offset; |
|---|
| 1845 | 1843 | |
|---|
| 1846 | | - this->ecc.bytes = host->devtype_data->eccbytes; |
|---|
| 1847 | | - host->eccsize = host->devtype_data->eccsize; |
|---|
| 1848 | | - |
|---|
| 1849 | | - this->select_chip = host->devtype_data->select_chip; |
|---|
| 1850 | | - this->ecc.size = 512; |
|---|
| 1851 | | - mtd_set_ooblayout(mtd, host->devtype_data->ooblayout); |
|---|
| 1852 | | - |
|---|
| 1853 | | - if (host->pdata.hw_ecc) { |
|---|
| 1854 | | - this->ecc.mode = NAND_ECC_HW; |
|---|
| 1855 | | - } else { |
|---|
| 1856 | | - this->ecc.mode = NAND_ECC_SOFT; |
|---|
| 1857 | | - this->ecc.algo = NAND_ECC_HAMMING; |
|---|
| 1858 | | - } |
|---|
| 1844 | + this->legacy.select_chip = host->devtype_data->select_chip; |
|---|
| 1859 | 1845 | |
|---|
| 1860 | 1846 | /* NAND bus width determines access functions used by upper layer */ |
|---|
| 1861 | 1847 | if (host->pdata.width == 2) |
|---|
| .. | .. |
|---|
| 1899 | 1885 | } |
|---|
| 1900 | 1886 | |
|---|
| 1901 | 1887 | /* Scan the NAND device */ |
|---|
| 1902 | | - this->dummy_controller.ops = &mxcnd_controller_ops; |
|---|
| 1888 | + this->legacy.dummy_controller.ops = &mxcnd_controller_ops; |
|---|
| 1903 | 1889 | err = nand_scan(this, is_imx25_nfc(host) ? 4 : 1); |
|---|
| 1904 | 1890 | if (err) |
|---|
| 1905 | 1891 | goto escan; |
|---|
| .. | .. |
|---|
| 1927 | 1913 | static int mxcnd_remove(struct platform_device *pdev) |
|---|
| 1928 | 1914 | { |
|---|
| 1929 | 1915 | struct mxc_nand_host *host = platform_get_drvdata(pdev); |
|---|
| 1916 | + struct nand_chip *chip = &host->nand; |
|---|
| 1917 | + int ret; |
|---|
| 1930 | 1918 | |
|---|
| 1931 | | - nand_release(&host->nand); |
|---|
| 1919 | + ret = mtd_device_unregister(nand_to_mtd(chip)); |
|---|
| 1920 | + WARN_ON(ret); |
|---|
| 1921 | + nand_cleanup(chip); |
|---|
| 1932 | 1922 | if (host->clk_act) |
|---|
| 1933 | 1923 | clk_disable_unprepare(host->clk); |
|---|
| 1934 | 1924 | |
|---|