• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/isdn/hardware/mISDN/
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
9#include <asm/8xx_immap.h>
10
11/* Change this to the value used by your board */
12#ifndef IMAP_ADDR
13#define IMAP_ADDR	0xFFF00000
14#endif
15
16static void
17#ifdef HFC_REGISTER_DEBUG
18HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val,
19		const char *function, int line)
20#else
21HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val)
22#endif
23{
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);
28}
29static u_char
30#ifdef HFC_REGISTER_DEBUG
31HFC_inb_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)
32#else
33HFC_inb_embsd(struct hfc_multi *hc, u_char reg)
34#endif
35{
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);
40}
41static u_short
42#ifdef HFC_REGISTER_DEBUG
43HFC_inw_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)
44#else
45HFC_inw_embsd(struct hfc_multi *hc, u_char reg)
46#endif
47{
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);
52}
53static void
54#ifdef HFC_REGISTER_DEBUG
55HFC_wait_embsd(struct hfc_multi *hc, const char *function, int line)
56#else
57HFC_wait_embsd(struct hfc_multi *hc)
58#endif
59{
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();
65}
66
67/* write fifo data (EMBSD) */
68void
69write_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)
70{
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--;
78	}
79}
80
81/* read fifo data (EMBSD) */
82void
83read_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)
84{
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--;
92	}
93}
94
95static int
96setup_embedded(struct hfc_multi *hc, struct hm_map *m)
97{
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");
101
102	hc->pci_dev = NULL;
103	if (m->clock2)
104		test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip);
105
106	hc->leds = m->leds;
107	hc->ledstate = 0xAFFEAFFE;
108	hc->opticalsupport = m->opticalsupport;
109
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;
115
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;
138		}
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;
150	}
151
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;
157
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);
163
164	/* At this point the needed config is done */
165	/* fifos are still not enabled */
166	return 0;
167}
168