jazzdma.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Helpfile for jazzdma.c -- Mips Jazz R4030 DMA controller support
  4. */
  5. #ifndef _ASM_JAZZDMA_H
  6. #define _ASM_JAZZDMA_H
  7. /*
  8. * Prototypes and macros
  9. */
  10. extern unsigned long vdma_alloc(unsigned long paddr, unsigned long size);
  11. extern int vdma_free(unsigned long laddr);
  12. extern int vdma_remap(unsigned long laddr, unsigned long paddr,
  13. unsigned long size);
  14. extern unsigned long vdma_phys2log(unsigned long paddr);
  15. extern unsigned long vdma_log2phys(unsigned long laddr);
  16. extern void vdma_stats(void); /* for debugging only */
  17. extern void vdma_enable(int channel);
  18. extern void vdma_disable(int channel);
  19. extern void vdma_set_mode(int channel, int mode);
  20. extern void vdma_set_addr(int channel, long addr);
  21. extern void vdma_set_count(int channel, int count);
  22. extern int vdma_get_residue(int channel);
  23. extern int vdma_get_enable(int channel);
  24. /*
  25. * some definitions used by the driver functions
  26. */
  27. #define VDMA_PAGESIZE 4096
  28. #define VDMA_PGTBL_ENTRIES 4096
  29. #define VDMA_PGTBL_SIZE (sizeof(VDMA_PGTBL_ENTRY) * VDMA_PGTBL_ENTRIES)
  30. #define VDMA_PAGE_EMPTY 0xff000000
  31. /*
  32. * Macros to get page no. and offset of a given address
  33. * Note that VDMA_PAGE() works for physical addresses only
  34. */
  35. #define VDMA_PAGE(a) ((unsigned int)(a) >> 12)
  36. #define VDMA_OFFSET(a) ((unsigned int)(a) & (VDMA_PAGESIZE-1))
  37. /*
  38. * error code returned by vdma_alloc()
  39. * (See also arch/mips/kernel/jazzdma.c)
  40. */
  41. #define VDMA_ERROR 0xffffffff
  42. /*
  43. * VDMA pagetable entry description
  44. */
  45. typedef volatile struct VDMA_PGTBL_ENTRY {
  46. unsigned int frame; /* physical frame no. */
  47. unsigned int owner; /* owner of this entry (0=free) */
  48. } VDMA_PGTBL_ENTRY;
  49. /*
  50. * DMA channel control registers
  51. * in the R4030 MCT_ADR chip
  52. */
  53. #define JAZZ_R4030_CHNL_MODE 0xE0000100 /* 8 DMA Channel Mode Registers, */
  54. /* 0xE0000100,120,140... */
  55. #define JAZZ_R4030_CHNL_ENABLE 0xE0000108 /* 8 DMA Channel Enable Regs, */
  56. /* 0xE0000108,128,148... */
  57. #define JAZZ_R4030_CHNL_COUNT 0xE0000110 /* 8 DMA Channel Byte Cnt Regs, */
  58. /* 0xE0000110,130,150... */
  59. #define JAZZ_R4030_CHNL_ADDR 0xE0000118 /* 8 DMA Channel Address Regs, */
  60. /* 0xE0000118,138,158... */
  61. /* channel enable register bits */
  62. #define R4030_CHNL_ENABLE (1<<0)
  63. #define R4030_CHNL_WRITE (1<<1)
  64. #define R4030_TC_INTR (1<<8)
  65. #define R4030_MEM_INTR (1<<9)
  66. #define R4030_ADDR_INTR (1<<10)
  67. /*
  68. * Channel mode register bits
  69. */
  70. #define R4030_MODE_ATIME_40 (0) /* device access time on remote bus */
  71. #define R4030_MODE_ATIME_80 (1)
  72. #define R4030_MODE_ATIME_120 (2)
  73. #define R4030_MODE_ATIME_160 (3)
  74. #define R4030_MODE_ATIME_200 (4)
  75. #define R4030_MODE_ATIME_240 (5)
  76. #define R4030_MODE_ATIME_280 (6)
  77. #define R4030_MODE_ATIME_320 (7)
  78. #define R4030_MODE_WIDTH_8 (1<<3) /* device data bus width */
  79. #define R4030_MODE_WIDTH_16 (2<<3)
  80. #define R4030_MODE_WIDTH_32 (3<<3)
  81. #define R4030_MODE_INTR_EN (1<<5)
  82. #define R4030_MODE_BURST (1<<6) /* Rev. 2 only */
  83. #define R4030_MODE_FAST_ACK (1<<7) /* Rev. 2 only */
  84. #endif /* _ASM_JAZZDMA_H */