fsl_flexspi_nor_flash.c 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * The Clear BSD License
  3. * Copyright 2017 NXP
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted (subject to the limitations in the disclaimer below) provided
  8. * that the following conditions are met:
  9. *
  10. * o Redistributions of source code must retain the above copyright notice, this list
  11. * of conditions and the following disclaimer.
  12. *
  13. * o Redistributions in binary form must reproduce the above copyright notice, this
  14. * list of conditions and the following disclaimer in the documentation and/or
  15. * other materials provided with the distribution.
  16. *
  17. * o Neither the name of the copyright holder nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  26. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  29. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include "fsl_flexspi_nor_flash.h"
  34. /*******************************************************************************
  35. * Code
  36. ******************************************************************************/
  37. #if defined(__CC_ARM) || defined(__GNUC__)
  38. __attribute__((section(".boot_hdr.conf")))
  39. #elif defined(__ICCARM__)
  40. #pragma location=".boot_hdr.conf"
  41. #endif
  42. const flexspi_nor_config_t hyperflash_config =
  43. {
  44. .memConfig =
  45. {
  46. .tag = FLEXSPI_CFG_BLK_TAG,
  47. .version = FLEXSPI_CFG_BLK_VERSION,
  48. .readSampleClkSrc = kFlexSPIReadSampleClk_ExternalInputFromDqsPad,
  49. .csHoldTime = 3u,
  50. .csSetupTime = 3u,
  51. .columnAddressWidth = 3u,
  52. // Enable DDR mode, Wordaddassable, Safe configuration, Differential clock
  53. .controllerMiscOption = (1u << kFlexSpiMiscOffset_DdrModeEnable) |
  54. (1u << kFlexSpiMiscOffset_WordAddressableEnable) |
  55. (1u << kFlexSpiMiscOffset_SafeConfigFreqEnable) |
  56. (1u << kFlexSpiMiscOffset_DiffClkEnable),
  57. .sflashPadType = kSerialFlash_8Pads,
  58. .serialClkFreq = kFlexSpiSerialClk_133MHz,
  59. .sflashA1Size = 64u * 1024u * 1024u,
  60. .dataValidTime = {16u, 16u},
  61. .lookupTable =
  62. {
  63. // Read LUTs
  64. FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0xA0, RADDR_DDR, FLEXSPI_8PAD, 0x18),
  65. FLEXSPI_LUT_SEQ(CADDR_DDR, FLEXSPI_8PAD, 0x10, DUMMY_DDR, FLEXSPI_8PAD, 0x06),
  66. FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP, FLEXSPI_1PAD, 0x0),
  67. },
  68. },
  69. .pageSize = 512u,
  70. .sectorSize = 256u * 1024u,
  71. .blockSize = 256u * 1024u,
  72. .isUniformBlockSize = true,
  73. };