@@ -2541,9 +2541,11 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
2541
2541
return 0 ;
2542
2542
}
2543
2543
2544
- static int qcom_op_cmd_mapping (struct qcom_nand_controller * nandc , u8 opcode ,
2544
+ static int qcom_op_cmd_mapping (struct nand_chip * chip , u8 opcode ,
2545
2545
struct qcom_op * q_op )
2546
2546
{
2547
+ struct qcom_nand_controller * nandc = get_qcom_nand_controller (chip );
2548
+ struct qcom_nand_host * host = to_qcom_nand_host (chip );
2547
2549
int cmd ;
2548
2550
2549
2551
switch (opcode ) {
@@ -2571,6 +2573,13 @@ static int qcom_op_cmd_mapping(struct qcom_nand_controller *nandc, u8 opcode,
2571
2573
q_op -> flag = OP_PROGRAM_PAGE ;
2572
2574
nandc -> exec_opwrite = true;
2573
2575
break ;
2576
+ case NAND_CMD_READ0 :
2577
+ case NAND_CMD_READSTART :
2578
+ if (host -> use_ecc )
2579
+ cmd = OP_PAGE_READ_WITH_ECC ;
2580
+ else
2581
+ cmd = OP_PAGE_READ ;
2582
+ break ;
2574
2583
default :
2575
2584
dev_err (nandc -> dev , "Opcode not supported: %u\n" , opcode );
2576
2585
return - EOPNOTSUPP ;
@@ -2584,7 +2593,6 @@ static int qcom_parse_instructions(struct nand_chip *chip,
2584
2593
const struct nand_subop * subop ,
2585
2594
struct qcom_op * q_op )
2586
2595
{
2587
- struct qcom_nand_controller * nandc = get_qcom_nand_controller (chip );
2588
2596
const struct nand_op_instr * instr = NULL ;
2589
2597
unsigned int op_id ;
2590
2598
int i , ret ;
@@ -2597,7 +2605,7 @@ static int qcom_parse_instructions(struct nand_chip *chip,
2597
2605
2598
2606
switch (instr -> type ) {
2599
2607
case NAND_OP_CMD_INSTR :
2600
- ret = qcom_op_cmd_mapping (nandc , instr -> ctx .cmd .opcode , q_op );
2608
+ ret = qcom_op_cmd_mapping (chip , instr -> ctx .cmd .opcode , q_op );
2601
2609
if (ret < 0 )
2602
2610
return ret ;
2603
2611
@@ -2791,13 +2799,25 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub
2791
2799
struct qcom_nand_host * host = to_qcom_nand_host (chip );
2792
2800
struct qcom_op q_op = {};
2793
2801
int ret ;
2802
+ int instrs = 1 ;
2794
2803
2795
2804
ret = qcom_parse_instructions (chip , subop , & q_op );
2796
2805
if (ret )
2797
2806
return ret ;
2798
2807
2799
- if (q_op .flag == OP_PROGRAM_PAGE )
2808
+ if (q_op .flag == OP_PROGRAM_PAGE ) {
2800
2809
goto wait_rdy ;
2810
+ } else if (q_op .cmd_reg == OP_BLOCK_ERASE ) {
2811
+ q_op .cmd_reg |= PAGE_ACC | LAST_PAGE ;
2812
+ nandc_set_reg (chip , NAND_ADDR0 , q_op .addr1_reg );
2813
+ nandc_set_reg (chip , NAND_ADDR1 , q_op .addr2_reg );
2814
+ nandc_set_reg (chip , NAND_DEV0_CFG0 ,
2815
+ host -> cfg0_raw & ~(7 << CW_PER_PAGE ));
2816
+ nandc_set_reg (chip , NAND_DEV0_CFG1 , host -> cfg1_raw );
2817
+ instrs = 3 ;
2818
+ } else {
2819
+ return 0 ;
2820
+ }
2801
2821
2802
2822
nandc -> buf_count = 0 ;
2803
2823
nandc -> buf_start = 0 ;
@@ -2809,9 +2829,12 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub
2809
2829
nandc_set_reg (chip , NAND_FLASH_CMD , q_op .cmd_reg );
2810
2830
nandc_set_reg (chip , NAND_EXEC_CMD , 1 );
2811
2831
2812
- write_reg_dma (nandc , NAND_FLASH_CMD , 1 , NAND_BAM_NEXT_SGL );
2813
- write_reg_dma (nandc , NAND_EXEC_CMD , 1 , NAND_BAM_NEXT_SGL );
2832
+ write_reg_dma (nandc , NAND_FLASH_CMD , instrs , NAND_BAM_NEXT_SGL );
2833
+ (q_op .cmd_reg == OP_BLOCK_ERASE ) ? write_reg_dma (nandc , NAND_DEV0_CFG0 ,
2834
+ 2 , NAND_BAM_NEXT_SGL ) : read_reg_dma (nandc ,
2835
+ NAND_FLASH_STATUS , 1 , NAND_BAM_NEXT_SGL );
2814
2836
2837
+ write_reg_dma (nandc , NAND_EXEC_CMD , 1 , NAND_BAM_NEXT_SGL );
2815
2838
read_reg_dma (nandc , NAND_FLASH_STATUS , 1 , NAND_BAM_NEXT_SGL );
2816
2839
2817
2840
ret = submit_descs (nandc );
@@ -2925,56 +2948,7 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
2925
2948
return ret ;
2926
2949
}
2927
2950
2928
- static int qcom_erase_cmd_type_exec (struct nand_chip * chip , const struct nand_subop * subop )
2929
- {
2930
- struct qcom_nand_host * host = to_qcom_nand_host (chip );
2931
- struct qcom_nand_controller * nandc = get_qcom_nand_controller (chip );
2932
- struct qcom_op q_op = {};
2933
- int ret ;
2934
-
2935
- ret = qcom_parse_instructions (chip , subop , & q_op );
2936
- if (ret )
2937
- return ret ;
2938
-
2939
- q_op .cmd_reg |= PAGE_ACC | LAST_PAGE ;
2940
-
2941
- nandc -> buf_count = 0 ;
2942
- nandc -> buf_start = 0 ;
2943
- host -> use_ecc = false;
2944
- clear_read_regs (nandc );
2945
- clear_bam_transaction (nandc );
2946
-
2947
- nandc_set_reg (chip , NAND_FLASH_CMD , q_op .cmd_reg );
2948
- nandc_set_reg (chip , NAND_ADDR0 , q_op .addr1_reg );
2949
- nandc_set_reg (chip , NAND_ADDR1 , q_op .addr2_reg );
2950
- nandc_set_reg (chip , NAND_DEV0_CFG0 ,
2951
- host -> cfg0_raw & ~(7 << CW_PER_PAGE ));
2952
- nandc_set_reg (chip , NAND_DEV0_CFG1 , host -> cfg1_raw );
2953
- nandc_set_reg (chip , NAND_EXEC_CMD , 1 );
2954
-
2955
- write_reg_dma (nandc , NAND_FLASH_CMD , 3 , NAND_BAM_NEXT_SGL );
2956
- write_reg_dma (nandc , NAND_DEV0_CFG0 , 2 , NAND_BAM_NEXT_SGL );
2957
- write_reg_dma (nandc , NAND_EXEC_CMD , 1 , NAND_BAM_NEXT_SGL );
2958
-
2959
- ret = submit_descs (nandc );
2960
- if (ret ) {
2961
- dev_err (nandc -> dev , "failure in submitting erase descriptor\n" );
2962
- goto err_out ;
2963
- }
2964
-
2965
- ret = qcom_wait_rdy_poll (chip , q_op .rdy_timeout_ms );
2966
- if (ret )
2967
- goto err_out ;
2968
-
2969
- err_out :
2970
- return ret ;
2971
- }
2972
-
2973
2951
static const struct nand_op_parser qcom_op_parser = NAND_OP_PARSER (
2974
- NAND_OP_PARSER_PATTERN (
2975
- qcom_misc_cmd_type_exec ,
2976
- NAND_OP_PARSER_PAT_CMD_ELEM (false),
2977
- NAND_OP_PARSER_PAT_WAITRDY_ELEM (false)),
2978
2952
NAND_OP_PARSER_PATTERN (
2979
2953
qcom_read_id_type_exec ,
2980
2954
NAND_OP_PARSER_PAT_CMD_ELEM (false),
@@ -2991,10 +2965,10 @@ static const struct nand_op_parser qcom_op_parser = NAND_OP_PARSER(
2991
2965
NAND_OP_PARSER_PAT_WAITRDY_ELEM (true),
2992
2966
NAND_OP_PARSER_PAT_DATA_IN_ELEM (false, 512 )),
2993
2967
NAND_OP_PARSER_PATTERN (
2994
- qcom_erase_cmd_type_exec ,
2995
- NAND_OP_PARSER_PAT_CMD_ELEM (false),
2996
- NAND_OP_PARSER_PAT_ADDR_ELEM (false, MAX_ADDRESS_CYCLE ),
2968
+ qcom_misc_cmd_type_exec ,
2997
2969
NAND_OP_PARSER_PAT_CMD_ELEM (false),
2970
+ NAND_OP_PARSER_PAT_ADDR_ELEM (true, MAX_ADDRESS_CYCLE ),
2971
+ NAND_OP_PARSER_PAT_CMD_ELEM (true),
2998
2972
NAND_OP_PARSER_PAT_WAITRDY_ELEM (false)),
2999
2973
);
3000
2974
@@ -3015,7 +2989,9 @@ static int qcom_check_op(struct nand_chip *chip,
3015
2989
instr -> ctx .cmd .opcode != NAND_CMD_ERASE1 &&
3016
2990
instr -> ctx .cmd .opcode != NAND_CMD_ERASE2 &&
3017
2991
instr -> ctx .cmd .opcode != NAND_CMD_STATUS &&
3018
- instr -> ctx .cmd .opcode != NAND_CMD_PAGEPROG )
2992
+ instr -> ctx .cmd .opcode != NAND_CMD_PAGEPROG &&
2993
+ instr -> ctx .cmd .opcode != NAND_CMD_READ0 &&
2994
+ instr -> ctx .cmd .opcode != NAND_CMD_READSTART )
3019
2995
return - EOPNOTSUPP ;
3020
2996
break ;
3021
2997
default :
0 commit comments