omap-gpmc.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * OMAP GPMC (General Purpose Memory Controller) defines
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. */
  9. /* Maximum Number of Chip Selects */
  10. #define GPMC_CS_NUM 8
  11. #define GPMC_CONFIG_WP 0x00000005
  12. #define GPMC_IRQ_FIFOEVENTENABLE 0x01
  13. #define GPMC_IRQ_COUNT_EVENT 0x02
  14. #define GPMC_BURST_4 4 /* 4 word burst */
  15. #define GPMC_BURST_8 8 /* 8 word burst */
  16. #define GPMC_BURST_16 16 /* 16 word burst */
  17. #define GPMC_DEVWIDTH_8BIT 1 /* 8-bit device width */
  18. #define GPMC_DEVWIDTH_16BIT 2 /* 16-bit device width */
  19. #define GPMC_MUX_AAD 1 /* Addr-Addr-Data multiplex */
  20. #define GPMC_MUX_AD 2 /* Addr-Data multiplex */
  21. /* bool type time settings */
  22. struct gpmc_bool_timings {
  23. bool cycle2cyclediffcsen;
  24. bool cycle2cyclesamecsen;
  25. bool we_extra_delay;
  26. bool oe_extra_delay;
  27. bool adv_extra_delay;
  28. bool cs_extra_delay;
  29. bool time_para_granularity;
  30. };
  31. /*
  32. * Note that all values in this struct are in nanoseconds except sync_clk
  33. * (which is in picoseconds), while the register values are in gpmc_fck cycles.
  34. */
  35. struct gpmc_timings {
  36. /* Minimum clock period for synchronous mode (in picoseconds) */
  37. u32 sync_clk;
  38. /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
  39. u32 cs_on; /* Assertion time */
  40. u32 cs_rd_off; /* Read deassertion time */
  41. u32 cs_wr_off; /* Write deassertion time */
  42. /* ADV signal timings corresponding to GPMC_CONFIG3 */
  43. u32 adv_on; /* Assertion time */
  44. u32 adv_rd_off; /* Read deassertion time */
  45. u32 adv_wr_off; /* Write deassertion time */
  46. /* WE signals timings corresponding to GPMC_CONFIG4 */
  47. u32 we_on; /* WE assertion time */
  48. u32 we_off; /* WE deassertion time */
  49. /* OE signals timings corresponding to GPMC_CONFIG4 */
  50. u32 oe_on; /* OE assertion time */
  51. u32 oe_off; /* OE deassertion time */
  52. /* Access time and cycle time timings corresponding to GPMC_CONFIG5 */
  53. u32 page_burst_access; /* Multiple access word delay */
  54. u32 access; /* Start-cycle to first data valid delay */
  55. u32 rd_cycle; /* Total read cycle time */
  56. u32 wr_cycle; /* Total write cycle time */
  57. u32 bus_turnaround;
  58. u32 cycle2cycle_delay;
  59. u32 wait_monitoring;
  60. u32 clk_activation;
  61. /* The following are only on OMAP3430 */
  62. u32 wr_access; /* WRACCESSTIME */
  63. u32 wr_data_mux_bus; /* WRDATAONADMUXBUS */
  64. struct gpmc_bool_timings bool_timings;
  65. };
  66. /* Device timings in picoseconds */
  67. struct gpmc_device_timings {
  68. u32 t_ceasu; /* address setup to CS valid */
  69. u32 t_avdasu; /* address setup to ADV valid */
  70. /* XXX: try to combine t_avdp_r & t_avdp_w. Issue is
  71. * of tusb using these timings even for sync whilst
  72. * ideally for adv_rd/(wr)_off it should have considered
  73. * t_avdh instead. This indirectly necessitates r/w
  74. * variations of t_avdp as it is possible to have one
  75. * sync & other async
  76. */
  77. u32 t_avdp_r; /* ADV low time (what about t_cer ?) */
  78. u32 t_avdp_w;
  79. u32 t_aavdh; /* address hold time */
  80. u32 t_oeasu; /* address setup to OE valid */
  81. u32 t_aa; /* access time from ADV assertion */
  82. u32 t_iaa; /* initial access time */
  83. u32 t_oe; /* access time from OE assertion */
  84. u32 t_ce; /* access time from CS asertion */
  85. u32 t_rd_cycle; /* read cycle time */
  86. u32 t_cez_r; /* read CS deassertion to high Z */
  87. u32 t_cez_w; /* write CS deassertion to high Z */
  88. u32 t_oez; /* OE deassertion to high Z */
  89. u32 t_weasu; /* address setup to WE valid */
  90. u32 t_wpl; /* write assertion time */
  91. u32 t_wph; /* write deassertion time */
  92. u32 t_wr_cycle; /* write cycle time */
  93. u32 clk;
  94. u32 t_bacc; /* burst access valid clock to output delay */
  95. u32 t_ces; /* CS setup time to clk */
  96. u32 t_avds; /* ADV setup time to clk */
  97. u32 t_avdh; /* ADV hold time from clk */
  98. u32 t_ach; /* address hold time from clk */
  99. u32 t_rdyo; /* clk to ready valid */
  100. u32 t_ce_rdyz; /* XXX: description ?, or use t_cez instead */
  101. u32 t_ce_avd; /* CS on to ADV on delay */
  102. /* XXX: check the possibility of combining
  103. * cyc_aavhd_oe & cyc_aavdh_we
  104. */
  105. u8 cyc_aavdh_oe;/* read address hold time in cycles */
  106. u8 cyc_aavdh_we;/* write address hold time in cycles */
  107. u8 cyc_oe; /* access time from OE assertion in cycles */
  108. u8 cyc_wpl; /* write deassertion time in cycles */
  109. u32 cyc_iaa; /* initial access time in cycles */
  110. /* extra delays */
  111. bool ce_xdelay;
  112. bool avd_xdelay;
  113. bool oe_xdelay;
  114. bool we_xdelay;
  115. };
  116. struct gpmc_settings {
  117. bool burst_wrap; /* enables wrap bursting */
  118. bool burst_read; /* enables read page/burst mode */
  119. bool burst_write; /* enables write page/burst mode */
  120. bool device_nand; /* device is NAND */
  121. bool sync_read; /* enables synchronous reads */
  122. bool sync_write; /* enables synchronous writes */
  123. bool wait_on_read; /* monitor wait on reads */
  124. bool wait_on_write; /* monitor wait on writes */
  125. u32 burst_len; /* page/burst length */
  126. u32 device_width; /* device bus width (8 or 16 bit) */
  127. u32 mux_add_data; /* multiplex address & data */
  128. u32 wait_pin; /* wait-pin to be used */
  129. };
  130. extern int gpmc_calc_timings(struct gpmc_timings *gpmc_t,
  131. struct gpmc_settings *gpmc_s,
  132. struct gpmc_device_timings *dev_t);
  133. struct gpmc_nand_regs;
  134. struct device_node;
  135. extern void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs);
  136. extern int gpmc_get_client_irq(unsigned irq_config);
  137. extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
  138. extern void gpmc_cs_write_reg(int cs, int idx, u32 val);
  139. extern int gpmc_calc_divider(unsigned int sync_clk);
  140. extern int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t,
  141. const struct gpmc_settings *s);
  142. extern int gpmc_cs_program_settings(int cs, struct gpmc_settings *p);
  143. extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
  144. extern void gpmc_cs_free(int cs);
  145. extern int gpmc_configure(int cmd, int wval);
  146. extern void gpmc_read_settings_dt(struct device_node *np,
  147. struct gpmc_settings *p);
  148. extern void omap3_gpmc_save_context(void);
  149. extern void omap3_gpmc_restore_context(void);
  150. struct gpmc_timings;
  151. struct omap_nand_platform_data;
  152. struct omap_onenand_platform_data;
  153. #if IS_ENABLED(CONFIG_MTD_NAND_OMAP2)
  154. extern int gpmc_nand_init(struct omap_nand_platform_data *d,
  155. struct gpmc_timings *gpmc_t);
  156. #else
  157. static inline int gpmc_nand_init(struct omap_nand_platform_data *d,
  158. struct gpmc_timings *gpmc_t)
  159. {
  160. return 0;
  161. }
  162. #endif
  163. #if IS_ENABLED(CONFIG_MTD_ONENAND_OMAP2)
  164. extern int gpmc_onenand_init(struct omap_onenand_platform_data *d);
  165. #else
  166. #define board_onenand_data NULL
  167. static inline int gpmc_onenand_init(struct omap_onenand_platform_data *d)
  168. {
  169. return 0;
  170. }
  171. #endif