diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2007-05-08 03:36:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:23 -0400 |
commit | d407c78188c718c00e997ce7f8b8d45e92ee2dd6 (patch) | |
tree | 8a0a4103bbbc9fbc59f6002fb10697dd1d11d338 /drivers/char/cyclades.c | |
parent | 7e92b4fc345f5b6f57585fbe5ffdb0f24d7c9b26 (diff) |
Char: 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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/cyclades.c')
-rw-r--r-- | 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 962a36303d5e..1430e136d44d 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -4711,6 +4711,92 @@ static void plx_init(void __iomem * addr, __u32 initctl) | |||
4711 | cy_writel(addr + initctl, readl(addr + initctl) & ~0x20000000); | 4711 | cy_writel(addr + initctl, readl(addr + initctl) & ~0x20000000); |
4712 | } | 4712 | } |
4713 | 4713 | ||
4714 | static int __devinit cy_init_Ze(unsigned long cy_pci_phys0, | ||
4715 | unsigned long cy_pci_phys2, | ||
4716 | struct RUNTIME_9060 __iomem *cy_pci_addr0, | ||
4717 | void __iomem *cy_pci_addr2, int cy_pci_irq, | ||
4718 | struct pci_dev *pdev) | ||
4719 | { | ||
4720 | unsigned int j; | ||
4721 | unsigned short cy_pci_nchan; | ||
4722 | |||
4723 | readl(&cy_pci_addr0->mail_box_0); | ||
4724 | #ifdef CY_PCI_DEBUG | ||
4725 | printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", | ||
4726 | (ulong)cy_pci_addr2, (ulong)cy_pci_addr0); | ||
4727 | printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not " | ||
4728 | "loaded\n"); | ||
4729 | #endif | ||
4730 | /* This must be the new Cyclades-Ze/PCI. */ | ||
4731 | cy_pci_nchan = ZE_V1_NPORTS; | ||
4732 | |||
4733 | if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) { | ||
4734 | printk("Cyclades-Ze/PCI found at 0x%lx but no channels " | ||
4735 | "are available.\nChange NR_PORTS in cyclades.c " | ||
4736 | "and recompile kernel.\n", | ||
4737 | (ulong) cy_pci_phys2); | ||
4738 | return -EIO; | ||
4739 | } | ||
4740 | |||
4741 | /* fill the next cy_card structure available */ | ||
4742 | for (j = 0; j < NR_CARDS; j++) { | ||
4743 | if (cy_card[j].base_addr == 0) | ||
4744 | break; | ||
4745 | } | ||
4746 | if (j == NR_CARDS) { /* no more cy_cards available */ | ||
4747 | printk("Cyclades-Ze/PCI found at 0x%lx but no more " | ||
4748 | "cards can be used.\nChange NR_CARDS in " | ||
4749 | "cyclades.c and recompile kernel.\n", | ||
4750 | (ulong) cy_pci_phys2); | ||
4751 | return -EIO; | ||
4752 | } | ||
4753 | #ifdef CONFIG_CYZ_INTR | ||
4754 | /* allocate IRQ only if board has an IRQ */ | ||
4755 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) { | ||
4756 | if (request_irq(cy_pci_irq, cyz_interrupt, | ||
4757 | IRQF_SHARED, "Cyclades-Z", | ||
4758 | &cy_card[j])) { | ||
4759 | printk("Cyclom-Ze/PCI found at 0x%lx ", | ||
4760 | (ulong) cy_pci_phys2); | ||
4761 | printk("but could not allocate IRQ%d.\n", | ||
4762 | cy_pci_irq); | ||
4763 | return -EIO; | ||
4764 | } | ||
4765 | } | ||
4766 | #endif /* CONFIG_CYZ_INTR */ | ||
4767 | |||
4768 | /* set cy_card */ | ||
4769 | cy_card[j].base_phys = cy_pci_phys2; | ||
4770 | cy_card[j].ctl_phys = cy_pci_phys0; | ||
4771 | cy_card[j].base_addr = cy_pci_addr2; | ||
4772 | cy_card[j].ctl_addr = cy_pci_addr0; | ||
4773 | cy_card[j].irq = (int)cy_pci_irq; | ||
4774 | cy_card[j].bus_index = 1; | ||
4775 | cy_card[j].first_line = cy_next_channel; | ||
4776 | cy_card[j].num_chips = -1; | ||
4777 | cy_card[j].pdev = pdev; | ||
4778 | |||
4779 | /* print message */ | ||
4780 | #ifdef CONFIG_CYZ_INTR | ||
4781 | /* don't report IRQ if board is no IRQ */ | ||
4782 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) | ||
4783 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", | ||
4784 | j + 1, (ulong) cy_pci_phys2, | ||
4785 | (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1), | ||
4786 | (int)cy_pci_irq); | ||
4787 | else | ||
4788 | #endif /* CONFIG_CYZ_INTR */ | ||
4789 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ", | ||
4790 | j + 1, (ulong) cy_pci_phys2, | ||
4791 | (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1)); | ||
4792 | |||
4793 | printk("%d channels starting from port %d.\n", | ||
4794 | cy_pci_nchan, cy_next_channel); | ||
4795 | cy_next_channel += cy_pci_nchan; | ||
4796 | |||
4797 | return 0; | ||
4798 | } | ||
4799 | |||
4714 | /* | 4800 | /* |
4715 | * --------------------------------------------------------------------- | 4801 | * --------------------------------------------------------------------- |
4716 | * cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI. | 4802 | * cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI. |
@@ -4734,6 +4820,7 @@ static int __init cy_detect_pci(void) | |||
4734 | __u32 Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS]; | 4820 | __u32 Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS]; |
4735 | unsigned char Ze_irq[NR_CARDS]; | 4821 | unsigned char Ze_irq[NR_CARDS]; |
4736 | struct pci_dev *Ze_pdev[NR_CARDS]; | 4822 | struct pci_dev *Ze_pdev[NR_CARDS]; |
4823 | int retval; | ||
4737 | 4824 | ||
4738 | for (i = 0; i < NR_CARDS; i++) { | 4825 | for (i = 0; i < NR_CARDS; i++) { |
4739 | /* look for a Cyclades card by vendor and device id */ | 4826 | /* look for a Cyclades card by vendor and device id */ |
@@ -5095,80 +5182,10 @@ static int __init cy_detect_pci(void) | |||
5095 | Ze_pdev[j] = Ze_pdev[j + 1]; | 5182 | Ze_pdev[j] = Ze_pdev[j + 1]; |
5096 | } | 5183 | } |
5097 | ZeIndex--; | 5184 | ZeIndex--; |
5098 | mailbox = (__u32)readl(&((struct RUNTIME_9060 __iomem *) | 5185 | retval = cy_init_Ze(cy_pci_phys0, cy_pci_phys2, cy_pci_addr0, |
5099 | cy_pci_addr0)->mail_box_0); | 5186 | cy_pci_addr2, cy_pci_irq, pdev); |
5100 | #ifdef CY_PCI_DEBUG | 5187 | if (retval < 0) |
5101 | printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", | ||
5102 | (ulong)cy_pci_addr2, (ulong)cy_pci_addr0); | ||
5103 | printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not " | ||
5104 | "loaded\n"); | ||
5105 | #endif | ||
5106 | /* This must be the new Cyclades-Ze/PCI. */ | ||
5107 | cy_pci_nchan = ZE_V1_NPORTS; | ||
5108 | |||
5109 | if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) { | ||
5110 | printk("Cyclades-Ze/PCI found at 0x%lx but no channels " | ||
5111 | "are available.\nChange NR_PORTS in cyclades.c " | ||
5112 | "and recompile kernel.\n", | ||
5113 | (ulong) cy_pci_phys2); | ||
5114 | return i; | ||
5115 | } | ||
5116 | |||
5117 | /* fill the next cy_card structure available */ | ||
5118 | for (j = 0; j < NR_CARDS; j++) { | ||
5119 | if (cy_card[j].base_addr == 0) | ||
5120 | break; | ||
5121 | } | ||
5122 | if (j == NR_CARDS) { /* no more cy_cards available */ | ||
5123 | printk("Cyclades-Ze/PCI found at 0x%lx but no more " | ||
5124 | "cards can be used.\nChange NR_CARDS in " | ||
5125 | "cyclades.c and recompile kernel.\n", | ||
5126 | (ulong) cy_pci_phys2); | ||
5127 | return i; | 5188 | return i; |
5128 | } | ||
5129 | #ifdef CONFIG_CYZ_INTR | ||
5130 | /* allocate IRQ only if board has an IRQ */ | ||
5131 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) { | ||
5132 | if (request_irq(cy_pci_irq, cyz_interrupt, | ||
5133 | IRQF_SHARED, "Cyclades-Z", | ||
5134 | &cy_card[j])) { | ||
5135 | printk("Cyclom-Ze/PCI found at 0x%lx ", | ||
5136 | (ulong) cy_pci_phys2); | ||
5137 | printk("but could not allocate IRQ%d.\n", | ||
5138 | cy_pci_irq); | ||
5139 | return i; | ||
5140 | } | ||
5141 | } | ||
5142 | #endif /* CONFIG_CYZ_INTR */ | ||
5143 | |||
5144 | /* set cy_card */ | ||
5145 | cy_card[j].base_phys = cy_pci_phys2; | ||
5146 | cy_card[j].ctl_phys = cy_pci_phys0; | ||
5147 | cy_card[j].base_addr = cy_pci_addr2; | ||
5148 | cy_card[j].ctl_addr = cy_pci_addr0; | ||
5149 | cy_card[j].irq = (int)cy_pci_irq; | ||
5150 | cy_card[j].bus_index = 1; | ||
5151 | cy_card[j].first_line = cy_next_channel; | ||
5152 | cy_card[j].num_chips = -1; | ||
5153 | cy_card[j].pdev = pdev; | ||
5154 | |||
5155 | /* print message */ | ||
5156 | #ifdef CONFIG_CYZ_INTR | ||
5157 | /* don't report IRQ if board is no IRQ */ | ||
5158 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) | ||
5159 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", | ||
5160 | j + 1, (ulong) cy_pci_phys2, | ||
5161 | (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1), | ||
5162 | (int)cy_pci_irq); | ||
5163 | else | ||
5164 | #endif /* CONFIG_CYZ_INTR */ | ||
5165 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ", | ||
5166 | j + 1, (ulong) cy_pci_phys2, | ||
5167 | (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1)); | ||
5168 | |||
5169 | printk("%d channels starting from port %d.\n", | ||
5170 | cy_pci_nchan, cy_next_channel); | ||
5171 | cy_next_channel += cy_pci_nchan; | ||
5172 | } | 5189 | } |
5173 | if (ZeIndex != 0) { | 5190 | if (ZeIndex != 0) { |
5174 | printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be " | 5191 | printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be " |