gpmc.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. /* ECC commands */
  38. #define GPMC_ECC_READ 0 /* Reset Hardware ECC for read */
  39. #define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */
  40. #define GPMC_ECC_READSYN 2 /* Reset before syndrom is read back */
  41. #define GPMC_CONFIG1_WRAPBURST_SUPP (1 << 31)
  42. #define GPMC_CONFIG1_READMULTIPLE_SUPP (1 << 30)
  43. #define GPMC_CONFIG1_READTYPE_ASYNC (0 << 29)
  44. #define GPMC_CONFIG1_READTYPE_SYNC (1 << 29)
  45. #define GPMC_CONFIG1_WRITEMULTIPLE_SUPP (1 << 28)
  46. #define GPMC_CONFIG1_WRITETYPE_ASYNC (0 << 27)
  47. #define GPMC_CONFIG1_WRITETYPE_SYNC (1 << 27)
  48. #define GPMC_CONFIG1_CLKACTIVATIONTIME(val) ((val & 3) << 25)
  49. #define GPMC_CONFIG1_PAGE_LEN(val) ((val & 3) << 23)
  50. #define GPMC_CONFIG1_WAIT_READ_MON (1 << 22)
  51. #define GPMC_CONFIG1_WAIT_WRITE_MON (1 << 21)
  52. #define GPMC_CONFIG1_WAIT_MON_IIME(val) ((val & 3) << 18)
  53. #define GPMC_CONFIG1_WAIT_PIN_SEL(val) ((val & 3) << 16)
  54. #define GPMC_CONFIG1_DEVICESIZE(val) ((val & 3) << 12)
  55. #define GPMC_CONFIG1_DEVICESIZE_16 GPMC_CONFIG1_DEVICESIZE(1)
  56. #define GPMC_CONFIG1_DEVICETYPE(val) ((val & 3) << 10)
  57. #define GPMC_CONFIG1_DEVICETYPE_NOR GPMC_CONFIG1_DEVICETYPE(0)
  58. #define GPMC_CONFIG1_MUXADDDATA (1 << 9)
  59. #define GPMC_CONFIG1_TIME_PARA_GRAN (1 << 4)
  60. #define GPMC_CONFIG1_FCLK_DIV(val) (val & 3)
  61. #define GPMC_CONFIG1_FCLK_DIV2 (GPMC_CONFIG1_FCLK_DIV(1))
  62. #define GPMC_CONFIG1_FCLK_DIV3 (GPMC_CONFIG1_FCLK_DIV(2))
  63. #define GPMC_CONFIG1_FCLK_DIV4 (GPMC_CONFIG1_FCLK_DIV(3))
  64. #define GPMC_CONFIG7_CSVALID (1 << 6)
  65. #define GPMC_DEVICETYPE_NOR 0
  66. #define GPMC_DEVICETYPE_NAND 2
  67. #define GPMC_CONFIG_WRITEPROTECT 0x00000010
  68. #define GPMC_STATUS_BUFF_EMPTY 0x00000001
  69. #define WR_RD_PIN_MONITORING 0x00600000
  70. #define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F)
  71. #define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
  72. /*
  73. * Note that all values in this struct are in nanoseconds, while
  74. * the register values are in gpmc_fck cycles.
  75. */
  76. struct gpmc_timings {
  77. /* Minimum clock period for synchronous mode */
  78. u16 sync_clk;
  79. /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
  80. u16 cs_on; /* Assertion time */
  81. u16 cs_rd_off; /* Read deassertion time */
  82. u16 cs_wr_off; /* Write deassertion time */
  83. /* ADV signal timings corresponding to GPMC_CONFIG3 */
  84. u16 adv_on; /* Assertion time */
  85. u16 adv_rd_off; /* Read deassertion time */
  86. u16 adv_wr_off; /* Write deassertion time */
  87. /* WE signals timings corresponding to GPMC_CONFIG4 */
  88. u16 we_on; /* WE assertion time */
  89. u16 we_off; /* WE deassertion time */
  90. /* OE signals timings corresponding to GPMC_CONFIG4 */
  91. u16 oe_on; /* OE assertion time */
  92. u16 oe_off; /* OE deassertion time */
  93. /* Access time and cycle time timings corresponding to GPMC_CONFIG5 */
  94. u16 page_burst_access; /* Multiple access word delay */
  95. u16 access; /* Start-cycle to first data valid delay */
  96. u16 rd_cycle; /* Total read cycle time */
  97. u16 wr_cycle; /* Total write cycle time */
  98. /* The following are only on OMAP3430 */
  99. u16 wr_access; /* WRACCESSTIME */
  100. u16 wr_data_mux_bus; /* WRDATAONADMUXBUS */
  101. };
  102. extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns);
  103. extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
  104. extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns);
  105. extern unsigned long gpmc_get_fclk_period(void);
  106. extern void gpmc_cs_write_reg(int cs, int idx, u32 val);
  107. extern u32 gpmc_cs_read_reg(int cs, int idx);
  108. extern int gpmc_cs_calc_divider(int cs, unsigned int sync_clk);
  109. extern int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t);
  110. extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
  111. extern void gpmc_cs_free(int cs);
  112. extern int gpmc_cs_set_reserved(int cs, int reserved);
  113. extern int gpmc_cs_reserved(int cs);
  114. extern int gpmc_prefetch_enable(int cs, int dma_mode,
  115. unsigned int u32_count, int is_write);
  116. extern int gpmc_prefetch_reset(int cs);
  117. extern void omap3_gpmc_save_context(void);
  118. extern void omap3_gpmc_restore_context(void);
  119. extern void gpmc_init(void);
  120. extern int gpmc_read_status(int cmd);
  121. extern int gpmc_cs_configure(int cs, int cmd, int wval);
  122. extern int gpmc_nand_read(int cs, int cmd);
  123. extern int gpmc_nand_write(int cs, int cmd, int wval);
  124. int gpmc_enable_hwecc(int cs, int mode, int dev_width, int ecc_size);
  125. int gpmc_calculate_ecc(int cs, const u_char *dat, u_char *ecc_code);
  126. #endif