diff mbox series

[v2] mtd: spinand: micron: add support for MT29F2G01AAAED

Message ID 20200823111410.13049-1-nthirumalesha7@gmail.com
State Changes Requested
Delegated to: Miquel Raynal
Headers show
Series [v2] mtd: spinand: micron: add support for MT29F2G01AAAED | expand

Commit Message

Thirumalesha Narasimhappa Aug. 23, 2020, 11:14 a.m. UTC
The MT29F2G01AAAED is a single die, 2Gb Micron SPI NAND Flash with 4-bit
ECC

Signed-off-by: Thirumalesha Narasimhappa <nthirumalesha7@gmail.com>
---
 v2: removed SPINAND_SELECT_TARGET as per the comments & fixed typo errors

 drivers/mtd/nand/spi/micron.c | 78 +++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

Comments

kernel test robot Aug. 23, 2020, 12:52 p.m. UTC | #1
Hi Thirumalesha,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9-rc1 next-20200821]
[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]

url:    https://github.com/0day-ci/linux/commits/Thirumalesha-Narasimhappa/mtd-spinand-micron-add-support-for-MT29F2G01AAAED/20200823-191310
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git c3d8f220d01220a5b253e422be407d068dc65511
config: openrisc-randconfig-m031-20200823 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=openrisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/mtd/nand/spi/micron.c:323: error: unterminated argument list invoking macro "SPINAND_INFO"
     323 | };
         | 
