nand_legacy.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
  4. * 2002-2006 Thomas Gleixner (tglx@linutronix.de)
  5. *
  6. * Credits:
  7. * David Woodhouse for adding multichip support
  8. *
  9. * Aleph One Ltd. and Toby Churchill Ltd. for supporting the
  10. * rework for 2K page size chips
  11. *
  12. * This file contains all legacy helpers/code that should be removed
  13. * at some point.
  14. */
  15. #include <linux/delay.h>
  16. #include <linux/io.h>
  17. #include <linux/nmi.h>
  18. #include "internals.h"
  19. /**
  20. * nand_read_byte - [DEFAULT] read one byte from the chip
  21. * @chip: NAND chip object
  22. *
  23. * Default read function for 8bit buswidth
  24. */
  25. static uint8_t nand_read_byte(struct nand_chip *chip)
  26. {
  27. return readb(chip->legacy.IO_ADDR_R);
  28. }
  29. /**
  30. * nand_read_byte16 - [DEFAULT] read one byte endianness aware from the chip
  31. * @chip: NAND chip object
  32. *
  33. * Default read function for 16bit buswidth with endianness conversion.
  34. *
  35. */
  36. static uint8_t nand_read_byte16(struct nand_chip *chip)
  37. {
  38. return (uint8_t) cpu_to_le16(readw(chip->legacy.IO_ADDR_R));
  39. }
  40. /**
  41. * nand_select_chip - [DEFAULT] control CE line
  42. * @chip: NAND chip object
  43. * @chipnr: chipnumber to select, -1 for deselect
  44. *
  45. * Default select function for 1 chip devices.
  46. */
  47. static void nand_select_chip(struct nand_chip *chip, int chipnr)
  48. {
  49. switch (chipnr) {
  50. case -1:
  51. chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  52. 0 | NAND_CTRL_CHANGE);
  53. break;
  54. case 0:
  55. break;
  56. default:
  57. BUG();
  58. }
  59. }
  60. /**
  61. * nand_write_byte - [DEFAULT] write single byte to chip
  62. * @chip: NAND chip object
  63. * @byte: value to write
  64. *
  65. * Default function to write a byte to I/O[7:0]
  66. */
  67. static void nand_write_byte(struct nand_chip *chip, uint8_t byte)
  68. {
  69. chip->legacy.write_buf(chip, &byte, 1);
  70. }
  71. /**
  72. * nand_write_byte16 - [DEFAULT] write single byte to a chip with width 16
  73. * @chip: NAND chip object
  74. * @byte: value to write
  75. *
  76. * Default function to write a byte to I/O[7:0] on a 16-bit wide chip.
  77. */
  78. static void nand_write_byte16(struct nand_chip *chip, uint8_t byte)
  79. {
  80. uint16_t word = byte;
  81. /*
  82. * It's not entirely clear what should happen to I/O[15:8] when writing
  83. * a byte. The ONFi spec (Revision 3.1; 2012-09-19, Section 2.16) reads:
  84. *
  85. * When the host supports a 16-bit bus width, only data is
  86. * transferred at the 16-bit width. All address and command line
  87. * transfers shall use only the lower 8-bits of the data bus. During
  88. * command transfers, the host may place any value on the upper
  89. * 8-bits of the data bus. During address transfers, the host shall
  90. * set the upper 8-bits of the data bus to 00h.
  91. *
  92. * One user of the write_byte callback is nand_set_features. The
  93. * four parameters are specified to be written to I/O[7:0], but this is
  94. * neither an address nor a command transfer. Let's assume a 0 on the
  95. * upper I/O lines is OK.
  96. */
  97. chip->legacy.write_buf(chip, (uint8_t *)&word, 2);
  98. }
  99. /**
  100. * nand_write_buf - [DEFAULT] write buffer to chip
  101. * @chip: NAND chip object
  102. * @buf: data buffer
  103. * @len: number of bytes to write
  104. *
  105. * Default write function for 8bit buswidth.
  106. */
  107. static void nand_write_buf(struct nand_chip *chip, const uint8_t *buf, int len)
  108. {
  109. iowrite8_rep(chip->legacy.IO_ADDR_W, buf, len);
  110. }
  111. /**
  112. * nand_read_buf - [DEFAULT] read chip data into buffer
  113. * @chip: NAND chip object
  114. * @buf: buffer to store date
  115. * @len: number of bytes to read
  116. *
  117. * Default read function for 8bit buswidth.
  118. */
  119. static void nand_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
  120. {
  121. ioread8_rep(chip->legacy.IO_ADDR_R, buf, len);
  122. }
  123. /**
  124. * nand_write_buf16 - [DEFAULT] write buffer to chip
  125. * @chip: NAND chip object
  126. * @buf: data buffer
  127. * @len: number of bytes to write
  128. *
  129. * Default write function for 16bit buswidth.
  130. */
  131. static void nand_write_buf16(struct nand_chip *chip, const uint8_t *buf,
  132. int len)
  133. {
  134. u16 *p = (u16 *) buf;
  135. iowrite16_rep(chip->legacy.IO_ADDR_W, p, len >> 1);
  136. }
  137. /**
  138. * nand_read_buf16 - [DEFAULT] read chip data into buffer
  139. * @chip: NAND chip object
  140. * @buf: buffer to store date
  141. * @len: number of bytes to read
  142. *
  143. * Default read function for 16bit buswidth.
  144. */
  145. static void nand_read_buf16(struct nand_chip *chip, uint8_t *buf, int len)
  146. {
  147. u16 *p = (u16 *) buf;
  148. ioread16_rep(chip->legacy.IO_ADDR_R, p, len >> 1);
  149. }
  150. /**
  151. * panic_nand_wait_ready - [GENERIC] Wait for the ready pin after commands.
  152. * @mtd: MTD device structure
  153. * @timeo: Timeout
  154. *
  155. * Helper function for nand_wait_ready used when needing to wait in interrupt
  156. * context.
  157. */
  158. static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)
  159. {
  160. struct nand_chip *chip = mtd_to_nand(mtd);
  161. int i;
  162. /* Wait for the device to get ready */
  163. for (i = 0; i < timeo; i++) {
  164. if (chip->legacy.dev_ready(chip))
  165. break;
  166. touch_softlockup_watchdog();
  167. mdelay(1);
  168. }
  169. }
  170. /**
  171. * nand_wait_ready - [GENERIC] Wait for the ready pin after commands.
  172. * @chip: NAND chip object
  173. *
  174. * Wait for the ready pin after a command, and warn if a timeout occurs.
  175. */
  176. void nand_wait_ready(struct nand_chip *chip)
  177. {
  178. struct mtd_info *mtd = nand_to_mtd(chip);
  179. unsigned long timeo = 400;
  180. if (in_interrupt() || oops_in_progress)
  181. return panic_nand_wait_ready(mtd, timeo);
  182. /* Wait until command is processed or timeout occurs */
  183. timeo = jiffies + msecs_to_jiffies(timeo);
  184. do {
  185. if (chip->legacy.dev_ready(chip))
  186. return;
  187. cond_resched();
  188. } while (time_before(jiffies, timeo));
  189. if (!chip->legacy.dev_ready(chip))
  190. pr_warn_ratelimited("timeout while waiting for chip to become ready\n");
  191. }
  192. EXPORT_SYMBOL_GPL(nand_wait_ready);
  193. /**
  194. * nand_wait_status_ready - [GENERIC] Wait for the ready status after commands.
  195. * @mtd: MTD device structure
  196. * @timeo: Timeout in ms
  197. *
  198. * Wait for status ready (i.e. command done) or timeout.
  199. */
  200. static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)
  201. {
  202. register struct nand_chip *chip = mtd_to_nand(mtd);
  203. int ret;
  204. timeo = jiffies + msecs_to_jiffies(timeo);
  205. do {
  206. u8 status;
  207. ret = nand_read_data_op(chip, &status, sizeof(status), true);
  208. if (ret)
  209. return;
  210. if (status & NAND_STATUS_READY)
  211. break;
  212. touch_softlockup_watchdog();
  213. } while (time_before(jiffies, timeo));
  214. };
  215. /**
  216. * nand_command - [DEFAULT] Send command to NAND device
  217. * @chip: NAND chip object
  218. * @command: the command to be sent
  219. * @column: the column address for this command, -1 if none
  220. * @page_addr: the page address for this command, -1 if none
  221. *
  222. * Send command to NAND device. This function is used for small page devices
  223. * (512 Bytes per page).
  224. */
  225. static void nand_command(struct nand_chip *chip, unsigned int command,
  226. int column, int page_addr)
  227. {
  228. struct mtd_info *mtd = nand_to_mtd(chip);
  229. int ctrl = NAND_CTRL_CLE | NAND_CTRL_CHANGE;
  230. /* Write out the command to the device */
  231. if (command == NAND_CMD_SEQIN) {
  232. int readcmd;
  233. if (column >= mtd->writesize) {
  234. /* OOB area */
  235. column -= mtd->writesize;
  236. readcmd = NAND_CMD_READOOB;
  237. } else if (column < 256) {
  238. /* First 256 bytes --> READ0 */
  239. readcmd = NAND_CMD_READ0;
  240. } else {
  241. column -= 256;
  242. readcmd = NAND_CMD_READ1;
  243. }
  244. chip->legacy.cmd_ctrl(chip, readcmd, ctrl);
  245. ctrl &= ~NAND_CTRL_CHANGE;
  246. }
  247. if (command != NAND_CMD_NONE)
  248. chip->legacy.cmd_ctrl(chip, command, ctrl);
  249. /* Address cycle, when necessary */
  250. ctrl = NAND_CTRL_ALE | NAND_CTRL_CHANGE;
  251. /* Serially input address */
  252. if (column != -1) {
  253. /* Adjust columns for 16 bit buswidth */
  254. if (chip->options & NAND_BUSWIDTH_16 &&
  255. !nand_opcode_8bits(command))
  256. column >>= 1;
  257. chip->legacy.cmd_ctrl(chip, column, ctrl);
  258. ctrl &= ~NAND_CTRL_CHANGE;
  259. }
  260. if (page_addr != -1) {
  261. chip->legacy.cmd_ctrl(chip, page_addr, ctrl);
  262. ctrl &= ~NAND_CTRL_CHANGE;
  263. chip->legacy.cmd_ctrl(chip, page_addr >> 8, ctrl);
  264. if (chip->options & NAND_ROW_ADDR_3)
  265. chip->legacy.cmd_ctrl(chip, page_addr >> 16, ctrl);
  266. }
  267. chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  268. NAND_NCE | NAND_CTRL_CHANGE);
  269. /*
  270. * Program and erase have their own busy handlers status and sequential
  271. * in needs no delay
  272. */
  273. switch (command) {
  274. case NAND_CMD_NONE:
  275. case NAND_CMD_PAGEPROG:
  276. case NAND_CMD_ERASE1:
  277. case NAND_CMD_ERASE2:
  278. case NAND_CMD_SEQIN:
  279. case NAND_CMD_STATUS:
  280. case NAND_CMD_READID:
  281. case NAND_CMD_SET_FEATURES:
  282. return;
  283. case NAND_CMD_RESET:
  284. if (chip->legacy.dev_ready)
  285. break;
  286. udelay(chip->legacy.chip_delay);
  287. chip->legacy.cmd_ctrl(chip, NAND_CMD_STATUS,
  288. NAND_CTRL_CLE | NAND_CTRL_CHANGE);
  289. chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  290. NAND_NCE | NAND_CTRL_CHANGE);
  291. /* EZ-NAND can take upto 250ms as per ONFi v4.0 */
  292. nand_wait_status_ready(mtd, 250);
  293. return;
  294. /* This applies to read commands */
  295. case NAND_CMD_READ0:
  296. /*
  297. * READ0 is sometimes used to exit GET STATUS mode. When this
  298. * is the case no address cycles are requested, and we can use
  299. * this information to detect that we should not wait for the
  300. * device to be ready.
  301. */
  302. if (column == -1 && page_addr == -1)
  303. return;
  304. default:
  305. /*
  306. * If we don't have access to the busy pin, we apply the given
  307. * command delay
  308. */
  309. if (!chip->legacy.dev_ready) {
  310. udelay(chip->legacy.chip_delay);
  311. return;
  312. }
  313. }
  314. /*
  315. * Apply this short delay always to ensure that we do wait tWB in
  316. * any case on any machine.
  317. */
  318. ndelay(100);
  319. nand_wait_ready(chip);
  320. }
  321. static void nand_ccs_delay(struct nand_chip *chip)
  322. {
  323. /*
  324. * The controller already takes care of waiting for tCCS when the RNDIN
  325. * or RNDOUT command is sent, return directly.
  326. */
  327. if (!(chip->options & NAND_WAIT_TCCS))
  328. return;
  329. /*
  330. * Wait tCCS_min if it is correctly defined, otherwise wait 500ns
  331. * (which should be safe for all NANDs).
  332. */
  333. if (chip->setup_data_interface)
  334. ndelay(chip->data_interface.timings.sdr.tCCS_min / 1000);
  335. else
  336. ndelay(500);
  337. }
  338. /**
  339. * nand_command_lp - [DEFAULT] Send command to NAND large page device
  340. * @chip: NAND chip object
  341. * @command: the command to be sent
  342. * @column: the column address for this command, -1 if none
  343. * @page_addr: the page address for this command, -1 if none
  344. *
  345. * Send command to NAND device. This is the version for the new large page
  346. * devices. We don't have the separate regions as we have in the small page
  347. * devices. We must emulate NAND_CMD_READOOB to keep the code compatible.
  348. */
  349. static void nand_command_lp(struct nand_chip *chip, unsigned int command,
  350. int column, int page_addr)
  351. {
  352. struct mtd_info *mtd = nand_to_mtd(chip);
  353. /* Emulate NAND_CMD_READOOB */
  354. if (command == NAND_CMD_READOOB) {
  355. column += mtd->writesize;
  356. command = NAND_CMD_READ0;
  357. }
  358. /* Command latch cycle */
  359. if (command != NAND_CMD_NONE)
  360. chip->legacy.cmd_ctrl(chip, command,
  361. NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE);
  362. if (column != -1 || page_addr != -1) {
  363. int ctrl = NAND_CTRL_CHANGE | NAND_NCE | NAND_ALE;
  364. /* Serially input address */
  365. if (column != -1) {
  366. /* Adjust columns for 16 bit buswidth */
  367. if (chip->options & NAND_BUSWIDTH_16 &&
  368. !nand_opcode_8bits(command))
  369. column >>= 1;
  370. chip->legacy.cmd_ctrl(chip, column, ctrl);
  371. ctrl &= ~NAND_CTRL_CHANGE;
  372. /* Only output a single addr cycle for 8bits opcodes. */
  373. if (!nand_opcode_8bits(command))
  374. chip->legacy.cmd_ctrl(chip, column >> 8, ctrl);
  375. }
  376. if (page_addr != -1) {
  377. chip->legacy.cmd_ctrl(chip, page_addr, ctrl);
  378. chip->legacy.cmd_ctrl(chip, page_addr >> 8,
  379. NAND_NCE | NAND_ALE);
  380. if (chip->options & NAND_ROW_ADDR_3)
  381. chip->legacy.cmd_ctrl(chip, page_addr >> 16,
  382. NAND_NCE | NAND_ALE);
  383. }
  384. }
  385. chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  386. NAND_NCE | NAND_CTRL_CHANGE);
  387. /*
  388. * Program and erase have their own busy handlers status, sequential
  389. * in and status need no delay.
  390. */
  391. switch (command) {
  392. case NAND_CMD_NONE:
  393. case NAND_CMD_CACHEDPROG:
  394. case NAND_CMD_PAGEPROG:
  395. case NAND_CMD_ERASE1:
  396. case NAND_CMD_ERASE2:
  397. case NAND_CMD_SEQIN:
  398. case NAND_CMD_STATUS:
  399. case NAND_CMD_READID:
  400. case NAND_CMD_SET_FEATURES:
  401. return;
  402. case NAND_CMD_RNDIN:
  403. nand_ccs_delay(chip);
  404. return;
  405. case NAND_CMD_RESET:
  406. if (chip->legacy.dev_ready)
  407. break;
  408. udelay(chip->legacy.chip_delay);
  409. chip->legacy.cmd_ctrl(chip, NAND_CMD_STATUS,
  410. NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE);
  411. chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  412. NAND_NCE | NAND_CTRL_CHANGE);
  413. /* EZ-NAND can take upto 250ms as per ONFi v4.0 */
  414. nand_wait_status_ready(mtd, 250);
  415. return;
  416. case NAND_CMD_RNDOUT:
  417. /* No ready / busy check necessary */
  418. chip->legacy.cmd_ctrl(chip, NAND_CMD_RNDOUTSTART,
  419. NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE);
  420. chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  421. NAND_NCE | NAND_CTRL_CHANGE);
  422. nand_ccs_delay(chip);
  423. return;
  424. case NAND_CMD_READ0:
  425. /*
  426. * READ0 is sometimes used to exit GET STATUS mode. When this
  427. * is the case no address cycles are requested, and we can use
  428. * this information to detect that READSTART should not be
  429. * issued.
  430. */
  431. if (column == -1 && page_addr == -1)
  432. return;
  433. chip->legacy.cmd_ctrl(chip, NAND_CMD_READSTART,
  434. NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE);
  435. chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  436. NAND_NCE | NAND_CTRL_CHANGE);
  437. /* This applies to read commands */
  438. default:
  439. /*
  440. * If we don't have access to the busy pin, we apply the given
  441. * command delay.
  442. */
  443. if (!chip->legacy.dev_ready) {
  444. udelay(chip->legacy.chip_delay);
  445. return;
  446. }
  447. }
  448. /*
  449. * Apply this short delay always to ensure that we do wait tWB in
  450. * any case on any machine.
  451. */
  452. ndelay(100);
  453. nand_wait_ready(chip);
  454. }
  455. /**
  456. * nand_get_set_features_notsupp - set/get features stub returning -ENOTSUPP
  457. * @chip: nand chip info structure
  458. * @addr: feature address.
  459. * @subfeature_param: the subfeature parameters, a four bytes array.
  460. *
  461. * Should be used by NAND controller drivers that do not support the SET/GET
  462. * FEATURES operations.
  463. */
  464. int nand_get_set_features_notsupp(struct nand_chip *chip, int addr,
  465. u8 *subfeature_param)
  466. {
  467. return -ENOTSUPP;
  468. }
  469. EXPORT_SYMBOL(nand_get_set_features_notsupp);
  470. /**
  471. * nand_wait - [DEFAULT] wait until the command is done
  472. * @mtd: MTD device structure
  473. * @chip: NAND chip structure
  474. *
  475. * Wait for command done. This applies to erase and program only.
  476. */
  477. static int nand_wait(struct nand_chip *chip)
  478. {
  479. unsigned long timeo = 400;
  480. u8 status;
  481. int ret;
  482. /*
  483. * Apply this short delay always to ensure that we do wait tWB in any
  484. * case on any machine.
  485. */
  486. ndelay(100);
  487. ret = nand_status_op(chip, NULL);
  488. if (ret)
  489. return ret;
  490. if (in_interrupt() || oops_in_progress)
  491. panic_nand_wait(chip, timeo);
  492. else {
  493. timeo = jiffies + msecs_to_jiffies(timeo);
  494. do {
  495. if (chip->legacy.dev_ready) {
  496. if (chip->legacy.dev_ready(chip))
  497. break;
  498. } else {
  499. ret = nand_read_data_op(chip, &status,
  500. sizeof(status), true);
  501. if (ret)
  502. return ret;
  503. if (status & NAND_STATUS_READY)
  504. break;
  505. }
  506. cond_resched();
  507. } while (time_before(jiffies, timeo));
  508. }
  509. ret = nand_read_data_op(chip, &status, sizeof(status), true);
  510. if (ret)
  511. return ret;
  512. /* This can happen if in case of timeout or buggy dev_ready */
  513. WARN_ON(!(status & NAND_STATUS_READY));
  514. return status;
  515. }
  516. void nand_legacy_set_defaults(struct nand_chip *chip)
  517. {
  518. unsigned int busw = chip->options & NAND_BUSWIDTH_16;
  519. if (chip->exec_op)
  520. return;
  521. /* check for proper chip_delay setup, set 20us if not */
  522. if (!chip->legacy.chip_delay)
  523. chip->legacy.chip_delay = 20;
  524. /* check, if a user supplied command function given */
  525. if (!chip->legacy.cmdfunc && !chip->exec_op)
  526. chip->legacy.cmdfunc = nand_command;
  527. /* check, if a user supplied wait function given */
  528. if (chip->legacy.waitfunc == NULL)
  529. chip->legacy.waitfunc = nand_wait;
  530. if (!chip->select_chip)
  531. chip->select_chip = nand_select_chip;
  532. /* If called twice, pointers that depend on busw may need to be reset */
  533. if (!chip->legacy.read_byte || chip->legacy.read_byte == nand_read_byte)
  534. chip->legacy.read_byte = busw ? nand_read_byte16 : nand_read_byte;
  535. if (!chip->legacy.write_buf || chip->legacy.write_buf == nand_write_buf)
  536. chip->legacy.write_buf = busw ? nand_write_buf16 : nand_write_buf;
  537. if (!chip->legacy.write_byte || chip->legacy.write_byte == nand_write_byte)
  538. chip->legacy.write_byte = busw ? nand_write_byte16 : nand_write_byte;
  539. if (!chip->legacy.read_buf || chip->legacy.read_buf == nand_read_buf)
  540. chip->legacy.read_buf = busw ? nand_read_buf16 : nand_read_buf;
  541. }
  542. void nand_legacy_adjust_cmdfunc(struct nand_chip *chip)
  543. {
  544. struct mtd_info *mtd = nand_to_mtd(chip);
  545. /* Do not replace user supplied command function! */
  546. if (mtd->writesize > 512 && chip->legacy.cmdfunc == nand_command)
  547. chip->legacy.cmdfunc = nand_command_lp;
  548. }
  549. int nand_legacy_check_hooks(struct nand_chip *chip)
  550. {
  551. /*
  552. * ->legacy.cmdfunc() is legacy and will only be used if ->exec_op() is
  553. * not populated.
  554. */
  555. if (chip->exec_op)
  556. return 0;
  557. /*
  558. * Default functions assigned for ->legacy.cmdfunc() and
  559. * ->select_chip() both expect ->legacy.cmd_ctrl() to be populated.
  560. */
  561. if ((!chip->legacy.cmdfunc || !chip->select_chip) &&
  562. !chip->legacy.cmd_ctrl) {
  563. pr_err("->legacy.cmd_ctrl() should be provided\n");
  564. return -EINVAL;
  565. }
  566. return 0;
  567. }