Message ID | 20240724114225.2176448-6-quic_mdalam@quicinc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add QPIC SPI NAND driver | expand |
Hi Md, kernel test robot noticed the following build warnings: [auto build test WARNING on mtd/nand/next] [also build test WARNING on broonie-spi/for-next robh/for-next linus/master v6.10 next-20240725] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Md-Sadre-Alam/spi-dt-bindings-Introduce-qcom-spi-qpic-snand/20240724-195819 base: https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next patch link: https://lore.kernel.org/r/20240724114225.2176448-6-quic_mdalam%40quicinc.com patch subject: [PATCH v7 5/8] mtd: rawnand: qcom: use FIELD_PREP and GENMASK config: microblaze-randconfig-r133-20240725 (https://download.01.org/0day-ci/archive/20240726/202407260410.p2IXTwQb-lkp@intel.com/config) compiler: microblaze-linux-gcc (GCC) 14.1.0 reproduce: (https://download.01.org/0day-ci/archive/20240726/202407260410.p2IXTwQb-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202407260410.p2IXTwQb-lkp@intel.com/ sparse warnings: (new ones prefixed by >>) drivers/mtd/nand/raw/qcom_nandc.c:171:45: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location0 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:171:45: sparse: expected restricted __le32 [usertype] read_location0 drivers/mtd/nand/raw/qcom_nandc.c:171:45: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:173:45: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location1 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:173:45: sparse: expected restricted __le32 [usertype] read_location1 drivers/mtd/nand/raw/qcom_nandc.c:173:45: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:175:45: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location2 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:175:45: sparse: expected restricted __le32 [usertype] read_location2 drivers/mtd/nand/raw/qcom_nandc.c:175:45: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:177:45: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location3 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:177:45: sparse: expected restricted __le32 [usertype] read_location3 drivers/mtd/nand/raw/qcom_nandc.c:177:45: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:200:50: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location_last0 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:200:50: sparse: expected restricted __le32 [usertype] read_location_last0 drivers/mtd/nand/raw/qcom_nandc.c:200:50: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:202:50: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location_last1 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:202:50: sparse: expected restricted __le32 [usertype] read_location_last1 drivers/mtd/nand/raw/qcom_nandc.c:202:50: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:204:50: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location_last2 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:204:50: sparse: expected restricted __le32 [usertype] read_location_last2 drivers/mtd/nand/raw/qcom_nandc.c:204:50: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:206:50: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] read_location_last3 @@ got int val @@ drivers/mtd/nand/raw/qcom_nandc.c:206:50: sparse: expected restricted __le32 [usertype] read_location_last3 drivers/mtd/nand/raw/qcom_nandc.c:206:50: sparse: got int val drivers/mtd/nand/raw/qcom_nandc.c:239:28: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] addr0 @@ got int @@ drivers/mtd/nand/raw/qcom_nandc.c:239:28: sparse: expected restricted __le32 [usertype] addr0 drivers/mtd/nand/raw/qcom_nandc.c:239:28: sparse: got int drivers/mtd/nand/raw/qcom_nandc.c:240:28: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] addr1 @@ got int @@ drivers/mtd/nand/raw/qcom_nandc.c:240:28: sparse: expected restricted __le32 [usertype] addr1 drivers/mtd/nand/raw/qcom_nandc.c:240:28: sparse: got int drivers/mtd/nand/raw/qcom_nandc.c:280:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cmd @@ got unsigned int [assigned] [usertype] cmd @@ drivers/mtd/nand/raw/qcom_nandc.c:280:26: sparse: expected restricted __le32 [usertype] cmd drivers/mtd/nand/raw/qcom_nandc.c:280:26: sparse: got unsigned int [assigned] [usertype] cmd drivers/mtd/nand/raw/qcom_nandc.c:281:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cfg0 @@ got unsigned int [assigned] [usertype] cfg0 @@ drivers/mtd/nand/raw/qcom_nandc.c:281:27: sparse: expected restricted __le32 [usertype] cfg0 drivers/mtd/nand/raw/qcom_nandc.c:281:27: sparse: got unsigned int [assigned] [usertype] cfg0 drivers/mtd/nand/raw/qcom_nandc.c:282:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cfg1 @@ got unsigned int [assigned] [usertype] cfg1 @@ drivers/mtd/nand/raw/qcom_nandc.c:282:27: sparse: expected restricted __le32 [usertype] cfg1 drivers/mtd/nand/raw/qcom_nandc.c:282:27: sparse: got unsigned int [assigned] [usertype] cfg1 drivers/mtd/nand/raw/qcom_nandc.c:283:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] ecc_bch_cfg @@ got unsigned int [assigned] [usertype] ecc_bch_cfg @@ drivers/mtd/nand/raw/qcom_nandc.c:283:34: sparse: expected restricted __le32 [usertype] ecc_bch_cfg drivers/mtd/nand/raw/qcom_nandc.c:283:34: sparse: got unsigned int [assigned] [usertype] ecc_bch_cfg drivers/mtd/nand/raw/qcom_nandc.c:286:42: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] ecc_buf_cfg @@ got unsigned int [usertype] ecc_buf_cfg @@ drivers/mtd/nand/raw/qcom_nandc.c:286:42: sparse: expected restricted __le32 [usertype] ecc_buf_cfg drivers/mtd/nand/raw/qcom_nandc.c:286:42: sparse: got unsigned int [usertype] ecc_buf_cfg drivers/mtd/nand/raw/qcom_nandc.c:288:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] clrflashstatus @@ got unsigned int [usertype] clrflashstatus @@ drivers/mtd/nand/raw/qcom_nandc.c:288:37: sparse: expected restricted __le32 [usertype] clrflashstatus drivers/mtd/nand/raw/qcom_nandc.c:288:37: sparse: got unsigned int [usertype] clrflashstatus drivers/mtd/nand/raw/qcom_nandc.c:289:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] clrreadstatus @@ got unsigned int [usertype] clrreadstatus @@ drivers/mtd/nand/raw/qcom_nandc.c:289:36: sparse: expected restricted __le32 [usertype] clrreadstatus drivers/mtd/nand/raw/qcom_nandc.c:289:36: sparse: got unsigned int [usertype] clrreadstatus drivers/mtd/nand/raw/qcom_nandc.c:290:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] exec @@ got int @@ drivers/mtd/nand/raw/qcom_nandc.c:290:27: sparse: expected restricted __le32 [usertype] exec drivers/mtd/nand/raw/qcom_nandc.c:290:27: sparse: got int drivers/mtd/nand/raw/qcom_nandc.c:1708:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cmd @@ got unsigned int [addressable] [usertype] cmd_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1708:26: sparse: expected restricted __le32 [usertype] cmd drivers/mtd/nand/raw/qcom_nandc.c:1708:26: sparse: got unsigned int [addressable] [usertype] cmd_reg drivers/mtd/nand/raw/qcom_nandc.c:1709:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] exec @@ got int @@ drivers/mtd/nand/raw/qcom_nandc.c:1709:27: sparse: expected restricted __le32 [usertype] exec drivers/mtd/nand/raw/qcom_nandc.c:1709:27: sparse: got int drivers/mtd/nand/raw/qcom_nandc.c:1765:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cmd @@ got unsigned int [addressable] [usertype] cmd_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1765:26: sparse: expected restricted __le32 [usertype] cmd drivers/mtd/nand/raw/qcom_nandc.c:1765:26: sparse: got unsigned int [addressable] [usertype] cmd_reg drivers/mtd/nand/raw/qcom_nandc.c:1766:28: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] addr0 @@ got unsigned int [addressable] [usertype] addr1_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1766:28: sparse: expected restricted __le32 [usertype] addr0 drivers/mtd/nand/raw/qcom_nandc.c:1766:28: sparse: got unsigned int [addressable] [usertype] addr1_reg drivers/mtd/nand/raw/qcom_nandc.c:1767:28: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] addr1 @@ got unsigned int [addressable] [usertype] addr2_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1767:28: sparse: expected restricted __le32 [usertype] addr1 drivers/mtd/nand/raw/qcom_nandc.c:1767:28: sparse: got unsigned int [addressable] [usertype] addr2_reg drivers/mtd/nand/raw/qcom_nandc.c:1768:31: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] chip_sel @@ got unsigned long @@ drivers/mtd/nand/raw/qcom_nandc.c:1768:31: sparse: expected restricted __le32 [usertype] chip_sel drivers/mtd/nand/raw/qcom_nandc.c:1768:31: sparse: got unsigned long drivers/mtd/nand/raw/qcom_nandc.c:1769:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] exec @@ got int @@ drivers/mtd/nand/raw/qcom_nandc.c:1769:27: sparse: expected restricted __le32 [usertype] exec drivers/mtd/nand/raw/qcom_nandc.c:1769:27: sparse: got int drivers/mtd/nand/raw/qcom_nandc.c:1809:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] addr0 @@ got unsigned int [addressable] [assigned] [usertype] addr1_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1809:36: sparse: expected restricted __le32 [usertype] addr0 drivers/mtd/nand/raw/qcom_nandc.c:1809:36: sparse: got unsigned int [addressable] [assigned] [usertype] addr1_reg drivers/mtd/nand/raw/qcom_nandc.c:1810:36: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] addr1 @@ got unsigned int [addressable] [assigned] [usertype] addr2_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1810:36: sparse: expected restricted __le32 [usertype] addr1 drivers/mtd/nand/raw/qcom_nandc.c:1810:36: sparse: got unsigned int [addressable] [assigned] [usertype] addr2_reg drivers/mtd/nand/raw/qcom_nandc.c:1811:35: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cfg0 @@ got unsigned int @@ drivers/mtd/nand/raw/qcom_nandc.c:1811:35: sparse: expected restricted __le32 [usertype] cfg0 drivers/mtd/nand/raw/qcom_nandc.c:1811:35: sparse: got unsigned int drivers/mtd/nand/raw/qcom_nandc.c:1812:35: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cfg1 @@ got unsigned int [usertype] cfg1_raw @@ drivers/mtd/nand/raw/qcom_nandc.c:1812:35: sparse: expected restricted __le32 [usertype] cfg1 drivers/mtd/nand/raw/qcom_nandc.c:1812:35: sparse: got unsigned int [usertype] cfg1_raw drivers/mtd/nand/raw/qcom_nandc.c:1825:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cmd @@ got unsigned int [addressable] [assigned] [usertype] cmd_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1825:26: sparse: expected restricted __le32 [usertype] cmd drivers/mtd/nand/raw/qcom_nandc.c:1825:26: sparse: got unsigned int [addressable] [assigned] [usertype] cmd_reg drivers/mtd/nand/raw/qcom_nandc.c:1826:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] exec @@ got int @@ drivers/mtd/nand/raw/qcom_nandc.c:1826:27: sparse: expected restricted __le32 [usertype] exec drivers/mtd/nand/raw/qcom_nandc.c:1826:27: sparse: got int drivers/mtd/nand/raw/qcom_nandc.c:1872:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cmd @@ got unsigned int [addressable] [assigned] [usertype] cmd_reg @@ drivers/mtd/nand/raw/qcom_nandc.c:1872:26: sparse: expected restricted __le32 [usertype] cmd drivers/mtd/nand/raw/qcom_nandc.c:1872:26: sparse: got unsigned int [addressable] [assigned] [usertype] cmd_reg >> drivers/mtd/nand/raw/qcom_nandc.c:1890:42: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] ecc_buf_cfg @@ got unsigned long @@ drivers/mtd/nand/raw/qcom_nandc.c:1890:42: sparse: expected restricted __le32 [usertype] ecc_buf_cfg drivers/mtd/nand/raw/qcom_nandc.c:1890:42: sparse: got unsigned long drivers/mtd/nand/raw/qcom_nandc.c:1894:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] vld @@ got unsigned long @@ drivers/mtd/nand/raw/qcom_nandc.c:1894:34: sparse: expected restricted __le32 [usertype] vld drivers/mtd/nand/raw/qcom_nandc.c:1894:34: sparse: got unsigned long drivers/mtd/nand/raw/qcom_nandc.c:1895:35: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] cmd1 @@ got unsigned int @@ drivers/mtd/nand/raw/qcom_nandc.c:1895:35: sparse: expected restricted __le32 [usertype] cmd1 drivers/mtd/nand/raw/qcom_nandc.c:1895:35: sparse: got unsigned int drivers/mtd/nand/raw/qcom_nandc.c:1899:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] exec @@ got int @@ drivers/mtd/nand/raw/qcom_nandc.c:1899:27: sparse: expected restricted __le32 [usertype] exec drivers/mtd/nand/raw/qcom_nandc.c:1899:27: sparse: got int drivers/mtd/nand/raw/qcom_nandc.c:1902:40: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] orig_cmd1 @@ got unsigned int [usertype] cmd1 @@ drivers/mtd/nand/raw/qcom_nandc.c:1902:40: sparse: expected restricted __le32 [usertype] orig_cmd1 drivers/mtd/nand/raw/qcom_nandc.c:1902:40: sparse: got unsigned int [usertype] cmd1 drivers/mtd/nand/raw/qcom_nandc.c:1903:39: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 [usertype] orig_vld @@ got unsigned int [usertype] vld @@ drivers/mtd/nand/raw/qcom_nandc.c:1903:39: sparse: expected restricted __le32 [usertype] orig_vld drivers/mtd/nand/raw/qcom_nandc.c:1903:39: sparse: got unsigned int [usertype] vld drivers/mtd/nand/raw/qcom_nandc.c: note: in included file: include/linux/mtd/nand-qpic-common.h:453:34: sparse: sparse: marked inline, but without a definition include/linux/mtd/nand-qpic-common.h:453:34: sparse: sparse: marked inline, but without a definition include/linux/mtd/nand-qpic-common.h:453:34: sparse: sparse: marked inline, but without a definition include/linux/mtd/nand-qpic-common.h:453:34: sparse: sparse: marked inline, but without a definition include/linux/mtd/nand-qpic-common.h:453:34: sparse: sparse: marked inline, but without a definition vim +1890 drivers/mtd/nand/raw/qcom_nandc.c 1849 1850 static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_subop *subop) 1851 { 1852 struct qcom_nand_host *host = to_qcom_nand_host(chip); 1853 struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); 1854 struct qcom_op q_op = {}; 1855 const struct nand_op_instr *instr = NULL; 1856 unsigned int op_id = 0; 1857 unsigned int len = 0; 1858 int ret; 1859 1860 ret = qcom_parse_instructions(chip, subop, &q_op); 1861 if (ret) 1862 return ret; 1863 1864 q_op.cmd_reg |= PAGE_ACC | LAST_PAGE; 1865 1866 nandc->buf_count = 0; 1867 nandc->buf_start = 0; 1868 host->use_ecc = false; 1869 qcom_clear_read_regs(nandc); 1870 qcom_clear_bam_transaction(nandc); 1871 1872 nandc->regs->cmd = q_op.cmd_reg; 1873 nandc->regs->addr0 = 0; 1874 nandc->regs->addr1 = 0; 1875 1876 host->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, 0) | 1877 FIELD_PREP(UD_SIZE_BYTES_MASK, 512) | 1878 FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | 1879 FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); 1880 1881 host->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | 1882 FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | 1883 FIELD_PREP(CS_ACTIVE_BSY, 0) | 1884 FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | 1885 FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | 1886 FIELD_PREP(WIDE_FLASH, 0) | 1887 FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); 1888 1889 if (!nandc->props->qpic_version2) > 1890 nandc->regs->ecc_buf_cfg = ECC_CFG_ECC_DISABLE; 1891 1892 /* configure CMD1 and VLD for ONFI param probing in QPIC v1 */ 1893 if (!nandc->props->qpic_version2) { 1894 nandc->regs->vld = (nandc->vld & ~READ_START_VLD); 1895 nandc->regs->cmd1 = (nandc->cmd1 & ~(0xFF << READ_ADDR)) 1896 | NAND_CMD_PARAM << READ_ADDR; 1897 } 1898 1899 nandc->regs->exec = 1; 1900 1901 if (!nandc->props->qpic_version2) { 1902 nandc->regs->orig_cmd1 = nandc->cmd1; 1903 nandc->regs->orig_vld = nandc->vld; 1904 } 1905 1906 instr = q_op.data_instr; 1907 op_id = q_op.data_instr_idx; 1908 len = nand_subop_get_data_len(subop, op_id); 1909 1910 nandc_set_read_loc(chip, 0, 0, 0, len, 1); 1911 1912 if (!nandc->props->qpic_version2) { 1913 qcom_write_reg_dma(nandc, &nandc->regs->vld, NAND_DEV_CMD_VLD, 1, 0); 1914 qcom_write_reg_dma(nandc, &nandc->regs->cmd1, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL); 1915 } 1916 1917 nandc->buf_count = len; 1918 memset(nandc->data_buffer, 0xff, nandc->buf_count); 1919 1920 config_nand_single_cw_page_read(chip, false, 0); 1921 1922 qcom_read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, nandc->buf_count, 0); 1923 1924 /* restore CMD1 and VLD regs */ 1925 if (!nandc->props->qpic_version2) { 1926 qcom_write_reg_dma(nandc, &nandc->regs->orig_cmd1, NAND_DEV_CMD1_RESTORE, 1, 0); 1927 qcom_write_reg_dma(nandc, &nandc->regs->orig_vld, NAND_DEV_CMD_VLD_RESTORE, 1, 1928 NAND_BAM_NEXT_SGL); 1929 } 1930 1931 ret = qcom_submit_descs(nandc); 1932 if (ret) { 1933 dev_err(nandc->dev, "failure in submitting param page descriptor\n"); 1934 goto err_out; 1935 } 1936 1937 ret = qcom_wait_rdy_poll(chip, q_op.rdy_timeout_ms); 1938 if (ret) 1939 goto err_out; 1940 1941 memcpy(instr->ctx.data.buf.in, nandc->data_buffer, len); 1942 1943 err_out: 1944 return ret; 1945 } 1946
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index cced35d6d870..5028969f2fbf 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -274,7 +274,7 @@ static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read, i (num_cw - 1) << CW_PER_PAGE; cfg1 = host->cfg1_raw; - ecc_bch_cfg = 1 << ECC_CFG_ECC_DISABLE; + ecc_bch_cfg = ECC_CFG_ECC_DISABLE; } nandc->regs->cmd = cmd; @@ -1485,42 +1485,41 @@ static int qcom_nand_attach_chip(struct nand_chip *chip) host->cw_size = host->cw_data + ecc->bytes; bad_block_byte = mtd->writesize - host->cw_size * (cwperpage - 1) + 1; - host->cfg0 = (cwperpage - 1) << CW_PER_PAGE - | host->cw_data << UD_SIZE_BYTES - | 0 << DISABLE_STATUS_AFTER_WRITE - | 5 << NUM_ADDR_CYCLES - | host->ecc_bytes_hw << ECC_PARITY_SIZE_BYTES_RS - | 0 << STATUS_BFR_READ - | 1 << SET_RD_MODE_AFTER_STATUS - | host->spare_bytes << SPARE_SIZE_BYTES; - - host->cfg1 = 7 << NAND_RECOVERY_CYCLES - | 0 << CS_ACTIVE_BSY - | bad_block_byte << BAD_BLOCK_BYTE_NUM - | 0 << BAD_BLOCK_IN_SPARE_AREA - | 2 << WR_RD_BSY_GAP - | wide_bus << WIDE_FLASH - | host->bch_enabled << ENABLE_BCH_ECC; - - host->cfg0_raw = (cwperpage - 1) << CW_PER_PAGE - | host->cw_size << UD_SIZE_BYTES - | 5 << NUM_ADDR_CYCLES - | 0 << SPARE_SIZE_BYTES; - - host->cfg1_raw = 7 << NAND_RECOVERY_CYCLES - | 0 << CS_ACTIVE_BSY - | 17 << BAD_BLOCK_BYTE_NUM - | 1 << BAD_BLOCK_IN_SPARE_AREA - | 2 << WR_RD_BSY_GAP - | wide_bus << WIDE_FLASH - | 1 << DEV0_CFG1_ECC_DISABLE; - - host->ecc_bch_cfg = !host->bch_enabled << ECC_CFG_ECC_DISABLE - | 0 << ECC_SW_RESET - | host->cw_data << ECC_NUM_DATA_BYTES - | 1 << ECC_FORCE_CLK_OPEN - | ecc_mode << ECC_MODE - | host->ecc_bytes_hw << ECC_PARITY_SIZE_BYTES_BCH; + host->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, (cwperpage - 1)) | + FIELD_PREP(UD_SIZE_BYTES_MASK, host->cw_data) | + FIELD_PREP(DISABLE_STATUS_AFTER_WRITE, 0) | + FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | + FIELD_PREP(ECC_PARITY_SIZE_BYTES_RS, host->ecc_bytes_hw) | + FIELD_PREP(STATUS_BFR_READ, 0) | + FIELD_PREP(SET_RD_MODE_AFTER_STATUS, 1) | + FIELD_PREP(SPARE_SIZE_BYTES_MASK, host->spare_bytes); + + host->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | + FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, bad_block_byte) | + FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 0) | + FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | + FIELD_PREP(WIDE_FLASH, wide_bus) | + FIELD_PREP(ENABLE_BCH_ECC, host->bch_enabled); + + host->cfg0_raw = FIELD_PREP(CW_PER_PAGE_MASK, (cwperpage - 1)) | + FIELD_PREP(UD_SIZE_BYTES_MASK, host->cw_size) | + FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | + FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); + + host->cfg1_raw = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | + FIELD_PREP(CS_ACTIVE_BSY, 0) | + FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | + FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | + FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | + FIELD_PREP(WIDE_FLASH, wide_bus) | + FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); + + host->ecc_bch_cfg = FIELD_PREP(ECC_CFG_ECC_DISABLE, !host->bch_enabled) | + FIELD_PREP(ECC_SW_RESET, 0) | + FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, host->cw_data) | + FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) | + FIELD_PREP(ECC_MODE_MASK, ecc_mode) | + FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, host->ecc_bytes_hw); if (!nandc->props->qpic_version2) host->ecc_buf_cfg = 0x203 << NUM_STEPS; @@ -1874,21 +1873,21 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_ nandc->regs->addr0 = 0; nandc->regs->addr1 = 0; - nandc->regs->cfg0 = 0 << CW_PER_PAGE - | 512 << UD_SIZE_BYTES - | 5 << NUM_ADDR_CYCLES - | 0 << SPARE_SIZE_BYTES; + host->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, 0) | + FIELD_PREP(UD_SIZE_BYTES_MASK, 512) | + FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | + FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); - nandc->regs->cfg1 = 7 << NAND_RECOVERY_CYCLES - | 0 << CS_ACTIVE_BSY - | 17 << BAD_BLOCK_BYTE_NUM - | 1 << BAD_BLOCK_IN_SPARE_AREA - | 2 << WR_RD_BSY_GAP - | 0 << WIDE_FLASH - | 1 << DEV0_CFG1_ECC_DISABLE; + host->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | + FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | + FIELD_PREP(CS_ACTIVE_BSY, 0) | + FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | + FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | + FIELD_PREP(WIDE_FLASH, 0) | + FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); if (!nandc->props->qpic_version2) - nandc->regs->ecc_buf_cfg = 1 << ECC_CFG_ECC_DISABLE; + nandc->regs->ecc_buf_cfg = ECC_CFG_ECC_DISABLE; /* configure CMD1 and VLD for ONFI param probing in QPIC v1 */ if (!nandc->props->qpic_version2) { diff --git a/include/linux/mtd/nand-qpic-common.h b/include/linux/mtd/nand-qpic-common.h index 17d9d131639f..a4819db31034 100644 --- a/include/linux/mtd/nand-qpic-common.h +++ b/include/linux/mtd/nand-qpic-common.h @@ -70,35 +70,42 @@ #define BS_CORRECTABLE_ERR_MSK 0x1f /* NAND_DEVn_CFG0 bits */ -#define DISABLE_STATUS_AFTER_WRITE 4 +#define DISABLE_STATUS_AFTER_WRITE BIT(4) #define CW_PER_PAGE 6 +#define CW_PER_PAGE_MASK GENMASK(8, 6) #define UD_SIZE_BYTES 9 #define UD_SIZE_BYTES_MASK GENMASK(18, 9) -#define ECC_PARITY_SIZE_BYTES_RS 19 +#define ECC_PARITY_SIZE_BYTES_RS GENMASK(22, 19) #define SPARE_SIZE_BYTES 23 #define SPARE_SIZE_BYTES_MASK GENMASK(26, 23) #define NUM_ADDR_CYCLES 27 -#define STATUS_BFR_READ 30 -#define SET_RD_MODE_AFTER_STATUS 31 +#define NUM_ADDR_CYCLES_MASK GENMASK(29, 27) +#define STATUS_BFR_READ BIT(30) +#define SET_RD_MODE_AFTER_STATUS BIT(31) /* NAND_DEVn_CFG0 bits */ -#define DEV0_CFG1_ECC_DISABLE 0 -#define WIDE_FLASH 1 +#define DEV0_CFG1_ECC_DISABLE BIT(0) +#define WIDE_FLASH BIT(1) #define NAND_RECOVERY_CYCLES 2 -#define CS_ACTIVE_BSY 5 +#define NAND_RECOVERY_CYCLES_MASK GENMASK(4, 2) +#define CS_ACTIVE_BSY BIT(5) #define BAD_BLOCK_BYTE_NUM 6 -#define BAD_BLOCK_IN_SPARE_AREA 16 +#define BAD_BLOCK_BYTE_NUM_MASK GENMASK(15, 6) +#define BAD_BLOCK_IN_SPARE_AREA BIT(16) #define WR_RD_BSY_GAP 17 -#define ENABLE_BCH_ECC 27 +#define WR_RD_BSY_GAP_MASK GENMASK(22, 17) +#define ENABLE_BCH_ECC BIT(27) /* NAND_DEV0_ECC_CFG bits */ -#define ECC_CFG_ECC_DISABLE 0 -#define ECC_SW_RESET 1 +#define ECC_CFG_ECC_DISABLE BIT(0) +#define ECC_SW_RESET BIT(1) #define ECC_MODE 4 +#define ECC_MODE_MASK GENMASK(5, 4) #define ECC_PARITY_SIZE_BYTES_BCH 8 +#define ECC_PARITY_SIZE_BYTES_BCH_MASK GENMASK(12, 8) #define ECC_NUM_DATA_BYTES 16 #define ECC_NUM_DATA_BYTES_MASK GENMASK(25, 16) -#define ECC_FORCE_CLK_OPEN 30 +#define ECC_FORCE_CLK_OPEN BIT(30) /* NAND_DEV_CMD1 bits */ #define READ_ADDR 0
Use the bitfield macro FIELD_PREP, and GENMASK to do the shift and mask in one go. This makes the code more readable. Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com> --- Change in [v7] * No change Change in [v6] * Added FIELD_PREP() and GENMASK() macro Change in [v5] * This patch was not included in [v1] Change in [v4] * This patch was not included in [v4] Change in [v3] * This patch was not included in [v3] Change in [v2] * This patch was not included in [v2] Change in [v1] * This patch was not included in [v1] drivers/mtd/nand/raw/qcom_nandc.c | 97 ++++++++++++++-------------- include/linux/mtd/nand-qpic-common.h | 31 +++++---- 2 files changed, 67 insertions(+), 61 deletions(-)