cpu.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. * Copyright (C) 2004-2006 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. /*
  23. * CPU specific code for the MPC83xx family.
  24. *
  25. * Derived from the MPC8260 and MPC85xx.
  26. */
  27. #include <common.h>
  28. #include <watchdog.h>
  29. #include <command.h>
  30. #include <mpc83xx.h>
  31. #include <asm/processor.h>
  32. #if defined(CONFIG_OF_FLAT_TREE)
  33. #include <ft_build.h>
  34. #endif
  35. #if defined(CONFIG_OF_LIBFDT)
  36. #include <libfdt.h>
  37. #include <libfdt_env.h>
  38. #endif
  39. DECLARE_GLOBAL_DATA_PTR;
  40. int checkcpu(void)
  41. {
  42. volatile immap_t *immr;
  43. ulong clock = gd->cpu_clk;
  44. u32 pvr = get_pvr();
  45. u32 spridr;
  46. char buf[32];
  47. immr = (immap_t *)CFG_IMMR;
  48. if ((pvr & 0xFFFF0000) != PVR_83xx) {
  49. puts("Not MPC83xx Family!!!\n");
  50. return -1;
  51. }
  52. spridr = immr->sysconf.spridr;
  53. puts("CPU: ");
  54. switch(spridr) {
  55. case SPR_8349E_REV10:
  56. case SPR_8349E_REV11:
  57. case SPR_8349E_REV31:
  58. puts("MPC8349E, ");
  59. break;
  60. case SPR_8349_REV10:
  61. case SPR_8349_REV11:
  62. case SPR_8349_REV31:
  63. puts("MPC8349, ");
  64. break;
  65. case SPR_8347E_REV10_TBGA:
  66. case SPR_8347E_REV11_TBGA:
  67. case SPR_8347E_REV31_TBGA:
  68. case SPR_8347E_REV10_PBGA:
  69. case SPR_8347E_REV11_PBGA:
  70. case SPR_8347E_REV31_PBGA:
  71. puts("MPC8347E, ");
  72. break;
  73. case SPR_8347_REV10_TBGA:
  74. case SPR_8347_REV11_TBGA:
  75. case SPR_8347_REV31_TBGA:
  76. case SPR_8347_REV10_PBGA:
  77. case SPR_8347_REV11_PBGA:
  78. case SPR_8347_REV31_PBGA:
  79. puts("MPC8347, ");
  80. break;
  81. case SPR_8343E_REV10:
  82. case SPR_8343E_REV11:
  83. case SPR_8343E_REV31:
  84. puts("MPC8343E, ");
  85. break;
  86. case SPR_8343_REV10:
  87. case SPR_8343_REV11:
  88. case SPR_8343_REV31:
  89. puts("MPC8343, ");
  90. break;
  91. case SPR_8360E_REV10:
  92. case SPR_8360E_REV11:
  93. case SPR_8360E_REV12:
  94. case SPR_8360E_REV20:
  95. puts("MPC8360E, ");
  96. break;
  97. case SPR_8360_REV10:
  98. case SPR_8360_REV11:
  99. case SPR_8360_REV12:
  100. case SPR_8360_REV20:
  101. puts("MPC8360, ");
  102. break;
  103. case SPR_8323E_REV10:
  104. case SPR_8323E_REV11:
  105. puts("MPC8323E, ");
  106. break;
  107. case SPR_8323_REV10:
  108. case SPR_8323_REV11:
  109. puts("MPC8323, ");
  110. break;
  111. case SPR_8321E_REV10:
  112. case SPR_8321E_REV11:
  113. puts("MPC8321E, ");
  114. break;
  115. case SPR_8321_REV10:
  116. case SPR_8321_REV11:
  117. puts("MPC8321, ");
  118. break;
  119. default:
  120. puts("Rev: Unknown revision number.\nWarning: Unsupported cpu revision!\n");
  121. return 0;
  122. }
  123. #if defined(CONFIG_MPC834X)
  124. /* Multiple revisons of 834x processors may have the same SPRIDR value.
  125. * So use PVR to identify the revision number.
  126. */
  127. printf("Rev: %02x at %s MHz\n", PVR_MAJ(pvr)<<4 | PVR_MIN(pvr), strmhz(buf, clock));
  128. #else
  129. printf("Rev: %02x at %s MHz\n", spridr & 0x0000FFFF, strmhz(buf, clock));
  130. #endif
  131. return 0;
  132. }
  133. /*
  134. * Program a UPM with the code supplied in the table.
  135. *
  136. * The 'dummy' variable is used to increment the MAD. 'dummy' is
  137. * supposed to be a pointer to the memory of the device being
  138. * programmed by the UPM. The data in the MDR is written into
  139. * memory and the MAD is incremented every time there's a read
  140. * from 'dummy'. Unfortunately, the current prototype for this
  141. * function doesn't allow for passing the address of this
  142. * device, and changing the prototype will break a number lots
  143. * of other code, so we need to use a round-about way of finding
  144. * the value for 'dummy'.
  145. *
  146. * The value can be extracted from the base address bits of the
  147. * Base Register (BR) associated with the specific UPM. To find
  148. * that BR, we need to scan all 8 BRs until we find the one that
  149. * has its MSEL bits matching the UPM we want. Once we know the
  150. * right BR, we can extract the base address bits from it.
  151. *
  152. * The MxMR and the BR and OR of the chosen bank should all be
  153. * configured before calling this function.
  154. *
  155. * Parameters:
  156. * upm: 0=UPMA, 1=UPMB, 2=UPMC
  157. * table: Pointer to an array of values to program
  158. * size: Number of elements in the array. Must be 64 or less.
  159. */
  160. void upmconfig (uint upm, uint *table, uint size)
  161. {
  162. #if defined(CONFIG_MPC834X)
  163. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  164. volatile lbus83xx_t *lbus = &immap->lbus;
  165. volatile uchar *dummy = NULL;
  166. const u32 msel = (upm + 4) << BR_MSEL_SHIFT; /* What the MSEL field in BRn should be */
  167. volatile u32 *mxmr = &lbus->mamr + upm; /* Pointer to mamr, mbmr, or mcmr */
  168. uint i;
  169. /* Scan all the banks to determine the base address of the device */
  170. for (i = 0; i < 8; i++) {
  171. if ((lbus->bank[i].br & BR_MSEL) == msel) {
  172. dummy = (uchar *) (lbus->bank[i].br & BR_BA);
  173. break;
  174. }
  175. }
  176. if (!dummy) {
  177. printf("Error: %s() could not find matching BR\n", __FUNCTION__);
  178. hang();
  179. }
  180. /* Set the OP field in the MxMR to "write" and the MAD field to 000000 */
  181. *mxmr = (*mxmr & 0xCFFFFFC0) | 0x10000000;
  182. for (i = 0; i < size; i++) {
  183. lbus->mdr = table[i];
  184. __asm__ __volatile__ ("sync");
  185. *dummy; /* Write the value to memory and increment MAD */
  186. __asm__ __volatile__ ("sync");
  187. }
  188. /* Set the OP field in the MxMR to "normal" and the MAD field to 000000 */
  189. *mxmr &= 0xCFFFFFC0;
  190. #else
  191. printf("Error: %s() not defined for this configuration.\n", __FUNCTION__);
  192. hang();
  193. #endif
  194. }
  195. int
  196. do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  197. {
  198. ulong msr;
  199. #ifndef MPC83xx_RESET
  200. ulong addr;
  201. #endif
  202. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  203. #ifdef MPC83xx_RESET
  204. /* Interrupts and MMU off */
  205. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  206. msr &= ~( MSR_EE | MSR_IR | MSR_DR);
  207. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  208. /* enable Reset Control Reg */
  209. immap->reset.rpr = 0x52535445;
  210. __asm__ __volatile__ ("sync");
  211. __asm__ __volatile__ ("isync");
  212. /* confirm Reset Control Reg is enabled */
  213. while(!((immap->reset.rcer) & RCER_CRE));
  214. printf("Resetting the board.");
  215. printf("\n");
  216. udelay(200);
  217. /* perform reset, only one bit */
  218. immap->reset.rcr = RCR_SWHR;
  219. #else /* ! MPC83xx_RESET */
  220. immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
  221. /* Interrupts and MMU off */
  222. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  223. msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
  224. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  225. /*
  226. * Trying to execute the next instruction at a non-existing address
  227. * should cause a machine check, resulting in reset
  228. */
  229. addr = CFG_RESET_ADDRESS;
  230. printf("resetting the board.");
  231. printf("\n");
  232. ((void (*)(void)) addr) ();
  233. #endif /* MPC83xx_RESET */
  234. return 1;
  235. }
  236. /*
  237. * Get timebase clock frequency (like cpu_clk in Hz)
  238. */
  239. unsigned long get_tbclk(void)
  240. {
  241. ulong tbclk;
  242. tbclk = (gd->bus_clk + 3L) / 4L;
  243. return tbclk;
  244. }
  245. #if defined(CONFIG_WATCHDOG)
  246. void watchdog_reset (void)
  247. {
  248. int re_enable = disable_interrupts();
  249. /* Reset the 83xx watchdog */
  250. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  251. immr->wdt.swsrr = 0x556c;
  252. immr->wdt.swsrr = 0xaa39;
  253. if (re_enable)
  254. enable_interrupts ();
  255. }
  256. #endif
  257. #if defined(CONFIG_OF_LIBFDT)
  258. /*
  259. * "Setter" functions used to add/modify FDT entries.
  260. */
  261. static int fdt_set_eth0(void *fdt, int nodeoffset, const char *name, bd_t *bd)
  262. {
  263. /*
  264. * Fix it up if it exists, don't create it if it doesn't exist.
  265. */
  266. if (fdt_get_property(fdt, nodeoffset, name, 0)) {
  267. return fdt_setprop(fdt, nodeoffset, name, bd->bi_enetaddr, 6);
  268. }
  269. return -FDT_ERR_NOTFOUND;
  270. }
  271. #ifdef CONFIG_HAS_ETH1
  272. /* second onboard ethernet port */
  273. static int fdt_set_eth1(void *fdt, int nodeoffset, const char *name, bd_t *bd)
  274. {
  275. /*
  276. * Fix it up if it exists, don't create it if it doesn't exist.
  277. */
  278. if (fdt_get_property(fdt, nodeoffset, name, 0)) {
  279. return fdt_setprop(fdt, nodeoffset, name, bd->bi_enet1addr, 6);
  280. }
  281. return -FDT_ERR_NOTFOUND;
  282. }
  283. #endif
  284. #ifdef CONFIG_HAS_ETH2
  285. /* third onboard ethernet port */
  286. static int fdt_set_eth2(void *fdt, int nodeoffset, const char *name, bd_t *bd)
  287. {
  288. /*
  289. * Fix it up if it exists, don't create it if it doesn't exist.
  290. */
  291. if (fdt_get_property(fdt, nodeoffset, name, 0)) {
  292. return fdt_setprop(fdt, nodeoffset, name, bd->bi_enet2addr, 6);
  293. }
  294. return -FDT_ERR_NOTFOUND;
  295. }
  296. #endif
  297. #ifdef CONFIG_HAS_ETH3
  298. /* fourth onboard ethernet port */
  299. static int fdt_set_eth3(void *fdt, int nodeoffset, const char *name, bd_t *bd)
  300. {
  301. /*
  302. * Fix it up if it exists, don't create it if it doesn't exist.
  303. */
  304. if (fdt_get_property(fdt, nodeoffset, name, 0)) {
  305. return fdt_setprop(fdt, nodeoffset, name, bd->bi_enet3addr, 6);
  306. }
  307. return -FDT_ERR_NOTFOUND;
  308. }
  309. #endif
  310. static int fdt_set_busfreq(void *fdt, int nodeoffset, const char *name, bd_t *bd)
  311. {
  312. u32 tmp;
  313. /*
  314. * Create or update the property.
  315. */
  316. tmp = cpu_to_be32(bd->bi_busfreq);
  317. return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
  318. }
  319. /*
  320. * Fixups to the fdt. If "create" is TRUE, the node is created
  321. * unconditionally. If "create" is FALSE, the node is updated
  322. * only if it already exists.
  323. */
  324. static const struct {
  325. char *node;
  326. char *prop;
  327. int (*set_fn)(void *fdt, int nodeoffset, const char *name, bd_t *bd);
  328. } fixup_props[] = {
  329. { "/cpus/" OF_CPU,
  330. "bus-frequency",
  331. fdt_set_busfreq
  332. },
  333. { "/cpus/" OF_SOC,
  334. "bus-frequency",
  335. fdt_set_busfreq
  336. },
  337. { "/" OF_SOC "/serial@4500/",
  338. "clock-frequency",
  339. fdt_set_busfreq
  340. },
  341. { "/" OF_SOC "/serial@4600/",
  342. "clock-frequency",
  343. fdt_set_busfreq
  344. },
  345. #ifdef CONFIG_MPC83XX_TSEC1
  346. { "/" OF_SOC "/ethernet@24000,
  347. "mac-address",
  348. fdt_set_eth0
  349. },
  350. { "/" OF_SOC "/ethernet@24000,
  351. "local-mac-address",
  352. fdt_set_eth0
  353. },
  354. #endif
  355. #ifdef CONFIG_MPC83XX_TSEC2
  356. { "/" OF_SOC "/ethernet@25000,
  357. "mac-address",
  358. fdt_set_eth1
  359. },
  360. { "/" OF_SOC "/ethernet@25000,
  361. "local-mac-address",
  362. fdt_set_eth1
  363. },
  364. #endif
  365. #ifdef CONFIG_UEC_ETH1
  366. #if CFG_UEC1_UCC_NUM == 0 /* UCC1 */
  367. { "/" OF_QE "/ucc@2000/mac-address",
  368. "mac-address",
  369. fdt_set_eth0
  370. },
  371. { "/" OF_QE "/ucc@2000/mac-address",
  372. "local-mac-address",
  373. fdt_set_eth0
  374. },
  375. #elif CFG_UEC1_UCC_NUM == 2 /* UCC3 */
  376. { "/" OF_QE "/ucc@2200/mac-address",
  377. "mac-address",
  378. fdt_set_eth0
  379. },
  380. { "/" OF_QE "/ucc@2200/mac-address",
  381. "local-mac-address",
  382. fdt_set_eth0
  383. },
  384. #endif
  385. #endif
  386. #ifdef CONFIG_UEC_ETH2
  387. #if CFG_UEC2_UCC_NUM == 1 /* UCC2 */
  388. { "/" OF_QE "/ucc@3000/mac-address",
  389. "mac-address",
  390. fdt_set_eth1
  391. },
  392. { "/" OF_QE "/ucc@3000/mac-address",
  393. "local-mac-address",
  394. fdt_set_eth1
  395. },
  396. #elif CFG_UEC1_UCC_NUM == 3 /* UCC4 */
  397. { "/" OF_QE "/ucc@3200/mac-address",
  398. "mac-address",
  399. fdt_set_eth1
  400. },
  401. { "/" OF_QE "/ucc@3200/mac-address",
  402. "local-mac-address",
  403. fdt_set_eth1
  404. },
  405. #endif
  406. #endif
  407. };
  408. void
  409. ft_cpu_setup(void *blob, bd_t *bd)
  410. {
  411. int nodeoffset;
  412. int err;
  413. int j;
  414. for (j = 0; j < (sizeof(fixup_props) / sizeof(fixup_props[0])); j++) {
  415. nodeoffset = fdt_path_offset(fdt, fixup_props[j].node);
  416. if (nodeoffset >= 0) {
  417. err = (*fixup_props[j].set_fn)(blob, nodeoffset, fixup_props[j].prop, bd);
  418. if (err < 0)
  419. printf("set_fn/libfdt: %s %s returned %s\n",
  420. fixup_props[j].node,
  421. fixup_props[j].prop,
  422. fdt_strerror(err));
  423. }
  424. }
  425. }
  426. #endif
  427. #if defined(CONFIG_OF_FLAT_TREE)
  428. void
  429. ft_cpu_setup(void *blob, bd_t *bd)
  430. {
  431. u32 *p;
  432. int len;
  433. ulong clock;
  434. clock = bd->bi_busfreq;
  435. p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
  436. if (p != NULL)
  437. *p = cpu_to_be32(clock);
  438. p = ft_get_prop(blob, "/" OF_SOC "/bus-frequency", &len);
  439. if (p != NULL)
  440. *p = cpu_to_be32(clock);
  441. p = ft_get_prop(blob, "/" OF_SOC "/serial@4500/clock-frequency", &len);
  442. if (p != NULL)
  443. *p = cpu_to_be32(clock);
  444. p = ft_get_prop(blob, "/" OF_SOC "/serial@4600/clock-frequency", &len);
  445. if (p != NULL)
  446. *p = cpu_to_be32(clock);
  447. #ifdef CONFIG_MPC83XX_TSEC1
  448. p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/mac-address", &len);
  449. if (p != NULL)
  450. memcpy(p, bd->bi_enetaddr, 6);
  451. p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/local-mac-address", &len);
  452. if (p != NULL)
  453. memcpy(p, bd->bi_enetaddr, 6);
  454. #endif
  455. #ifdef CONFIG_MPC83XX_TSEC2
  456. p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/mac-address", &len);
  457. if (p != NULL)
  458. memcpy(p, bd->bi_enet1addr, 6);
  459. p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/local-mac-address", &len);
  460. if (p != NULL)
  461. memcpy(p, bd->bi_enet1addr, 6);
  462. #endif
  463. #ifdef CONFIG_UEC_ETH1
  464. #if CFG_UEC1_UCC_NUM == 0 /* UCC1 */
  465. p = ft_get_prop(blob, "/" OF_QE "/ucc@2000/mac-address", &len);
  466. if (p != NULL)
  467. memcpy(p, bd->bi_enetaddr, 6);
  468. p = ft_get_prop(blob, "/" OF_QE "/ucc@2000/local-mac-address", &len);
  469. if (p != NULL)
  470. memcpy(p, bd->bi_enetaddr, 6);
  471. #elif CFG_UEC1_UCC_NUM == 2 /* UCC3 */
  472. p = ft_get_prop(blob, "/" OF_QE "/ucc@2200/mac-address", &len);
  473. if (p != NULL)
  474. memcpy(p, bd->bi_enetaddr, 6);
  475. p = ft_get_prop(blob, "/" OF_QE "/ucc@2200/local-mac-address", &len);
  476. if (p != NULL)
  477. memcpy(p, bd->bi_enetaddr, 6);
  478. #endif
  479. #endif
  480. #ifdef CONFIG_UEC_ETH2
  481. #if CFG_UEC2_UCC_NUM == 1 /* UCC2 */
  482. p = ft_get_prop(blob, "/" OF_QE "/ucc@3000/mac-address", &len);
  483. if (p != NULL)
  484. memcpy(p, bd->bi_enet1addr, 6);
  485. p = ft_get_prop(blob, "/" OF_QE "/ucc@3000/local-mac-address", &len);
  486. if (p != NULL)
  487. memcpy(p, bd->bi_enet1addr, 6);
  488. #elif CFG_UEC2_UCC_NUM == 3 /* UCC4 */
  489. p = ft_get_prop(blob, "/" OF_QE "/ucc@3200/mac-address", &len);
  490. if (p != NULL)
  491. memcpy(p, bd->bi_enet1addr, 6);
  492. p = ft_get_prop(blob, "/" OF_QE "/ucc@3200/local-mac-address", &len);
  493. if (p != NULL)
  494. memcpy(p, bd->bi_enet1addr, 6);
  495. #endif
  496. #endif
  497. }
  498. #endif
  499. #if defined(CONFIG_DDR_ECC)
  500. void dma_init(void)
  501. {
  502. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  503. volatile dma83xx_t *dma = &immap->dma;
  504. volatile u32 status = swab32(dma->dmasr0);
  505. volatile u32 dmamr0 = swab32(dma->dmamr0);
  506. debug("DMA-init\n");
  507. /* initialize DMASARn, DMADAR and DMAABCRn */
  508. dma->dmadar0 = (u32)0;
  509. dma->dmasar0 = (u32)0;
  510. dma->dmabcr0 = 0;
  511. __asm__ __volatile__ ("sync");
  512. __asm__ __volatile__ ("isync");
  513. /* clear CS bit */
  514. dmamr0 &= ~DMA_CHANNEL_START;
  515. dma->dmamr0 = swab32(dmamr0);
  516. __asm__ __volatile__ ("sync");
  517. __asm__ __volatile__ ("isync");
  518. /* while the channel is busy, spin */
  519. while(status & DMA_CHANNEL_BUSY) {
  520. status = swab32(dma->dmasr0);
  521. }
  522. debug("DMA-init end\n");
  523. }
  524. uint dma_check(void)
  525. {
  526. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  527. volatile dma83xx_t *dma = &immap->dma;
  528. volatile u32 status = swab32(dma->dmasr0);
  529. volatile u32 byte_count = swab32(dma->dmabcr0);
  530. /* while the channel is busy, spin */
  531. while (status & DMA_CHANNEL_BUSY) {
  532. status = swab32(dma->dmasr0);
  533. }
  534. if (status & DMA_CHANNEL_TRANSFER_ERROR) {
  535. printf ("DMA Error: status = %x @ %d\n", status, byte_count);
  536. }
  537. return status;
  538. }
  539. int dma_xfer(void *dest, u32 count, void *src)
  540. {
  541. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  542. volatile dma83xx_t *dma = &immap->dma;
  543. volatile u32 dmamr0;
  544. /* initialize DMASARn, DMADAR and DMAABCRn */
  545. dma->dmadar0 = swab32((u32)dest);
  546. dma->dmasar0 = swab32((u32)src);
  547. dma->dmabcr0 = swab32(count);
  548. __asm__ __volatile__ ("sync");
  549. __asm__ __volatile__ ("isync");
  550. /* init direct transfer, clear CS bit */
  551. dmamr0 = (DMA_CHANNEL_TRANSFER_MODE_DIRECT |
  552. DMA_CHANNEL_SOURCE_ADDRESS_HOLD_8B |
  553. DMA_CHANNEL_SOURCE_ADRESSS_HOLD_EN);
  554. dma->dmamr0 = swab32(dmamr0);
  555. __asm__ __volatile__ ("sync");
  556. __asm__ __volatile__ ("isync");
  557. /* set CS to start DMA transfer */
  558. dmamr0 |= DMA_CHANNEL_START;
  559. dma->dmamr0 = swab32(dmamr0);
  560. __asm__ __volatile__ ("sync");
  561. __asm__ __volatile__ ("isync");
  562. return ((int)dma_check());
  563. }
  564. #endif /*CONFIG_DDR_ECC*/