flash-defines.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * U-boot - flash-defines.h
  3. *
  4. * Copyright (c) 2005-2007 Analog Devices Inc.
  5. *
  6. * (C) Copyright 2000-2004
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  25. * MA 02110-1301 USA
  26. */
  27. #ifndef __FLASHDEFINES_H__
  28. #define __FLASHDEFINES_H__
  29. #include <common.h>
  30. #define V_ULONG(a) (*(volatile unsigned long *)( a ))
  31. #define V_BYTE(a) (*(volatile unsigned char *)( a ))
  32. #define BUFFER_SIZE 0x80000
  33. #define NO_COMMAND 0
  34. #define GET_CODES 1
  35. #define RESET 2
  36. #define WRITE 3
  37. #define FILL 4
  38. #define ERASE_ALL 5
  39. #define ERASE_SECT 6
  40. #define READ 7
  41. #define GET_SECTNUM 8
  42. #define FLASH_START_L 0x0000
  43. #define FLASH_START_H 0x2000
  44. #define FLASH_TOT_SECT 40
  45. #define FLASH_SIZE 0x220000
  46. #define FLASH_MAN_ST 2
  47. #define CONFIG_SYS_FLASH0_BASE 0x20000000
  48. #define CONFIG_SYS_FLASH1_BASE 0x20200000
  49. #define RESET_VAL 0xF0
  50. flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
  51. int get_codes(void);
  52. int poll_toggle_bit(long lOffset);
  53. void reset_flash(void);
  54. int erase_flash(void);
  55. int erase_block_flash(int, unsigned long);
  56. void unlock_flash(long lOffset);
  57. int write_data(long lStart, long lCount, uchar *pnData);
  58. int FillData(long lStart, long lCount, long lStride, int *pnData);
  59. int read_data(long lStart, long lCount, long lStride, int *pnData);
  60. int read_flash(long nOffset, int *pnValue);
  61. int write_flash(long nOffset, int nValue);
  62. void get_sector_number(long lOffset, int *pnSector);
  63. int GetSectorProtectionStatus(flash_info_t * info, int nSector);
  64. int GetOffset(int nBlock);
  65. #define WRITESEQ1 0x0AAA
  66. #define WRITESEQ2 0x0554
  67. #define WRITESEQ3 0x0AAA
  68. #define WRITESEQ4 0x0AAA
  69. #define WRITESEQ5 0x0554
  70. #define WRITESEQ6 0x0AAA
  71. #define WRITEDATA1 0xaa
  72. #define WRITEDATA2 0x55
  73. #define WRITEDATA3 0x80
  74. #define WRITEDATA4 0xaa
  75. #define WRITEDATA5 0x55
  76. #define WRITEDATA6 0x10
  77. #define PriFlashABegin 0
  78. #define SecFlashABegin 32
  79. #define SecFlashBBegin 36
  80. #define PriFlashAOff 0x0
  81. #define PriFlashBOff 0x100000
  82. #define SecFlashAOff 0x200000
  83. #define SecFlashBOff 0x280000
  84. #define INVALIDLOCNSTART 0x20270000
  85. #define INVALIDLOCNEND 0x20280000
  86. #define BlockEraseVal 0x30
  87. #define UNLOCKDATA1 0xaa
  88. #define UNLOCKDATA2 0x55
  89. #define UNLOCKDATA3 0xa0
  90. #define GETCODEDATA1 0xaa
  91. #define GETCODEDATA2 0x55
  92. #define GETCODEDATA3 0x90
  93. #define SecFlashASec1Off 0x200000
  94. #define SecFlashASec2Off 0x204000
  95. #define SecFlashASec3Off 0x206000
  96. #define SecFlashASec4Off 0x208000
  97. #define SecFlashAEndOff 0x210000
  98. #define SecFlashBSec1Off 0x280000
  99. #define SecFlashBSec2Off 0x284000
  100. #define SecFlashBSec3Off 0x286000
  101. #define SecFlashBSec4Off 0x288000
  102. #define SecFlashBEndOff 0x290000
  103. #define SECT32 32
  104. #define SECT33 33
  105. #define SECT34 34
  106. #define SECT35 35
  107. #define SECT36 36
  108. #define SECT37 37
  109. #define SECT38 38
  110. #define SECT39 39
  111. #define FLASH_SUCCESS 0
  112. #define FLASH_FAIL -1
  113. #endif