atmel_nand_nfc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Atmel Nand Flash Controller (NFC) - System peripherals regsters.
  3. * Based on SAMA5D3 datasheet.
  4. *
  5. * © Copyright 2013 Atmel Corporation.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #ifndef ATMEL_NAND_NFC_H
  13. #define ATMEL_NAND_NFC_H
  14. /*
  15. * HSMC NFC registers
  16. */
  17. #define ATMEL_HSMC_NFC_CFG 0x00 /* NFC Configuration Register */
  18. #define NFC_CFG_PAGESIZE (7 << 0)
  19. #define NFC_CFG_PAGESIZE_512 (0 << 0)
  20. #define NFC_CFG_PAGESIZE_1024 (1 << 0)
  21. #define NFC_CFG_PAGESIZE_2048 (2 << 0)
  22. #define NFC_CFG_PAGESIZE_4096 (3 << 0)
  23. #define NFC_CFG_PAGESIZE_8192 (4 << 0)
  24. #define NFC_CFG_WSPARE (1 << 8)
  25. #define NFC_CFG_RSPARE (1 << 9)
  26. #define NFC_CFG_NFC_DTOCYC (0xf << 16)
  27. #define NFC_CFG_NFC_DTOMUL (0x7 << 20)
  28. #define NFC_CFG_NFC_SPARESIZE (0x7f << 24)
  29. #define NFC_CFG_NFC_SPARESIZE_BIT_POS 24
  30. #define ATMEL_HSMC_NFC_CTRL 0x04 /* NFC Control Register */
  31. #define NFC_CTRL_ENABLE (1 << 0)
  32. #define NFC_CTRL_DISABLE (1 << 1)
  33. #define ATMEL_HSMC_NFC_SR 0x08 /* NFC Status Register */
  34. #define NFC_SR_BUSY (1 << 8)
  35. #define NFC_SR_XFR_DONE (1 << 16)
  36. #define NFC_SR_CMD_DONE (1 << 17)
  37. #define NFC_SR_DTOE (1 << 20)
  38. #define NFC_SR_UNDEF (1 << 21)
  39. #define NFC_SR_AWB (1 << 22)
  40. #define NFC_SR_ASE (1 << 23)
  41. #define NFC_SR_RB_EDGE (1 << 24)
  42. #define ATMEL_HSMC_NFC_IER 0x0c
  43. #define ATMEL_HSMC_NFC_IDR 0x10
  44. #define ATMEL_HSMC_NFC_IMR 0x14
  45. #define ATMEL_HSMC_NFC_CYCLE0 0x18 /* NFC Address Cycle Zero */
  46. #define ATMEL_HSMC_NFC_ADDR_CYCLE0 (0xff)
  47. #define ATMEL_HSMC_NFC_BANK 0x1c /* NFC Bank Register */
  48. #define ATMEL_HSMC_NFC_BANK0 (0 << 0)
  49. #define ATMEL_HSMC_NFC_BANK1 (1 << 0)
  50. #define nfc_writel(addr, reg, value) \
  51. writel((value), (addr) + ATMEL_HSMC_NFC_##reg)
  52. #define nfc_readl(addr, reg) \
  53. readl_relaxed((addr) + ATMEL_HSMC_NFC_##reg)
  54. /*
  55. * NFC Address Command definitions
  56. */
  57. #define NFCADDR_CMD_CMD1 (0xff << 2) /* Command for Cycle 1 */
  58. #define NFCADDR_CMD_CMD1_BIT_POS 2
  59. #define NFCADDR_CMD_CMD2 (0xff << 10) /* Command for Cycle 2 */
  60. #define NFCADDR_CMD_CMD2_BIT_POS 10
  61. #define NFCADDR_CMD_VCMD2 (0x1 << 18) /* Valid Cycle 2 Command */
  62. #define NFCADDR_CMD_ACYCLE (0x7 << 19) /* Number of Address required */
  63. #define NFCADDR_CMD_ACYCLE_NONE (0x0 << 19)
  64. #define NFCADDR_CMD_ACYCLE_1 (0x1 << 19)
  65. #define NFCADDR_CMD_ACYCLE_2 (0x2 << 19)
  66. #define NFCADDR_CMD_ACYCLE_3 (0x3 << 19)
  67. #define NFCADDR_CMD_ACYCLE_4 (0x4 << 19)
  68. #define NFCADDR_CMD_ACYCLE_5 (0x5 << 19)
  69. #define NFCADDR_CMD_ACYCLE_BIT_POS 19
  70. #define NFCADDR_CMD_CSID (0x7 << 22) /* Chip Select Identifier */
  71. #define NFCADDR_CMD_CSID_0 (0x0 << 22)
  72. #define NFCADDR_CMD_CSID_1 (0x1 << 22)
  73. #define NFCADDR_CMD_CSID_2 (0x2 << 22)
  74. #define NFCADDR_CMD_CSID_3 (0x3 << 22)
  75. #define NFCADDR_CMD_CSID_4 (0x4 << 22)
  76. #define NFCADDR_CMD_CSID_5 (0x5 << 22)
  77. #define NFCADDR_CMD_CSID_6 (0x6 << 22)
  78. #define NFCADDR_CMD_CSID_7 (0x7 << 22)
  79. #define NFCADDR_CMD_DATAEN (0x1 << 25) /* Data Transfer Enable */
  80. #define NFCADDR_CMD_DATADIS (0x0 << 25) /* Data Transfer Disable */
  81. #define NFCADDR_CMD_NFCRD (0x0 << 26) /* NFC Read Enable */
  82. #define NFCADDR_CMD_NFCWR (0x1 << 26) /* NFC Write Enable */
  83. #define NFCADDR_CMD_NFCBUSY (0x1 << 27) /* NFC Busy */
  84. #define nfc_cmd_addr1234_writel(cmd, addr1234, nfc_base) \
  85. writel((addr1234), (cmd) + nfc_base)
  86. #define nfc_cmd_readl(bitstatus, nfc_base) \
  87. readl_relaxed((bitstatus) + nfc_base)
  88. #define NFC_TIME_OUT_MS 100
  89. #define NFC_SRAM_BANK1_OFFSET 0x1200
  90. #endif