omap-gpmc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #include <linux/platform_data/gpmc-omap.h>
  10. #define GPMC_CONFIG_WP 0x00000005
  11. /* IRQ numbers in GPMC IRQ domain for legacy boot use */
  12. #define GPMC_IRQ_FIFOEVENTENABLE 0
  13. #define GPMC_IRQ_COUNT_EVENT 1
  14. /**
  15. * gpmc_nand_ops - Interface between NAND and GPMC
  16. * @nand_write_buffer_empty: get the NAND write buffer empty status.
  17. */
  18. struct gpmc_nand_ops {
  19. bool (*nand_writebuffer_empty)(void);
  20. };
  21. struct gpmc_nand_regs;
  22. struct gpmc_onenand_info {
  23. bool sync_read;
  24. bool sync_write;
  25. int burst_len;
  26. };
  27. #if IS_ENABLED(CONFIG_OMAP_GPMC)
  28. struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
  29. int cs);
  30. /**
  31. * gpmc_omap_onenand_set_timings - set optimized sync timings.
  32. * @cs: Chip Select Region
  33. * @freq: Chip frequency
  34. * @latency: Burst latency cycle count
  35. * @info: Structure describing parameters used
  36. *
  37. * Sets optimized timings for the @cs region based on @freq and @latency.
  38. * Updates the @info structure based on the GPMC settings.
  39. */
  40. int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq,
  41. int latency,
  42. struct gpmc_onenand_info *info);
  43. #else
  44. static inline struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
  45. int cs)
  46. {
  47. return NULL;
  48. }
  49. static inline
  50. int gpmc_omap_onenand_set_timings(struct device *dev, int cs, int freq,
  51. int latency,
  52. struct gpmc_onenand_info *info)
  53. {
  54. return -EINVAL;
  55. }
  56. #endif /* CONFIG_OMAP_GPMC */
  57. extern int gpmc_calc_timings(struct gpmc_timings *gpmc_t,
  58. struct gpmc_settings *gpmc_s,
  59. struct gpmc_device_timings *dev_t);
  60. struct device_node;
  61. extern int gpmc_get_client_irq(unsigned irq_config);
  62. extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
  63. extern void gpmc_cs_write_reg(int cs, int idx, u32 val);
  64. extern int gpmc_calc_divider(unsigned int sync_clk);
  65. extern int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t,
  66. const struct gpmc_settings *s);
  67. extern int gpmc_cs_program_settings(int cs, struct gpmc_settings *p);
  68. extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
  69. extern void gpmc_cs_free(int cs);
  70. extern int gpmc_configure(int cmd, int wval);
  71. extern void gpmc_read_settings_dt(struct device_node *np,
  72. struct gpmc_settings *p);
  73. extern void omap3_gpmc_save_context(void);
  74. extern void omap3_gpmc_restore_context(void);
  75. struct gpmc_timings;
  76. struct omap_nand_platform_data;
  77. struct omap_onenand_platform_data;
  78. #if IS_ENABLED(CONFIG_MTD_ONENAND_OMAP2)
  79. extern int gpmc_onenand_init(struct omap_onenand_platform_data *d);
  80. #else
  81. #define board_onenand_data NULL
  82. static inline int gpmc_onenand_init(struct omap_onenand_platform_data *d)
  83. {
  84. return 0;
  85. }
  86. #endif