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
17 * While sparc64 doesn't have an ISA DMA API, we provide something that looks
18 * close enough to make parport_pc happy
22 static struct sparc_ebus_info {
23 struct ebus_dma_info info;
27 } sparc_ebus_dmas[PARPORT_PC_MAX_PORTS];
29 static __inline__ int request_dma(unsigned int dmanr, const char *device_id)
31 if (dmanr >= PARPORT_PC_MAX_PORTS)
33 if (xchg(&sparc_ebus_dmas[dmanr].lock, 1) != 0)
38 static __inline__ void free_dma(unsigned int dmanr)
40 if (dmanr >= PARPORT_PC_MAX_PORTS) {
41 printk(KERN_WARNING "Trying to free DMA%d\n", dmanr);
44 if (xchg(&sparc_ebus_dmas[dmanr].lock, 0) == 0) {
45 printk(KERN_WARNING "Trying to free free DMA%d\n", dmanr);
50 static __inline__ void enable_dma(unsigned int dmanr)
52 ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 1);
54 if (ebus_dma_request(&sparc_ebus_dmas[dmanr].info,
55 sparc_ebus_dmas[dmanr].addr,
56 sparc_ebus_dmas[dmanr].count))
60 static __inline__ void disable_dma(unsigned int dmanr)
62 ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 0);
65 static __inline__ void clear_dma_ff(unsigned int dmanr)
70 static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
72 ebus_dma_prepare(&sparc_ebus_dmas[dmanr].info, (mode != DMA_MODE_WRITE));
75 static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int addr)
77 sparc_ebus_dmas[dmanr].addr = addr;
80 static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
82 sparc_ebus_dmas[dmanr].count = count;
85 static __inline__ unsigned int get_dma_residue(unsigned int dmanr)
87 return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info);
90 static int ebus_ecpp_p(struct linux_ebus_device *edev)
92 if (!strcmp(edev->prom_node->name, "ecpp"))
94 if (!strcmp(edev->prom_node->name, "parallel")) {
97 compat = of_get_property(edev->prom_node,
100 (!strcmp(compat, "ecpp") ||
101 !strcmp(compat, "ns87317-ecpp") ||
102 !strcmp(compat + 13, "ecpp")))
108 static int parport_isa_probe(int count)
110 struct sparc_isa_bridge *isa_br;
111 struct sparc_isa_device *isa_dev;
113 for_each_isa(isa_br) {
114 for_each_isadev(isa_dev, isa_br) {
115 struct sparc_isa_device *child;
118 if (strcmp(isa_dev->prom_node->name, "dma"))
121 child = isa_dev->child;
123 if (!strcmp(child->prom_node->name, "parallel"))
130 base = child->resource.start;
132 /* No DMA, see commentary in
133 * asm-sparc64/floppy.h:isa_floppy_init()
135 if (parport_pc_probe_port(base, base + 0x400,
136 child->irq, PARPORT_DMA_NOFIFO,
145 static int parport_pc_find_nonpci_ports (int autoirq, int autodma)
147 struct linux_ebus *ebus;
148 struct linux_ebus_device *edev;
151 for_each_ebus(ebus) {
152 for_each_ebusdev(edev, ebus) {
153 if (ebus_ecpp_p(edev)) {
154 unsigned long base = edev->resource[0].start;
155 unsigned long config = edev->resource[1].start;
156 unsigned long d_base = edev->resource[2].start;
159 spin_lock_init(&sparc_ebus_dmas[count].info.lock);
160 d_len = (edev->resource[2].end -
162 sparc_ebus_dmas[count].info.regs =
163 ioremap(d_base, d_len);
164 if (!sparc_ebus_dmas[count].info.regs)
166 sparc_ebus_dmas[count].info.flags = 0;
167 sparc_ebus_dmas[count].info.callback = NULL;
168 sparc_ebus_dmas[count].info.client_cookie = NULL;
169 sparc_ebus_dmas[count].info.irq = 0xdeadbeef;
170 strcpy(sparc_ebus_dmas[count].info.name, "parport");
171 if (ebus_dma_register(&sparc_ebus_dmas[count].info))
173 ebus_dma_irq_enable(&sparc_ebus_dmas[count].info, 1);
175 /* Configure IRQ to Push Pull, Level Low */
176 /* Enable ECP, set bit 2 of the CTR first */
177 outb(0x04, base + 0x02);
178 ns87303_modify(config, PCR,
185 /* CTR bit 5 controls direction of port */
186 ns87303_modify(config, PTR,
189 if (parport_pc_probe_port(base, base + 0x400,
197 count = parport_isa_probe(count);
202 #endif /* !(_ASM_SPARC64_PARPORT_H */