>> drivers/mtd/nand/spi/micron.c:288:2: error: 'SPINAND_INFO' undeclared here (not in a function)
     288 |  SPINAND_INFO("MT29F2G01AAAED",
         |  ^~~~~~~~~~~~
>> drivers/mtd/nand/spi/micron.c:323: error: expected '}' at end of input
     323 | };
         | 
   drivers/mtd/nand/spi/micron.c:184:59: note: to match this '{'
     184 | static const struct spinand_info micron_spinand_table[] = {
         |                                                           ^
   drivers/mtd/nand/spi/micron.c:184:34: warning: 'micron_spinand_table' defined but not used [-Wunused-const-variable=]
     184 | static const struct spinand_info micron_spinand_table[] = {
         |                                  ^~~~~~~~~~~~~~~~~~~~
   drivers/mtd/nand/spi/micron.c:163:12: warning: 'mt29f2g01aaaed_ecc_get_status' defined but not used [-Wunused-function]
     163 | static int mt29f2g01aaaed_ecc_get_status(struct spinand_device *spinand,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/mtd/nand/spi/micron.c:118:39: warning: 'mt29f2g01aaaed_ooblayout' defined but not used [-Wunused-const-variable=]
     118 | static const struct mtd_ooblayout_ops mt29f2g01aaaed_ooblayout = {
         |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/mtd/nand/spi/micron.c:11:
   drivers/mtd/nand/spi/micron.c:60:28: warning: 'update_cache_variants_mt29f2g01aaaed' defined but not used [-Wunused-const-variable=]
      60 | static SPINAND_OP_VARIANTS(update_cache_variants_mt29f2g01aaaed,
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mtd/spinand.h:265:35: note: in definition of macro 'SPINAND_OP_VARIANTS'
     265 |  const struct spinand_op_variants name = {   \
         |                                   ^~~~
   drivers/mtd/nand/spi/micron.c:57:28: warning: 'write_cache_variants_mt29f2g01aaaed' defined but not used [-Wunused-const-variable=]
      57 | static SPINAND_OP_VARIANTS(write_cache_variants_mt29f2g01aaaed,
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mtd/spinand.h:265:35: note: in definition of macro 'SPINAND_OP_VARIANTS'
     265 |  const struct spinand_op_variants name = {   \
         |                                   ^~~~
   drivers/mtd/nand/spi/micron.c:51:28: warning: 'read_cache_variants_mt29f2g01aaaed' defined but not used [-Wunused-const-variable=]
      51 | static SPINAND_OP_VARIANTS(read_cache_variants_mt29f2g01aaaed,
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mtd/spinand.h:265:35: note: in definition of macro 'SPINAND_OP_VARIANTS'
     265 |  const struct spinand_op_variants name = {   \
         |                                   ^~~~

# https://github.com/0day-ci/linux/commit/8dc175bd1853ebc961fea42976cffc290b5fbf22
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thirumalesha-Narasimhappa/mtd-spinand-micron-add-support-for-MT29F2G01AAAED/20200823-191310
git checkout 8dc175bd1853ebc961fea42976cffc290b5fbf22
vim +/SPINAND_INFO +323 drivers/mtd/nand/spi/micron.c

8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  183  
a508e8875e135d Peter Pan                 2018-06-22  184  static const struct spinand_info micron_spinand_table[] = {
8511a3a9937e30 Shivamurthy Shastri       2020-03-11  185  	/* M79A 2Gb 3.3V */
f1541773af49ec Chuanhong Guo             2020-02-08  186  	SPINAND_INFO("MT29F2G01ABAGD",
f1541773af49ec Chuanhong Guo             2020-02-08  187  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24),
377e517b5fa535 Boris Brezillon           2018-11-04  188  		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1),
a508e8875e135d Peter Pan                 2018-06-22  189  		     NAND_ECCREQ(8, 512),
a508e8875e135d Peter Pan                 2018-06-22  190  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
a508e8875e135d Peter Pan                 2018-06-22  191  					      &write_cache_variants,
a508e8875e135d Peter Pan                 2018-06-22  192  					      &update_cache_variants),
a508e8875e135d Peter Pan                 2018-06-22  193  		     0,
d3137043440fb1 Shivamurthy Shastri       2020-03-11  194  		     SPINAND_ECCINFO(&micron_8_ooblayout,
d3137043440fb1 Shivamurthy Shastri       2020-03-11  195  				     micron_8_ecc_get_status)),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  196  	/* M79A 2Gb 1.8V */
a15335a17f4abf Shivamurthy Shastri       2020-03-11  197  	SPINAND_INFO("MT29F2G01ABBGD",
a15335a17f4abf Shivamurthy Shastri       2020-03-11  198  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  199  		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  200  		     NAND_ECCREQ(8, 512),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  201  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  202  					      &write_cache_variants,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  203  					      &update_cache_variants),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  204  		     0,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  205  		     SPINAND_ECCINFO(&micron_8_ooblayout,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  206  				     micron_8_ecc_get_status)),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  207  	/* M78A 1Gb 3.3V */
a15335a17f4abf Shivamurthy Shastri       2020-03-11  208  	SPINAND_INFO("MT29F1G01ABAFD",
a15335a17f4abf Shivamurthy Shastri       2020-03-11  209  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  210  		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  211  		     NAND_ECCREQ(8, 512),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  212  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  213  					      &write_cache_variants,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  214  					      &update_cache_variants),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  215  		     0,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  216  		     SPINAND_ECCINFO(&micron_8_ooblayout,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  217  				     micron_8_ecc_get_status)),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  218  	/* M78A 1Gb 1.8V */
a15335a17f4abf Shivamurthy Shastri       2020-03-11  219  	SPINAND_INFO("MT29F1G01ABAFD",
a15335a17f4abf Shivamurthy Shastri       2020-03-11  220  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  221  		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  222  		     NAND_ECCREQ(8, 512),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  223  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  224  					      &write_cache_variants,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  225  					      &update_cache_variants),
a15335a17f4abf Shivamurthy Shastri       2020-03-11  226  		     0,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  227  		     SPINAND_ECCINFO(&micron_8_ooblayout,
a15335a17f4abf Shivamurthy Shastri       2020-03-11  228  				     micron_8_ecc_get_status)),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  229  	/* M79A 4Gb 3.3V */
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  230  	SPINAND_INFO("MT29F4G01ADAGD",
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  231  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x36),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  232  		     NAND_MEMORG(1, 2048, 128, 64, 2048, 80, 2, 1, 2),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  233  		     NAND_ECCREQ(8, 512),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  234  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  235  					      &write_cache_variants,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  236  					      &update_cache_variants),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  237  		     0,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  238  		     SPINAND_ECCINFO(&micron_8_ooblayout,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  239  				     micron_8_ecc_get_status),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  240  		     SPINAND_SELECT_TARGET(micron_select_target)),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  241  	/* M70A 4Gb 3.3V */
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  242  	SPINAND_INFO("MT29F4G01ABAFD",
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  243  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x34),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  244  		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  245  		     NAND_ECCREQ(8, 512),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  246  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  247  					      &write_cache_variants,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  248  					      &update_cache_variants),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  249  		     SPINAND_HAS_CR_FEAT_BIT,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  250  		     SPINAND_ECCINFO(&micron_8_ooblayout,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  251  				     micron_8_ecc_get_status)),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  252  	/* M70A 4Gb 1.8V */
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  253  	SPINAND_INFO("MT29F4G01ABBFD",
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  254  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  255  		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  256  		     NAND_ECCREQ(8, 512),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  257  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  258  					      &write_cache_variants,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  259  					      &update_cache_variants),
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  260  		     SPINAND_HAS_CR_FEAT_BIT,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  261  		     SPINAND_ECCINFO(&micron_8_ooblayout,
a7e5daccc310c3 Shivamurthy Shastri       2020-03-11  262  				     micron_8_ecc_get_status)),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  263  	/* M70A 8Gb 3.3V */
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  264  	SPINAND_INFO("MT29F8G01ADAFD",
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  265  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x46),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  266  		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 2),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  267  		     NAND_ECCREQ(8, 512),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  268  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  269  					      &write_cache_variants,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  270  					      &update_cache_variants),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  271  		     SPINAND_HAS_CR_FEAT_BIT,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  272  		     SPINAND_ECCINFO(&micron_8_ooblayout,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  273  				     micron_8_ecc_get_status),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  274  		     SPINAND_SELECT_TARGET(micron_select_target)),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  275  	/* M70A 8Gb 1.8V */
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  276  	SPINAND_INFO("MT29F8G01ADBFD",
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  277  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x47),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  278  		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 2),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  279  		     NAND_ECCREQ(8, 512),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  280  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  281  					      &write_cache_variants,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  282  					      &update_cache_variants),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  283  		     SPINAND_HAS_CR_FEAT_BIT,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  284  		     SPINAND_ECCINFO(&micron_8_ooblayout,
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  285  				     micron_8_ecc_get_status),
9f9ae0c253c1e0 Shivamurthy Shastri       2020-03-11  286  		     SPINAND_SELECT_TARGET(micron_select_target)),
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  287  	/* M69A 2Gb 3.3V */
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23 @288  	SPINAND_INFO("MT29F2G01AAAED",
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  289  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x9F),
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  290  		     NAND_MEMORG(1, 2048, 64, 64, 2048, 80, 2, 1, 1),
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  291  		     NAND_ECCREQ(4, 512),
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  292  		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants_mt29f2g01aaaed,
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  293  					      &write_cache_variants_mt29f2g01aaaed,
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  294  					      &update_cache_variants_mt29f2g01aaaed),
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  295  		     0,
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  296  		     SPINAND_ECCINFO(&mt29f2g01aaaed_ooblayout,
8dc175bd1853eb Thirumalesha Narasimhappa 2020-08-23  297  				     mt29f2g01aaaed_ecc_get_status),
a508e8875e135d Peter Pan                 2018-06-22  298  };
a508e8875e135d Peter Pan                 2018-06-22  299  
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  300  static int micron_spinand_init(struct spinand_device *spinand)
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  301  {
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  302  	/*
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  303  	 * M70A device series enable Continuous Read feature at Power-up,
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  304  	 * which is not supported. Disable this bit to avoid any possible
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  305  	 * failure.
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  306  	 */
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  307  	if (spinand->flags & SPINAND_HAS_CR_FEAT_BIT)
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  308  		return spinand_upd_cfg(spinand, MICRON_CFG_CR, 0);
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  309  
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  310  	return 0;
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  311  }
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  312  
a508e8875e135d Peter Pan                 2018-06-22  313  static const struct spinand_manufacturer_ops micron_spinand_manuf_ops = {
0bc68af9137dc3 Shivamurthy Shastri       2020-03-11  314  	.init = micron_spinand_init,
a508e8875e135d Peter Pan                 2018-06-22  315  };
a508e8875e135d Peter Pan                 2018-06-22  316  
a508e8875e135d Peter Pan                 2018-06-22  317  const struct spinand_manufacturer micron_spinand_manufacturer = {
a508e8875e135d Peter Pan                 2018-06-22  318  	.id = SPINAND_MFR_MICRON,
a508e8875e135d Peter Pan                 2018-06-22  319  	.name = "Micron",
f1541773af49ec Chuanhong Guo             2020-02-08  320  	.chips = micron_spinand_table,
f1541773af49ec Chuanhong Guo             2020-02-08  321  	.nchips = ARRAY_SIZE(micron_spinand_table),
a508e8875e135d Peter Pan                 2018-06-22  322  	.ops = &micron_spinand_manuf_ops,
a508e8875e135d Peter Pan                 2018-06-22 @323  };

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Boris Brezillon Aug. 23, 2020, 1:31 p.m. UTC | #2
On Sun, 23 Aug 2020 19:14:10 +0800
Thirumalesha Narasimhappa <nthirumalesha7@gmail.com> wrote:

