dvma.c 2.8 KB

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