hfc_multi_8xx.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * For License see notice in hfc_multi.c
  3. *
  4. * special IO and init functions for the embedded XHFC board
  5. * from Speech Design
  6. *
  7. */
  8. #include <asm/8xx_immap.h>
  9. /* Change this to the value used by your board */
  10. #ifndef IMAP_ADDR
  11. #define IMAP_ADDR 0xFFF00000
  12. #endif
  13. static void
  14. #ifdef HFC_REGISTER_DEBUG
  15. HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val,
  16. const char *function, int line)
  17. #else
  18. HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val)
  19. #endif
  20. {
  21. hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
  22. writeb(reg, hc->xhfc_memaddr);
  23. hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
  24. writeb(val, hc->xhfc_memdata);
  25. }
  26. static u_char
  27. #ifdef HFC_REGISTER_DEBUG
  28. HFC_inb_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)
  29. #else
  30. HFC_inb_embsd(struct hfc_multi *hc, u_char reg)
  31. #endif
  32. {
  33. hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
  34. writeb(reg, hc->xhfc_memaddr);
  35. hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
  36. return readb(hc->xhfc_memdata);
  37. }
  38. static u_short
  39. #ifdef HFC_REGISTER_DEBUG
  40. HFC_inw_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)
  41. #else
  42. HFC_inw_embsd(struct hfc_multi *hc, u_char reg)
  43. #endif
  44. {
  45. hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
  46. writeb(reg, hc->xhfc_memaddr);
  47. hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
  48. return readb(hc->xhfc_memdata);
  49. }
  50. static void
  51. #ifdef HFC_REGISTER_DEBUG
  52. HFC_wait_embsd(struct hfc_multi *hc, const char *function, int line)
  53. #else
  54. HFC_wait_embsd(struct hfc_multi *hc)
  55. #endif
  56. {
  57. hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
  58. writeb(R_STATUS, hc->xhfc_memaddr);
  59. hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
  60. while (readb(hc->xhfc_memdata) & V_BUSY)
  61. cpu_relax();
  62. }
  63. /* write fifo data (EMBSD) */
  64. void
  65. write_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)
  66. {
  67. hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
  68. *hc->xhfc_memaddr = A_FIFO_DATA0;
  69. hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
  70. while (len) {
  71. *hc->xhfc_memdata = *data;
  72. data++;
  73. len--;
  74. }
  75. }
  76. /* read fifo data (EMBSD) */
  77. void
  78. read_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)
  79. {
  80. hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;
  81. *hc->xhfc_memaddr = A_FIFO_DATA0;
  82. hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);
  83. while (len) {
  84. *data = (u_char)(*hc->xhfc_memdata);
  85. data++;
  86. len--;
  87. }
  88. }
  89. static int
  90. setup_embedded(struct hfc_multi *hc, struct hm_map *m)
  91. {
  92. printk(KERN_INFO
  93. "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n",
  94. m->vendor_name, m->card_name, m->clock2 ? "double" : "normal");
  95. hc->pci_dev = NULL;
  96. if (m->clock2)
  97. test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip);
  98. hc->leds = m->leds;
  99. hc->ledstate = 0xAFFEAFFE;
  100. hc->opticalsupport = m->opticalsupport;
  101. hc->pci_iobase = 0;
  102. hc->pci_membase = 0;
  103. hc->xhfc_membase = NULL;
  104. hc->xhfc_memaddr = NULL;
  105. hc->xhfc_memdata = NULL;
  106. /* set memory access methods */
  107. if (m->io_mode) /* use mode from card config */
  108. hc->io_mode = m->io_mode;
  109. switch (hc->io_mode) {
  110. case HFC_IO_MODE_EMBSD:
  111. test_and_set_bit(HFC_CHIP_EMBSD, &hc->chip);
  112. hc->slots = 128; /* required */
  113. /* fall through */
  114. hc->HFC_outb = HFC_outb_embsd;
  115. hc->HFC_inb = HFC_inb_embsd;
  116. hc->HFC_inw = HFC_inw_embsd;
  117. hc->HFC_wait = HFC_wait_embsd;
  118. hc->read_fifo = read_fifo_embsd;
  119. hc->write_fifo = write_fifo_embsd;
  120. hc->xhfc_origmembase = XHFC_MEMBASE + XHFC_OFFSET * hc->id;
  121. hc->xhfc_membase = (u_char *)ioremap(hc->xhfc_origmembase,
  122. XHFC_MEMSIZE);
  123. if (!hc->xhfc_membase) {
  124. printk(KERN_WARNING
  125. "HFC-multi: failed to remap xhfc address space. "
  126. "(internal error)\n");
  127. return -EIO;
  128. }
  129. hc->xhfc_memaddr = (u_long *)(hc->xhfc_membase + 4);
  130. hc->xhfc_memdata = (u_long *)(hc->xhfc_membase);
  131. printk(KERN_INFO
  132. "HFC-multi: xhfc_membase:%#lx xhfc_origmembase:%#lx "
  133. "xhfc_memaddr:%#lx xhfc_memdata:%#lx\n",
  134. (u_long)hc->xhfc_membase, hc->xhfc_origmembase,
  135. (u_long)hc->xhfc_memaddr, (u_long)hc->xhfc_memdata);
  136. break;
  137. default:
  138. printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n");
  139. return -EIO;
  140. }
  141. /* Prepare the MPC8XX PortA 10 as output (address/data selector) */
  142. hc->immap = (struct immap *)(IMAP_ADDR);
  143. hc->immap->im_ioport.iop_papar &= ~(PA_XHFC_A0);
  144. hc->immap->im_ioport.iop_paodr &= ~(PA_XHFC_A0);
  145. hc->immap->im_ioport.iop_padir |= PA_XHFC_A0;
  146. /* Prepare the MPC8xx PortB __X__ as input (ISDN__X__IRQ) */
  147. hc->pb_irqmsk = (PB_XHFC_IRQ1 << hc->id);
  148. hc->immap->im_cpm.cp_pbpar &= ~(hc->pb_irqmsk);
  149. hc->immap->im_cpm.cp_pbodr &= ~(hc->pb_irqmsk);
  150. hc->immap->im_cpm.cp_pbdir &= ~(hc->pb_irqmsk);
  151. /* At this point the needed config is done */
  152. /* fifos are still not enabled */
  153. return 0;
  154. }