1 /* $Id: parport.h,v 1.11 2001/05/11 07:54:24 davem Exp $
2 * parport.h: sparc64 specific parport initialization and dma.
4 * Copyright (C) 1999 Eddie C. Dost (ecd@skynet.be)
7 #ifndef _ASM_SPARC64_PARPORT_H
8 #define _ASM_SPARC64_PARPORT_H 1
12 #include <asm/ns87303.h>
14 #define PARPORT_PC_MAX_PORTS PARPORT_MAX
16 static struct sparc_ebus_info
{
17 struct ebus_dma_info info
;
20 } sparc_ebus_dmas
[PARPORT_PC_MAX_PORTS
];
22 static __inline__
void enable_dma(unsigned int dmanr
)
24 if (ebus_dma_request(&sparc_ebus_dmas
[dmanr
].info
,
25 sparc_ebus_dmas
[dmanr
].addr
,
26 sparc_ebus_dmas
[dmanr
].count
))
29 ebus_dma_enable(&sparc_ebus_dmas
[dmanr
].info
, 1);
32 static __inline__
void disable_dma(unsigned int dmanr
)
34 ebus_dma_enable(&sparc_ebus_dmas
[dmanr
].info
, 0);
37 static __inline__
void clear_dma_ff(unsigned int dmanr
)
42 static __inline__
void set_dma_mode(unsigned int dmanr
, char mode
)
44 ebus_dma_prepare(&sparc_ebus_dmas
[dmanr
].info
, (mode
!= DMA_MODE_WRITE
));
47 static __inline__
void set_dma_addr(unsigned int dmanr
, unsigned int addr
)
49 sparc_ebus_dmas
[dmanr
].addr
= addr
;
52 static __inline__
void set_dma_count(unsigned int dmanr
, unsigned int count
)
54 sparc_ebus_dmas
[dmanr
].count
= count
;
57 static __inline__
unsigned int get_dma_residue(unsigned int dmanr
)
59 return ebus_dma_residue(&sparc_ebus_dmas
[dmanr
].info
);
62 static int ebus_ecpp_p(struct linux_ebus_device
*edev
)
64 if (!strcmp(edev
->prom_name
, "ecpp"))
66 if (!strcmp(edev
->prom_name
, "parallel")) {
68 prom_getstring(edev
->prom_node
,
70 compat
, sizeof(compat
));
72 if (!strcmp(compat
, "ecpp"))
74 if (!strcmp(compat
, "ns87317-ecpp") &&
75 !strcmp(compat
+ 13, "ecpp"))
81 static int parport_isa_probe(int count
)
83 struct sparc_isa_bridge
*isa_br
;
84 struct sparc_isa_device
*isa_dev
;
86 for_each_isa(isa_br
) {
87 for_each_isadev(isa_dev
, isa_br
) {
88 struct sparc_isa_device
*child
;
91 if (strcmp(isa_dev
->prom_name
, "dma"))
94 child
= isa_dev
->child
;
96 if (!strcmp(child
->prom_name
, "parallel"))
103 base
= child
->resource
.start
;
105 /* No DMA, see commentary in
106 * asm-sparc64/floppy.h:isa_floppy_init()
108 if (parport_pc_probe_port(base
, base
+ 0x400,
109 child
->irq
, PARPORT_DMA_NOFIFO
,
118 static int parport_pc_find_nonpci_ports (int autoirq
, int autodma
)
120 struct linux_ebus
*ebus
;
121 struct linux_ebus_device
*edev
;
124 for_each_ebus(ebus
) {
125 for_each_ebusdev(edev
, ebus
) {
126 if (ebus_ecpp_p(edev
)) {
127 unsigned long base
= edev
->resource
[0].start
;
128 unsigned long config
= edev
->resource
[1].start
;
129 unsigned long d_base
= edev
->resource
[2].start
;
132 spin_lock_init(&sparc_ebus_dmas
[count
].info
.lock
);
133 d_len
= (edev
->resource
[2].end
-
135 sparc_ebus_dmas
[count
].info
.regs
=
136 ioremap(d_base
, d_len
);
137 if (!sparc_ebus_dmas
[count
].info
.regs
)
139 sparc_ebus_dmas
[count
].info
.flags
= 0;
140 sparc_ebus_dmas
[count
].info
.callback
= NULL
;
141 sparc_ebus_dmas
[count
].info
.client_cookie
= NULL
;
142 sparc_ebus_dmas
[count
].info
.irq
= 0xdeadbeef;
143 strcpy(sparc_ebus_dmas
[count
].info
.name
, "parport");
144 if (ebus_dma_register(&sparc_ebus_dmas
[count
].info
))
146 ebus_dma_irq_enable(&sparc_ebus_dmas
[count
].info
, 1);
148 /* Configure IRQ to Push Pull, Level Low */
149 /* Enable ECP, set bit 2 of the CTR first */
150 outb(0x04, base
+ 0x02);
151 ns87303_modify(config
, PCR
,
158 /* CTR bit 5 controls direction of port */
159 ns87303_modify(config
, PTR
,
162 if (parport_pc_probe_port(base
, base
+ 0x400,
170 count
= parport_isa_probe(count
);
175 #endif /* !(_ASM_SPARC64_PARPORT_H */
This page took 0.0334 seconds and 5 git commands to generate.