gpmc.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * General-Purpose Memory Controller for OMAP2
  3. *
  4. * Copyright (C) 2005-2006 Nokia Corporation
  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 version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __OMAP2_GPMC_H
  11. #define __OMAP2_GPMC_H
  12. /* Maximum Number of Chip Selects */
  13. #define GPMC_CS_NUM 8
  14. #define GPMC_CS_CONFIG1 0x00
  15. #define GPMC_CS_CONFIG2 0x04
  16. #define GPMC_CS_CONFIG3 0x08
  17. #define GPMC_CS_CONFIG4 0x0c
  18. #define GPMC_CS_CONFIG5 0x10
  19. #define GPMC_CS_CONFIG6 0x14
  20. #define GPMC_CS_CONFIG7 0x18
  21. #define GPMC_CS_NAND_COMMAND 0x1c
  22. #define GPMC_CS_NAND_ADDRESS 0x20
  23. #define GPMC_CS_NAND_DATA 0x24
  24. /* Control Commands */
  25. #define GPMC_CONFIG_RDY_BSY 0x00000001
  26. #define GPMC_CONFIG_DEV_SIZE 0x00000002
  27. #define GPMC_CONFIG_DEV_TYPE 0x00000003
  28. #define GPMC_SET_IRQ_STATUS 0x00000004
  29. #define GPMC_CONFIG_WP 0x00000005
  30. #define GPMC_GET_IRQ_STATUS 0x00000006
  31. #define GPMC_PREFETCH_FIFO_CNT 0x00000007 /* bytes available in FIFO for r/w */
  32. #define GPMC_PREFETCH_COUNT 0x00000008 /* remaining bytes to be read/write*/
  33. #define GPMC_STATUS_BUFFER 0x00000009 /* 1: buffer is available to write */
  34. #define GPMC_NAND_COMMAND 0x0000000a
  35. #define GPMC_NAND_ADDRESS 0x0000000b
  36. #define GPMC_NAND_DATA 0x0000000c
  37. #define GPMC_ENABLE_IRQ 0x0000000d
  38. /* ECC commands */
  39. #define GPMC_ECC_READ 0 /* Reset Hardware ECC for read */
  40. #define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */
  41. #define GPMC_ECC_READSYN 2 /* Reset before syndrom is read back */
  42. #define GPMC_CONFIG1_WRAPBURST_SUPP (1 << 31)
  43. #define GPMC_CONFIG1_READMULTIPLE_SUPP (1 << 30)
  44. #define GPMC_CONFIG1_READTYPE_ASYNC (0 << 29)
  45. #define GPMC_CONFIG1_READTYPE_SYNC (1 << 29)
  46. #define GPMC_CONFIG1_WRITEMULTIPLE_SUPP (1 << 28)
  47. #define GPMC_CONFIG1_WRITETYPE_ASYNC (0 << 27)
  48. #define GPMC_CONFIG1_WRITETYPE_SYNC (1 << 27)
  49. #define GPMC_CONFIG1_CLKACTIVATIONTIME(val) ((val & 3) << 25)
  50. #define GPMC_CONFIG1_PAGE_LEN(val) ((val & 3) << 23)
  51. #define GPMC_CONFIG1_WAIT_READ_MON (1 << 22)
  52. #define GPMC_CONFIG1_WAIT_WRITE_MON (1 << 21)
  53. #define GPMC_CONFIG1_WAIT_MON_IIME(val) ((val & 3) << 18)
  54. #define GPMC_CONFIG1_WAIT_PIN_SEL(val) ((val & 3) << 16)
  55. #define GPMC_CONFIG1_DEVICESIZE(val) ((val & 3) << 12)
  56. #define GPMC_CONFIG1_DEVICESIZE_16 GPMC_CONFIG1_DEVICESIZE(1)
  57. #define GPMC_CONFIG1_DEVICETYPE(val) ((val & 3) << 10)
  58. #define GPMC_CONFIG1_DEVICETYPE_NOR GPMC_CONFIG1_DEVICETYPE(0)
  59. #define GPMC_CONFIG1_MUXADDDATA (1 << 9)
  60. #define GPMC_CONFIG1_TIME_PARA_GRAN (1 << 4)
  61. #define GPMC_CONFIG1_FCLK_DIV(val) (val & 3)
  62. #define GPMC_CONFIG1_FCLK_DIV2 (GPMC_CONFIG1_FCLK_DIV(1))
  63. #define GPMC_CONFIG1_FCLK_DIV3 (GPMC_CONFIG1_FCLK_DIV(2))
  64. #define GPMC_CONFIG1_FCLK_DIV4 (GPMC_CONFIG1_FCLK_DIV(3))
  65. #define GPMC_CONFIG7_CSVALID (1 << 6)
  66. #define GPMC_DEVICETYPE_NOR 0
  67. #define GPMC_DEVICETYPE_NAND 2
  68. #define GPMC_CONFIG_WRITEPROTECT 0x00000010
  69. #define GPMC_STATUS_BUFF_EMPTY 0x00000001
  70. #define WR_RD_PIN_MONITORING 0x00600000
  71. #define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F)
  72. #define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
  73. #define GPMC_IRQ_FIFOEVENTENABLE 0x01
  74. #define GPMC_IRQ_COUNT_EVENT 0x02
  75. #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
  76. #define PREFETCH_FIFOTHRESHOLD(val) ((val) << 8)
  77. enum omap_ecc {
  78. /* 1-bit ecc: stored at end of spare area */
  79. OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
  80. OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
  81. /* 1-bit ecc: stored at beginning of spare area as romcode */
  82. OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method & romcode layout */
  83. };
  84. /*
  85. * Note that all values in this struct are in nanoseconds except sync_clk
  86. * (which is in picoseconds), while the register values are in gpmc_fck cycles.
  87. */
  88. struct gpmc_timings {
  89. /* Minimum clock period for synchronous mode (in picoseconds) */
  90. u32 sync_clk;
  91. /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
  92. u16 cs_on; /* Assertion time */
  93. u16 cs_rd_off; /* Read deassertion time */
  94. u16 cs_wr_off; /* Write deassertion time */
  95. /* ADV signal timings corresponding to GPMC_CONFIG3 */
  96. u16 adv_on; /* Assertion time */
  97. u16 adv_rd_off; /* Read deassertion time */
  98. u16 adv_wr_off; /* Write deassertion time */
  99. /* WE signals timings corresponding to GPMC_CONFIG4 */
  100. u16 we_on; /* WE assertion time */
  101. u16 we_off; /* WE deassertion time */
  102. /* OE signals timings corresponding to GPMC_CONFIG4 */
  103. u16 oe_on; /* OE assertion time */
  104. u16 oe_off; /* OE deassertion time */
  105. /* Access time and cycle time timings corresponding to GPMC_CONFIG5 */
  106. u16 page_burst_access; /* Multiple access word delay */
  107. u16 access; /* Start-cycle to first data valid delay */
  108. u16 rd_cycle; /* Total read cycle time */
  109. u16 wr_cycle; /* Total write cycle time */
  110. /* The following are only on OMAP3430 */
  111. u16 wr_access; /* WRACCESSTIME */
  112. u16 wr_data_mux_bus; /* WRDATAONADMUXBUS */
  113. };
  114. extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns);
  115. extern unsigned int gpmc_ps_to_ticks(unsigned int time_ps);
  116. extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
  117. extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns);
  118. extern unsigned long gpmc_get_fclk_period(void);
  119. extern void gpmc_cs_write_reg(int cs, int idx, u32 val);
  120. extern u32 gpmc_cs_read_reg(int cs, int idx);
  121. extern int gpmc_cs_calc_divider(int cs, unsigned int sync_clk);
  122. extern int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t);
  123. extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
  124. extern void gpmc_cs_free(int cs);
  125. extern int gpmc_cs_set_reserved(int cs, int reserved);
  126. extern int gpmc_cs_reserved(int cs);
  127. extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
  128. unsigned int u32_count, int is_write);
  129. extern int gpmc_prefetch_reset(int cs);
  130. extern void omap3_gpmc_save_context(void);
  131. extern void omap3_gpmc_restore_context(void);
  132. extern int gpmc_read_status(int cmd);
  133. extern int gpmc_cs_configure(int cs, int cmd, int wval);
  134. extern int gpmc_nand_read(int cs, int cmd);
  135. extern int gpmc_nand_write(int cs, int cmd, int wval);
  136. int gpmc_enable_hwecc(int cs, int mode, int dev_width, int ecc_size);
  137. int gpmc_calculate_ecc(int cs, const u_char *dat, u_char *ecc_code);
  138. #endif