* [PATCH 1/11] Char: cyclades, create cy_init_Ze
@ 2007-04-18 10:03 Jiri Slaby
2007-04-18 10:03 ` [PATCH 2/11] Char: cyclades, use pci_iomap/unmap Jiri Slaby
` (9 more replies)
0 siblings, 10 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:03 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, create cy_init_Ze
Move Ze init code into new cy_init_Ze, because we will need it in another
place and it will make the code totally unreadable.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 1cd1f5e029963fc449c4f84495770611e5c35297
tree a81b2b0a68303d8dfe616edc4c12c9030723ca12
parent 6f42cfdf174bdd2c05edf7d192713042bf25339c
author Jiri Slaby <jirislaby@gmail.com> Tue, 27 Mar 2007 11:25:47 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:47:56 +0200
drivers/char/cyclades.c | 163 ++++++++++++++++++++++++++---------------------
1 files changed, 90 insertions(+), 73 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index abdc3c7..26d9ea7 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4711,6 +4711,92 @@ static void plx_init(void __iomem * addr, __u32 initctl)
cy_writel(addr + initctl, readl(addr + initctl) & ~0x20000000);
}
+static int __devinit cy_init_Ze(unsigned long cy_pci_phys0,
+ unsigned long cy_pci_phys2,
+ struct RUNTIME_9060 __iomem *cy_pci_addr0,
+ void __iomem *cy_pci_addr2, int cy_pci_irq,
+ struct pci_dev *pdev)
+{
+ unsigned int j;
+ unsigned short cy_pci_nchan;
+
+ readl(&cy_pci_addr0->mail_box_0);
+#ifdef CY_PCI_DEBUG
+ printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
+ (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
+ printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not "
+ "loaded\n");
+#endif
+ /* This must be the new Cyclades-Ze/PCI. */
+ cy_pci_nchan = ZE_V1_NPORTS;
+
+ if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+ printk("Cyclades-Ze/PCI found at 0x%lx but no channels "
+ "are available.\nChange NR_PORTS in cyclades.c "
+ "and recompile kernel.\n",
+ (ulong) cy_pci_phys2);
+ return -EIO;
+ }
+
+ /* fill the next cy_card structure available */
+ for (j = 0; j < NR_CARDS; j++) {
+ if (cy_card[j].base_addr == 0)
+ break;
+ }
+ if (j == NR_CARDS) { /* no more cy_cards available */
+ printk("Cyclades-Ze/PCI found at 0x%lx but no more "
+ "cards can be used.\nChange NR_CARDS in "
+ "cyclades.c and recompile kernel.\n",
+ (ulong) cy_pci_phys2);
+ return -EIO;
+ }
+#ifdef CONFIG_CYZ_INTR
+ /* allocate IRQ only if board has an IRQ */
+ if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
+ if (request_irq(cy_pci_irq, cyz_interrupt,
+ IRQF_SHARED, "Cyclades-Z",
+ &cy_card[j])) {
+ printk("Cyclom-Ze/PCI found at 0x%lx ",
+ (ulong) cy_pci_phys2);
+ printk("but could not allocate IRQ%d.\n",
+ cy_pci_irq);
+ return -EIO;
+ }
+ }
+#endif /* CONFIG_CYZ_INTR */
+
+ /* set cy_card */
+ cy_card[j].base_phys = cy_pci_phys2;
+ cy_card[j].ctl_phys = cy_pci_phys0;
+ cy_card[j].base_addr = cy_pci_addr2;
+ cy_card[j].ctl_addr = cy_pci_addr0;
+ cy_card[j].irq = (int)cy_pci_irq;
+ cy_card[j].bus_index = 1;
+ cy_card[j].first_line = cy_next_channel;
+ cy_card[j].num_chips = -1;
+ cy_card[j].pdev = pdev;
+
+ /* print message */
+#ifdef CONFIG_CYZ_INTR
+ /* don't report IRQ if board is no IRQ */
+ if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
+ printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
+ j + 1, (ulong) cy_pci_phys2,
+ (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1),
+ (int)cy_pci_irq);
+ else
+#endif /* CONFIG_CYZ_INTR */
+ printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ",
+ j + 1, (ulong) cy_pci_phys2,
+ (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1));
+
+ printk("%d channels starting from port %d.\n",
+ cy_pci_nchan, cy_next_channel);
+ cy_next_channel += cy_pci_nchan;
+
+ return 0;
+}
+
/*
* ---------------------------------------------------------------------
* cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI.
@@ -4734,6 +4820,7 @@ static int __init cy_detect_pci(void)
__u32 Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS];
unsigned char Ze_irq[NR_CARDS];
struct pci_dev *Ze_pdev[NR_CARDS];
+ int retval;
for (i = 0; i < NR_CARDS; i++) {
/* look for a Cyclades card by vendor and device id */
@@ -5095,80 +5182,10 @@ static int __init cy_detect_pci(void)
Ze_pdev[j] = Ze_pdev[j + 1];
}
ZeIndex--;
- mailbox = (__u32)readl(&((struct RUNTIME_9060 __iomem *)
- cy_pci_addr0)->mail_box_0);
-#ifdef CY_PCI_DEBUG
- printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
- (ulong)cy_pci_addr2, (ulong)cy_pci_addr0);
- printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not "
- "loaded\n");
-#endif
- /* This must be the new Cyclades-Ze/PCI. */
- cy_pci_nchan = ZE_V1_NPORTS;
-
- if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
- printk("Cyclades-Ze/PCI found at 0x%lx but no channels "
- "are available.\nChange NR_PORTS in cyclades.c "
- "and recompile kernel.\n",
- (ulong) cy_pci_phys2);
- return i;
- }
-
- /* fill the next cy_card structure available */
- for (j = 0; j < NR_CARDS; j++) {
- if (cy_card[j].base_addr == 0)
- break;
- }
- if (j == NR_CARDS) { /* no more cy_cards available */
- printk("Cyclades-Ze/PCI found at 0x%lx but no more "
- "cards can be used.\nChange NR_CARDS in "
- "cyclades.c and recompile kernel.\n",
- (ulong) cy_pci_phys2);
+ retval = cy_init_Ze(cy_pci_phys0, cy_pci_phys2, cy_pci_addr0,
+ cy_pci_addr2, cy_pci_irq, pdev);
+ if (retval < 0)
return i;
- }
-#ifdef CONFIG_CYZ_INTR
- /* allocate IRQ only if board has an IRQ */
- if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
- if (request_irq(cy_pci_irq, cyz_interrupt,
- IRQF_SHARED, "Cyclades-Z",
- &cy_card[j])) {
- printk("Cyclom-Ze/PCI found at 0x%lx ",
- (ulong) cy_pci_phys2);
- printk("but could not allocate IRQ%d.\n",
- cy_pci_irq);
- return i;
- }
- }
-#endif /* CONFIG_CYZ_INTR */
-
- /* set cy_card */
- cy_card[j].base_phys = cy_pci_phys2;
- cy_card[j].ctl_phys = cy_pci_phys0;
- cy_card[j].base_addr = cy_pci_addr2;
- cy_card[j].ctl_addr = cy_pci_addr0;
- cy_card[j].irq = (int)cy_pci_irq;
- cy_card[j].bus_index = 1;
- cy_card[j].first_line = cy_next_channel;
- cy_card[j].num_chips = -1;
- cy_card[j].pdev = pdev;
-
- /* print message */
-#ifdef CONFIG_CYZ_INTR
- /* don't report IRQ if board is no IRQ */
- if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
- printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
- j + 1, (ulong) cy_pci_phys2,
- (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1),
- (int)cy_pci_irq);
- else
-#endif /* CONFIG_CYZ_INTR */
- printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ",
- j + 1, (ulong) cy_pci_phys2,
- (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1));
-
- printk("%d channels starting from port %d.\n",
- cy_pci_nchan, cy_next_channel);
- cy_next_channel += cy_pci_nchan;
}
if (ZeIndex != 0) {
printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be "
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/11] Char: cyclades, use pci_iomap/unmap
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
@ 2007-04-18 10:03 ` Jiri Slaby
2007-04-18 10:04 ` [PATCH 3/11] Char: cyclades, init Ze immediately Jiri Slaby
` (8 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:03 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, use pci_iomap/unmap
fork remove code for pci -- move it to separate, new, function and don't
care about pci in the former.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 2d99f97963f6a60727c1cc8d21d3bdbf4ba48d7f
tree aba7f710a1668c17d56d45ff805ec03adc950c42
parent 1cd1f5e029963fc449c4f84495770611e5c35297
author Jiri Slaby <jirislaby@gmail.com> Thu, 29 Mar 2007 19:43:52 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:47:58 +0200
drivers/char/cyclades.c | 42 ++++++++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 26d9ea7..1d5fe9a 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4775,6 +4775,7 @@ static int __devinit cy_init_Ze(unsigned long cy_pci_phys0,
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = -1;
cy_card[j].pdev = pdev;
+ pci_set_drvdata(pdev, &cy_card[j]);
/* print message */
#ifdef CONFIG_CYZ_INTR
@@ -4889,8 +4890,8 @@ static int __init cy_detect_pci(void)
continue;
}
#endif
- cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Yctl);
- cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin);
+ cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Yctl);
+ cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ywin);
#ifdef CY_PCI_DEBUG
printk("Cyclom-Y/PCI: relocate winaddr=0x%lx "
@@ -4948,6 +4949,7 @@ static int __init cy_detect_pci(void)
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = cy_pci_nchan / 4;
cy_card[j].pdev = pdev;
+ pci_set_drvdata(pdev, &cy_card[j]);
/* enable interrupts in the PCI interface */
plx_ver = readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
@@ -5006,7 +5008,7 @@ static int __init cy_detect_pci(void)
"ctladdr=0x%lx\n",
(ulong) cy_pci_phys2, (ulong) cy_pci_phys0);
#endif
- cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl);
+ cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Zctl);
/* Disable interrupts on the PLX before resetting it */
cy_writew(cy_pci_addr0 + 0x68,
@@ -5040,8 +5042,7 @@ static int __init cy_detect_pci(void)
}
if (mailbox == ZE_V1) {
- cy_pci_addr2 = ioremap(cy_pci_phys2,
- CyPCI_Ze_win);
+ cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ze_win);
if (ZeIndex == NR_CARDS) {
printk("Cyclades-Ze/PCI found at "
"0x%lx but no more cards can "
@@ -5061,7 +5062,7 @@ static int __init cy_detect_pci(void)
i--;
continue;
} else {
- cy_pci_addr2 = ioremap(cy_pci_phys2,CyPCI_Zwin);
+ cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Zwin);
}
#ifdef CY_PCI_DEBUG
@@ -5145,6 +5146,7 @@ static int __init cy_detect_pci(void)
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = -1;
cy_card[j].pdev = pdev;
+ pci_set_drvdata(pdev, &cy_card[j]);
/* print message */
#ifdef CONFIG_CYZ_INTR
@@ -5198,6 +5200,26 @@ static int __init cy_detect_pci(void)
#endif /* ifdef CONFIG_PCI */
} /* cy_detect_pci */
+static void __devexit cy_pci_release(struct pci_dev *pdev)
+{
+#ifdef CONFIG_PCI
+ struct cyclades_card *cinfo = pci_get_drvdata(pdev);
+
+ pci_iounmap(pdev, cinfo->base_addr);
+ if (cinfo->ctl_addr)
+ pci_iounmap(pdev, cinfo->ctl_addr);
+ if (cinfo->irq
+#ifndef CONFIG_CYZ_INTR
+ && cinfo->num_chips != -1 /* not a Z card */
+#endif /* CONFIG_CYZ_INTR */
+ )
+ free_irq(cinfo->irq, cinfo);
+ pci_release_regions(pdev);
+
+ cinfo->base_addr = NULL;
+#endif
+}
+
/*
* This routine prints out the appropriate serial driver version number
* and identifies which options were configured into this driver.
@@ -5546,6 +5568,10 @@ static void __exit cy_cleanup_module(void)
for (i = 0; i < NR_CARDS; i++) {
if (cy_card[i].base_addr) {
+ if (cy_card[i].pdev) {
+ cy_pci_release(cy_card[i].pdev);
+ continue;
+ }
iounmap(cy_card[i].base_addr);
if (cy_card[i].ctl_addr)
iounmap(cy_card[i].ctl_addr);
@@ -5555,10 +5581,6 @@ static void __exit cy_cleanup_module(void)
#endif /* CONFIG_CYZ_INTR */
)
free_irq(cy_card[i].irq, &cy_card[i]);
-#ifdef CONFIG_PCI
- if (cy_card[i].pdev)
- pci_release_regions(cy_card[i].pdev);
-#endif
}
}
} /* cy_cleanup_module */
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/11] Char: cyclades, init Ze immediately
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
2007-04-18 10:03 ` [PATCH 2/11] Char: cyclades, use pci_iomap/unmap Jiri Slaby
@ 2007-04-18 10:04 ` Jiri Slaby
2007-04-18 10:04 ` [PATCH 4/11] Char: cyclades, create cy_pci_probe Jiri Slaby
` (7 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:04 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, init Ze immediately
There will be no other choice after introducing pci probing anyway.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 15bad81f3abe0638e7ccf34fd14cf6c372146742
tree 3dfe3a58322b197e80d09757e4049f1221240a6d
parent 2d99f97963f6a60727c1cc8d21d3bdbf4ba48d7f
author Jiri Slaby <jirislaby@gmail.com> Sun, 01 Apr 2007 22:20:05 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:47:59 +0200
drivers/char/cyclades.c | 59 ++++++-----------------------------------------
1 files changed, 8 insertions(+), 51 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 1d5fe9a..43cf832 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4714,12 +4714,14 @@ static void plx_init(void __iomem * addr, __u32 initctl)
static int __devinit cy_init_Ze(unsigned long cy_pci_phys0,
unsigned long cy_pci_phys2,
struct RUNTIME_9060 __iomem *cy_pci_addr0,
- void __iomem *cy_pci_addr2, int cy_pci_irq,
- struct pci_dev *pdev)
+ int cy_pci_irq, struct pci_dev *pdev)
{
+ void __iomem *cy_pci_addr2;
unsigned int j;
unsigned short cy_pci_nchan;
+ cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ze_win);
+
readl(&cy_pci_addr0->mail_box_0);
#ifdef CY_PCI_DEBUG
printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n",
@@ -4816,11 +4818,6 @@ static int __init cy_detect_pci(void)
unsigned short i, j, cy_pci_nchan, plx_ver;
unsigned short device_id, dev_index = 0;
__u32 mailbox;
- __u32 ZeIndex = 0;
- void __iomem *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS];
- __u32 Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS];
- unsigned char Ze_irq[NR_CARDS];
- struct pci_dev *Ze_pdev[NR_CARDS];
int retval;
for (i = 0; i < NR_CARDS; i++) {
@@ -5042,24 +5039,10 @@ static int __init cy_detect_pci(void)
}
if (mailbox == ZE_V1) {
- cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ze_win);
- if (ZeIndex == NR_CARDS) {
- printk("Cyclades-Ze/PCI found at "
- "0x%lx but no more cards can "
- "be used.\nChange NR_CARDS in "
- "cyclades.c and recompile "
- "kernel.\n",
- (ulong)cy_pci_phys2);
- } else {
- Ze_phys0[ZeIndex] = cy_pci_phys0;
- Ze_phys2[ZeIndex] = cy_pci_phys2;
- Ze_addr0[ZeIndex] = cy_pci_addr0;
- Ze_addr2[ZeIndex] = cy_pci_addr2;
- Ze_irq[ZeIndex] = cy_pci_irq;
- Ze_pdev[ZeIndex] = pdev;
- ZeIndex++;
- }
- i--;
+ retval = cy_init_Ze(cy_pci_phys0, cy_pci_phys2,
+ cy_pci_addr0, cy_pci_irq, pdev);
+ if (retval < 0)
+ i--;
continue;
} else {
cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Zwin);
@@ -5168,32 +5151,6 @@ static int __init cy_detect_pci(void)
}
}
- for (; ZeIndex != 0 && i < NR_CARDS; i++) {
- cy_pci_phys0 = Ze_phys0[0];
- cy_pci_phys2 = Ze_phys2[0];
- cy_pci_addr0 = Ze_addr0[0];
- cy_pci_addr2 = Ze_addr2[0];
- cy_pci_irq = Ze_irq[0];
- pdev = Ze_pdev[0];
- for (j = 0; j < ZeIndex - 1; j++) {
- Ze_phys0[j] = Ze_phys0[j + 1];
- Ze_phys2[j] = Ze_phys2[j + 1];
- Ze_addr0[j] = Ze_addr0[j + 1];
- Ze_addr2[j] = Ze_addr2[j + 1];
- Ze_irq[j] = Ze_irq[j + 1];
- Ze_pdev[j] = Ze_pdev[j + 1];
- }
- ZeIndex--;
- retval = cy_init_Ze(cy_pci_phys0, cy_pci_phys2, cy_pci_addr0,
- cy_pci_addr2, cy_pci_irq, pdev);
- if (retval < 0)
- return i;
- }
- if (ZeIndex != 0) {
- printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be "
- "used.\nChange NR_CARDS in cyclades.c and recompile "
- "kernel.\n", (unsigned int)Ze_phys2[0]);
- }
return i;
#else
return 0;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/11] Char: cyclades, create cy_pci_probe
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
2007-04-18 10:03 ` [PATCH 2/11] Char: cyclades, use pci_iomap/unmap Jiri Slaby
2007-04-18 10:04 ` [PATCH 3/11] Char: cyclades, init Ze immediately Jiri Slaby
@ 2007-04-18 10:04 ` Jiri Slaby
2007-04-18 10:05 ` [PATCH 5/11] Char: cyclades, move card entries init into function Jiri Slaby
` (6 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:04 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, create cy_pci_probe
Move probing code to separate function for easy pci probing conversion.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 07df3f0fcb1cad6a274d5b7b32d65df54c3f4fb4
tree cb3c77a959c7ca9d63faaec82c154a752e87ff42
parent 15bad81f3abe0638e7ccf34fd14cf6c372146742
author Jiri Slaby <jirislaby@gmail.com> Sun, 01 Apr 2007 23:26:58 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:01 +0200
drivers/char/cyclades.c | 623 ++++++++++++++++++++++++-----------------------
1 files changed, 318 insertions(+), 305 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 43cf832..adf993a 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4698,7 +4698,8 @@ static int __init cy_detect_isa(void)
#endif /* CONFIG_ISA */
} /* cy_detect_isa */
-static void plx_init(void __iomem * addr, __u32 initctl)
+#ifdef CONFIG_PCI
+static void __devinit plx_init(void __iomem * addr, __u32 initctl)
{
/* Reset PLX */
cy_writel(addr + initctl, readl(addr + initctl) | 0x40000000);
@@ -4800,355 +4801,367 @@ static int __devinit cy_init_Ze(unsigned long cy_pci_phys0,
return 0;
}
-/*
- * ---------------------------------------------------------------------
- * cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI.
- * sets global variables and return the number of PCI boards found.
- * ---------------------------------------------------------------------
- */
-static int __init cy_detect_pci(void)
+static int __devinit cy_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
{
-#ifdef CONFIG_PCI
-
- struct pci_dev *pdev = NULL;
unsigned char cyy_rev_id;
- unsigned char cy_pci_irq = 0;
- __u32 cy_pci_phys0, cy_pci_phys2;
+ unsigned char cy_pci_irq;
+ __u32 cy_pci_phys0, cy_pci_phys2, mailbox;
void __iomem *cy_pci_addr0, *cy_pci_addr2;
- unsigned short i, j, cy_pci_nchan, plx_ver;
- unsigned short device_id, dev_index = 0;
- __u32 mailbox;
+ unsigned int device_id;
+ unsigned short j, cy_pci_nchan, plx_ver;
int retval;
- for (i = 0; i < NR_CARDS; i++) {
- /* look for a Cyclades card by vendor and device id */
- while ((device_id = cy_pci_dev_id[dev_index].device) != 0) {
- if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
- device_id, pdev)) == NULL) {
- dev_index++; /* try next device id */
- } else {
- break; /* found a board */
- }
- }
+ retval = pci_enable_device(pdev);
+ if (retval) {
+ dev_err(&pdev->dev, "cannot enable device\n");
+ return retval;
+ }
- if (device_id == 0)
- break;
+ /* read PCI configuration area */
+ cy_pci_irq = pdev->irq;
+ cy_pci_phys0 = pci_resource_start(pdev, 0);
+ cy_pci_phys2 = pci_resource_start(pdev, 2);
+ pci_read_config_byte(pdev, PCI_REVISION_ID, &cyy_rev_id);
- if (pci_enable_device(pdev))
- continue;
+ device_id = pdev->device & ~PCI_DEVICE_ID_MASK;
- /* read PCI configuration area */
- cy_pci_irq = pdev->irq;
- cy_pci_phys0 = pci_resource_start(pdev, 0);
- cy_pci_phys2 = pci_resource_start(pdev, 2);
- pci_read_config_byte(pdev, PCI_REVISION_ID, &cyy_rev_id);
+ if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
+ device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
+#ifdef CY_PCI_DEBUG
+ printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
+ pdev->bus->number, pdev->devfn);
+ printk("rev_id=%d) IRQ%d\n",
+ cyy_rev_id, (int)cy_pci_irq);
+ printk("Cyclom-Y/PCI:found winaddr=0x%lx "
+ "ctladdr=0x%lx\n",
+ (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
+#endif
- device_id &= ~PCI_DEVICE_ID_MASK;
+ if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
+ printk(" Warning: PCI I/O bit incorrectly "
+ "set. Ignoring it...\n");
+ pdev->resource[2].flags &= ~IORESOURCE_IO;
+ }
- if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo ||
- device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) {
-#ifdef CY_PCI_DEBUG
+ /* Although we don't use this I/O region, we should
+ request it from the kernel anyway, to avoid problems
+ with other drivers accessing it. */
+ retval = pci_request_regions(pdev, "Cyclom-Y");
+ if (retval) {
+ printk(KERN_ERR "cyclades: failed to reserve "
+ "PCI resources\n");
+ return retval;
+ }
+#if defined(__alpha__)
+ if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */
printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
pdev->bus->number, pdev->devfn);
printk("rev_id=%d) IRQ%d\n",
cyy_rev_id, (int)cy_pci_irq);
printk("Cyclom-Y/PCI:found winaddr=0x%lx "
"ctladdr=0x%lx\n",
- (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
-#endif
-
- if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
- printk(" Warning: PCI I/O bit incorrectly "
- "set. Ignoring it...\n");
- pdev->resource[2].flags &= ~IORESOURCE_IO;
- }
-
- /* Although we don't use this I/O region, we should
- request it from the kernel anyway, to avoid problems
- with other drivers accessing it. */
- if (pci_request_regions(pdev, "Cyclom-Y") != 0) {
- printk(KERN_ERR "cyclades: failed to reserve "
- "PCI resources\n");
- continue;
- }
-#if defined(__alpha__)
- if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */
- printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ",
- pdev->bus->number, pdev->devfn);
- printk("rev_id=%d) IRQ%d\n",
- cyy_rev_id, (int)cy_pci_irq);
- printk("Cyclom-Y/PCI:found winaddr=0x%lx "
- "ctladdr=0x%lx\n",
- (ulong)cy_pci_phys2,
- (ulong)cy_pci_phys0);
- printk("Cyclom-Y/PCI not supported for low "
- "addresses in Alpha systems.\n");
- i--;
- continue;
- }
+ (ulong)cy_pci_phys2,
+ (ulong)cy_pci_phys0);
+ printk("Cyclom-Y/PCI not supported for low "
+ "addresses in Alpha systems.\n");
+ return -EIO;
+ }
#endif
- cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Yctl);
- cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ywin);
+ cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Yctl);
+ cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Ywin);
#ifdef CY_PCI_DEBUG
- printk("Cyclom-Y/PCI: relocate winaddr=0x%lx "
- "ctladdr=0x%lx\n",
- (u_long)cy_pci_addr2, (u_long)cy_pci_addr0);
+ printk("Cyclom-Y/PCI: relocate winaddr=0x%lx "
+ "ctladdr=0x%lx\n",
+ (u_long)cy_pci_addr2, (u_long)cy_pci_addr0);
#endif
- cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP *
- cyy_init_card(cy_pci_addr2, 1));
- if (cy_pci_nchan == 0) {
- printk("Cyclom-Y PCI host card with ");
- printk("no Serial-Modules at 0x%lx.\n",
- (ulong) cy_pci_phys2);
- i--;
- continue;
- }
- if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
- printk("Cyclom-Y/PCI found at 0x%lx ",
- (ulong) cy_pci_phys2);
- printk("but no channels are available.\n");
- printk("Change NR_PORTS in cyclades.c and "
- "recompile kernel.\n");
- return i;
- }
- /* fill the next cy_card structure available */
- for (j = 0; j < NR_CARDS; j++) {
- if (cy_card[j].base_addr == 0)
- break;
- }
- if (j == NR_CARDS) { /* no more cy_cards available */
- printk("Cyclom-Y/PCI found at 0x%lx ",
- (ulong) cy_pci_phys2);
- printk("but no more cards can be used.\n");
- printk("Change NR_CARDS in cyclades.c and "
- "recompile kernel.\n");
- return i;
- }
-
- /* allocate IRQ */
- if (request_irq(cy_pci_irq, cyy_interrupt,
- IRQF_SHARED, "Cyclom-Y", &cy_card[j])) {
- printk("Cyclom-Y/PCI found at 0x%lx ",
- (ulong) cy_pci_phys2);
- printk("but could not allocate IRQ%d.\n",
- cy_pci_irq);
- return i;
- }
-
- /* set cy_card */
- cy_card[j].base_phys = (ulong) cy_pci_phys2;
- cy_card[j].ctl_phys = (ulong) cy_pci_phys0;
- cy_card[j].base_addr = cy_pci_addr2;
- cy_card[j].ctl_addr = cy_pci_addr0;
- cy_card[j].irq = (int)cy_pci_irq;
- cy_card[j].bus_index = 1;
- cy_card[j].first_line = cy_next_channel;
- cy_card[j].num_chips = cy_pci_nchan / 4;
- cy_card[j].pdev = pdev;
- pci_set_drvdata(pdev, &cy_card[j]);
-
- /* enable interrupts in the PCI interface */
- plx_ver = readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
- switch (plx_ver) {
- case PLX_9050:
-
- cy_writeb(cy_pci_addr0 + 0x4c, 0x43);
+ cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP *
+ cyy_init_card(cy_pci_addr2, 1));
+ if (cy_pci_nchan == 0) {
+ printk("Cyclom-Y PCI host card with ");
+ printk("no Serial-Modules at 0x%lx.\n",
+ (ulong) cy_pci_phys2);
+ return -EIO;
+ }
+ if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+ printk("Cyclom-Y/PCI found at 0x%lx ",
+ (ulong) cy_pci_phys2);
+ printk("but no channels are available.\n");
+ printk("Change NR_PORTS in cyclades.c and "
+ "recompile kernel.\n");
+ return -EIO;
+ }
+ /* fill the next cy_card structure available */
+ for (j = 0; j < NR_CARDS; j++) {
+ if (cy_card[j].base_addr == 0)
break;
+ }
+ if (j == NR_CARDS) { /* no more cy_cards available */
+ printk("Cyclom-Y/PCI found at 0x%lx ",
+ (ulong) cy_pci_phys2);
+ printk("but no more cards can be used.\n");
+ printk("Change NR_CARDS in cyclades.c and "
+ "recompile kernel.\n");
+ return -EIO;
+ }
- case PLX_9060:
- case PLX_9080:
- default: /* Old boards, use PLX_9060 */
-
- plx_init(cy_pci_addr0, 0x6c);
- /* For some yet unknown reason, once the PLX9060 reloads
- the EEPROM, the IRQ is lost and, thus, we have to
- re-write it to the PCI config. registers.
- This will remain here until we find a permanent
- fix. */
- pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
- cy_pci_irq);
-
- cy_writew(cy_pci_addr0 + 0x68,
- readw(cy_pci_addr0 + 0x68) | 0x0900);
- break;
- }
+ /* allocate IRQ */
+ retval = request_irq(cy_pci_irq, cyy_interrupt,
+ IRQF_SHARED, "Cyclom-Y", &cy_card[j]);
+ if (retval) {
+ printk("Cyclom-Y/PCI found at 0x%lx ",
+ (ulong) cy_pci_phys2);
+ printk("but could not allocate IRQ%d.\n",
+ cy_pci_irq);
+ return retval;
+ }
- /* print message */
- printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
- j + 1, (ulong)cy_pci_phys2,
- (ulong) (cy_pci_phys2 + CyPCI_Ywin - 1),
- (int)cy_pci_irq);
- printk("%d channels starting from port %d.\n",
- cy_pci_nchan, cy_next_channel);
+ /* set cy_card */
+ cy_card[j].base_phys = (ulong) cy_pci_phys2;
+ cy_card[j].ctl_phys = (ulong) cy_pci_phys0;
+ cy_card[j].base_addr = cy_pci_addr2;
+ cy_card[j].ctl_addr = cy_pci_addr0;
+ cy_card[j].irq = (int)cy_pci_irq;
+ cy_card[j].bus_index = 1;
+ cy_card[j].first_line = cy_next_channel;
+ cy_card[j].num_chips = cy_pci_nchan / 4;
+ cy_card[j].pdev = pdev;
+ pci_set_drvdata(pdev, &cy_card[j]);
- cy_next_channel += cy_pci_nchan;
- } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) {
- /* print message */
- printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
- pdev->bus->number, pdev->devfn);
- printk("rev_id=%d) IRQ%d\n",
- cyy_rev_id, (int)cy_pci_irq);
- printk("Cyclades-Z/PCI: found winaddr=0x%lx "
- "ctladdr=0x%lx\n",
- (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
- printk("Cyclades-Z/PCI not supported for low "
- "addresses\n");
+ /* enable interrupts in the PCI interface */
+ plx_ver = readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
+ switch (plx_ver) {
+ case PLX_9050:
+
+ cy_writeb(cy_pci_addr0 + 0x4c, 0x43);
break;
- } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) {
-#ifdef CY_PCI_DEBUG
- printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
- pdev->bus->number, pdev->devfn);
- printk("rev_id=%d) IRQ%d\n",
- cyy_rev_id, (int)cy_pci_irq);
- printk("Cyclades-Z/PCI: found winaddr=0x%lx "
- "ctladdr=0x%lx\n",
- (ulong) cy_pci_phys2, (ulong) cy_pci_phys0);
-#endif
- cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Zctl);
- /* Disable interrupts on the PLX before resetting it */
- cy_writew(cy_pci_addr0 + 0x68,
- readw(cy_pci_addr0 + 0x68) & ~0x0900);
+ case PLX_9060:
+ case PLX_9080:
+ default: /* Old boards, use PLX_9060 */
plx_init(cy_pci_addr0, 0x6c);
- /* For some yet unknown reason, once the PLX9060 reloads
- the EEPROM, the IRQ is lost and, thus, we have to
- re-write it to the PCI config. registers.
- This will remain here until we find a permanent
- fix. */
+ /* For some yet unknown reason, once the PLX9060 reloads
+ the EEPROM, the IRQ is lost and, thus, we have to
+ re-write it to the PCI config. registers.
+ This will remain here until we find a permanent
+ fix. */
pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
- cy_pci_irq);
+ cy_pci_irq);
- mailbox = (__u32)readl(&((struct RUNTIME_9060 __iomem *)
- cy_pci_addr0)->mail_box_0);
+ cy_writew(cy_pci_addr0 + 0x68,
+ readw(cy_pci_addr0 + 0x68) | 0x0900);
+ break;
+ }
- if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
- printk(" Warning: PCI I/O bit incorrectly "
- "set. Ignoring it...\n");
- pdev->resource[2].flags &= ~IORESOURCE_IO;
- }
+ /* print message */
+ printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ",
+ j + 1, (ulong)cy_pci_phys2,
+ (ulong) (cy_pci_phys2 + CyPCI_Ywin - 1),
+ (int)cy_pci_irq);
+ printk("%d channels starting from port %d.\n",
+ cy_pci_nchan, cy_next_channel);
- /* Although we don't use this I/O region, we should
- request it from the kernel anyway, to avoid problems
- with other drivers accessing it. */
- if (pci_request_regions(pdev, "Cyclades-Z") != 0) {
- printk(KERN_ERR "cyclades: failed to reserve "
- "PCI resources\n");
- continue;
- }
+ cy_next_channel += cy_pci_nchan;
+ } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) {
+ /* print message */
+ printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
+ pdev->bus->number, pdev->devfn);
+ printk("rev_id=%d) IRQ%d\n",
+ cyy_rev_id, (int)cy_pci_irq);
+ printk("Cyclades-Z/PCI: found winaddr=0x%lx "
+ "ctladdr=0x%lx\n",
+ (ulong)cy_pci_phys2, (ulong)cy_pci_phys0);
+ printk("Cyclades-Z/PCI not supported for low "
+ "addresses\n");
+ return -EIO;
+ } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) {
+#ifdef CY_PCI_DEBUG
+ printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ",
+ pdev->bus->number, pdev->devfn);
+ printk("rev_id=%d) IRQ%d\n",
+ cyy_rev_id, (int)cy_pci_irq);
+ printk("Cyclades-Z/PCI: found winaddr=0x%lx "
+ "ctladdr=0x%lx\n",
+ (ulong) cy_pci_phys2, (ulong) cy_pci_phys0);
+#endif
+ cy_pci_addr0 = pci_iomap(pdev, 0, CyPCI_Zctl);
+
+ /* Disable interrupts on the PLX before resetting it */
+ cy_writew(cy_pci_addr0 + 0x68,
+ readw(cy_pci_addr0 + 0x68) & ~0x0900);
+
+ plx_init(cy_pci_addr0, 0x6c);
+ /* For some yet unknown reason, once the PLX9060 reloads
+ the EEPROM, the IRQ is lost and, thus, we have to
+ re-write it to the PCI config. registers.
+ This will remain here until we find a permanent
+ fix. */
+ pci_write_config_byte(pdev, PCI_INTERRUPT_LINE,
+ cy_pci_irq);
- if (mailbox == ZE_V1) {
- retval = cy_init_Ze(cy_pci_phys0, cy_pci_phys2,
- cy_pci_addr0, cy_pci_irq, pdev);
- if (retval < 0)
- i--;
- continue;
- } else {
- cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Zwin);
- }
+ mailbox = (__u32)readl(&((struct RUNTIME_9060 __iomem *)
+ cy_pci_addr0)->mail_box_0);
+
+ if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
+ printk(" Warning: PCI I/O bit incorrectly "
+ "set. Ignoring it...\n");
+ pdev->resource[2].flags &= ~IORESOURCE_IO;
+ }
+
+ /* Although we don't use this I/O region, we should
+ request it from the kernel anyway, to avoid problems
+ with other drivers accessing it. */
+ retval = pci_request_regions(pdev, "Cyclades-Z");
+ if (retval) {
+ printk(KERN_ERR "cyclades: failed to reserve "
+ "PCI resources\n");
+ return retval;
+ }
+
+ if (mailbox == ZE_V1) {
+ retval = cy_init_Ze(cy_pci_phys0, cy_pci_phys2,
+ cy_pci_addr0, cy_pci_irq, pdev);
+ return retval;
+ } else {
+ cy_pci_addr2 = pci_iomap(pdev, 2, CyPCI_Zwin);
+ }
#ifdef CY_PCI_DEBUG
- printk("Cyclades-Z/PCI: relocate winaddr=0x%lx "
- "ctladdr=0x%lx\n",
- (ulong) cy_pci_addr2, (ulong) cy_pci_addr0);
- if (mailbox == ZO_V1) {
- cy_writel(&((struct RUNTIME_9060 *)
- (cy_pci_addr0))->loc_addr_base,
- WIN_CREG);
- printk("Cyclades-8Zo/PCI: FPGA id %lx, ver "
- "%lx\n", (ulong) (0xff &
- readl(&((struct CUSTOM_REG *)
- (cy_pci_addr2))->fpga_id)),
- (ulong)(0xff &
- readl(&((struct CUSTOM_REG *)
- (cy_pci_addr2))->
- fpga_version)));
- cy_writel(&((struct RUNTIME_9060 *)
- (cy_pci_addr0))->loc_addr_base,
- WIN_RAM);
- } else {
- printk("Cyclades-Z/PCI: New Cyclades-Z board. "
- "FPGA not loaded\n");
- }
+ printk("Cyclades-Z/PCI: relocate winaddr=0x%lx "
+ "ctladdr=0x%lx\n",
+ (ulong) cy_pci_addr2, (ulong) cy_pci_addr0);
+ if (mailbox == ZO_V1) {
+ cy_writel(&((struct RUNTIME_9060 *)
+ (cy_pci_addr0))->loc_addr_base,
+ WIN_CREG);
+ printk("Cyclades-8Zo/PCI: FPGA id %lx, ver "
+ "%lx\n", (ulong) (0xff &
+ readl(&((struct CUSTOM_REG *)
+ (cy_pci_addr2))->fpga_id)),
+ (ulong)(0xff &
+ readl(&((struct CUSTOM_REG *)
+ (cy_pci_addr2))->
+ fpga_version)));
+ cy_writel(&((struct RUNTIME_9060 *)
+ (cy_pci_addr0))->loc_addr_base,
+ WIN_RAM);
+ } else {
+ printk("Cyclades-Z/PCI: New Cyclades-Z board. "
+ "FPGA not loaded\n");
+ }
#endif
- /* The following clears the firmware id word. This
- ensures that the driver will not attempt to talk to
- the board until it has been properly initialized.
- */
- if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
- cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L);
-
- /* This must be a Cyclades-8Zo/PCI. The extendable
- version will have a different device_id and will
- be allocated its maximum number of ports. */
- cy_pci_nchan = 8;
-
- if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
- printk("Cyclades-8Zo/PCI found at 0x%lx but"
- "no channels are available.\nChange "
- "NR_PORTS in cyclades.c and recompile "
- "kernel.\n", (ulong)cy_pci_phys2);
- return i;
- }
+ /* The following clears the firmware id word. This
+ ensures that the driver will not attempt to talk to
+ the board until it has been properly initialized.
+ */
+ if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
+ cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L);
+
+ /* This must be a Cyclades-8Zo/PCI. The extendable
+ version will have a different device_id and will
+ be allocated its maximum number of ports. */
+ cy_pci_nchan = 8;
+
+ if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) {
+ printk("Cyclades-8Zo/PCI found at 0x%lx but"
+ "no channels are available.\nChange "
+ "NR_PORTS in cyclades.c and recompile "
+ "kernel.\n", (ulong)cy_pci_phys2);
+ return -EIO;
+ }
- /* fill the next cy_card structure available */
- for (j = 0; j < NR_CARDS; j++) {
- if (cy_card[j].base_addr == 0)
- break;
- }
- if (j == NR_CARDS) { /* no more cy_cards available */
- printk("Cyclades-8Zo/PCI found at 0x%lx but"
- "no more cards can be used.\nChange "
- "NR_CARDS in cyclades.c and recompile "
- "kernel.\n", (ulong)cy_pci_phys2);
- return i;
- }
+ /* fill the next cy_card structure available */
+ for (j = 0; j < NR_CARDS; j++) {
+ if (cy_card[j].base_addr == 0)
+ break;
+ }
+ if (j == NR_CARDS) { /* no more cy_cards available */
+ printk("Cyclades-8Zo/PCI found at 0x%lx but"
+ "no more cards can be used.\nChange "
+ "NR_CARDS in cyclades.c and recompile "
+ "kernel.\n", (ulong)cy_pci_phys2);
+ return -EIO;
+ }
#ifdef CONFIG_CYZ_INTR
- /* allocate IRQ only if board has an IRQ */
- if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
- if (request_irq(cy_pci_irq, cyz_interrupt,
- IRQF_SHARED, "Cyclades-Z",
- &cy_card[j])) {
- printk("Cyclom-8Zo/PCI found at 0x%lx "
- "but could not allocate "
- "IRQ%d.\n", (ulong)cy_pci_phys2,
- cy_pci_irq);
- return i;
- }
+ /* allocate IRQ only if board has an IRQ */
+ if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) {
+ retval = request_irq(cy_pci_irq, cyz_interrupt,
+ IRQF_SHARED, "Cyclades-Z",
+ &cy_card[j]);
+ if (retval) {
+ printk("Cyclom-8Zo/PCI found at 0x%lx "
+ "but could not allocate "
+ "IRQ%d.\n", (ulong)cy_pci_phys2,
+ cy_pci_irq);
+ return retval;
}
+ }
#endif /* CONFIG_CYZ_INTR */
- /* set cy_card */
- cy_card[j].base_phys = cy_pci_phys2;
- cy_card[j].ctl_phys = cy_pci_phys0;
- cy_card[j].base_addr = cy_pci_addr2;
- cy_card[j].ctl_addr = cy_pci_addr0;
- cy_card[j].irq = (int)cy_pci_irq;
- cy_card[j].bus_index = 1;
- cy_card[j].first_line = cy_next_channel;
- cy_card[j].num_chips = -1;
- cy_card[j].pdev = pdev;
- pci_set_drvdata(pdev, &cy_card[j]);
-
- /* print message */
+ /* set cy_card */
+ cy_card[j].base_phys = cy_pci_phys2;
+ cy_card[j].ctl_phys = cy_pci_phys0;
+ cy_card[j].base_addr = cy_pci_addr2;
+ cy_card[j].ctl_addr = cy_pci_addr0;
+ cy_card[j].irq = (int)cy_pci_irq;
+ cy_card[j].bus_index = 1;
+ cy_card[j].first_line = cy_next_channel;
+ cy_card[j].num_chips = -1;
+ cy_card[j].pdev = pdev;
+ pci_set_drvdata(pdev, &cy_card[j]);
+
+ /* print message */
#ifdef CONFIG_CYZ_INTR
- /* don't report IRQ if board is no IRQ */
- if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
- printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, "
- "IRQ%d, ", j + 1, (ulong)cy_pci_phys2,
- (ulong) (cy_pci_phys2 + CyPCI_Zwin - 1),
- (int)cy_pci_irq);
- else
+ /* don't report IRQ if board is no IRQ */
+ if ((cy_pci_irq != 0) && (cy_pci_irq != 255))
+ printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, "
+ "IRQ%d, ", j + 1, (ulong)cy_pci_phys2,
+ (ulong) (cy_pci_phys2 + CyPCI_Zwin - 1),
+ (int)cy_pci_irq);
+ else
#endif /* CONFIG_CYZ_INTR */
- printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ",
- j + 1, (ulong)cy_pci_phys2,
- (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1));
+ printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ",
+ j + 1, (ulong)cy_pci_phys2,
+ (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1));
+
+ printk("%d channels starting from port %d.\n",
+ cy_pci_nchan, cy_next_channel);
+ cy_next_channel += cy_pci_nchan;
+ }
+
+ return 0;
+}
+#endif
+
+/*
+ * ---------------------------------------------------------------------
+ * cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI.
+ * sets global variables and return the number of PCI boards found.
+ * ---------------------------------------------------------------------
+ */
+static int __init cy_detect_pci(void)
+{
+#ifdef CONFIG_PCI
+ struct pci_dev *pdev = NULL;
+ unsigned int i, device_id, dev_index = 0;
- printk("%d channels starting from port %d.\n",
- cy_pci_nchan, cy_next_channel);
- cy_next_channel += cy_pci_nchan;
+ for (i = 0; i < NR_CARDS; i++) {
+ /* look for a Cyclades card by vendor and device id */
+ while ((device_id = cy_pci_dev_id[dev_index].device) != 0) {
+ if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
+ device_id, pdev)) == NULL) {
+ dev_index++; /* try next device id */
+ } else {
+ break; /* found a board */
+ }
}
+
+ if (device_id == 0)
+ break;
+
+ i -= !!cy_pci_probe(pdev, &cy_pci_dev_id[dev_index]);
}
return i;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/11] Char: cyclades, move card entries init into function
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
` (2 preceding siblings ...)
2007-04-18 10:04 ` [PATCH 4/11] Char: cyclades, create cy_pci_probe Jiri Slaby
@ 2007-04-18 10:05 ` Jiri Slaby
2007-04-18 10:05 ` [PATCH 6/11] Char: cyclades, init card struct immediately Jiri Slaby
` (5 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:05 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, move card entries init into function
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit de8850dd6c04762688b19609b13cb16a1e6399a9
tree 288721fb454613ce1d3bdd6ec10ca6e01c3059c7
parent 07df3f0fcb1cad6a274d5b7b32d65df54c3f4fb4
author Jiri Slaby <jirislaby@gmail.com> Mon, 02 Apr 2007 12:07:20 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:02 +0200
drivers/char/cyclades.c | 311 ++++++++++++++++++++++++-----------------------
1 files changed, 156 insertions(+), 155 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index adf993a..fe967be 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4503,6 +4503,159 @@ static void cy_hangup(struct tty_struct *tty)
* ---------------------------------------------------------------------
*/
+static void __devinit cy_init_card(struct cyclades_card *cinfo,
+ const unsigned int board)
+{
+ struct cyclades_port *info;
+ u32 mailbox;
+ unsigned int nports;
+ unsigned short chip_number;
+ int index, port;
+
+ if (cinfo->num_chips == -1) { /* Cyclades-Z */
+ mailbox = readl(&((struct RUNTIME_9060 __iomem *)
+ cinfo->ctl_addr)->mail_box_0);
+ nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
+ cinfo->intr_enabled = 0;
+ cinfo->nports = 0; /* Will be correctly set later, after
+ Z FW is loaded */
+ spin_lock_init(&cinfo->card_lock);
+ for (port = cinfo->first_line;
+ port < cinfo->first_line + nports; port++) {
+ info = &cy_port[port];
+ info->magic = CYCLADES_MAGIC;
+ info->type = PORT_STARTECH;
+ info->card = board;
+ info->line = port;
+ info->chip_rev = 0;
+ info->flags = STD_COM_FLAGS;
+ info->tty = NULL;
+ if (mailbox == ZO_V1)
+ info->xmit_fifo_size = CYZ_FIFO_SIZE;
+ else
+ info->xmit_fifo_size =
+ 4 * CYZ_FIFO_SIZE;
+ info->cor1 = 0;
+ info->cor2 = 0;
+ info->cor3 = 0;
+ info->cor4 = 0;
+ info->cor5 = 0;
+ info->tbpr = 0;
+ info->tco = 0;
+ info->rbpr = 0;
+ info->rco = 0;
+ info->custom_divisor = 0;
+ info->close_delay = 5 * HZ / 10;
+ info->closing_wait = CLOSING_WAIT_DELAY;
+ info->icount.cts = info->icount.dsr =
+ info->icount.rng = info->icount.dcd = 0;
+ info->icount.rx = info->icount.tx = 0;
+ info->icount.frame = info->icount.parity = 0;
+ info->icount.overrun = info->icount.brk = 0;
+ info->x_char = 0;
+ info->event = 0;
+ info->count = 0;
+ info->blocked_open = 0;
+ info->default_threshold = 0;
+ info->default_timeout = 0;
+ INIT_WORK(&info->tqueue, do_softint);
+ init_waitqueue_head(&info->open_wait);
+ init_waitqueue_head(&info->close_wait);
+ init_waitqueue_head(&info->shutdown_wait);
+ init_waitqueue_head(&info->delta_msr_wait);
+ /* info->session */
+ /* info->pgrp */
+ info->read_status_mask = 0;
+ /* info->timeout */
+ /* Bentson's vars */
+ info->jiffies[0] = 0;
+ info->jiffies[1] = 0;
+ info->jiffies[2] = 0;
+ info->rflush_count = 0;
+#ifdef CONFIG_CYZ_INTR
+ init_timer(&cyz_rx_full_timer[port]);
+ cyz_rx_full_timer[port].function = NULL;
+#endif
+ }
+#ifndef CONFIG_CYZ_INTR
+ if (!timer_pending(&cyz_timerlist)) {
+ mod_timer(&cyz_timerlist, jiffies + 1);
+#ifdef CY_PCI_DEBUG
+ printk("Cyclades-Z polling initialized\n");
+#endif
+ }
+#endif /* CONFIG_CYZ_INTR */
+
+ } else { /* Cyclom-Y of some kind */
+ index = cinfo->bus_index;
+ spin_lock_init(&cinfo->card_lock);
+ cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
+ for (port = cinfo->first_line;
+ port < cinfo->first_line + cinfo->nports; port++) {
+ info = &cy_port[port];
+ info->magic = CYCLADES_MAGIC;
+ info->type = PORT_CIRRUS;
+ info->card = board;
+ info->line = port;
+ info->flags = STD_COM_FLAGS;
+ info->tty = NULL;
+ info->xmit_fifo_size = CyMAX_CHAR_FIFO;
+ info->cor1 =
+ CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
+ info->cor2 = CyETC;
+ info->cor3 = 0x08; /* _very_ small rcv threshold */
+ info->cor4 = 0;
+ info->cor5 = 0;
+ info->custom_divisor = 0;
+ info->close_delay = 5 * HZ / 10;
+ info->closing_wait = CLOSING_WAIT_DELAY;
+ info->icount.cts = info->icount.dsr =
+ info->icount.rng = info->icount.dcd = 0;
+ info->icount.rx = info->icount.tx = 0;
+ info->icount.frame = info->icount.parity = 0;
+ info->icount.overrun = info->icount.brk = 0;
+ chip_number = (port - cinfo->first_line) / 4;
+ if ((info->chip_rev =
+ readb(cinfo->base_addr +
+ (cy_chip_offset[chip_number] <<
+ index) + (CyGFRCR << index))) >=
+ CD1400_REV_J) {
+ /* It is a CD1400 rev. J or later */
+ info->tbpr = baud_bpr_60[13]; /* Tx BPR */
+ info->tco = baud_co_60[13]; /* Tx CO */
+ info->rbpr = baud_bpr_60[13]; /* Rx BPR */
+ info->rco = baud_co_60[13]; /* Rx CO */
+ info->rflow = 0;
+ info->rtsdtr_inv = 1;
+ } else {
+ info->tbpr = baud_bpr_25[13]; /* Tx BPR */
+ info->tco = baud_co_25[13]; /* Tx CO */
+ info->rbpr = baud_bpr_25[13]; /* Rx BPR */
+ info->rco = baud_co_25[13]; /* Rx CO */
+ info->rflow = 0;
+ info->rtsdtr_inv = 0;
+ }
+ info->x_char = 0;
+ info->event = 0;
+ info->count = 0;
+ info->blocked_open = 0;
+ info->default_threshold = 0;
+ info->default_timeout = 0;
+ INIT_WORK(&info->tqueue, do_softint);
+ init_waitqueue_head(&info->open_wait);
+ init_waitqueue_head(&info->close_wait);
+ init_waitqueue_head(&info->shutdown_wait);
+ init_waitqueue_head(&info->delta_msr_wait);
+ /* info->session */
+ /* info->pgrp */
+ info->read_status_mask =
+ CyTIMEOUT | CySPECHAR | CyBREAK
+ | CyPARITY | CyFRAME | CyOVERRUN;
+ /* info->timeout */
+ }
+ }
+}
+
/* initialize chips on Cyclom-Y card -- return number of valid
chips (which is number of ports/4) */
static unsigned short __init
@@ -5300,13 +5453,7 @@ static const struct tty_operations cy_ops = {
static int __init cy_init(void)
{
- struct cyclades_port *info;
- struct cyclades_card *cinfo;
- int number_z_boards = 0;
- int board, port, i, index;
- unsigned long mailbox;
- unsigned short chip_number;
- int nports;
+ unsigned int i;
cy_serial_driver = alloc_tty_driver(NR_PORTS);
if (!cy_serial_driver)
@@ -5369,154 +5516,8 @@ static int __init cy_init(void)
}
/* initialize per-port data structures for each valid board found */
- for (board = 0; board < cy_nboard; board++) {
- cinfo = &cy_card[board];
- if (cinfo->num_chips == -1) { /* Cyclades-Z */
- number_z_boards++;
- mailbox = readl(&((struct RUNTIME_9060 __iomem *)
- cy_card[board].ctl_addr)->
- mail_box_0);
- nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
- cinfo->intr_enabled = 0;
- cinfo->nports = 0; /* Will be correctly set later, after
- Z FW is loaded */
- spin_lock_init(&cinfo->card_lock);
- for (port = cinfo->first_line;
- port < cinfo->first_line + nports; port++) {
- info = &cy_port[port];
- info->magic = CYCLADES_MAGIC;
- info->type = PORT_STARTECH;
- info->card = board;
- info->line = port;
- info->chip_rev = 0;
- info->flags = STD_COM_FLAGS;
- info->tty = NULL;
- if (mailbox == ZO_V1)
- info->xmit_fifo_size = CYZ_FIFO_SIZE;
- else
- info->xmit_fifo_size =
- 4 * CYZ_FIFO_SIZE;
- info->cor1 = 0;
- info->cor2 = 0;
- info->cor3 = 0;
- info->cor4 = 0;
- info->cor5 = 0;
- info->tbpr = 0;
- info->tco = 0;
- info->rbpr = 0;
- info->rco = 0;
- info->custom_divisor = 0;
- info->close_delay = 5 * HZ / 10;
- info->closing_wait = CLOSING_WAIT_DELAY;
- info->icount.cts = info->icount.dsr =
- info->icount.rng = info->icount.dcd = 0;
- info->icount.rx = info->icount.tx = 0;
- info->icount.frame = info->icount.parity = 0;
- info->icount.overrun = info->icount.brk = 0;
- info->x_char = 0;
- info->event = 0;
- info->count = 0;
- info->blocked_open = 0;
- info->default_threshold = 0;
- info->default_timeout = 0;
- INIT_WORK(&info->tqueue, do_softint);
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
- init_waitqueue_head(&info->shutdown_wait);
- init_waitqueue_head(&info->delta_msr_wait);
- /* info->session */
- /* info->pgrp */
- info->read_status_mask = 0;
- /* info->timeout */
- /* Bentson's vars */
- info->jiffies[0] = 0;
- info->jiffies[1] = 0;
- info->jiffies[2] = 0;
- info->rflush_count = 0;
-#ifdef CONFIG_CYZ_INTR
- init_timer(&cyz_rx_full_timer[port]);
- cyz_rx_full_timer[port].function = NULL;
-#endif
- }
- continue;
- } else { /* Cyclom-Y of some kind */
- index = cinfo->bus_index;
- spin_lock_init(&cinfo->card_lock);
- cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips;
- for (port = cinfo->first_line;
- port < cinfo->first_line + cinfo->nports; port++) {
- info = &cy_port[port];
- info->magic = CYCLADES_MAGIC;
- info->type = PORT_CIRRUS;
- info->card = board;
- info->line = port;
- info->flags = STD_COM_FLAGS;
- info->tty = NULL;
- info->xmit_fifo_size = CyMAX_CHAR_FIFO;
- info->cor1 =
- CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS;
- info->cor2 = CyETC;
- info->cor3 = 0x08; /* _very_ small rcv threshold */
- info->cor4 = 0;
- info->cor5 = 0;
- info->custom_divisor = 0;
- info->close_delay = 5 * HZ / 10;
- info->closing_wait = CLOSING_WAIT_DELAY;
- info->icount.cts = info->icount.dsr =
- info->icount.rng = info->icount.dcd = 0;
- info->icount.rx = info->icount.tx = 0;
- info->icount.frame = info->icount.parity = 0;
- info->icount.overrun = info->icount.brk = 0;
- chip_number = (port - cinfo->first_line) / 4;
- if ((info->chip_rev =
- readb(cinfo->base_addr +
- (cy_chip_offset[chip_number] <<
- index) + (CyGFRCR << index))) >=
- CD1400_REV_J) {
- /* It is a CD1400 rev. J or later */
- info->tbpr = baud_bpr_60[13]; /* Tx BPR */
- info->tco = baud_co_60[13]; /* Tx CO */
- info->rbpr = baud_bpr_60[13]; /* Rx BPR */
- info->rco = baud_co_60[13]; /* Rx CO */
- info->rflow = 0;
- info->rtsdtr_inv = 1;
- } else {
- info->tbpr = baud_bpr_25[13]; /* Tx BPR */
- info->tco = baud_co_25[13]; /* Tx CO */
- info->rbpr = baud_bpr_25[13]; /* Rx BPR */
- info->rco = baud_co_25[13]; /* Rx CO */
- info->rflow = 0;
- info->rtsdtr_inv = 0;
- }
- info->x_char = 0;
- info->event = 0;
- info->count = 0;
- info->blocked_open = 0;
- info->default_threshold = 0;
- info->default_timeout = 0;
- INIT_WORK(&info->tqueue, do_softint);
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
- init_waitqueue_head(&info->shutdown_wait);
- init_waitqueue_head(&info->delta_msr_wait);
- /* info->session */
- /* info->pgrp */
- info->read_status_mask =
- CyTIMEOUT | CySPECHAR | CyBREAK
- | CyPARITY | CyFRAME | CyOVERRUN;
- /* info->timeout */
- }
- }
- }
-
-#ifndef CONFIG_CYZ_INTR
- if (number_z_boards) {
- mod_timer(&cyz_timerlist, jiffies + 1);
-#ifdef CY_PCI_DEBUG
- printk("Cyclades-Z polling initialized\n");
-#endif
- }
-#endif /* CONFIG_CYZ_INTR */
+ for (i = 0; i < cy_nboard; i++)
+ cy_init_card(&cy_card[i], i);
return 0;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/11] Char: cyclades, init card struct immediately
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
` (3 preceding siblings ...)
2007-04-18 10:05 ` [PATCH 5/11] Char: cyclades, move card entries init into function Jiri Slaby
@ 2007-04-18 10:05 ` Jiri Slaby
2007-04-18 10:06 ` [PATCH 7/11] Char: cyclades, remove some global vars Jiri Slaby
` (4 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:05 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, init card struct immediately
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 39e37f9c0e50657a546e20c2e37f58e0f260cdf6
tree f67e112b80d616e9d2fc57f35b6e39a45bea81a7
parent de8850dd6c04762688b19609b13cb16a1e6399a9
author Jiri Slaby <jirislaby@gmail.com> Mon, 02 Apr 2007 12:47:57 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:03 +0200
drivers/char/cyclades.c | 37 +++++++++++++++----------------------
1 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index fe967be..2abe6f2 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4834,6 +4834,7 @@ static int __init cy_detect_isa(void)
cy_card[j].bus_index = 0;
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = cy_isa_nchan / 4;
+ cy_init_card(&cy_card[j], j);
nboard++;
/* print message */
@@ -4931,6 +4932,7 @@ static int __devinit cy_init_Ze(unsigned long cy_pci_phys0,
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = -1;
cy_card[j].pdev = pdev;
+ cy_init_card(&cy_card[j], j);
pci_set_drvdata(pdev, &cy_card[j]);
/* print message */
@@ -5080,6 +5082,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = cy_pci_nchan / 4;
cy_card[j].pdev = pdev;
+ cy_init_card(&cy_card[j], j);
pci_set_drvdata(pdev, &cy_card[j]);
/* enable interrupts in the PCI interface */
@@ -5263,6 +5266,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = -1;
cy_card[j].pdev = pdev;
+ cy_init_card(&cy_card[j], j);
pci_set_drvdata(pdev, &cy_card[j]);
/* print message */
@@ -5327,6 +5331,7 @@ static void __devexit cy_pci_release(struct pci_dev *pdev)
{
#ifdef CONFIG_PCI
struct cyclades_card *cinfo = pci_get_drvdata(pdev);
+ unsigned int i;
pci_iounmap(pdev, cinfo->base_addr);
if (cinfo->ctl_addr)
@@ -5340,6 +5345,10 @@ static void __devexit cy_pci_release(struct pci_dev *pdev)
pci_release_regions(pdev);
cinfo->base_addr = NULL;
+ for (i = cinfo->first_line; i < cinfo->first_line + cinfo->nports; i++){
+ cy_port[i].line = -1;
+ cy_port[i].magic = -1;
+ }
#endif
}
@@ -5483,6 +5492,12 @@ static int __init cy_init(void)
cy_card[i].base_addr = NULL;
}
+ /* invalidate remaining cy_port structures */
+ for (i = 0; i < NR_PORTS; i++) {
+ cy_port[i].line = -1;
+ cy_port[i].magic = -1;
+ }
+
/* the code below is responsible to find the boards. Each different
type of board has its own detection routine. If a board is found,
the next cy_card structure available is set by the detection
@@ -5498,29 +5513,7 @@ static int __init cy_init(void)
cy_nboard = cy_isa_nboard + cy_pci_nboard;
- /* invalidate remaining cy_card structures */
- for (i = 0; i < NR_CARDS; i++) {
- if (cy_card[i].base_addr == 0) {
- cy_card[i].first_line = -1;
- cy_card[i].ctl_addr = NULL;
- cy_card[i].irq = 0;
- cy_card[i].bus_index = 0;
- cy_card[i].first_line = 0;
- cy_card[i].num_chips = 0;
- }
- }
- /* invalidate remaining cy_port structures */
- for (i = cy_next_channel; i < NR_PORTS; i++) {
- cy_port[i].line = -1;
- cy_port[i].magic = -1;
- }
-
- /* initialize per-port data structures for each valid board found */
- for (i = 0; i < cy_nboard; i++)
- cy_init_card(&cy_card[i], i);
-
return 0;
-
} /* cy_init */
static void __exit cy_cleanup_module(void)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/11] Char: cyclades, remove some global vars
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
` (4 preceding siblings ...)
2007-04-18 10:05 ` [PATCH 6/11] Char: cyclades, init card struct immediately Jiri Slaby
@ 2007-04-18 10:06 ` Jiri Slaby
2007-04-18 10:06 ` [PATCH 8/11] Char: cyclades, cy_init error handling Jiri Slaby
` (3 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, remove some global vars
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit b1b13ea51dcaef72c5298a04d233b92206adf978
tree a55032090e0b1c40e541685b49f8f608edf60611
parent 39e37f9c0e50657a546e20c2e37f58e0f260cdf6
author Jiri Slaby <jirislaby@gmail.com> Mon, 02 Apr 2007 12:50:04 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:05 +0200
drivers/char/cyclades.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 2abe6f2..1baf7d7 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -818,9 +818,6 @@ static int cy_chip_offset[] = { 0x0000,
/* PCI related definitions */
-static unsigned short cy_pci_nboard;
-static unsigned short cy_isa_nboard;
-static unsigned short cy_nboard;
#ifdef CONFIG_PCI
static struct pci_device_id cy_pci_dev_id[] __devinitdata = {
{ PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Lo) }, /* PCI < 1Mb */
@@ -5462,7 +5459,7 @@ static const struct tty_operations cy_ops = {
static int __init cy_init(void)
{
- unsigned int i;
+ unsigned int i, nboards;
cy_serial_driver = alloc_tty_driver(NR_PORTS);
if (!cy_serial_driver)
@@ -5506,14 +5503,12 @@ static int __init cy_init(void)
the cy_next_channel. */
/* look for isa boards */
- cy_isa_nboard = cy_detect_isa();
+ nboards = cy_detect_isa();
/* look for pci boards */
- cy_pci_nboard = cy_detect_pci();
-
- cy_nboard = cy_isa_nboard + cy_pci_nboard;
+ nboards += cy_detect_pci();
- return 0;
+ return nboards ? 0 : -ENODEV;
} /* cy_init */
static void __exit cy_cleanup_module(void)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 8/11] Char: cyclades, cy_init error handling
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
` (5 preceding siblings ...)
2007-04-18 10:06 ` [PATCH 7/11] Char: cyclades, remove some global vars Jiri Slaby
@ 2007-04-18 10:06 ` Jiri Slaby
2007-04-18 10:07 ` [PATCH 9/11] Char: cyclades, tty_register_device separately for each device Jiri Slaby
` (2 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:06 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, cy_init error handling
- do not panic if tty_register_driver fails
- handle fail paths properly
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 8c76c370ee1c1efa31f64807162c15922fae1e3a
tree 19fe12eba568aece1d0b406a4d735f393f2cd3dd
parent b1b13ea51dcaef72c5298a04d233b92206adf978
author Jiri Slaby <jirislaby@gmail.com> Mon, 02 Apr 2007 15:47:49 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:06 +0200
drivers/char/cyclades.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 1baf7d7..22f8ec4 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -5460,10 +5460,11 @@ static const struct tty_operations cy_ops = {
static int __init cy_init(void)
{
unsigned int i, nboards;
+ int retval = -ENOMEM;
cy_serial_driver = alloc_tty_driver(NR_PORTS);
if (!cy_serial_driver)
- return -ENOMEM;
+ goto err;
show_version();
/* Initialize the tty_driver structure */
@@ -5481,8 +5482,11 @@ static int __init cy_init(void)
cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(cy_serial_driver, &cy_ops);
- if (tty_register_driver(cy_serial_driver))
- panic("Couldn't register Cyclades serial driver\n");
+ retval = tty_register_driver(cy_serial_driver);
+ if (retval) {
+ printk(KERN_ERR "Couldn't register Cyclades serial driver\n");
+ goto err_frtty;
+ }
for (i = 0; i < NR_CARDS; i++) {
/* base_addr=0 indicates board not found */
@@ -5508,7 +5512,18 @@ static int __init cy_init(void)
/* look for pci boards */
nboards += cy_detect_pci();
- return nboards ? 0 : -ENODEV;
+ if (nboards == 0) {
+ retval = -ENODEV;
+ goto err_unr;
+ }
+
+ return 0;
+err_unr:
+ tty_unregister_driver(cy_serial_driver);
+err_frtty:
+ put_tty_driver(cy_serial_driver);
+err:
+ return retval;
} /* cy_init */
static void __exit cy_cleanup_module(void)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 9/11] Char: cyclades, tty_register_device separately for each device
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
` (6 preceding siblings ...)
2007-04-18 10:06 ` [PATCH 8/11] Char: cyclades, cy_init error handling Jiri Slaby
@ 2007-04-18 10:07 ` Jiri Slaby
2007-04-18 10:07 ` [PATCH 10/11] Char: cyclades, clear interrupts before releasing Jiri Slaby
2007-04-18 10:08 ` [PATCH 11/11] Char: cyclades, allow DEBUG_SHIRQ Jiri Slaby
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:07 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, tty_register_device separately for each device
Do not register all tty devices at the init time, delay it for the time
until some device is found.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit ad4f792b92f8e6350a62b61442bb6812969bfd73
tree de126dc99bbafbb15d3fc7c96211e9648f4de354
parent 8c76c370ee1c1efa31f64807162c15922fae1e3a
author Jiri Slaby <jirislaby@gmail.com> Thu, 05 Apr 2007 17:44:51 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:07 +0200
drivers/char/cyclades.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 22f8ec4..0c2c120 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4841,6 +4841,9 @@ static int __init cy_detect_isa(void)
cy_isa_irq);
printk("%d channels starting from port %d.\n",
cy_isa_nchan, cy_next_channel);
+ for (j = cy_next_channel;
+ j < cy_next_channel + cy_isa_nchan; j++)
+ tty_register_device(cy_serial_driver, j, NULL);
cy_next_channel += cy_isa_nchan;
}
return nboard;
@@ -4948,6 +4951,8 @@ static int __devinit cy_init_Ze(unsigned long cy_pci_phys0,
printk("%d channels starting from port %d.\n",
cy_pci_nchan, cy_next_channel);
+ for (j = cy_next_channel; j < cy_next_channel + cy_pci_nchan; j++)
+ tty_register_device(cy_serial_driver, j, &pdev->dev);
cy_next_channel += cy_pci_nchan;
return 0;
@@ -5115,6 +5120,9 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
(int)cy_pci_irq);
printk("%d channels starting from port %d.\n",
cy_pci_nchan, cy_next_channel);
+ for (j = cy_next_channel;
+ j < cy_next_channel + cy_pci_nchan; j++)
+ tty_register_device(cy_serial_driver, j, &pdev->dev);
cy_next_channel += cy_pci_nchan;
} else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) {
@@ -5282,6 +5290,9 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
printk("%d channels starting from port %d.\n",
cy_pci_nchan, cy_next_channel);
+ for (j = cy_next_channel;
+ j < cy_next_channel + cy_pci_nchan; j++)
+ tty_register_device(cy_serial_driver, j, &pdev->dev);
cy_next_channel += cy_pci_nchan;
}
@@ -5346,6 +5357,9 @@ static void __devexit cy_pci_release(struct pci_dev *pdev)
cy_port[i].line = -1;
cy_port[i].magic = -1;
}
+ for (i = cinfo->first_line; i < cinfo->first_line +
+ cinfo->nports; i++)
+ tty_unregister_device(cy_serial_driver, i);
#endif
}
@@ -5479,7 +5493,7 @@ static int __init cy_init(void)
cy_serial_driver->init_termios = tty_std_termios;
cy_serial_driver->init_termios.c_cflag =
B9600 | CS8 | CREAD | HUPCL | CLOCAL;
- cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
+ cy_serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
tty_set_operations(cy_serial_driver, &cy_ops);
retval = tty_register_driver(cy_serial_driver);
@@ -5555,6 +5569,10 @@ static void __exit cy_cleanup_module(void)
#endif /* CONFIG_CYZ_INTR */
)
free_irq(cy_card[i].irq, &cy_card[i]);
+ for (e1 = cy_card[i].first_line;
+ e1 < cy_card[i].first_line +
+ cy_card[i].nports; e1++)
+ tty_unregister_device(cy_serial_driver, e1);
}
}
} /* cy_cleanup_module */
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 10/11] Char: cyclades, clear interrupts before releasing
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
` (7 preceding siblings ...)
2007-04-18 10:07 ` [PATCH 9/11] Char: cyclades, tty_register_device separately for each device Jiri Slaby
@ 2007-04-18 10:07 ` Jiri Slaby
2007-04-20 4:51 ` Andrew Morton
2007-04-18 10:08 ` [PATCH 11/11] Char: cyclades, allow DEBUG_SHIRQ Jiri Slaby
9 siblings, 1 reply; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:07 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, clear interrupts before releasing
Without this patch, the driver sometimes causes "IRQXX: Nobody cares". Fix
it by turning off irqs when releasing.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 0156510dee9d326af2ec52cf8b1a388ce9a839e9
tree 29d863d5eca58913c306bc8cd9a6b3a5dcef01fe
parent ad4f792b92f8e6350a62b61442bb6812969bfd73
author Jiri Slaby <jirislaby@gmail.com> Thu, 05 Apr 2007 18:26:08 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:09 +0200
drivers/char/cyclades.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 0c2c120..5a9e7d6 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -5341,6 +5341,17 @@ static void __devexit cy_pci_release(struct pci_dev *pdev)
struct cyclades_card *cinfo = pci_get_drvdata(pdev);
unsigned int i;
+ /* non-Z with old PLX */
+ if (cinfo->num_chips != -1 && (readb(cinfo->base_addr + CyPLX_VER) &
+ 0x0f) == PLX_9050)
+ cy_writeb(cinfo->ctl_addr + 0x4c, 0);
+ else
+#ifndef CONFIG_CYZ_INTR
+ if (cinfo->num_chips != -1)
+#endif
+ cy_writew(cinfo->ctl_addr + 0x68,
+ readw(cinfo->ctl_addr + 0x68) & ~0x0900);
+
pci_iounmap(pdev, cinfo->base_addr);
if (cinfo->ctl_addr)
pci_iounmap(pdev, cinfo->ctl_addr);
@@ -5560,6 +5571,8 @@ static void __exit cy_cleanup_module(void)
cy_pci_release(cy_card[i].pdev);
continue;
}
+ /* clear interrupt */
+ cy_writeb(cy_card[i].base_addr + Cy_ClrIntr, 0);
iounmap(cy_card[i].base_addr);
if (cy_card[i].ctl_addr)
iounmap(cy_card[i].ctl_addr);
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 11/11] Char: cyclades, allow DEBUG_SHIRQ
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
` (8 preceding siblings ...)
2007-04-18 10:07 ` [PATCH 10/11] Char: cyclades, clear interrupts before releasing Jiri Slaby
@ 2007-04-18 10:08 ` Jiri Slaby
9 siblings, 0 replies; 12+ messages in thread
From: Jiri Slaby @ 2007-04-18 10:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
cyclades, allow DEBUG_SHIRQ
Test if base addr is non-null in ISR to prove the card has been correctly
initialized. This is needed for DEBUG_SHIRQ for example.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
commit 71c2e9b72594f69e4e226006206ffa74b55c1642
tree 0134ea3532474f2c7bc2deabcf453b83f0747e5f
parent 73621a789a0482299242ea61c971af6b5f8b828a
author Jiri Slaby <jirislaby@gmail.com> Wed, 18 Apr 2007 11:59:22 +0200
committer Jiri Slaby <jirislaby@gmail.com> Wed, 18 Apr 2007 11:59:22 +0200
drivers/char/cyclades.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 5a9e7d6..5d6559e 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1444,6 +1444,10 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
card_base_addr = cinfo->base_addr;
index = cinfo->bus_index;
+ /* card was not initialized yet (e.g. DEBUG_SHIRQ) */
+ if (unlikely(card_base_addr == NULL))
+ return IRQ_HANDLED;
+
/* This loop checks all chips in the card. Make a note whenever
_any_ chip had some work to do, as this is considered an
indication that there will be more to do. Only when no chip
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 10/11] Char: cyclades, clear interrupts before releasing
2007-04-18 10:07 ` [PATCH 10/11] Char: cyclades, clear interrupts before releasing Jiri Slaby
@ 2007-04-20 4:51 ` Andrew Morton
0 siblings, 0 replies; 12+ messages in thread
From: Andrew Morton @ 2007-04-20 4:51 UTC (permalink / raw)
To: Jiri Slaby; +Cc: linux-kernel
On Wed, 18 Apr 2007 12:07:56 +0200 (CEST) Jiri Slaby <jirislaby@gmail.com> wrote:
> + /* non-Z with old PLX */
> + if (cinfo->num_chips != -1 && (readb(cinfo->base_addr + CyPLX_VER) &
> + 0x0f) == PLX_9050)
> + cy_writeb(cinfo->ctl_addr + 0x4c, 0);
> + else
> +#ifndef CONFIG_CYZ_INTR
> + if (cinfo->num_chips != -1)
> +#endif
> + cy_writew(cinfo->ctl_addr + 0x68,
> + readw(cinfo->ctl_addr + 0x68) & ~0x0900);
well that a bit nasty.
We already have that IS_CYC_Z() thing. Perhaps we could turn that into a nice
lowercase-named C function and provide a CONFIG_CYZ_INTR=y version which
does `return 1'. Or something like that.
But the above is, umm, inconsistent with the cleanups you've been doing ;)
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2007-04-20 4:51 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
2007-04-18 10:03 ` [PATCH 2/11] Char: cyclades, use pci_iomap/unmap Jiri Slaby
2007-04-18 10:04 ` [PATCH 3/11] Char: cyclades, init Ze immediately Jiri Slaby
2007-04-18 10:04 ` [PATCH 4/11] Char: cyclades, create cy_pci_probe Jiri Slaby
2007-04-18 10:05 ` [PATCH 5/11] Char: cyclades, move card entries init into function Jiri Slaby
2007-04-18 10:05 ` [PATCH 6/11] Char: cyclades, init card struct immediately Jiri Slaby
2007-04-18 10:06 ` [PATCH 7/11] Char: cyclades, remove some global vars Jiri Slaby
2007-04-18 10:06 ` [PATCH 8/11] Char: cyclades, cy_init error handling Jiri Slaby
2007-04-18 10:07 ` [PATCH 9/11] Char: cyclades, tty_register_device separately for each device Jiri Slaby
2007-04-18 10:07 ` [PATCH 10/11] Char: cyclades, clear interrupts before releasing Jiri Slaby
2007-04-20 4:51 ` Andrew Morton
2007-04-18 10:08 ` [PATCH 11/11] Char: cyclades, allow DEBUG_SHIRQ Jiri Slaby
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.