> The MT29F2G01AAAED is a single die, 2Gb Micron SPI NAND Flash with 4-bit
> ECC
> 
> Signed-off-by: Thirumalesha Narasimhappa <nthirumalesha7@gmail.com>
> ---
>  v2: removed SPINAND_SELECT_TARGET as per the comments & fixed typo errors
> 
>  drivers/mtd/nand/spi/micron.c | 78 +++++++++++++++++++++++++++++++++++
>  1 file changed, 78 insertions(+)
> 
> diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
> index 5d370cfcdaaa..c21ca395d657 100644
> --- a/drivers/mtd/nand/spi/micron.c
> +++ b/drivers/mtd/nand/spi/micron.c
> @@ -18,6 +18,9 @@
>  #define MICRON_STATUS_ECC_4TO6_BITFLIPS	(3 << 4)
>  #define MICRON_STATUS_ECC_7TO8_BITFLIPS	(5 << 4)
>  
> +/* For Micron MT29F2G01AAAED Device */
> +#define MICRON_STATUS_ECC_1TO4_BITFLIPS	(1 << 4)
> +

You shouldn't need that new definition (see below).

>  #define MICRON_CFG_CR			BIT(0)
>  
>  /*
> @@ -44,6 +47,19 @@ static SPINAND_OP_VARIANTS(update_cache_variants,
>  		SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
>  		SPINAND_PROG_LOAD(false, 0, NULL, 0));
>  
> +/* Micron  MT29F2G01AAAED Device */
> +static SPINAND_OP_VARIANTS(read_cache_variants_mt29f2g01aaaed,
> +		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
> +		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
> +		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
> +		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(write_cache_variants_mt29f2g01aaaed,
> +		SPINAND_PROG_LOAD(true, 0, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(update_cache_variants_mt29f2g01aaaed,
> +		SPINAND_PROG_LOAD(false, 0, NULL, 0));
> +

Okay, I'd suggest picking more generic names. How about renaming the
existing variants into quadio_read_cache_variants,
x4_write_cache_variants and x4_update_cache_variants and naming the new
ones x4_read_cache_variants, x1_write_cache_variants and
x1_update_cache_variants.

>  static int micron_8_ooblayout_ecc(struct mtd_info *mtd, int section,
>  				  struct mtd_oob_region *region)
>  {
> @@ -69,11 +85,41 @@ static int micron_8_ooblayout_free(struct mtd_info *mtd, int section,
>  	return 0;
>  }
>  
> +static int mt29f2g01aaaed_ooblayout_ecc(struct mtd_info *mtd, int section,
> +					struct mtd_oob_region *region)
> +{
> +	if (section >= 4)
> +		return -ERANGE;

Hm, I'd try to deduce the max section based on the
pagesize/ecc-step-size so we can re-use the same ooblayout def for different
pagesize/ecc-step-size combinations.

> +
> +	region->offset = (section * 16) + 8;
> +	region->length = 8;
> +
> +	return 0;
> +}
> +
> +static int mt29f2g01aaaed_ooblayout_free(struct mtd_info *mtd, int section,
> +					 struct mtd_oob_region *region)
> +{
> +	if (section >= 4)
> +		return -ERANGE;
> +
> +	/* Reserve 2 bytes for the BBM. */
> +	region->offset = (section * 16) + 2;

You should probably only reserve those 2 bytes in section 0 (where the
BBM is).

> +	region->length = 6;
> +
> +	return 0;
> +}
> +
>  static const struct mtd_ooblayout_ops micron_8_ooblayout = {
>  	.ecc = micron_8_ooblayout_ecc,
>  	.free = micron_8_ooblayout_free,
>  };
>  
> +static const struct mtd_ooblayout_ops mt29f2g01aaaed_ooblayout = {

Maybe name that one micron_interleaved_ooblayout, and rename
micron_8_ooblayout into micron_grouped_ooblayout.

> +	.ecc = mt29f2g01aaaed_ooblayout_ecc,
> +	.free = mt29f2g01aaaed_ooblayout_free,
> +};
> +
>  static int micron_select_target(struct spinand_device *spinand,
>  				unsigned int target)
>  {
> @@ -114,6 +160,27 @@ static int micron_8_ecc_get_status(struct spinand_device *spinand,
>  	return -EINVAL;
>  }
>  
> +static int mt29f2g01aaaed_ecc_get_status(struct spinand_device *spinand,
> +					 u8 status)
> +{
> +	switch (status & MICRON_STATUS_ECC_MASK) {
> +	case STATUS_ECC_NO_BITFLIPS:
> +		return 0;
> +
> +	case STATUS_ECC_UNCOR_ERROR:
> +		return -EBADMSG;
> +
> +	/* 1 to 4-bit error detected and corrected */
> +	case MICRON_STATUS_ECC_1TO4_BITFLIPS:
> +		return 4;
> +
> +	default:
> +		break;
> +	}
> +
> +	return -EINVAL;
> +}

Looks like you're duplicating spinand_check_ecc_status(). Just leave the
get_status hook to NULL, that should do trick.
diff mbox series

Patch

diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
index 5d370cfcdaaa..c21ca395d657 100644
--- a/drivers/mtd/nand/spi/micron.c
+++ b/drivers/mtd/nand/spi/micron.c
@@ -18,6 +18,9 @@ 
 #define MICRON_STATUS_ECC_4TO6_BITFLIPS	(3 << 4)
 #define MICRON_STATUS_ECC_7TO8_BITFLIPS	(5 << 4)
 
+/* For Micron MT29F2G01AAAED Device */
+#define MICRON_STATUS_ECC_1TO4_BITFLIPS	(1 << 4)
+
 #define MICRON_CFG_CR			BIT(0)
 
 /*
@@ -44,6 +47,19 @@  static SPINAND_OP_VARIANTS(update_cache_variants,
 		SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
 		SPINAND_PROG_LOAD(false, 0, NULL, 0));
 
+/* Micron  MT29F2G01AAAED Device */
+static SPINAND_OP_VARIANTS(read_cache_variants_mt29f2g01aaaed,
+		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+		SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants_mt29f2g01aaaed,
+		SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants_mt29f2g01aaaed,
+		SPINAND_PROG_LOAD(false, 0, NULL, 0));
+
 static int micron_8_ooblayout_ecc(struct mtd_info *mtd, int section,
 				  struct mtd_oob_region *region)
 {
@@ -69,11 +85,41 @@  static int micron_8_ooblayout_free(struct mtd_info *mtd, int section,
 	return 0;
 }
 
+static int mt29f2g01aaaed_ooblayout_ecc(struct mtd_info *mtd, int section,
+					struct mtd_oob_region *region)
+{
+	if (section >= 4)
+		return -ERANGE;
+
+	region->offset = (section * 16) + 8;
+	region->length = 8;
+
+	return 0;
+}
+
+static int mt29f2g01aaaed_ooblayout_free(struct mtd_info *mtd, int section,
+					 struct mtd_oob_region *region)
+{
+	if (section >= 4)
+		return -ERANGE;
+
+	/* Reserve 2 bytes for the BBM. */
+	region->offset = (section * 16) + 2;
+	region->length = 6;
+
+	return 0;
+}
+
 static const struct mtd_ooblayout_ops micron_8_ooblayout = {
 	.ecc = micron_8_ooblayout_ecc,
 	.free = micron_8_ooblayout_free,
 };
 
+static const struct mtd_ooblayout_ops mt29f2g01aaaed_ooblayout = {
+	.ecc = mt29f2g01aaaed_ooblayout_ecc,
+	.free = mt29f2g01aaaed_ooblayout_free,
+};
+
 static int micron_select_target(struct spinand_device *spinand,
 				unsigned int target)
 {
@@ -114,6 +160,27 @@  static int micron_8_ecc_get_status(struct spinand_device *spinand,
 	return -EINVAL;
 }
 
+static int mt29f2g01aaaed_ecc_get_status(struct spinand_device *spinand,
+					 u8 status)
+{
+	switch (status & MICRON_STATUS_ECC_MASK) {
+	case STATUS_ECC_NO_BITFLIPS:
+		return 0;
+
+	case STATUS_ECC_UNCOR_ERROR:
+		return -EBADMSG;
+
+	/* 1 to 4-bit error detected and corrected */
+	case MICRON_STATUS_ECC_1TO4_BITFLIPS:
+		return 4;
+
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+
 static const struct spinand_info micron_spinand_table[] = {
 	/* M79A 2Gb 3.3V */
 	SPINAND_INFO("MT29F2G01ABAGD",
@@ -217,6 +284,17 @@  static const struct spinand_info micron_spinand_table[] = {
 		     SPINAND_ECCINFO(&micron_8_ooblayout,
 				     micron_8_ecc_get_status),
 		     SPINAND_SELECT_TARGET(micron_select_target)),
+	/* M69A 2Gb 3.3V */
+	SPINAND_INFO("MT29F2G01AAAED",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x9F),
+		     NAND_MEMORG(1, 2048, 64, 64, 2048, 80, 2, 1, 1),
+		     NAND_ECCREQ(4, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants_mt29f2g01aaaed,
+					      &write_cache_variants_mt29f2g01aaaed,
+					      &update_cache_variants_mt29f2g01aaaed),
+		     0,
+		     SPINAND_ECCINFO(&mt29f2g01aaaed_ooblayout,
+				     mt29f2g01aaaed_ecc_get_status),
 };
 
 static int micron_spinand_init(struct spinand_device *spinand)