dvma.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* dvma.c: Routines that are used to access DMA on the Sparc SBus.
  2. *
  3. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  4. */
  5. #include <linux/string.h>
  6. #include <linux/kernel.h>
  7. #include <linux/slab.h>
  8. #include <linux/init.h>
  9. #include <linux/delay.h>
  10. #include <asm/oplib.h>
  11. #include <asm/io.h>
  12. #include <asm/dma.h>
  13. #include <asm/sbus.h>
  14. struct sbus_dma *dma_chain;
  15. static void __init init_one_dvma(struct sbus_dma *dma, int num_dma)
  16. {
  17. printk("dma%d: ", num_dma);
  18. dma->next = NULL;
  19. dma->running = 0; /* No transfers going on as of yet */
  20. dma->allocated = 0; /* No one has allocated us yet */
  21. switch(sbus_readl(dma->regs + DMA_CSR)&DMA_DEVICE_ID) {
  22. case DMA_VERS0:
  23. dma->revision = dvmarev0;
  24. printk("Revision 0 ");
  25. break;
  26. case DMA_ESCV1:
  27. dma->revision = dvmaesc1;
  28. printk("ESC Revision 1 ");
  29. break;
  30. case DMA_VERS1:
  31. dma->revision = dvmarev1;
  32. printk("Revision 1 ");
  33. break;
  34. case DMA_VERS2:
  35. dma->revision = dvmarev2;
  36. printk("Revision 2 ");
  37. break;
  38. case DMA_VERHME:
  39. dma->revision = dvmahme;
  40. printk("HME DVMA gate array ");
  41. break;
  42. case DMA_VERSPLUS:
  43. dma->revision = dvmarevplus;
  44. printk("Revision 1 PLUS ");
  45. break;
  46. default:
  47. printk("unknown dma version %08x",
  48. sbus_readl(dma->regs + DMA_CSR) & DMA_DEVICE_ID);
  49. dma->allocated = 1;
  50. break;
  51. }
  52. printk("\n");
  53. }
  54. /* Probe this SBus DMA module(s) */
  55. void __init dvma_init(struct sbus_bus *sbus)
  56. {
  57. struct sbus_dev *this_dev;
  58. struct sbus_dma *dma;
  59. struct sbus_dma *dchain;
  60. static int num_dma = 0;
  61. for_each_sbusdev(this_dev, sbus) {
  62. char *name = this_dev->prom_name;
  63. int hme = 0;
  64. if(!strcmp(name, "SUNW,fas"))
  65. hme = 1;
  66. else if(strcmp(name, "dma") &&
  67. strcmp(name, "ledma") &&
  68. strcmp(name, "espdma"))
  69. continue;
  70. /* Found one... */
  71. dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
  72. dma->sdev = this_dev;
  73. /* Put at end of dma chain */
  74. dchain = dma_chain;
  75. if(dchain) {
  76. while(dchain->next)
  77. dchain = dchain->next;
  78. dchain->next = dma;
  79. } else {
  80. /* We're the first in line */
  81. dma_chain = dma;
  82. }
  83. dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
  84. dma->sdev->resource[0].end - dma->sdev->resource[0].start + 1,
  85. "dma");
  86. dma->node = dma->sdev->prom_node;
  87. init_one_dvma(dma, num_dma++);
  88. }
  89. }
  90. #ifdef CONFIG_SUN4
  91. #include <asm/sun4paddr.h>
  92. void __init sun4_dvma_init(void)
  93. {
  94. struct sbus_dma *dma;
  95. struct resource r;
  96. if(sun4_dma_physaddr) {
  97. dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
  98. /* No SBUS */
  99. dma->sdev = NULL;
  100. /* Only one DMA device */
  101. dma_chain = dma;
  102. memset(&r, 0, sizeof(r));
  103. r.start = sun4_dma_physaddr;
  104. dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
  105. /* No prom node */
  106. dma->node = 0x0;
  107. init_one_dvma(dma, 0);
  108. } else {
  109. dma_chain = NULL;
  110. }
  111. }
  112. #endif