diff options
Diffstat (limited to 'include/linux/mtd/rawnand.h')
-rw-r--r-- | include/linux/mtd/rawnand.h | 443 |
1 files changed, 404 insertions, 39 deletions
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 749bb08c4772..56c5570aadbe 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h | |||
@@ -133,12 +133,6 @@ enum nand_ecc_algo { | |||
133 | */ | 133 | */ |
134 | #define NAND_ECC_GENERIC_ERASED_CHECK BIT(0) | 134 | #define NAND_ECC_GENERIC_ERASED_CHECK BIT(0) |
135 | #define NAND_ECC_MAXIMIZE BIT(1) | 135 | #define NAND_ECC_MAXIMIZE BIT(1) |
136 | /* | ||
137 | * If your controller already sends the required NAND commands when | ||
138 | * reading or writing a page, then the framework is not supposed to | ||
139 | * send READ0 and SEQIN/PAGEPROG respectively. | ||
140 | */ | ||
141 | #define NAND_ECC_CUSTOM_PAGE_ACCESS BIT(2) | ||
142 | 136 | ||
143 | /* Bit mask for flags passed to do_nand_read_ecc */ | 137 | /* Bit mask for flags passed to do_nand_read_ecc */ |
144 | #define NAND_GET_DEVICE 0x80 | 138 | #define NAND_GET_DEVICE 0x80 |
@@ -191,11 +185,6 @@ enum nand_ecc_algo { | |||
191 | /* Non chip related options */ | 185 | /* Non chip related options */ |
192 | /* This option skips the bbt scan during initialization. */ | 186 | /* This option skips the bbt scan during initialization. */ |
193 | #define NAND_SKIP_BBTSCAN 0x00010000 | 187 | #define NAND_SKIP_BBTSCAN 0x00010000 |
194 | /* | ||
195 | * This option is defined if the board driver allocates its own buffers | ||
196 | * (e.g. because it needs them DMA-coherent). | ||
197 | */ | ||
198 | #define NAND_OWN_BUFFERS 0x00020000 | ||
199 | /* Chip may not exist, so silence any errors in scan */ | 188 | /* Chip may not exist, so silence any errors in scan */ |
200 | #define NAND_SCAN_SILENT_NODEV 0x00040000 | 189 | #define NAND_SCAN_SILENT_NODEV 0x00040000 |
201 | /* | 190 | /* |
@@ -525,6 +514,8 @@ static const struct nand_ecc_caps __name = { \ | |||
525 | * @postpad: padding information for syndrome based ECC generators | 514 | * @postpad: padding information for syndrome based ECC generators |
526 | * @options: ECC specific options (see NAND_ECC_XXX flags defined above) | 515 | * @options: ECC specific options (see NAND_ECC_XXX flags defined above) |
527 | * @priv: pointer to private ECC control data | 516 | * @priv: pointer to private ECC control data |
517 | * @calc_buf: buffer for calculated ECC, size is oobsize. | ||
518 | * @code_buf: buffer for ECC read from flash, size is oobsize. | ||
528 | * @hwctl: function to control hardware ECC generator. Must only | 519 | * @hwctl: function to control hardware ECC generator. Must only |
529 | * be provided if an hardware ECC is available | 520 | * be provided if an hardware ECC is available |
530 | * @calculate: function for ECC calculation or readback from ECC hardware | 521 | * @calculate: function for ECC calculation or readback from ECC hardware |
@@ -575,6 +566,8 @@ struct nand_ecc_ctrl { | |||
575 | int postpad; | 566 | int postpad; |
576 | unsigned int options; | 567 | unsigned int options; |
577 | void *priv; | 568 | void *priv; |
569 | u8 *calc_buf; | ||
570 | u8 *code_buf; | ||
578 | void (*hwctl)(struct mtd_info *mtd, int mode); | 571 | void (*hwctl)(struct mtd_info *mtd, int mode); |
579 | int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, | 572 | int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, |
580 | uint8_t *ecc_code); | 573 | uint8_t *ecc_code); |
@@ -602,26 +595,6 @@ struct nand_ecc_ctrl { | |||
602 | int page); | 595 | int page); |
603 | }; | 596 | }; |
604 | 597 | ||
605 | static inline int nand_standard_page_accessors(struct nand_ecc_ctrl *ecc) | ||
606 | { | ||
607 | return !(ecc->options & NAND_ECC_CUSTOM_PAGE_ACCESS); | ||
608 | } | ||
609 | |||
610 | /** | ||
611 | * struct nand_buffers - buffer structure for read/write | ||
612 | * @ecccalc: buffer pointer for calculated ECC, size is oobsize. | ||
613 | * @ecccode: buffer pointer for ECC read from flash, size is oobsize. | ||
614 | * @databuf: buffer pointer for data, size is (page size + oobsize). | ||
615 | * | ||
616 | * Do not change the order of buffers. databuf and oobrbuf must be in | ||
617 | * consecutive order. | ||
618 | */ | ||
619 | struct nand_buffers { | ||
620 | uint8_t *ecccalc; | ||
621 | uint8_t *ecccode; | ||
622 | uint8_t *databuf; | ||
623 | }; | ||
624 | |||
625 | /** | 598 | /** |
626 | * struct nand_sdr_timings - SDR NAND chip timings | 599 | * struct nand_sdr_timings - SDR NAND chip timings |
627 | * | 600 | * |
@@ -762,6 +735,350 @@ struct nand_manufacturer_ops { | |||
762 | }; | 735 | }; |
763 | 736 | ||
764 | /** | 737 | /** |
738 | * struct nand_op_cmd_instr - Definition of a command instruction | ||
739 | * @opcode: the command to issue in one cycle | ||
740 | */ | ||
741 | struct nand_op_cmd_instr { | ||
742 | u8 opcode; | ||
743 | }; | ||
744 | |||
745 | /** | ||
746 | * struct nand_op_addr_instr - Definition of an address instruction | ||
747 | * @naddrs: length of the @addrs array | ||
748 | * @addrs: array containing the address cycles to issue | ||
749 | */ | ||
750 | struct nand_op_addr_instr { | ||
751 | unsigned int naddrs; | ||
752 | const u8 *addrs; | ||
753 | }; | ||
754 | |||
755 | /** | ||
756 | * struct nand_op_data_instr - Definition of a data instruction | ||
757 | * @len: number of data bytes to move | ||
758 | * @in: buffer to fill when reading from the NAND chip | ||
759 | * @out: buffer to read from when writing to the NAND chip | ||
760 | * @force_8bit: force 8-bit access | ||
761 | * | ||
762 | * Please note that "in" and "out" are inverted from the ONFI specification | ||
763 | * and are from the controller perspective, so a "in" is a read from the NAND | ||
764 | * chip while a "out" is a write to the NAND chip. | ||
765 | */ | ||
766 | struct nand_op_data_instr { | ||
767 | unsigned int len; | ||
768 | union { | ||
769 | void *in; | ||
770 | const void *out; | ||
771 | } buf; | ||
772 | bool force_8bit; | ||
773 | }; | ||
774 | |||
775 | /** | ||
776 | * struct nand_op_waitrdy_instr - Definition of a wait ready instruction | ||
777 | * @timeout_ms: maximum delay while waiting for the ready/busy pin in ms | ||
778 | */ | ||
779 | struct nand_op_waitrdy_instr { | ||
780 | unsigned int timeout_ms; | ||
781 | }; | ||
782 | |||
783 | /** | ||
784 | * enum nand_op_instr_type - Definition of all instruction types | ||
785 | * @NAND_OP_CMD_INSTR: command instruction | ||
786 | * @NAND_OP_ADDR_INSTR: address instruction | ||
787 | * @NAND_OP_DATA_IN_INSTR: data in instruction | ||
788 | * @NAND_OP_DATA_OUT_INSTR: data out instruction | ||
789 | * @NAND_OP_WAITRDY_INSTR: wait ready instruction | ||
790 | */ | ||
791 | enum nand_op_instr_type { | ||
792 | NAND_OP_CMD_INSTR, | ||
793 | NAND_OP_ADDR_INSTR, | ||
794 | NAND_OP_DATA_IN_INSTR, | ||
795 | NAND_OP_DATA_OUT_INSTR, | ||
796 | NAND_OP_WAITRDY_INSTR, | ||
797 | }; | ||
798 | |||
799 | /** | ||
800 | * struct nand_op_instr - Instruction object | ||
801 | * @type: the instruction type | ||
802 | * @cmd/@addr/@data/@waitrdy: extra data associated to the instruction. | ||
803 | * You'll have to use the appropriate element | ||
804 | * depending on @type | ||
805 | * @delay_ns: delay the controller should apply after the instruction has been | ||
806 | * issued on the bus. Most modern controllers have internal timings | ||
807 | * control logic, and in this case, the controller driver can ignore | ||
808 | * this field. | ||
809 | */ | ||
810 | struct nand_op_instr { | ||
811 | enum nand_op_instr_type type; | ||
812 | union { | ||
813 | struct nand_op_cmd_instr cmd; | ||
814 | struct nand_op_addr_instr addr; | ||
815 | struct nand_op_data_instr data; | ||
816 | struct nand_op_waitrdy_instr waitrdy; | ||
817 | } ctx; | ||
818 | unsigned int delay_ns; | ||
819 | }; | ||
820 | |||
821 | /* | ||
822 | * Special handling must be done for the WAITRDY timeout parameter as it usually | ||
823 | * is either tPROG (after a prog), tR (before a read), tRST (during a reset) or | ||
824 | * tBERS (during an erase) which all of them are u64 values that cannot be | ||
825 | * divided by usual kernel macros and must be handled with the special | ||
826 | * DIV_ROUND_UP_ULL() macro. | ||
827 | */ | ||
828 | #define __DIVIDE(dividend, divisor) ({ \ | ||
829 | sizeof(dividend) == sizeof(u32) ? \ | ||
830 | DIV_ROUND_UP(dividend, divisor) : \ | ||
831 | DIV_ROUND_UP_ULL(dividend, divisor); \ | ||
832 | }) | ||
833 | #define PSEC_TO_NSEC(x) __DIVIDE(x, 1000) | ||
834 | #define PSEC_TO_MSEC(x) __DIVIDE(x, 1000000000) | ||
835 | |||
836 | #define NAND_OP_CMD(id, ns) \ | ||
837 | { \ | ||
838 | .type = NAND_OP_CMD_INSTR, \ | ||
839 | .ctx.cmd.opcode = id, \ | ||
840 | .delay_ns = ns, \ | ||
841 | } | ||
842 | |||
843 | #define NAND_OP_ADDR(ncycles, cycles, ns) \ | ||
844 | { \ | ||
845 | .type = NAND_OP_ADDR_INSTR, \ | ||
846 | .ctx.addr = { \ | ||
847 | .naddrs = ncycles, \ | ||
848 | .addrs = cycles, \ | ||
849 | }, \ | ||
850 | .delay_ns = ns, \ | ||
851 | } | ||
852 | |||
853 | #define NAND_OP_DATA_IN(l, b, ns) \ | ||
854 | { \ | ||
855 | .type = NAND_OP_DATA_IN_INSTR, \ | ||
856 | .ctx.data = { \ | ||
857 | .len = l, \ | ||
858 | .buf.in = b, \ | ||
859 | .force_8bit = false, \ | ||
860 | }, \ | ||
861 | .delay_ns = ns, \ | ||
862 | } | ||
863 | |||
864 | #define NAND_OP_DATA_OUT(l, b, ns) \ | ||
865 | { \ | ||
866 | .type = NAND_OP_DATA_OUT_INSTR, \ | ||
867 | .ctx.data = { \ | ||
868 | .len = l, \ | ||
869 | .buf.out = b, \ | ||
870 | .force_8bit = false, \ | ||
871 | }, \ | ||
872 | .delay_ns = ns, \ | ||
873 | } | ||
874 | |||
875 | #define NAND_OP_8BIT_DATA_IN(l, b, ns) \ | ||
876 | { \ | ||
877 | .type = NAND_OP_DATA_IN_INSTR, \ | ||
878 | .ctx.data = { \ | ||
879 | .len = l, \ | ||
880 | .buf.in = b, \ | ||
881 | .force_8bit = true, \ | ||
882 | }, \ | ||
883 | .delay_ns = ns, \ | ||
884 | } | ||
885 | |||
886 | #define NAND_OP_8BIT_DATA_OUT(l, b, ns) \ | ||
887 | { \ | ||
888 | .type = NAND_OP_DATA_OUT_INSTR, \ | ||
889 | .ctx.data = { \ | ||
890 | .len = l, \ | ||
891 | .buf.out = b, \ | ||
892 | .force_8bit = true, \ | ||
893 | }, \ | ||
894 | .delay_ns = ns, \ | ||
895 | } | ||
896 | |||
897 | #define NAND_OP_WAIT_RDY(tout_ms, ns) \ | ||
898 | { \ | ||
899 | .type = NAND_OP_WAITRDY_INSTR, \ | ||
900 | .ctx.waitrdy.timeout_ms = tout_ms, \ | ||
901 | .delay_ns = ns, \ | ||
902 | } | ||
903 | |||
904 | /** | ||
905 | * struct nand_subop - a sub operation | ||
906 | * @instrs: array of instructions | ||
907 | * @ninstrs: length of the @instrs array | ||
908 | * @first_instr_start_off: offset to start from for the first instruction | ||
909 | * of the sub-operation | ||
910 | * @last_instr_end_off: offset to end at (excluded) for the last instruction | ||
911 | * of the sub-operation | ||
912 | * | ||
913 | * Both @first_instr_start_off and @last_instr_end_off only apply to data or | ||
914 | * address instructions. | ||
915 | * | ||
916 | * When an operation cannot be handled as is by the NAND controller, it will | ||
917 | * be split by the parser into sub-operations which will be passed to the | ||
918 | * controller driver. | ||
919 | */ | ||
920 | struct nand_subop { | ||
921 | const struct nand_op_instr *instrs; | ||
922 | unsigned int ninstrs; | ||
923 | unsigned int first_instr_start_off; | ||
924 | unsigned int last_instr_end_off; | ||
925 | }; | ||
926 | |||
927 | int nand_subop_get_addr_start_off(const struct nand_subop *subop, | ||
928 | unsigned int op_id); | ||
929 | int nand_subop_get_num_addr_cyc(const struct nand_subop *subop, | ||
930 | unsigned int op_id); | ||
931 | int nand_subop_get_data_start_off(const struct nand_subop *subop, | ||
932 | unsigned int op_id); | ||
933 | int nand_subop_get_data_len(const struct nand_subop *subop, | ||
934 | unsigned int op_id); | ||
935 | |||
936 | /** | ||
937 | * struct nand_op_parser_addr_constraints - Constraints for address instructions | ||
938 | * @maxcycles: maximum number of address cycles the controller can issue in a | ||
939 | * single step | ||
940 | */ | ||
941 | struct nand_op_parser_addr_constraints { | ||
942 | unsigned int maxcycles; | ||
943 | }; | ||
944 | |||
945 | /** | ||
946 | * struct nand_op_parser_data_constraints - Constraints for data instructions | ||
947 | * @maxlen: maximum data length that the controller can handle in a single step | ||
948 | */ | ||
949 | struct nand_op_parser_data_constraints { | ||
950 | unsigned int maxlen; | ||
951 | }; | ||
952 | |||
953 | /** | ||
954 | * struct nand_op_parser_pattern_elem - One element of a pattern | ||
955 | * @type: the instructuction type | ||
956 | * @optional: whether this element of the pattern is optional or mandatory | ||
957 | * @addr/@data: address or data constraint (number of cycles or data length) | ||
958 | */ | ||
959 | struct nand_op_parser_pattern_elem { | ||
960 | enum nand_op_instr_type type; | ||
961 | bool optional; | ||
962 | union { | ||
963 | struct nand_op_parser_addr_constraints addr; | ||
964 | struct nand_op_parser_data_constraints data; | ||
965 | } ctx; | ||
966 | }; | ||
967 | |||
968 | #define NAND_OP_PARSER_PAT_CMD_ELEM(_opt) \ | ||
969 | { \ | ||
970 | .type = NAND_OP_CMD_INSTR, \ | ||
971 | .optional = _opt, \ | ||
972 | } | ||
973 | |||
974 | #define NAND_OP_PARSER_PAT_ADDR_ELEM(_opt, _maxcycles) \ | ||
975 | { \ | ||
976 | .type = NAND_OP_ADDR_INSTR, \ | ||
977 | .optional = _opt, \ | ||
978 | .ctx.addr.maxcycles = _maxcycles, \ | ||
979 | } | ||
980 | |||
981 | #define NAND_OP_PARSER_PAT_DATA_IN_ELEM(_opt, _maxlen) \ | ||
982 | { \ | ||
983 | .type = NAND_OP_DATA_IN_INSTR, \ | ||
984 | .optional = _opt, \ | ||
985 | .ctx.data.maxlen = _maxlen, \ | ||
986 | } | ||
987 | |||
988 | #define NAND_OP_PARSER_PAT_DATA_OUT_ELEM(_opt, _maxlen) \ | ||
989 | { \ | ||
990 | .type = NAND_OP_DATA_OUT_INSTR, \ | ||
991 | .optional = _opt, \ | ||
992 | .ctx.data.maxlen = _maxlen, \ | ||
993 | } | ||
994 | |||
995 | #define NAND_OP_PARSER_PAT_WAITRDY_ELEM(_opt) \ | ||
996 | { \ | ||
997 | .type = NAND_OP_WAITRDY_INSTR, \ | ||
998 | .optional = _opt, \ | ||
999 | } | ||
1000 | |||
1001 | /** | ||
1002 | * struct nand_op_parser_pattern - NAND sub-operation pattern descriptor | ||
1003 | * @elems: array of pattern elements | ||
1004 | * @nelems: number of pattern elements in @elems array | ||
1005 | * @exec: the function that will issue a sub-operation | ||
1006 | * | ||
1007 | * A pattern is a list of elements, each element reprensenting one instruction | ||
1008 | * with its constraints. The pattern itself is used by the core to match NAND | ||
1009 | * chip operation with NAND controller operations. | ||
1010 | * Once a match between a NAND controller operation pattern and a NAND chip | ||
1011 | * operation (or a sub-set of a NAND operation) is found, the pattern ->exec() | ||
1012 | * hook is called so that the controller driver can issue the operation on the | ||
1013 | * bus. | ||
1014 | * | ||
1015 | * Controller drivers should declare as many patterns as they support and pass | ||
1016 | * this list of patterns (created with the help of the following macro) to | ||
1017 | * the nand_op_parser_exec_op() helper. | ||
1018 | */ | ||
1019 | struct nand_op_parser_pattern { | ||
1020 | const struct nand_op_parser_pattern_elem *elems; | ||
1021 | unsigned int nelems; | ||
1022 | int (*exec)(struct nand_chip *chip, const struct nand_subop *subop); | ||
1023 | }; | ||
1024 | |||
1025 | #define NAND_OP_PARSER_PATTERN(_exec, ...) \ | ||
1026 | { \ | ||
1027 | .exec = _exec, \ | ||
1028 | .elems = (struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }, \ | ||
1029 | .nelems = sizeof((struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }) / \ | ||
1030 | sizeof(struct nand_op_parser_pattern_elem), \ | ||
1031 | } | ||
1032 | |||
1033 | /** | ||
1034 | * struct nand_op_parser - NAND controller operation parser descriptor | ||
1035 | * @patterns: array of supported patterns | ||
1036 | * @npatterns: length of the @patterns array | ||
1037 | * | ||
1038 | * The parser descriptor is just an array of supported patterns which will be | ||
1039 | * iterated by nand_op_parser_exec_op() everytime it tries to execute an | ||
1040 | * NAND operation (or tries to determine if a specific operation is supported). | ||
1041 | * | ||
1042 | * It is worth mentioning that patterns will be tested in their declaration | ||
1043 | * order, and the first match will be taken, so it's important to order patterns | ||
1044 | * appropriately so that simple/inefficient patterns are placed at the end of | ||
1045 | * the list. Usually, this is where you put single instruction patterns. | ||
1046 | */ | ||
1047 | struct nand_op_parser { | ||
1048 | const struct nand_op_parser_pattern *patterns; | ||
1049 | unsigned int npatterns; | ||
1050 | }; | ||
1051 | |||
1052 | #define NAND_OP_PARSER(...) \ | ||
1053 | { \ | ||
1054 | .patterns = (struct nand_op_parser_pattern[]) { __VA_ARGS__ }, \ | ||
1055 | .npatterns = sizeof((struct nand_op_parser_pattern[]) { __VA_ARGS__ }) / \ | ||
1056 | sizeof(struct nand_op_parser_pattern), \ | ||
1057 | } | ||
1058 | |||
1059 | /** | ||
1060 | * struct nand_operation - NAND operation descriptor | ||
1061 | * @instrs: array of instructions to execute | ||
1062 | * @ninstrs: length of the @instrs array | ||
1063 | * | ||
1064 | * The actual operation structure that will be passed to chip->exec_op(). | ||
1065 | */ | ||
1066 | struct nand_operation { | ||
1067 | const struct nand_op_instr *instrs; | ||
1068 | unsigned int ninstrs; | ||
1069 | }; | ||
1070 | |||
1071 | #define NAND_OPERATION(_instrs) \ | ||
1072 | { \ | ||
1073 | .instrs = _instrs, \ | ||
1074 | .ninstrs = ARRAY_SIZE(_instrs), \ | ||
1075 | } | ||
1076 | |||
1077 | int nand_op_parser_exec_op(struct nand_chip *chip, | ||
1078 | const struct nand_op_parser *parser, | ||
1079 | const struct nand_operation *op, bool check_only); | ||
1080 | |||
1081 | /** | ||
765 | * struct nand_chip - NAND Private Flash Chip Data | 1082 | * struct nand_chip - NAND Private Flash Chip Data |
766 | * @mtd: MTD device registered to the MTD framework | 1083 | * @mtd: MTD device registered to the MTD framework |
767 | * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the | 1084 | * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the |
@@ -787,10 +1104,13 @@ struct nand_manufacturer_ops { | |||
787 | * commands to the chip. | 1104 | * commands to the chip. |
788 | * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on | 1105 | * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on |
789 | * ready. | 1106 | * ready. |
1107 | * @exec_op: controller specific method to execute NAND operations. | ||
1108 | * This method replaces ->cmdfunc(), | ||
1109 | * ->{read,write}_{buf,byte,word}(), ->dev_ready() and | ||
1110 | * ->waifunc(). | ||
790 | * @setup_read_retry: [FLASHSPECIFIC] flash (vendor) specific function for | 1111 | * @setup_read_retry: [FLASHSPECIFIC] flash (vendor) specific function for |
791 | * setting the read-retry mode. Mostly needed for MLC NAND. | 1112 | * setting the read-retry mode. Mostly needed for MLC NAND. |
792 | * @ecc: [BOARDSPECIFIC] ECC control structure | 1113 | * @ecc: [BOARDSPECIFIC] ECC control structure |
793 | * @buffers: buffer structure for read/write | ||
794 | * @buf_align: minimum buffer alignment required by a platform | 1114 | * @buf_align: minimum buffer alignment required by a platform |
795 | * @hwcontrol: platform-specific hardware control structure | 1115 | * @hwcontrol: platform-specific hardware control structure |
796 | * @erase: [REPLACEABLE] erase function | 1116 | * @erase: [REPLACEABLE] erase function |
@@ -830,6 +1150,7 @@ struct nand_manufacturer_ops { | |||
830 | * @numchips: [INTERN] number of physical chips | 1150 | * @numchips: [INTERN] number of physical chips |
831 | * @chipsize: [INTERN] the size of one chip for multichip arrays | 1151 | * @chipsize: [INTERN] the size of one chip for multichip arrays |
832 | * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 | 1152 | * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 |
1153 | * @data_buf: [INTERN] buffer for data, size is (page size + oobsize). | ||
833 | * @pagebuf: [INTERN] holds the pagenumber which is currently in | 1154 | * @pagebuf: [INTERN] holds the pagenumber which is currently in |
834 | * data_buf. | 1155 | * data_buf. |
835 | * @pagebuf_bitflips: [INTERN] holds the bitflip count for the page which is | 1156 | * @pagebuf_bitflips: [INTERN] holds the bitflip count for the page which is |
@@ -886,6 +1207,9 @@ struct nand_chip { | |||
886 | void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, | 1207 | void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, |
887 | int page_addr); | 1208 | int page_addr); |
888 | int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this); | 1209 | int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this); |
1210 | int (*exec_op)(struct nand_chip *chip, | ||
1211 | const struct nand_operation *op, | ||
1212 | bool check_only); | ||
889 | int (*erase)(struct mtd_info *mtd, int page); | 1213 | int (*erase)(struct mtd_info *mtd, int page); |
890 | int (*scan_bbt)(struct mtd_info *mtd); | 1214 | int (*scan_bbt)(struct mtd_info *mtd); |
891 | int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip, | 1215 | int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip, |
@@ -896,7 +1220,6 @@ struct nand_chip { | |||
896 | int (*setup_data_interface)(struct mtd_info *mtd, int chipnr, | 1220 | int (*setup_data_interface)(struct mtd_info *mtd, int chipnr, |
897 | const struct nand_data_interface *conf); | 1221 | const struct nand_data_interface *conf); |
898 | 1222 | ||
899 | |||
900 | int chip_delay; | 1223 | int chip_delay; |
901 | unsigned int options; | 1224 | unsigned int options; |
902 | unsigned int bbt_options; | 1225 | unsigned int bbt_options; |
@@ -908,6 +1231,7 @@ struct nand_chip { | |||
908 | int numchips; | 1231 | int numchips; |
909 | uint64_t chipsize; | 1232 | uint64_t chipsize; |
910 | int pagemask; | 1233 | int pagemask; |
1234 | u8 *data_buf; | ||
911 | int pagebuf; | 1235 | int pagebuf; |
912 | unsigned int pagebuf_bitflips; | 1236 | unsigned int pagebuf_bitflips; |
913 | int subpagesize; | 1237 | int subpagesize; |
@@ -928,7 +1252,7 @@ struct nand_chip { | |||
928 | u16 max_bb_per_die; | 1252 | u16 max_bb_per_die; |
929 | u32 blocks_per_die; | 1253 | u32 blocks_per_die; |
930 | 1254 | ||
931 | struct nand_data_interface *data_interface; | 1255 | struct nand_data_interface data_interface; |
932 | 1256 | ||
933 | int read_retries; | 1257 | int read_retries; |
934 | 1258 | ||
@@ -938,7 +1262,6 @@ struct nand_chip { | |||
938 | struct nand_hw_control *controller; | 1262 | struct nand_hw_control *controller; |
939 | 1263 | ||
940 | struct nand_ecc_ctrl ecc; | 1264 | struct nand_ecc_ctrl ecc; |
941 | struct nand_buffers *buffers; | ||
942 | unsigned long buf_align; | 1265 | unsigned long buf_align; |
943 | struct nand_hw_control hwcontrol; | 1266 | struct nand_hw_control hwcontrol; |
944 | 1267 | ||
@@ -956,6 +1279,15 @@ struct nand_chip { | |||
956 | } manufacturer; | 1279 | } manufacturer; |
957 | }; | 1280 | }; |
958 | 1281 | ||
1282 | static inline int nand_exec_op(struct nand_chip *chip, | ||
1283 | const struct nand_operation *op) | ||
1284 | { | ||
1285 | if (!chip->exec_op) | ||
1286 | return -ENOTSUPP; | ||
1287 | |||
1288 | return chip->exec_op(chip, op, false); | ||
1289 | } | ||
1290 | |||
959 | extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops; | 1291 | extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops; |
960 | extern const struct mtd_ooblayout_ops nand_ooblayout_lp_ops; | 1292 | extern const struct mtd_ooblayout_ops nand_ooblayout_lp_ops; |
961 | 1293 | ||
@@ -1225,8 +1557,7 @@ static inline int onfi_get_sync_timing_mode(struct nand_chip *chip) | |||
1225 | return le16_to_cpu(chip->onfi_params.src_sync_timing_mode); | 1557 | return le16_to_cpu(chip->onfi_params.src_sync_timing_mode); |
1226 | } | 1558 | } |
1227 | 1559 | ||
1228 | int onfi_init_data_interface(struct nand_chip *chip, | 1560 | int onfi_fill_data_interface(struct nand_chip *chip, |
1229 | struct nand_data_interface *iface, | ||
1230 | enum nand_data_interface_type type, | 1561 | enum nand_data_interface_type type, |
1231 | int timing_mode); | 1562 | int timing_mode); |
1232 | 1563 | ||
@@ -1269,8 +1600,6 @@ static inline int jedec_feature(struct nand_chip *chip) | |||
1269 | 1600 | ||
1270 | /* get timing characteristics from ONFI timing mode. */ | 1601 | /* get timing characteristics from ONFI timing mode. */ |
1271 | const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode); | 1602 | const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode); |
1272 | /* get data interface from ONFI timing mode 0, used after reset. */ | ||
1273 | const struct nand_data_interface *nand_get_default_data_interface(void); | ||
1274 | 1603 | ||
1275 | int nand_check_erased_ecc_chunk(void *data, int datalen, | 1604 | int nand_check_erased_ecc_chunk(void *data, int datalen, |
1276 | void *ecc, int ecclen, | 1605 | void *ecc, int ecclen, |
@@ -1316,9 +1645,45 @@ int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, | |||
1316 | /* Reset and initialize a NAND device */ | 1645 | /* Reset and initialize a NAND device */ |
1317 | int nand_reset(struct nand_chip *chip, int chipnr); | 1646 | int nand_reset(struct nand_chip *chip, int chipnr); |
1318 | 1647 | ||
1648 | /* NAND operation helpers */ | ||
1649 | int nand_reset_op(struct nand_chip *chip); | ||
1650 | int nand_readid_op(struct nand_chip *chip, u8 addr, void *buf, | ||
1651 | unsigned int len); | ||
1652 | int nand_status_op(struct nand_chip *chip, u8 *status); | ||
1653 | int nand_exit_status_op(struct nand_chip *chip); | ||
1654 | int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock); | ||
1655 | int nand_read_page_op(struct nand_chip *chip, unsigned int page, | ||
1656 | unsigned int offset_in_page, void *buf, unsigned int len); | ||
1657 | int nand_change_read_column_op(struct nand_chip *chip, | ||
1658 | unsigned int offset_in_page, void *buf, | ||
1659 | unsigned int len, bool force_8bit); | ||
1660 | int nand_read_oob_op(struct nand_chip *chip, unsigned int page, | ||
1661 | unsigned int offset_in_page, void *buf, unsigned int len); | ||
1662 | int nand_prog_page_begin_op(struct nand_chip *chip, unsigned int page, | ||
1663 | unsigned int offset_in_page, const void *buf, | ||
1664 | unsigned int len); | ||
1665 | int nand_prog_page_end_op(struct nand_chip *chip); | ||
1666 | int nand_prog_page_op(struct nand_chip *chip, unsigned int page, | ||
1667 | unsigned int offset_in_page, const void *buf, | ||
1668 | unsigned int len); | ||
1669 | int nand_change_write_column_op(struct nand_chip *chip, | ||
1670 | unsigned int offset_in_page, const void *buf, | ||
1671 | unsigned int len, bool force_8bit); | ||
1672 | int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len, | ||
1673 | bool force_8bit); | ||
1674 | int nand_write_data_op(struct nand_chip *chip, const void *buf, | ||
1675 | unsigned int len, bool force_8bit); | ||
1676 | |||
1319 | /* Free resources held by the NAND device */ | 1677 | /* Free resources held by the NAND device */ |
1320 | void nand_cleanup(struct nand_chip *chip); | 1678 | void nand_cleanup(struct nand_chip *chip); |
1321 | 1679 | ||
1322 | /* Default extended ID decoding function */ | 1680 | /* Default extended ID decoding function */ |
1323 | void nand_decode_ext_id(struct nand_chip *chip); | 1681 | void nand_decode_ext_id(struct nand_chip *chip); |
1682 | |||
1683 | /* | ||
1684 | * External helper for controller drivers that have to implement the WAITRDY | ||
1685 | * instruction and have no physical pin to check it. | ||
1686 | */ | ||
1687 | int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms); | ||
1688 | |||
1324 | #endif /* __LINUX_MTD_RAWNAND_H */ | 1689 | #endif /* __LINUX_MTD_RAWNAND_H */ |