@@ -1587,6 +1587,74 @@ static int check_flash_errors(struct qcom_nand_host *host, int cw_cnt)
1587
1587
return 0 ;
1588
1588
}
1589
1589
1590
+ /* performs raw read for one codeword */
1591
+ static int
1592
+ qcom_nandc_read_cw_raw (struct mtd_info * mtd , struct nand_chip * chip ,
1593
+ u8 * data_buf , u8 * oob_buf , int page , int cw )
1594
+ {
1595
+ struct qcom_nand_host * host = to_qcom_nand_host (chip );
1596
+ struct qcom_nand_controller * nandc = get_qcom_nand_controller (chip );
1597
+ struct nand_ecc_ctrl * ecc = & chip -> ecc ;
1598
+ int data_size1 , data_size2 , oob_size1 , oob_size2 ;
1599
+ int ret , reg_off = FLASH_BUF_ACC , read_loc = 0 ;
1600
+
1601
+ nand_read_page_op (chip , page , 0 , NULL , 0 );
1602
+ host -> use_ecc = false;
1603
+
1604
+ clear_bam_transaction (nandc );
1605
+ set_address (host , host -> cw_size * cw , page );
1606
+ update_rw_regs (host , 1 , true);
1607
+ config_nand_page_read (nandc );
1608
+
1609
+ data_size1 = mtd -> writesize - host -> cw_size * (ecc -> steps - 1 );
1610
+ oob_size1 = host -> bbm_size ;
1611
+
1612
+ if (cw == (ecc -> steps - 1 )) {
1613
+ data_size2 = ecc -> size - data_size1 -
1614
+ ((ecc -> steps - 1 ) * 4 );
1615
+ oob_size2 = (ecc -> steps * 4 ) + host -> ecc_bytes_hw +
1616
+ host -> spare_bytes ;
1617
+ } else {
1618
+ data_size2 = host -> cw_data - data_size1 ;
1619
+ oob_size2 = host -> ecc_bytes_hw + host -> spare_bytes ;
1620
+ }
1621
+
1622
+ if (nandc -> props -> is_bam ) {
1623
+ nandc_set_read_loc (nandc , 0 , read_loc , data_size1 , 0 );
1624
+ read_loc += data_size1 ;
1625
+
1626
+ nandc_set_read_loc (nandc , 1 , read_loc , oob_size1 , 0 );
1627
+ read_loc += oob_size1 ;
1628
+
1629
+ nandc_set_read_loc (nandc , 2 , read_loc , data_size2 , 0 );
1630
+ read_loc += data_size2 ;
1631
+
1632
+ nandc_set_read_loc (nandc , 3 , read_loc , oob_size2 , 1 );
1633
+ }
1634
+
1635
+ config_nand_cw_read (nandc , false);
1636
+
1637
+ read_data_dma (nandc , reg_off , data_buf , data_size1 , 0 );
1638
+ reg_off += data_size1 ;
1639
+
1640
+ read_data_dma (nandc , reg_off , oob_buf , oob_size1 , 0 );
1641
+ reg_off += oob_size1 ;
1642
+
1643
+ read_data_dma (nandc , reg_off , data_buf + data_size1 , data_size2 , 0 );
1644
+ reg_off += data_size2 ;
1645
+
1646
+ read_data_dma (nandc , reg_off , oob_buf + oob_size1 , oob_size2 , 0 );
1647
+
1648
+ ret = submit_descs (nandc );
1649
+ free_descs (nandc );
1650
+ if (ret ) {
1651
+ dev_err (nandc -> dev , "failure to read raw cw %d\n" , cw );
1652
+ return ret ;
1653
+ }
1654
+
1655
+ return check_flash_errors (host , 1 );
1656
+ }
1657
+
1590
1658
/*
1591
1659
* reads back status registers set by the controller to notify page read
1592
1660
* errors. this is equivalent to what 'ecc->correct()' would do.
@@ -1851,79 +1919,21 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd,
1851
1919
int oob_required , int page )
1852
1920
{
1853
1921
struct qcom_nand_host * host = to_qcom_nand_host (chip );
1854
- struct qcom_nand_controller * nandc = get_qcom_nand_controller (chip );
1855
- u8 * data_buf , * oob_buf ;
1856
1922
struct nand_ecc_ctrl * ecc = & chip -> ecc ;
1857
- int i , ret ;
1858
- int read_loc ;
1923
+ int cw , ret ;
1924
+ u8 * data_buf = buf , * oob_buf = chip -> oob_poi ;
1859
1925
1860
- nand_read_page_op (chip , page , 0 , NULL , 0 );
1861
- data_buf = buf ;
1862
- oob_buf = chip -> oob_poi ;
1863
-
1864
- host -> use_ecc = false;
1865
-
1866
- clear_bam_transaction (nandc );
1867
- update_rw_regs (host , ecc -> steps , true);
1868
- config_nand_page_read (nandc );
1869
-
1870
- for (i = 0 ; i < ecc -> steps ; i ++ ) {
1871
- int data_size1 , data_size2 , oob_size1 , oob_size2 ;
1872
- int reg_off = FLASH_BUF_ACC ;
1873
-
1874
- data_size1 = mtd -> writesize - host -> cw_size * (ecc -> steps - 1 );
1875
- oob_size1 = host -> bbm_size ;
1876
-
1877
- if (i == (ecc -> steps - 1 )) {
1878
- data_size2 = ecc -> size - data_size1 -
1879
- ((ecc -> steps - 1 ) << 2 );
1880
- oob_size2 = (ecc -> steps << 2 ) + host -> ecc_bytes_hw +
1881
- host -> spare_bytes ;
1882
- } else {
1883
- data_size2 = host -> cw_data - data_size1 ;
1884
- oob_size2 = host -> ecc_bytes_hw + host -> spare_bytes ;
1885
- }
1886
-
1887
- if (nandc -> props -> is_bam ) {
1888
- read_loc = 0 ;
1889
- nandc_set_read_loc (nandc , 0 , read_loc , data_size1 , 0 );
1890
- read_loc += data_size1 ;
1891
-
1892
- nandc_set_read_loc (nandc , 1 , read_loc , oob_size1 , 0 );
1893
- read_loc += oob_size1 ;
1894
-
1895
- nandc_set_read_loc (nandc , 2 , read_loc , data_size2 , 0 );
1896
- read_loc += data_size2 ;
1897
-
1898
- nandc_set_read_loc (nandc , 3 , read_loc , oob_size2 , 1 );
1899
- }
1900
-
1901
- config_nand_cw_read (nandc , false);
1902
-
1903
- read_data_dma (nandc , reg_off , data_buf , data_size1 , 0 );
1904
- reg_off += data_size1 ;
1905
- data_buf += data_size1 ;
1906
-
1907
- read_data_dma (nandc , reg_off , oob_buf , oob_size1 , 0 );
1908
- reg_off += oob_size1 ;
1909
- oob_buf += oob_size1 ;
1910
-
1911
- read_data_dma (nandc , reg_off , data_buf , data_size2 , 0 );
1912
- reg_off += data_size2 ;
1913
- data_buf += data_size2 ;
1926
+ for (cw = 0 ; cw < ecc -> steps ; cw ++ ) {
1927
+ ret = qcom_nandc_read_cw_raw (mtd , chip , data_buf , oob_buf ,
1928
+ page , cw );
1929
+ if (ret )
1930
+ return ret ;
1914
1931
1915
- read_data_dma ( nandc , reg_off , oob_buf , oob_size2 , 0 ) ;
1916
- oob_buf += oob_size2 ;
1932
+ data_buf += host -> cw_data ;
1933
+ oob_buf += ecc -> bytes ;
1917
1934
}
1918
1935
1919
- ret = submit_descs (nandc );
1920
- free_descs (nandc );
1921
- if (ret ) {
1922
- dev_err (nandc -> dev , "failure to read raw page\n" );
1923
- return ret ;
1924
- }
1925
-
1926
- return check_flash_errors (host , ecc -> steps );
1936
+ return 0 ;
1927
1937
}
1928
1938
1929
1939
/* implements ecc->read_oob() */
0 commit comments