memory.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:20k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* Memory.c - Memory mappings and remapping functions */
  2. /* Copyright - Galileo technology. */
  3. /*
  4. DESCRIPTION
  5. This file contains function which gives the user the ability to remap the
  6. SDRAM memory and devices windows, please pay attention to overlapping windows
  7. since the function do not take care of that for you.
  8. When remapping the SDRAM or devices memory space pay attention to the PCI
  9. mappings and make sure to coordinate between the two interfaces!!!
  10. */
  11. /* includes */
  12. #ifdef __linux__
  13. #include <asm/galileo-boards/evb64120A/core.h>
  14. #include <asm/galileo-boards/evb64120A/memory.h>
  15. #else
  16. #include "Core.h"
  17. #include "Memory.h"
  18. #endif
  19. /********************************************************************
  20. * getMemoryBankBaseAddress - Extract the base address of a memory bank
  21. *      - If the memory bank size is 0 then this base address has no meaning !!!
  22. *
  23. * INPUTS:  MEMORY_BANK bank - SDRAM Bank number.
  24. * OUTPUT:  N/A
  25. * RETURNS: Memory bank base address.
  26. *********************************************************************/
  27. unsigned int getMemoryBankBaseAddress(MEMORY_BANK bank)
  28. {
  29. unsigned int base, regBase;
  30. GT_REG_READ((SCS_1_0_LOW_DECODE_ADDRESS + (bank / 2) * 0x10),
  31.     &base);
  32. base = base << 21;
  33. GT_REG_READ((SCS_0_LOW_DECODE_ADDRESS + bank * 8), &regBase);
  34. base = base | (regBase << 20);
  35. return base;
  36. }
  37. /********************************************************************
  38. * getDeviceBaseAddress - Extract the base address of a device.
  39. *           - If the device size is 0 then this base address has no meaning!!!
  40. *
  41. * INPUT:   DEVICE device - Bank number.
  42. * OUTPUT:  N/A
  43. * RETURNS: Device base address.
  44. *********************************************************************/
  45. unsigned int getDeviceBaseAddress(DEVICE device)
  46. {
  47. unsigned int base, regBase;
  48. GT_REG_READ((CS_2_0_LOW_DECODE_ADDRESS + (device / 3) * 0x10),
  49.     &base);
  50. base = base << 21;
  51. GT_REG_READ((CS_0_LOW_DECODE_ADDRESS + device * 0x8), &regBase);
  52. base = base | (regBase << 20);
  53. return base;
  54. }
  55. /********************************************************************
  56. * getMemoryBankSize - Extract the size of a memory bank.
  57. *
  58. * INPUT:   MEMORY_BANK bank - Bank number
  59. * OUTPUT:  N/A
  60. * RETURNS: Memory bank size.
  61. *********************************************************************/
  62. unsigned int getMemoryBankSize(MEMORY_BANK bank)
  63. {
  64. unsigned int size, base, value;
  65. base = getMemoryBankBaseAddress(bank);
  66. GT_REG_READ((SCS_0_HIGH_DECODE_ADDRESS + bank * 8), &size);
  67. size = ((size + 1) << 20) - (base & 0x0fffffff);
  68. GT_REG_READ((SCS_0_HIGH_DECODE_ADDRESS + bank * 8), &value);
  69. if (value == 0)
  70. return 0;
  71. else
  72. return size;
  73. }
  74. /********************************************************************
  75. * getDeviceSize - Extract the size of a device memory space
  76. *
  77. * INPUT:    DEVICE device - Device number
  78. * OUTPUT:   N/A
  79. * RETURNS:  Size of a device memory space.
  80. *********************************************************************/
  81. unsigned int getDeviceSize(DEVICE device)
  82. {
  83. unsigned int size, base, value;
  84. base = getDeviceBaseAddress(device);
  85. GT_REG_READ((CS_0_HIGH_DECODE_ADDRESS + device * 8), &size);
  86. size = ((size + 1) << 20) - (base & 0x0fffffff);
  87. GT_REG_READ((CS_0_HIGH_DECODE_ADDRESS + device * 8), &value);
  88. if ((value + 1) == 0)
  89. return 0;
  90. else
  91. return size;
  92. }
  93. /********************************************************************
  94. * getDeviceWidth - A device can be with: 1,2,4 or 8 Bytes data width.
  95. *                  The width is determine in registers: 'Device Parameters'
  96. *                  registers (0x45c, 0x460, 0x464, 0x468, 0x46c - for each device.
  97. *                  at bits: [21:20].
  98. *
  99. * INPUT:    DEVICE device - Device number
  100. * OUTPUT:   N/A
  101. * RETURNS:  Device width in Bytes (1,2,4, or 8), 0 if error had occurred.
  102. *********************************************************************/
  103. unsigned int getDeviceWidth(DEVICE device)
  104. {
  105. unsigned int width;
  106. unsigned int regValue;
  107. GT_REG_READ(DEVICE_BANK0PARAMETERS + device * 4, &regValue);
  108. width = (regValue & 0x00300000) >> 20;
  109. switch (width) {
  110. case 0:
  111. return 1;
  112. case 1:
  113. return 2;
  114. case 2:
  115. return 4;
  116. case 3:
  117. return 8;
  118. default:
  119. return 0;
  120. }
  121. }
  122. /********************************************************************
  123. * mapMemoryBanks0and1 - Sets new bases and boundaries for memory banks 0 and 1
  124. *                     - Pay attention to the PCI mappings and make sure to
  125. *                       coordinate between the two interfaces!!!
  126. *                     - It is the programmer`s responsibility to make sure
  127. *                       there are no conflicts with other memory spaces!!!
  128. *                     - If a bank needs to be closed , give it a 0 length
  129. *
  130. *
  131. * INPUTS: unsigned int bank0Base - required bank 0 base address.
  132. *         unsigned int bank0Length - required bank 0 size.
  133. *         unsigned int bank1Base - required bank 1 base address.
  134. *         unsigned int bank1Length - required bank 1 size.
  135. * RETURNS: true on success, false on failure or if one of the parameters is
  136. *          erroneous.
  137. *********************************************************************/
  138. bool mapMemoryBanks0and1(unsigned int bank0Base, unsigned int bank0Length,
  139.  unsigned int bank1Base, unsigned int bank1Length)
  140. {
  141. unsigned int mainBank0Top = bank0Base + bank0Length;
  142. unsigned int mainBank1Top = bank1Base + bank1Length;
  143. unsigned int memBank0Base, bank0Top;
  144. unsigned int memBank1Base, bank1Top;
  145. if (bank0Base <= bank1Base) {
  146. if ((bank0Base + bank0Length) > bank1Base)
  147. return false;
  148. } else {
  149. if ((bank1Base + bank1Length) > bank0Base)
  150. return false;
  151. }
  152. if (bank0Length == 0)
  153. mainBank0Top++;
  154. if (bank1Length == 0)
  155. mainBank1Top++;
  156. memBank0Base = ((unsigned int) (bank0Base & 0x0fffffff)) >> 20;
  157. bank0Top = ((unsigned int) (mainBank0Top & 0x0fffffff)) >> 20;
  158. memBank1Base = ((unsigned int) (bank1Base & 0x0fffffff)) >> 20;
  159. bank1Top = ((unsigned int) (mainBank1Top & 0x0fffffff)) >> 20;
  160. if (mainBank1Top > mainBank0Top) {
  161. bank0Base >>= 21;
  162. mainBank0Top =
  163.     ((unsigned int) (mainBank1Top & 0x0fffffff)) >> 21;
  164. } else {
  165. bank0Base = bank1Base >> 21;
  166. mainBank0Top =
  167.     ((unsigned int) (mainBank0Top & 0x0fffffff)) >> 21;
  168. }
  169. GT_REG_WRITE(SCS_1_0_LOW_DECODE_ADDRESS, bank0Base);
  170. if ((bank0Length + bank1Length) != 0) {
  171. GT_REG_WRITE(SCS_1_0_HIGH_DECODE_ADDRESS,
  172.      mainBank0Top - 1);
  173. } else {
  174. GT_REG_WRITE(SCS_1_0_HIGH_DECODE_ADDRESS, 0x0);
  175. }
  176. if (bank1Length != 0) {
  177. GT_REG_WRITE(SCS_1_HIGH_DECODE_ADDRESS, bank1Top - 1);
  178. } else {
  179. GT_REG_WRITE(SCS_1_HIGH_DECODE_ADDRESS, 0x0);
  180. }
  181. GT_REG_WRITE(SCS_1_LOW_DECODE_ADDRESS, memBank1Base);
  182. if (bank0Length != 0) {
  183. GT_REG_WRITE(SCS_0_HIGH_DECODE_ADDRESS, bank0Top - 1);
  184. } else {
  185. GT_REG_WRITE(SCS_0_HIGH_DECODE_ADDRESS, 0x0);
  186. }
  187. GT_REG_WRITE(SCS_0_LOW_DECODE_ADDRESS, memBank0Base);
  188. return true;
  189. }
  190. /********************************************************************
  191. * mapMemoryBanks2and3 - Sets new bases and boundaries for memory banks 2 and 3
  192. *                     - Pay attention to the PCI mappings and make sure to
  193. *                       coordinate between the two interfaces!!!
  194. *                     - It`s the programmer`s responsibility to make sure there
  195. *                       are no conflicts with other memory spaces!!!
  196. *                     - If a bank needs to be closed , give it a 0 length.
  197. *
  198. *
  199. * INPUTS: unsigned int bank2Base - required bank 2 base address.
  200. *         unsigned int bank2Length - required bank 2 size.
  201. *         unsigned int bank3Base - required bank 3 base address.
  202. *         unsigned int bank3Length - required bank 3 size.
  203. * RETURNS: true on success, false on failure or if one of the parameters is
  204. *          erroneous.
  205. *********************************************************************/
  206. bool mapMemoryBanks2and3(unsigned int bank2Base, unsigned int bank2Length,
  207.  unsigned int bank3Base, unsigned int bank3Length)
  208. {
  209. unsigned int mainBank2Top =
  210.     (unsigned int) (bank2Base + bank2Length);
  211. unsigned int mainBank3Top =
  212.     (unsigned int) (bank3Base + bank3Length);
  213. unsigned int memBank2Base, bank2Top;
  214. unsigned int memBank3Base, bank3Top;
  215. if (bank2Base <= bank3Base) {
  216. if ((bank2Base + bank2Length) > bank3Base)
  217. return false;
  218. } else {
  219. if ((bank3Base + bank3Length) > bank2Base)
  220. return false;
  221. }
  222. if (bank2Length == 0)
  223. mainBank2Top++;
  224. if (bank3Length == 0)
  225. mainBank3Top++;
  226. memBank2Base = ((unsigned int) (bank2Base & 0x0fffffff)) >> 20;
  227. bank2Top = ((unsigned int) (mainBank2Top & 0x0fffffff)) >> 20;
  228. memBank3Base = ((unsigned int) (bank3Base & 0x0fffffff)) >> 20;
  229. bank3Top = ((unsigned int) (mainBank3Top & 0x0fffffff)) >> 20;
  230. if (mainBank3Top > mainBank2Top) {
  231. bank2Base >>= 21;
  232. mainBank2Top =
  233.     ((unsigned int) (mainBank3Top & 0x0fffffff)) >> 21;
  234. } else {
  235. bank2Base = bank3Base >> 21;
  236. mainBank2Top =
  237.     ((unsigned int) (mainBank2Top & 0x0fffffff)) >> 21;
  238. }
  239. GT_REG_WRITE(SCS_3_2_LOW_DECODE_ADDRESS, bank2Base);
  240. if ((bank2Length + bank3Length) != 0) {
  241. GT_REG_WRITE(SCS_3_2_HIGH_DECODE_ADDRESS,
  242.      mainBank2Top - 1);
  243. } else {
  244. GT_REG_WRITE(SCS_3_2_HIGH_DECODE_ADDRESS, 0x0);
  245. }
  246. if (bank3Length != 0) {
  247. GT_REG_WRITE(SCS_3_HIGH_DECODE_ADDRESS, bank3Top - 1);
  248. } else {
  249. GT_REG_WRITE(SCS_3_HIGH_DECODE_ADDRESS, 0x0);
  250. }
  251. GT_REG_WRITE(SCS_3_LOW_DECODE_ADDRESS, memBank3Base);
  252. if (bank2Length != 0) {
  253. GT_REG_WRITE(SCS_2_HIGH_DECODE_ADDRESS, bank2Top - 1);
  254. } else {
  255. GT_REG_WRITE(SCS_2_HIGH_DECODE_ADDRESS, 0x0);
  256. }
  257. GT_REG_WRITE(SCS_2_LOW_DECODE_ADDRESS, memBank2Base);
  258. return true;
  259. }
  260. /********************************************************************
  261. * mapDevices0_1and2MemorySpace - Sets new bases and boundaries for devices 0,1
  262. *                                and 2
  263. *                     - Pay attention to the PCI mappings and make sure to
  264. *                        coordinate between the two interfaces!!!
  265. *                     - It`s the programmer`s responsibility to make sure there
  266. *                       are no conflicts with other memory spaces!!!
  267. *                     - If a device needs to be closed , give it a 0 length
  268. *
  269. *
  270. * INPUTS: unsigned int device0Base - required cs_0 base address.
  271. *         unsigned int device0Length - required cs_0 size.
  272. *         unsigned int device1Base - required cs_1 base address.
  273. *         unsigned int device1Length - required cs_0 size.
  274. *         unsigned int device2Base - required cs_2 base address.
  275. *         unsigned int device2Length - required cs_2 size.
  276. * RETURNS: true on success, false on failure or if one of the parameters is
  277. *          erroneous.
  278. *********************************************************************/
  279. bool mapDevices0_1and2MemorySpace(unsigned int device0Base,
  280.   unsigned int device0Length,
  281.   unsigned int device1Base,
  282.   unsigned int device1Length,
  283.   unsigned int device2Base,
  284.   unsigned int device2Length)
  285. {
  286. unsigned int deviceBank0Top =
  287.     (unsigned int) (device0Base + device0Length);
  288. unsigned int deviceBank1Top =
  289.     (unsigned int) (device1Base + device1Length);
  290. unsigned int deviceBank2Top =
  291.     (unsigned int) (device2Base + device2Length);
  292. unsigned int device0BaseTemp = 0, device0TopTemp = 0;
  293. unsigned int bank0Base, bank0Top;
  294. unsigned int bank1Base, bank1Top;
  295. unsigned int bank2Base, bank2Top;
  296. bank0Base = ((unsigned int) (device0Base & 0x0fffffff)) >> 20;
  297. bank0Top = ((unsigned int) (deviceBank0Top & 0x0fffffff)) >> 20;
  298. bank1Base = ((unsigned int) (device1Base & 0x0fffffff)) >> 20;
  299. bank1Top = ((unsigned int) (deviceBank1Top & 0x0fffffff)) >> 20;
  300. bank2Base = ((unsigned int) (device2Base & 0x0fffffff)) >> 20;
  301. bank2Top = ((unsigned int) (deviceBank2Top & 0x0fffffff)) >> 20;
  302. if (device0Length == 0)
  303. deviceBank0Top++;
  304. if (device1Length == 0)
  305. deviceBank1Top++;
  306. if (device2Length == 0)
  307. deviceBank2Top++;
  308. if (device0Base <= device1Base && device0Base <= device2Base) {
  309. if ((device0Base + device0Length) > device1Base || 
  310.     (device0Base + device0Length) > device2Base)
  311. return false;
  312. if (device1Base <= device2Base) {
  313. if ((device1Base + device1Length) > device2Base)
  314. return false;
  315. } else {
  316. if ((device2Base + device2Length) > device1Base)
  317. return false;
  318. }
  319. }
  320. if (device1Base <= device0Base && device1Base <= device2Base) {
  321. if ((device1Base + device1Length) > device0Base ||
  322.     (device1Base + device1Length) > device2Base)
  323. return false;
  324. if (device0Base <= device2Base) {
  325. if ((device0Base + device0Length) > device2Base)
  326. return false;
  327. } else {
  328. if ((device2Base + device2Length) > device0Base)
  329. return false;
  330. }
  331. }
  332. if (device2Base <= device1Base && device2Base <= device0Base) {
  333. if ((device2Base + device2Length) > device1Base ||
  334.     (device2Base + device2Length) > device0Base)
  335. return false;
  336. if (device0Base <= device1Base) {
  337. if ((device0Base + device0Length) > device1Base)
  338. return false;
  339. } else {
  340. if ((device1Base + device1Length) > device0Base)
  341. return false;
  342. }
  343. }
  344. if ((deviceBank2Top > deviceBank1Top) && (deviceBank1Top >
  345.   deviceBank0Top)) {
  346. device0BaseTemp = device0Base >> 21;
  347. device0TopTemp =
  348.     ((unsigned int) (deviceBank2Top & 0x0fffffff)) >> 21;
  349. }
  350. if ((deviceBank2Top > deviceBank0Top)
  351.     && (deviceBank0Top > deviceBank1Top)) {
  352. device0BaseTemp = device1Base >> 21;
  353. device0TopTemp =
  354.     ((unsigned int) (deviceBank2Top & 0x0fffffff)) >> 21;
  355. }
  356. if ((deviceBank1Top > deviceBank2Top)
  357.     && (deviceBank2Top > deviceBank0Top)) {
  358. device0BaseTemp = device0Base >> 21;
  359. device0TopTemp =
  360.     ((unsigned int) (deviceBank1Top & 0x0fffffff)) >> 21;
  361. }
  362. if ((deviceBank1Top > deviceBank0Top)
  363.     && (deviceBank0Top > deviceBank2Top)) {
  364. device0BaseTemp = device2Base >> 21;
  365. device0TopTemp =
  366.     ((unsigned int) (deviceBank1Top & 0x0fffffff)) >> 21;
  367. }
  368. if ((deviceBank0Top > deviceBank2Top)
  369.     && (deviceBank2Top > deviceBank1Top)) {
  370. device0BaseTemp = device1Base >> 21;
  371. device0TopTemp =
  372.     ((unsigned int) (deviceBank0Top & 0x0fffffff)) >> 21;
  373. }
  374. if ((deviceBank0Top > deviceBank1Top)
  375.     && (deviceBank1Top > deviceBank2Top)) {
  376. device0BaseTemp = device2Base >> 21;
  377. device0TopTemp =
  378.     ((unsigned int) (deviceBank0Top & 0x0fffffff)) >> 21;
  379. }
  380. GT_REG_WRITE(CS_2_0_LOW_DECODE_ADDRESS, device0BaseTemp);
  381. if ((device0Length + device1Length + device2Length) != 0) {
  382. GT_REG_WRITE(CS_2_0_HIGH_DECODE_ADDRESS,
  383.      device0TopTemp - 1);
  384. } else {
  385. GT_REG_WRITE(CS_2_0_HIGH_DECODE_ADDRESS, 0x0);
  386. }
  387. GT_REG_WRITE(CS_0_LOW_DECODE_ADDRESS, bank0Base);
  388. if (device0Length != 0) {
  389. GT_REG_WRITE(CS_0_HIGH_DECODE_ADDRESS, bank0Top - 1);
  390. } else {
  391. GT_REG_WRITE(CS_0_HIGH_DECODE_ADDRESS, 0x0);
  392. }
  393. GT_REG_WRITE(CS_1_LOW_DECODE_ADDRESS, bank1Base);
  394. if (device1Length != 0) {
  395. GT_REG_WRITE(CS_1_HIGH_DECODE_ADDRESS, bank1Top - 1);
  396. } else {
  397. GT_REG_WRITE(CS_1_HIGH_DECODE_ADDRESS, 0x0);
  398. }
  399. GT_REG_WRITE(CS_2_LOW_DECODE_ADDRESS, bank2Base);
  400. if (device2Length != 0) {
  401. GT_REG_WRITE(CS_2_HIGH_DECODE_ADDRESS, bank2Top - 1);
  402. } else {
  403. GT_REG_WRITE(CS_2_HIGH_DECODE_ADDRESS, 0x0);
  404. }
  405. return true;
  406. }
  407. /********************************************************************
  408. * mapDevices3andBootMemorySpace - Sets new bases and boundaries for devices:
  409. *                                 3 and boot
  410. *                     - Pay attention to the PCI mappings and make sure to
  411. *                       coordinate between the two interfaces!!!
  412. *                     - It is the programmer`s responsibility to make sure
  413. *                       there are no conflicts with other memory spaces!!!
  414. *                     - If a device needs to be closed , give it a 0 length.
  415. *
  416. * INPUTS: base and length of device 3and boot
  417. * RETURNS: true on success, false on failure
  418. *********************************************************************/
  419. bool mapDevices3andBootMemorySpace(unsigned int device3Base,
  420.    unsigned int device3Length,
  421.    unsigned int bootDeviceBase,
  422.    unsigned int bootDeviceLength)
  423. {
  424. unsigned int deviceBank3Top =
  425.     (unsigned int) (device3Base + device3Length);
  426. unsigned int deviceBankBootTop =
  427.     (unsigned int) (bootDeviceBase + bootDeviceLength);
  428. unsigned int bank3Base, bank3Top;
  429. unsigned int bank4Base, bank4Top;
  430. unsigned int Device1Base, Device1Top;
  431. bank3Top = ((unsigned int) (deviceBank3Top & 0x0fffffff)) >> 20;
  432. bank4Top = ((unsigned int) (deviceBankBootTop & 0x0fffffff)) >> 20;
  433. bank3Base = ((unsigned int) (device3Base & 0x0fffffff)) >> 20;
  434. bank4Base = ((unsigned int) (bootDeviceBase & 0x0fffffff)) >> 20;
  435. if (device3Base <= bootDeviceBase) {
  436. if (deviceBank3Top > bootDeviceBase)
  437. return false;
  438. } else {
  439. if (deviceBankBootTop > device3Base)
  440. return false;
  441. }
  442. if (deviceBankBootTop > deviceBank3Top) {
  443. Device1Base = device3Base >> 21;
  444. Device1Top =
  445.     ((unsigned int) (deviceBankBootTop & 0x0fffffff)) >>
  446.     21;
  447. } else {
  448. Device1Base = bootDeviceBase >> 21;
  449. Device1Top =
  450.     ((unsigned int) (deviceBank3Top & 0x0fffffff)) >> 21;
  451. }
  452. GT_REG_WRITE(CS_3_BOOTCS_LOW_DECODE_ADDRESS, Device1Base);
  453. if ((device3Length + bootDeviceLength) != 0) {
  454. GT_REG_WRITE(CS_3_BOOTCS_HIGH_DECODE_ADDRESS,
  455.      Device1Top - 1);
  456. } else {
  457. GT_REG_WRITE(CS_3_BOOTCS_HIGH_DECODE_ADDRESS, 0x0);
  458. }
  459. GT_REG_WRITE(CS_3_LOW_DECODE_ADDRESS, bank3Base);
  460. if (device3Length != 0) {
  461. GT_REG_WRITE(CS_3_HIGH_DECODE_ADDRESS, bank3Top - 1);
  462. } else {
  463. GT_REG_WRITE(CS_3_HIGH_DECODE_ADDRESS, 0x0);
  464. }
  465. GT_REG_WRITE(BOOTCS_LOW_DECODE_ADDRESS, bank4Base);
  466. if (bootDeviceLength != 0) {
  467. GT_REG_WRITE(BOOTCS_HIGH_DECODE_ADDRESS, bank4Top - 1);
  468. } else {
  469. GT_REG_WRITE(BOOTCS_HIGH_DECODE_ADDRESS, 0x0);
  470. }
  471. return true;
  472. }
  473. /********************************************************************
  474. * modifyDeviceParameters - This function can be used to modify a device`s
  475. *                          parameters.
  476. *                        - Be advised to check the spec before modifying them.
  477. * Inputs:
  478. * Returns: false if one of the parameters is erroneous,true otherwise.
  479. *********************************************************************/
  480. bool modifyDeviceParameters(DEVICE device, unsigned int turnOff,
  481.     unsigned int accToFirst,
  482.     unsigned int accToNext, unsigned int aleToWr,
  483.     unsigned int wrActive, unsigned int wrHigh,
  484.     unsigned int width, bool paritySupport)
  485. {
  486. unsigned int data, oldValue;
  487. if ((turnOff > 0x7 && turnOff != DONT_MODIFY)
  488.     || (accToFirst > 0xf && accToFirst != DONT_MODIFY)
  489.     || (accToNext > 0xf && accToNext != DONT_MODIFY)
  490.     || (aleToWr > 0x7 && aleToWr != DONT_MODIFY)
  491.     || (wrActive > 0x7 && wrActive != DONT_MODIFY)
  492.     || (wrHigh > 0x7 && wrHigh != DONT_MODIFY)) {
  493. return false;
  494. }
  495. GT_REG_READ((DEVICE_BANK0PARAMETERS + device * 4), &oldValue);
  496. if (turnOff == DONT_MODIFY)
  497. turnOff = oldValue & 0x00000007;
  498. else
  499. turnOff = turnOff;
  500. if (accToFirst == DONT_MODIFY)
  501. accToFirst = oldValue & 0x00000078;
  502. else
  503. accToFirst = accToFirst << 3;
  504. if (accToNext == DONT_MODIFY)
  505. accToNext = oldValue & 0x00000780;
  506. else
  507. accToNext = accToNext << 7;
  508. if (aleToWr == DONT_MODIFY)
  509. aleToWr = oldValue & 0x00003800;
  510. else
  511. aleToWr = aleToWr << 11;
  512. if (wrActive == DONT_MODIFY)
  513. wrActive = oldValue & 0x0001c000;
  514. else
  515. wrActive = wrActive << 14;
  516. if (wrHigh == DONT_MODIFY)
  517. wrHigh = oldValue & 0x000e0000;
  518. else
  519. wrHigh = wrHigh << 17;
  520. data =
  521.     turnOff | accToFirst | accToNext | aleToWr | wrActive | wrHigh;
  522. switch (width) {
  523. case _8BIT:
  524. break;
  525. case _16BIT:
  526. data = data | _16BIT;
  527. break;
  528. case _32BIT:
  529. data = data | _32BIT;
  530. break;
  531. case _64BIT:
  532. data = data | _64BIT;
  533. break;
  534. default:
  535. return false;
  536. }
  537. if (paritySupport == true)
  538. data = data | PARITY_SUPPORT;
  539. GT_REG_WRITE(DEVICE_BANK0PARAMETERS + device * 4, data);
  540. return true;
  541. }
  542. /********************************************************************
  543. * remapAddress - This fubction used for address remapping
  544. * Inputs:      - regOffset: remap register
  545. *                remapHeader : remapped address
  546. * Returns: false if one of the parameters is erroneous,true otherwise.
  547. *********************************************************************/
  548. bool remapAddress(unsigned int remapReg, unsigned int remapValue)
  549. {
  550. unsigned int valueForReg;
  551. valueForReg = (remapValue & 0xffe00000) >> 21;
  552. GT_REG_WRITE(remapReg, valueForReg);
  553. return true;
  554. }