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