aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64/parport.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-sparc64/parport.h')
-rw-r--r--include/asm-sparc64/parport.h175
1 files changed, 175 insertions, 0 deletions
diff --git a/include/asm-sparc64/parport.h b/include/asm-sparc64/parport.h
new file mode 100644
index 000000000000..ab88349ddadc
--- /dev/null
+++ b/include/asm-sparc64/parport.h
@@ -0,0 +1,175 @@
1/* $Id: parport.h,v 1.11 2001/05/11 07:54:24 davem Exp $
2 * parport.h: sparc64 specific parport initialization and dma.
3 *
4 * Copyright (C) 1999 Eddie C. Dost (ecd@skynet.be)
5 */
6
7#ifndef _ASM_SPARC64_PARPORT_H
8#define _ASM_SPARC64_PARPORT_H 1
9
10#include <asm/ebus.h>
11#include <asm/isa.h>
12#include <asm/ns87303.h>
13
14#define PARPORT_PC_MAX_PORTS PARPORT_MAX
15
16static struct sparc_ebus_info {
17 struct ebus_dma_info info;
18 unsigned int addr;
19 unsigned int count;
20} sparc_ebus_dmas[PARPORT_PC_MAX_PORTS];
21
22static __inline__ void enable_dma(unsigned int dmanr)
23{
24 if (ebus_dma_request(&sparc_ebus_dmas[dmanr].info,
25 sparc_ebus_dmas[dmanr].addr,
26 sparc_ebus_dmas[dmanr].count))
27 BUG();
28
29 ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 1);
30}
31
32static __inline__ void disable_dma(unsigned int dmanr)
33{
34 ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 0);
35}
36
37static __inline__ void clear_dma_ff(unsigned int dmanr)
38{
39 /* nothing */
40}
41
42static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
43{
44 ebus_dma_prepare(&sparc_ebus_dmas[dmanr].info, (mode != DMA_MODE_WRITE));
45}
46
47static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int addr)
48{
49 sparc_ebus_dmas[dmanr].addr = addr;
50}
51
52static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
53{
54 sparc_ebus_dmas[dmanr].count = count;
55}
56
57static __inline__ unsigned int get_dma_residue(unsigned int dmanr)
58{
59 return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info);
60}
61
62static int ebus_ecpp_p(struct linux_ebus_device *edev)
63{
64 if (!strcmp(edev->prom_name, "ecpp"))
65 return 1;
66 if (!strcmp(edev->prom_name, "parallel")) {
67 char compat[19];
68 prom_getstring(edev->prom_node,
69 "compatible",
70 compat, sizeof(compat));
71 compat[18] = '\0';
72 if (!strcmp(compat, "ecpp"))
73 return 1;
74 if (!strcmp(compat, "ns87317-ecpp") &&
75 !strcmp(compat + 13, "ecpp"))
76 return 1;
77 }
78 return 0;
79}
80
81static int parport_isa_probe(int count)
82{
83 struct sparc_isa_bridge *isa_br;
84 struct sparc_isa_device *isa_dev;
85
86 for_each_isa(isa_br) {
87 for_each_isadev(isa_dev, isa_br) {
88 struct sparc_isa_device *child;
89 unsigned long base;
90
91 if (strcmp(isa_dev->prom_name, "dma"))
92 continue;
93
94 child = isa_dev->child;
95 while (child) {
96 if (!strcmp(child->prom_name, "parallel"))
97 break;
98 child = child->next;
99 }
100 if (!child)
101 continue;
102
103 base = child->resource.start;
104
105 /* No DMA, see commentary in
106 * asm-sparc64/floppy.h:isa_floppy_init()
107 */
108 if (parport_pc_probe_port(base, base + 0x400,
109 child->irq, PARPORT_DMA_NOFIFO,
110 child->bus->self))
111 count++;
112 }
113 }
114
115 return count;
116}
117
118static int parport_pc_find_nonpci_ports (int autoirq, int autodma)
119{
120 struct linux_ebus *ebus;
121 struct linux_ebus_device *edev;
122 int count = 0;
123
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;
130 unsigned long d_len;
131
132 spin_lock_init(&sparc_ebus_dmas[count].info.lock);
133 d_len = (edev->resource[2].end -
134 d_base) + 1;
135 sparc_ebus_dmas[count].info.regs =
136 ioremap(d_base, d_len);
137 if (!sparc_ebus_dmas[count].info.regs)
138 continue;
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))
145 continue;
146 ebus_dma_irq_enable(&sparc_ebus_dmas[count].info, 1);
147
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,
152 PCR_EPP_ENABLE |
153 PCR_IRQ_ODRAIN,
154 PCR_ECP_ENABLE |
155 PCR_ECP_CLK_ENA |
156 PCR_IRQ_POLAR);
157
158 /* CTR bit 5 controls direction of port */
159 ns87303_modify(config, PTR,
160 0, PTR_LPT_REG_DIR);
161
162 if (parport_pc_probe_port(base, base + 0x400,
163 edev->irqs[0],
164 count, ebus->self))
165 count++;
166 }
167 }
168 }
169
170 count = parport_isa_probe(count);
171
172 return count;
173}
174
175#endif /* !(_ASM_SPARC64_PARPORT_H */