flash.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * Modified 4/5/2001
  25. * Wait for completion of each sector erase command issued
  26. * 4/5/2001
  27. * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com
  28. */
  29. #include <common.h>
  30. #include <mpc824x.h>
  31. #include <asm/processor.h>
  32. #if CFG_MAX_FLASH_BANKS != 1
  33. #error "CFG_MAX_FLASH_BANKS must be 1"
  34. #endif
  35. flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
  36. /*-----------------------------------------------------------------------
  37. * Functions
  38. */
  39. static ulong flash_get_size (vu_long * addr, flash_info_t * info);
  40. static int write_word (flash_info_t * info, ulong dest, ulong data);
  41. static void flash_get_offsets (ulong base, flash_info_t * info);
  42. #define ADDR0 0x5555
  43. #define ADDR1 0x2aaa
  44. #define FLASH_WORD_SIZE unsigned char
  45. /*-----------------------------------------------------------------------
  46. */
  47. unsigned long flash_init (void)
  48. {
  49. unsigned long size_b0;
  50. /* Init: no FLASHes known */
  51. flash_info[0].flash_id = FLASH_UNKNOWN;
  52. /* Static FLASH Bank configuration here - FIXME XXX */
  53. size_b0 = flash_get_size ((vu_long *) FLASH_BASE0_PRELIM, &flash_info[0]);
  54. if (flash_info[0].flash_id == FLASH_UNKNOWN) {
  55. printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
  56. size_b0, size_b0 << 20);
  57. }
  58. /* Only one bank */
  59. /* Setup offsets */
  60. flash_get_offsets (FLASH_BASE0_PRELIM, &flash_info[0]);
  61. /* Monitor protection ON by default */
  62. (void) flash_protect (FLAG_PROTECT_SET,
  63. FLASH_BASE0_PRELIM,
  64. FLASH_BASE0_PRELIM + monitor_flash_len - 1,
  65. &flash_info[0]);
  66. flash_info[0].size = size_b0;
  67. return size_b0;
  68. }
  69. /*-----------------------------------------------------------------------
  70. */
  71. static void flash_get_offsets (ulong base, flash_info_t * info)
  72. {
  73. int i;
  74. /* set up sector start address table */
  75. if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) ||
  76. (info->flash_id == FLASH_AM040)) {
  77. for (i = 0; i < info->sector_count; i++)
  78. info->start[i] = base + (i * 0x00010000);
  79. } else {
  80. if (info->flash_id & FLASH_BTYPE) {
  81. /* set sector offsets for bottom boot block type */
  82. info->start[0] = base + 0x00000000;
  83. info->start[1] = base + 0x00004000;
  84. info->start[2] = base + 0x00006000;
  85. info->start[3] = base + 0x00008000;
  86. for (i = 4; i < info->sector_count; i++) {
  87. info->start[i] =
  88. base + (i * 0x00010000) - 0x00030000;
  89. }
  90. } else {
  91. /* set sector offsets for top boot block type */
  92. i = info->sector_count - 1;
  93. info->start[i--] = base + info->size - 0x00004000;
  94. info->start[i--] = base + info->size - 0x00006000;
  95. info->start[i--] = base + info->size - 0x00008000;
  96. for (; i >= 0; i--) {
  97. info->start[i] = base + i * 0x00010000;
  98. }
  99. }
  100. }
  101. }
  102. /*-----------------------------------------------------------------------
  103. */
  104. void flash_print_info (flash_info_t * info)
  105. {
  106. int i;
  107. int k;
  108. int size;
  109. int erased;
  110. volatile unsigned long *flash;
  111. if (info->flash_id == FLASH_UNKNOWN) {
  112. printf ("missing or unknown FLASH type\n");
  113. return;
  114. }
  115. switch (info->flash_id & FLASH_VENDMASK) {
  116. case FLASH_MAN_AMD:
  117. printf ("AMD ");
  118. break;
  119. case FLASH_MAN_FUJ:
  120. printf ("FUJITSU ");
  121. break;
  122. case FLASH_MAN_SST:
  123. printf ("SST ");
  124. break;
  125. default:
  126. printf ("Unknown Vendor ");
  127. break;
  128. }
  129. switch (info->flash_id & FLASH_TYPEMASK) {
  130. case FLASH_AM040:
  131. printf ("AM29F040 (512 Kbit, uniform sector size)\n");
  132. break;
  133. case FLASH_AM400B:
  134. printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
  135. break;
  136. case FLASH_AM400T:
  137. printf ("AM29LV400T (4 Mbit, top boot sector)\n");
  138. break;
  139. case FLASH_AM800B:
  140. printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
  141. break;
  142. case FLASH_AM800T:
  143. printf ("AM29LV800T (8 Mbit, top boot sector)\n");
  144. break;
  145. case FLASH_AM160B:
  146. printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
  147. break;
  148. case FLASH_AM160T:
  149. printf ("AM29LV160T (16 Mbit, top boot sector)\n");
  150. break;
  151. case FLASH_AM320B:
  152. printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
  153. break;
  154. case FLASH_AM320T:
  155. printf ("AM29LV320T (32 Mbit, top boot sector)\n");
  156. break;
  157. case FLASH_SST800A:
  158. printf ("SST39LF/VF800 (8 Mbit, uniform sector size)\n");
  159. break;
  160. case FLASH_SST160A:
  161. printf ("SST39LF/VF160 (16 Mbit, uniform sector size)\n");
  162. break;
  163. default:
  164. printf ("Unknown Chip Type\n");
  165. break;
  166. }
  167. printf (" Size: %ld KB in %d Sectors\n",
  168. info->size >> 10, info->sector_count);
  169. printf (" Sector Start Addresses:");
  170. for (i = 0; i < info->sector_count; ++i) {
  171. /*
  172. * Check if whole sector is erased
  173. */
  174. if (i != (info->sector_count - 1))
  175. size = info->start[i + 1] - info->start[i];
  176. else
  177. size = info->start[0] + info->size - info->start[i];
  178. erased = 1;
  179. flash = (volatile unsigned long *) info->start[i];
  180. size = size >> 2; /* divide by 4 for longword access */
  181. for (k = 0; k < size; k++) {
  182. if (*flash++ != 0xffffffff) {
  183. erased = 0;
  184. break;
  185. }
  186. }
  187. if ((i % 5) == 0)
  188. printf ("\n ");
  189. printf (" %08lX%s%s",
  190. info->start[i],
  191. erased ? " E" : " ", info->protect[i] ? "RO " : " "
  192. );
  193. }
  194. printf ("\n");
  195. return;
  196. }
  197. /*-----------------------------------------------------------------------
  198. */
  199. /*-----------------------------------------------------------------------
  200. */
  201. /*
  202. * The following code cannot be run from FLASH!
  203. */
  204. static ulong flash_get_size (vu_long * addr, flash_info_t * info)
  205. {
  206. short i;
  207. FLASH_WORD_SIZE value;
  208. ulong base = (ulong) addr;
  209. volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *) addr;
  210. /* Write auto select command: read Manufacturer ID */
  211. addr2[ADDR0] = (FLASH_WORD_SIZE) 0x00AA00AA;
  212. addr2[ADDR1] = (FLASH_WORD_SIZE) 0x00550055;
  213. addr2[ADDR0] = (FLASH_WORD_SIZE) 0x00900090;
  214. value = addr2[0];
  215. switch (value) {
  216. case (FLASH_WORD_SIZE) AMD_MANUFACT:
  217. info->flash_id = FLASH_MAN_AMD;
  218. break;
  219. case (FLASH_WORD_SIZE) FUJ_MANUFACT:
  220. info->flash_id = FLASH_MAN_FUJ;
  221. break;
  222. case (FLASH_WORD_SIZE) SST_MANUFACT:
  223. info->flash_id = FLASH_MAN_SST;
  224. break;
  225. default:
  226. info->flash_id = FLASH_UNKNOWN;
  227. info->sector_count = 0;
  228. info->size = 0;
  229. return (0); /* no or unknown flash */
  230. }
  231. value = addr2[1]; /* device ID */
  232. switch (value) {
  233. case (FLASH_WORD_SIZE) AMD_ID_F040B:
  234. info->flash_id += FLASH_AM040;
  235. info->sector_count = 8;
  236. info->size = 0x0080000; /* => 512 ko */
  237. break;
  238. case (FLASH_WORD_SIZE) AMD_ID_LV040B:
  239. info->flash_id += FLASH_AM040;
  240. info->sector_count = 8;
  241. info->size = 0x0080000; /* => 512 ko */
  242. break;
  243. case (FLASH_WORD_SIZE) AMD_ID_LV400T:
  244. info->flash_id += FLASH_AM400T;
  245. info->sector_count = 11;
  246. info->size = 0x00080000;
  247. break; /* => 0.5 MB */
  248. case (FLASH_WORD_SIZE) AMD_ID_LV400B:
  249. info->flash_id += FLASH_AM400B;
  250. info->sector_count = 11;
  251. info->size = 0x00080000;
  252. break; /* => 0.5 MB */
  253. case (FLASH_WORD_SIZE) AMD_ID_LV800T:
  254. info->flash_id += FLASH_AM800T;
  255. info->sector_count = 19;
  256. info->size = 0x00100000;
  257. break; /* => 1 MB */
  258. case (FLASH_WORD_SIZE) AMD_ID_LV800B:
  259. info->flash_id += FLASH_AM800B;
  260. info->sector_count = 19;
  261. info->size = 0x00100000;
  262. break; /* => 1 MB */
  263. case (FLASH_WORD_SIZE) AMD_ID_LV160T:
  264. info->flash_id += FLASH_AM160T;
  265. info->sector_count = 35;
  266. info->size = 0x00200000;
  267. break; /* => 2 MB */
  268. case (FLASH_WORD_SIZE) AMD_ID_LV160B:
  269. info->flash_id += FLASH_AM160B;
  270. info->sector_count = 35;
  271. info->size = 0x00200000;
  272. break; /* => 2 MB */
  273. #if 0 /* enable when device IDs are available */
  274. case (FLASH_WORD_SIZE) AMD_ID_LV320T:
  275. info->flash_id += FLASH_AM320T;
  276. info->sector_count = 67;
  277. info->size = 0x00400000;
  278. break; /* => 4 MB */
  279. case (FLASH_WORD_SIZE) AMD_ID_LV320B:
  280. info->flash_id += FLASH_AM320B;
  281. info->sector_count = 67;
  282. info->size = 0x00400000;
  283. break; /* => 4 MB */
  284. #endif
  285. case (FLASH_WORD_SIZE) SST_ID_xF800A:
  286. info->flash_id += FLASH_SST800A;
  287. info->sector_count = 16;
  288. info->size = 0x00100000;
  289. break; /* => 1 MB */
  290. case (FLASH_WORD_SIZE) SST_ID_xF160A:
  291. info->flash_id += FLASH_SST160A;
  292. info->sector_count = 32;
  293. info->size = 0x00200000;
  294. break; /* => 2 MB */
  295. default:
  296. info->flash_id = FLASH_UNKNOWN;
  297. return (0); /* => no or unknown flash */
  298. }
  299. /* set up sector start address table */
  300. if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) ||
  301. (info->flash_id == FLASH_AM040)) {
  302. for (i = 0; i < info->sector_count; i++)
  303. info->start[i] = base + (i * 0x00010000);
  304. } else {
  305. if (info->flash_id & FLASH_BTYPE) {
  306. /* set sector offsets for bottom boot block type */
  307. info->start[0] = base + 0x00000000;
  308. info->start[1] = base + 0x00004000;
  309. info->start[2] = base + 0x00006000;
  310. info->start[3] = base + 0x00008000;
  311. for (i = 4; i < info->sector_count; i++) {
  312. info->start[i] =
  313. base + (i * 0x00010000) - 0x00030000;
  314. }
  315. } else {
  316. /* set sector offsets for top boot block type */
  317. i = info->sector_count - 1;
  318. info->start[i--] = base + info->size - 0x00004000;
  319. info->start[i--] = base + info->size - 0x00006000;
  320. info->start[i--] = base + info->size - 0x00008000;
  321. for (; i >= 0; i--) {
  322. info->start[i] = base + i * 0x00010000;
  323. }
  324. }
  325. }
  326. /* check for protected sectors */
  327. for (i = 0; i < info->sector_count; i++) {
  328. /* read sector protection at sector address, (A7 .. A0) = 0x02 */
  329. /* D0 = 1 if protected */
  330. addr2 = (volatile FLASH_WORD_SIZE *) (info->start[i]);
  331. if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST)
  332. info->protect[i] = 0;
  333. else
  334. info->protect[i] = addr2[2] & 1;
  335. }
  336. /*
  337. * Prevent writes to uninitialized FLASH.
  338. */
  339. if (info->flash_id != FLASH_UNKNOWN) {
  340. addr2 = (FLASH_WORD_SIZE *) info->start[0];
  341. *addr2 = (FLASH_WORD_SIZE) 0x00F000F0; /* reset bank */
  342. }
  343. return (info->size);
  344. }
  345. int wait_for_DQ7 (flash_info_t * info, int sect)
  346. {
  347. ulong start, now, last;
  348. volatile FLASH_WORD_SIZE *addr =
  349. (FLASH_WORD_SIZE *) (info->start[sect]);
  350. start = get_timer (0);
  351. last = start;
  352. while ((addr[0] & (FLASH_WORD_SIZE) 0x00800080) !=
  353. (FLASH_WORD_SIZE) 0x00800080) {
  354. if ((now = get_timer (start)) > CFG_FLASH_ERASE_TOUT) {
  355. printf ("Timeout\n");
  356. return -1;
  357. }
  358. /* show that we're waiting */
  359. if ((now - last) > 1000) { /* every second */
  360. putc ('.');
  361. last = now;
  362. }
  363. }
  364. return 0;
  365. }
  366. /*-----------------------------------------------------------------------
  367. */
  368. int flash_erase (flash_info_t * info, int s_first, int s_last)
  369. {
  370. volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *) (info->start[0]);
  371. volatile FLASH_WORD_SIZE *addr2;
  372. int flag, prot, sect, l_sect;
  373. int i;
  374. if ((s_first < 0) || (s_first > s_last)) {
  375. if (info->flash_id == FLASH_UNKNOWN) {
  376. printf ("- missing\n");
  377. } else {
  378. printf ("- no sectors to erase\n");
  379. }
  380. return 1;
  381. }
  382. if (info->flash_id == FLASH_UNKNOWN) {
  383. printf ("Can't erase unknown flash type - aborted\n");
  384. return 1;
  385. }
  386. prot = 0;
  387. for (sect = s_first; sect <= s_last; ++sect) {
  388. if (info->protect[sect]) {
  389. prot++;
  390. }
  391. }
  392. if (prot) {
  393. printf ("- Warning: %d protected sectors will not be erased!\n", prot);
  394. } else {
  395. printf ("\n");
  396. }
  397. l_sect = -1;
  398. /* Disable interrupts which might cause a timeout here */
  399. flag = disable_interrupts ();
  400. /* Start erase on unprotected sectors */
  401. for (sect = s_first; sect <= s_last; sect++) {
  402. if (info->protect[sect] == 0) { /* not protected */
  403. addr2 = (FLASH_WORD_SIZE *) (info->start[sect]);
  404. printf ("Erasing sector %p\n", addr2); /* CLH */
  405. if ((info->flash_id & FLASH_VENDMASK) ==
  406. FLASH_MAN_SST) {
  407. addr[ADDR0] = (FLASH_WORD_SIZE) 0x00AA00AA;
  408. addr[ADDR1] = (FLASH_WORD_SIZE) 0x00550055;
  409. addr[ADDR0] = (FLASH_WORD_SIZE) 0x00800080;
  410. addr[ADDR0] = (FLASH_WORD_SIZE) 0x00AA00AA;
  411. addr[ADDR1] = (FLASH_WORD_SIZE) 0x00550055;
  412. addr2[0] = (FLASH_WORD_SIZE) 0x00500050; /* block erase */
  413. for (i = 0; i < 50; i++)
  414. udelay (1000); /* wait 1 ms */
  415. } else {
  416. addr[ADDR0] = (FLASH_WORD_SIZE) 0x00AA00AA;
  417. addr[ADDR1] = (FLASH_WORD_SIZE) 0x00550055;
  418. addr[ADDR0] = (FLASH_WORD_SIZE) 0x00800080;
  419. addr[ADDR0] = (FLASH_WORD_SIZE) 0x00AA00AA;
  420. addr[ADDR1] = (FLASH_WORD_SIZE) 0x00550055;
  421. addr2[0] = (FLASH_WORD_SIZE) 0x00300030; /* sector erase */
  422. }
  423. l_sect = sect;
  424. /*
  425. * Wait for each sector to complete, it's more
  426. * reliable. According to AMD Spec, you must
  427. * issue all erase commands within a specified
  428. * timeout. This has been seen to fail, especially
  429. * if printf()s are included (for debug)!!
  430. */
  431. wait_for_DQ7 (info, sect);
  432. }
  433. }
  434. /* re-enable interrupts if necessary */
  435. if (flag)
  436. enable_interrupts ();
  437. /* wait at least 80us - let's wait 1 ms */
  438. udelay (1000);
  439. #if 0
  440. /*
  441. * We wait for the last triggered sector
  442. */
  443. if (l_sect < 0)
  444. goto DONE;
  445. wait_for_DQ7 (info, l_sect);
  446. DONE:
  447. #endif
  448. /* reset to read mode */
  449. addr = (FLASH_WORD_SIZE *) info->start[0];
  450. addr[0] = (FLASH_WORD_SIZE) 0x00F000F0; /* reset bank */
  451. printf (" done\n");
  452. return 0;
  453. }
  454. /*-----------------------------------------------------------------------
  455. * Copy memory to flash, returns:
  456. * 0 - OK
  457. * 1 - write timeout
  458. * 2 - Flash not erased
  459. */
  460. int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
  461. {
  462. ulong cp, wp, data;
  463. int i, l, rc;
  464. wp = (addr & ~3); /* get lower word aligned address */
  465. /*
  466. * handle unaligned start bytes
  467. */
  468. if ((l = addr - wp) != 0) {
  469. data = 0;
  470. for (i = 0, cp = wp; i < l; ++i, ++cp) {
  471. data = (data << 8) | (*(uchar *) cp);
  472. }
  473. for (; i < 4 && cnt > 0; ++i) {
  474. data = (data << 8) | *src++;
  475. --cnt;
  476. ++cp;
  477. }
  478. for (; cnt == 0 && i < 4; ++i, ++cp) {
  479. data = (data << 8) | (*(uchar *) cp);
  480. }
  481. if ((rc = write_word (info, wp, data)) != 0) {
  482. return (rc);
  483. }
  484. wp += 4;
  485. }
  486. /*
  487. * handle word aligned part
  488. */
  489. while (cnt >= 4) {
  490. data = 0;
  491. for (i = 0; i < 4; ++i) {
  492. data = (data << 8) | *src++;
  493. }
  494. if ((rc = write_word (info, wp, data)) != 0) {
  495. return (rc);
  496. }
  497. wp += 4;
  498. cnt -= 4;
  499. }
  500. if (cnt == 0) {
  501. return (0);
  502. }
  503. /*
  504. * handle unaligned tail bytes
  505. */
  506. data = 0;
  507. for (i = 0, cp = wp; i < 4 && cnt > 0; ++i, ++cp) {
  508. data = (data << 8) | *src++;
  509. --cnt;
  510. }
  511. for (; i < 4; ++i, ++cp) {
  512. data = (data << 8) | (*(uchar *) cp);
  513. }
  514. return (write_word (info, wp, data));
  515. }
  516. /*-----------------------------------------------------------------------
  517. * Write a word to Flash, returns:
  518. * 0 - OK
  519. * 1 - write timeout
  520. * 2 - Flash not erased
  521. */
  522. static int write_word (flash_info_t * info, ulong dest, ulong data)
  523. {
  524. volatile FLASH_WORD_SIZE *addr2 =
  525. (FLASH_WORD_SIZE *) (info->start[0]);
  526. volatile FLASH_WORD_SIZE *dest2 = (FLASH_WORD_SIZE *) dest;
  527. volatile FLASH_WORD_SIZE *data2 = (FLASH_WORD_SIZE *) & data;
  528. ulong start;
  529. int i;
  530. /* Check if Flash is (sufficiently) erased */
  531. if ((*((volatile FLASH_WORD_SIZE *) dest) &
  532. (FLASH_WORD_SIZE) data) != (FLASH_WORD_SIZE) data) {
  533. return (2);
  534. }
  535. for (i = 0; i < 4 / sizeof (FLASH_WORD_SIZE); i++) {
  536. int flag;
  537. /* Disable interrupts which might cause a timeout here */
  538. flag = disable_interrupts ();
  539. addr2[ADDR0] = (FLASH_WORD_SIZE) 0x00AA00AA;
  540. addr2[ADDR1] = (FLASH_WORD_SIZE) 0x00550055;
  541. addr2[ADDR0] = (FLASH_WORD_SIZE) 0x00A000A0;
  542. dest2[i] = data2[i];
  543. /* re-enable interrupts if necessary */
  544. if (flag)
  545. enable_interrupts ();
  546. /* data polling for D7 */
  547. start = get_timer (0);
  548. while ((dest2[i] & (FLASH_WORD_SIZE) 0x00800080) !=
  549. (data2[i] & (FLASH_WORD_SIZE) 0x00800080)) {
  550. if (get_timer (start) > CFG_FLASH_WRITE_TOUT) {
  551. return (1);
  552. }
  553. }
  554. }
  555. return (0);
  556. }