tmio.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef MFD_TMIO_H
  3. #define MFD_TMIO_H
  4. #include <linux/device.h>
  5. #include <linux/fb.h>
  6. #include <linux/io.h>
  7. #include <linux/jiffies.h>
  8. #include <linux/mmc/card.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/pm_runtime.h>
  11. #define tmio_ioread8(addr) readb(addr)
  12. #define tmio_ioread16(addr) readw(addr)
  13. #define tmio_ioread16_rep(r, b, l) readsw(r, b, l)
  14. #define tmio_ioread32(addr) \
  15. (((u32)readw((addr))) | (((u32)readw((addr) + 2)) << 16))
  16. #define tmio_iowrite8(val, addr) writeb((val), (addr))
  17. #define tmio_iowrite16(val, addr) writew((val), (addr))
  18. #define tmio_iowrite16_rep(r, b, l) writesw(r, b, l)
  19. #define tmio_iowrite32(val, addr) \
  20. do { \
  21. writew((val), (addr)); \
  22. writew((val) >> 16, (addr) + 2); \
  23. } while (0)
  24. #define sd_config_write8(base, shift, reg, val) \
  25. tmio_iowrite8((val), (base) + ((reg) << (shift)))
  26. #define sd_config_write16(base, shift, reg, val) \
  27. tmio_iowrite16((val), (base) + ((reg) << (shift)))
  28. #define sd_config_write32(base, shift, reg, val) \
  29. do { \
  30. tmio_iowrite16((val), (base) + ((reg) << (shift))); \
  31. tmio_iowrite16((val) >> 16, (base) + ((reg + 2) << (shift))); \
  32. } while (0)
  33. /* tmio MMC platform flags */
  34. /*
  35. * Some controllers can support a 2-byte block size when the bus width
  36. * is configured in 4-bit mode.
  37. */
  38. #define TMIO_MMC_BLKSZ_2BYTES BIT(1)
  39. /*
  40. * Some controllers can support SDIO IRQ signalling.
  41. */
  42. #define TMIO_MMC_SDIO_IRQ BIT(2)
  43. /* Some features are only available or tested on R-Car Gen2 or later */
  44. #define TMIO_MMC_MIN_RCAR2 BIT(3)
  45. /*
  46. * Some controllers require waiting for the SD bus to become
  47. * idle before writing to some registers.
  48. */
  49. #define TMIO_MMC_HAS_IDLE_WAIT BIT(4)
  50. /*
  51. * Use the busy timeout feature. Probably all TMIO versions support it. Yet,
  52. * we don't have documentation for old variants, so we enable only known good
  53. * variants with this flag. Can be removed once all variants are known good.
  54. */
  55. #define TMIO_MMC_USE_BUSY_TIMEOUT BIT(5)
  56. /*
  57. * Some controllers have CMD12 automatically
  58. * issue/non-issue register
  59. */
  60. #define TMIO_MMC_HAVE_CMD12_CTRL BIT(7)
  61. /* Controller has some SDIO status bits which must be 1 */
  62. #define TMIO_MMC_SDIO_STATUS_SETBITS BIT(8)
  63. /*
  64. * Some controllers have a 32-bit wide data port register
  65. */
  66. #define TMIO_MMC_32BIT_DATA_PORT BIT(9)
  67. /*
  68. * Some controllers allows to set SDx actual clock
  69. */
  70. #define TMIO_MMC_CLK_ACTUAL BIT(10)
  71. /* Some controllers have a CBSY bit */
  72. #define TMIO_MMC_HAVE_CBSY BIT(11)
  73. int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base);
  74. int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base);
  75. void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state);
  76. void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state);
  77. struct dma_chan;
  78. /*
  79. * data for the MMC controller
  80. */
  81. struct tmio_mmc_data {
  82. void *chan_priv_tx;
  83. void *chan_priv_rx;
  84. unsigned int hclk;
  85. unsigned long capabilities;
  86. unsigned long capabilities2;
  87. unsigned long flags;
  88. u32 ocr_mask; /* available voltages */
  89. int alignment_shift;
  90. dma_addr_t dma_rx_offset;
  91. unsigned int max_blk_count;
  92. unsigned short max_segs;
  93. void (*set_pwr)(struct platform_device *host, int state);
  94. void (*set_clk_div)(struct platform_device *host, int state);
  95. };
  96. /*
  97. * data for the NAND controller
  98. */
  99. struct tmio_nand_data {
  100. struct nand_bbt_descr *badblock_pattern;
  101. struct mtd_partition *partition;
  102. unsigned int num_partitions;
  103. const char *const *part_parsers;
  104. };
  105. #define FBIO_TMIO_ACC_WRITE 0x7C639300
  106. #define FBIO_TMIO_ACC_SYNC 0x7C639301
  107. struct tmio_fb_data {
  108. int (*lcd_set_power)(struct platform_device *fb_dev,
  109. bool on);
  110. int (*lcd_mode)(struct platform_device *fb_dev,
  111. const struct fb_videomode *mode);
  112. int num_modes;
  113. struct fb_videomode *modes;
  114. /* in mm: size of screen */
  115. int height;
  116. int width;
  117. };
  118. #endif