Linux-2.6.12-rc2
[linux-2.6/kvm.git] / include / asm-sparc64 / parport.h
blobab88349ddadc71e39a72e7fa6b32baeb32bb2362
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)
5 */
7 #ifndef _ASM_SPARC64_PARPORT_H
8 #define _ASM_SPARC64_PARPORT_H 1
10 #include <asm/ebus.h>
11 #include <asm/isa.h>
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;
18 unsigned int addr;
19 unsigned int count;
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))
27 BUG();
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)
39 /* nothing */
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"))
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;
78 return 0;
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;
89 unsigned long base;
91 if (strcmp(isa_dev->prom_name, "dma"))
92 continue;
94 child = isa_dev->child;
95 while (child) {
96 if (!strcmp(child->prom_name, "parallel"))
97 break;
98 child = child->next;
100 if (!child)
101 continue;
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,
110 child->bus->self))
111 count++;
115 return count;
118 static int parport_pc_find_nonpci_ports (int autoirq, int autodma)
120 struct linux_ebus *ebus;
121 struct linux_ebus_device *edev;
122 int count = 0;
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;
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);
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);
158 /* CTR bit 5 controls direction of port */
159 ns87303_modify(config, PTR,
160 0, PTR_LPT_REG_DIR);
162 if (parport_pc_probe_port(base, base + 0x400,
163 edev->irqs[0],
164 count, ebus->self))
165 count++;
170 count = parport_isa_probe(count);
172 return count;
175 #endif /* !(_ASM_SPARC64_PARPORT_H */