2 * For License see notice in hfc_multi.c
4 * special IO and init functions for the embedded XHFC board
9 #include <asm/8xx_immap.h>
11 /* Change this to the value used by your board */
13 #define IMAP_ADDR 0xFFF00000
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
)
21 HFC_outb_embsd(struct hfc_multi
*hc
, u_char reg
, u_char val
)
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
);
30 #ifdef HFC_REGISTER_DEBUG
31 HFC_inb_embsd(struct hfc_multi
*hc
, u_char reg
, const char *function
, int line
)
33 HFC_inb_embsd(struct hfc_multi
*hc
, u_char reg
)
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
);
42 #ifdef HFC_REGISTER_DEBUG
43 HFC_inw_embsd(struct hfc_multi
*hc
, u_char reg
, const char *function
, int line
)
45 HFC_inw_embsd(struct hfc_multi
*hc
, u_char reg
)
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
);
54 #ifdef HFC_REGISTER_DEBUG
55 HFC_wait_embsd(struct hfc_multi
*hc
, const char *function
, int line
)
57 HFC_wait_embsd(struct hfc_multi
*hc
)
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
)
67 /* write fifo data (EMBSD) */
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
);
75 *hc
->xhfc_memdata
= *data
;
81 /* read fifo data (EMBSD) */
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
);
89 *data
= (u_char
)(*hc
->xhfc_memdata
);
96 setup_embedded(struct hfc_multi
*hc
, struct hm_map
*m
)
99 "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n",
100 m
->vendor_name
, m
->card_name
, m
->clock2
? "double" : "normal");
104 test_and_set_bit(HFC_CHIP_CLOCK2
, &hc
->chip
);
107 hc
->ledstate
= 0xAFFEAFFE;
108 hc
->opticalsupport
= m
->opticalsupport
;
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 */
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
,
133 if (!hc
->xhfc_membase
) {
135 "HFC-multi: failed to remap xhfc address space. "
136 "(internal error)\n");
139 hc
->xhfc_memaddr
= (u_long
*)(hc
->xhfc_membase
+ 4);
140 hc
->xhfc_memdata
= (u_long
*)(hc
->xhfc_membase
);
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
);
148 printk(KERN_WARNING
"HFC-multi: Invalid IO mode.\n");
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 */