You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
4.2KB

  1. /***************************************************************************
  2. * Copyright (C) 2009 by Alexei Babich *
  3. * Rezonans plc., Chelyabinsk, Russia *
  4. * impatt@mail.ru *
  5. * *
  6. * This program is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 2 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this program; if not, write to the *
  18. * Free Software Foundation, Inc., *
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
  20. ***************************************************************************/
  21. /*
  22. * Freescale iMX3* OpenOCD NAND Flash controller support.
  23. *
  24. * Many thanks to Ben Dooks for writing s3c24xx driver.
  25. */
  26. #define MX3_NF_BASE_ADDR 0xb8000000
  27. #define MX3_NF_BUFSIZ (MX3_NF_BASE_ADDR + 0xe00)
  28. #define MX3_NF_BUFADDR (MX3_NF_BASE_ADDR + 0xe04)
  29. #define MX3_NF_FADDR (MX3_NF_BASE_ADDR + 0xe06)
  30. #define MX3_NF_FCMD (MX3_NF_BASE_ADDR + 0xe08)
  31. #define MX3_NF_BUFCFG (MX3_NF_BASE_ADDR + 0xe0a)
  32. #define MX3_NF_ECCSTATUS (MX3_NF_BASE_ADDR + 0xe0c)
  33. #define MX3_NF_ECCMAINPOS (MX3_NF_BASE_ADDR + 0xe0e)
  34. #define MX3_NF_ECCSPAREPOS (MX3_NF_BASE_ADDR + 0xe10)
  35. #define MX3_NF_FWP (MX3_NF_BASE_ADDR + 0xe12)
  36. #define MX3_NF_LOCKSTART (MX3_NF_BASE_ADDR + 0xe14)
  37. #define MX3_NF_LOCKEND (MX3_NF_BASE_ADDR + 0xe16)
  38. #define MX3_NF_FWPSTATUS (MX3_NF_BASE_ADDR + 0xe18)
  39. /*
  40. * all bits not marked as self-clearing bit
  41. */
  42. #define MX3_NF_CFG1 (MX3_NF_BASE_ADDR + 0xe1a)
  43. #define MX3_NF_CFG2 (MX3_NF_BASE_ADDR + 0xe1c)
  44. #define MX3_NF_MAIN_BUFFER0 (MX3_NF_BASE_ADDR + 0x0000)
  45. #define MX3_NF_MAIN_BUFFER1 (MX3_NF_BASE_ADDR + 0x0200)
  46. #define MX3_NF_MAIN_BUFFER2 (MX3_NF_BASE_ADDR + 0x0400)
  47. #define MX3_NF_MAIN_BUFFER3 (MX3_NF_BASE_ADDR + 0x0600)
  48. #define MX3_NF_SPARE_BUFFER0 (MX3_NF_BASE_ADDR + 0x0800)
  49. #define MX3_NF_SPARE_BUFFER1 (MX3_NF_BASE_ADDR + 0x0810)
  50. #define MX3_NF_SPARE_BUFFER2 (MX3_NF_BASE_ADDR + 0x0820)
  51. #define MX3_NF_SPARE_BUFFER3 (MX3_NF_BASE_ADDR + 0x0830)
  52. #define MX3_NF_MAIN_BUFFER_LEN 512
  53. #define MX3_NF_SPARE_BUFFER_LEN 16
  54. #define MX3_NF_LAST_BUFFER_ADDR ((MX3_NF_SPARE_BUFFER3) + MX3_NF_SPARE_BUFFER_LEN - 2)
  55. /* bits in MX3_NF_CFG1 register */
  56. #define MX3_NF_BIT_SPARE_ONLY_EN (1<<2)
  57. #define MX3_NF_BIT_ECC_EN (1<<3)
  58. #define MX3_NF_BIT_INT_DIS (1<<4)
  59. #define MX3_NF_BIT_BE_EN (1<<5)
  60. #define MX3_NF_BIT_RESET_EN (1<<6)
  61. #define MX3_NF_BIT_FORCE_CE (1<<7)
  62. /* bits in MX3_NF_CFG2 register */
  63. /*Flash Command Input*/
  64. #define MX3_NF_BIT_OP_FCI (1<<0)
  65. /*
  66. * Flash Address Input
  67. */
  68. #define MX3_NF_BIT_OP_FAI (1<<1)
  69. /*
  70. * Flash Data Input
  71. */
  72. #define MX3_NF_BIT_OP_FDI (1<<2)
  73. /* see "enum mx_dataout_type" below */
  74. #define MX3_NF_BIT_DATAOUT_TYPE(x) ((x)<<3)
  75. #define MX3_NF_BIT_OP_DONE (1<<15)
  76. #define MX3_CCM_CGR2 0x53f80028
  77. #define MX3_GPR 0x43fac008
  78. #define MX3_PCSR 0x53f8000c
  79. enum mx_dataout_type {
  80. MX3_NF_DATAOUT_PAGE = 1,
  81. MX3_NF_DATAOUT_NANDID = 2,
  82. MX3_NF_DATAOUT_NANDSTATUS = 4,
  83. };
  84. enum mx_nf_finalize_action {
  85. MX3_NF_FIN_NONE,
  86. MX3_NF_FIN_DATAOUT,
  87. };
  88. struct mx3_nf_flags {
  89. unsigned host_little_endian:1;
  90. unsigned target_little_endian:1;
  91. unsigned nand_readonly:1;
  92. unsigned one_kb_sram:1;
  93. unsigned hw_ecc_enabled:1;
  94. };
  95. struct mx3_nf_controller {
  96. enum mx_dataout_type optype;
  97. enum mx_nf_finalize_action fin;
  98. struct mx3_nf_flags flags;
  99. };