omap-gpmc.h 2.7 KB

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