hfc_multi_8xx.h 4.6 KB

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