Commit 0fe85d50 authored by David S. Miller's avatar David S. Miller

[SPARC64]: Convert parport to of_platform_driver.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3adf55ad
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
#define _ASM_SPARC64_PARPORT_H 1 #define _ASM_SPARC64_PARPORT_H 1
#include <asm/ebus.h> #include <asm/ebus.h>
#include <asm/isa.h>
#include <asm/ns87303.h> #include <asm/ns87303.h>
#include <asm/of_device.h>
#include <asm/prom.h>
#define PARPORT_PC_MAX_PORTS PARPORT_MAX #define PARPORT_PC_MAX_PORTS PARPORT_MAX
...@@ -35,8 +36,12 @@ static struct sparc_ebus_info { ...@@ -35,8 +36,12 @@ static struct sparc_ebus_info {
unsigned int addr; unsigned int addr;
unsigned int count; unsigned int count;
int lock; int lock;
struct parport *port;
} sparc_ebus_dmas[PARPORT_PC_MAX_PORTS]; } sparc_ebus_dmas[PARPORT_PC_MAX_PORTS];
static DECLARE_BITMAP(dma_slot_map, PARPORT_PC_MAX_PORTS);
static __inline__ int request_dma(unsigned int dmanr, const char *device_id) static __inline__ int request_dma(unsigned int dmanr, const char *device_id)
{ {
if (dmanr >= PARPORT_PC_MAX_PORTS) if (dmanr >= PARPORT_PC_MAX_PORTS)
...@@ -98,90 +103,53 @@ static __inline__ unsigned int get_dma_residue(unsigned int dmanr) ...@@ -98,90 +103,53 @@ static __inline__ unsigned int get_dma_residue(unsigned int dmanr)
return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info); return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info);
} }
static int ebus_ecpp_p(struct linux_ebus_device *edev) static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id *match)
{ {
if (!strcmp(edev->prom_node->name, "ecpp")) unsigned long base = op->resource[0].start;
return 1; unsigned long config = op->resource[1].start;
if (!strcmp(edev->prom_node->name, "parallel")) { unsigned long d_base = op->resource[2].start;
const char *compat; unsigned long d_len;
struct device_node *parent;
compat = of_get_property(edev->prom_node, struct parport *p;
"compatible", NULL); int slot, err;
if (compat &&
(!strcmp(compat, "ecpp") || parent = op->node->parent;
!strcmp(compat, "ns87317-ecpp") || if (!strcmp(parent->name, "dma")) {
!strcmp(compat + 13, "ecpp"))) p = parport_pc_probe_port(base, base + 0x400,
return 1; op->irqs[0], PARPORT_DMA_NOFIFO,
} op->dev.parent);
if (!p)
return -ENOMEM;
dev_set_drvdata(&op->dev, p);
return 0; return 0;
} }
static int parport_isa_probe(int count)
{
struct sparc_isa_bridge *isa_br;
struct sparc_isa_device *isa_dev;
for_each_isa(isa_br) {
for_each_isadev(isa_dev, isa_br) {
struct sparc_isa_device *child;
unsigned long base;
if (strcmp(isa_dev->prom_node->name, "dma"))
continue;
child = isa_dev->child; for (slot = 0; slot < PARPORT_PC_MAX_PORTS; slot++) {
while (child) { if (!test_and_set_bit(slot, dma_slot_map))
if (!strcmp(child->prom_node->name, "parallel"))
break; break;
child = child->next;
} }
if (!child) err = -ENODEV;
continue; if (slot >= PARPORT_PC_MAX_PORTS)
goto out_err;
base = child->resource.start; spin_lock_init(&sparc_ebus_dmas[slot].info.lock);
/* No DMA, see commentary in d_len = (op->resource[2].end - d_base) + 1UL;
* asm-sparc64/floppy.h:isa_floppy_init() sparc_ebus_dmas[slot].info.regs =
*/ of_ioremap(&op->resource[2], 0, d_len, "ECPP DMA");
if (parport_pc_probe_port(base, base + 0x400,
child->irq, PARPORT_DMA_NOFIFO,
&child->bus->self->dev))
count++;
}
}
return count; if (!sparc_ebus_dmas[slot].info.regs)
} goto out_clear_map;
static int parport_pc_find_nonpci_ports (int autoirq, int autodma) sparc_ebus_dmas[slot].info.flags = 0;
{ sparc_ebus_dmas[slot].info.callback = NULL;
struct linux_ebus *ebus; sparc_ebus_dmas[slot].info.client_cookie = NULL;
struct linux_ebus_device *edev; sparc_ebus_dmas[slot].info.irq = 0xdeadbeef;
int count = 0; strcpy(sparc_ebus_dmas[slot].info.name, "parport");
if (ebus_dma_register(&sparc_ebus_dmas[slot].info))
for_each_ebus(ebus) { goto out_unmap_regs;
for_each_ebusdev(edev, ebus) {
if (ebus_ecpp_p(edev)) {
unsigned long base = edev->resource[0].start;
unsigned long config = edev->resource[1].start;
unsigned long d_base = edev->resource[2].start;
unsigned long d_len;
spin_lock_init(&sparc_ebus_dmas[count].info.lock); ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 1);
d_len = (edev->resource[2].end -
d_base) + 1;
sparc_ebus_dmas[count].info.regs =
ioremap(d_base, d_len);
if (!sparc_ebus_dmas[count].info.regs)
continue;
sparc_ebus_dmas[count].info.flags = 0;
sparc_ebus_dmas[count].info.callback = NULL;
sparc_ebus_dmas[count].info.client_cookie = NULL;
sparc_ebus_dmas[count].info.irq = 0xdeadbeef;
strcpy(sparc_ebus_dmas[count].info.name, "parport");
if (ebus_dma_register(&sparc_ebus_dmas[count].info))
continue;
ebus_dma_irq_enable(&sparc_ebus_dmas[count].info, 1);
/* Configure IRQ to Push Pull, Level Low */ /* Configure IRQ to Push Pull, Level Low */
/* Enable ECP, set bit 2 of the CTR first */ /* Enable ECP, set bit 2 of the CTR first */
...@@ -197,18 +165,83 @@ static int parport_pc_find_nonpci_ports (int autoirq, int autodma) ...@@ -197,18 +165,83 @@ static int parport_pc_find_nonpci_ports (int autoirq, int autodma)
ns87303_modify(config, PTR, ns87303_modify(config, PTR,
0, PTR_LPT_REG_DIR); 0, PTR_LPT_REG_DIR);
if (parport_pc_probe_port(base, base + 0x400, p = parport_pc_probe_port(base, base + 0x400,
edev->irqs[0], op->irqs[0],
count, slot,
&ebus->self->dev)) op->dev.parent);
count++; err = -ENOMEM;
} if (!p)
} goto out_disable_irq;
dev_set_drvdata(&op->dev, p);
return 0;
out_disable_irq:
ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 0);
ebus_dma_unregister(&sparc_ebus_dmas[slot].info);
out_unmap_regs:
of_iounmap(&op->resource[2], sparc_ebus_dmas[slot].info.regs, d_len);
out_clear_map:
clear_bit(slot, dma_slot_map);
out_err:
return err;
}
static int __devexit ecpp_remove(struct of_device *op)
{
struct parport *p = dev_get_drvdata(&op->dev);
int slot = p->dma;
parport_pc_unregister_port(p);
if (slot != PARPORT_DMA_NOFIFO) {
unsigned long d_base = op->resource[2].start;
unsigned long d_len;
d_len = (op->resource[2].end - d_base) + 1UL;
ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 0);
ebus_dma_unregister(&sparc_ebus_dmas[slot].info);
of_iounmap(&op->resource[2],
sparc_ebus_dmas[slot].info.regs,
d_len);
clear_bit(slot, dma_slot_map);
} }
count = parport_isa_probe(count); return 0;
}
static struct of_device_id ecpp_match[] = {
{
.name = "ecpp",
},
{
.name = "parallel",
.compatible = "ecpp",
},
{
.name = "parallel",
.compatible = "ns87317-ecpp",
},
{},
};
static struct of_platform_driver ecpp_driver = {
.name = "ecpp",
.match_table = ecpp_match,
.probe = ecpp_probe,
.remove = __devexit_p(ecpp_remove),
};
static int parport_pc_find_nonpci_ports(int autoirq, int autodma)
{
of_register_driver(&ecpp_driver, &of_bus_type);
return count; return 0;
} }
#endif /* !(_ASM_SPARC64_PARPORT_H */ #endif /* !(_ASM_SPARC64_PARPORT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment