aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorSergei Shtylyov <sshtylyov@ru.mvista.com>2009-06-15 12:52:57 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-06-15 12:52:57 -0400
commiteba8999cefb6b61704d8fa825b7694825a087765 (patch)
treee5f7d1ed464efe21160b425e8a57b017b9e99441 /drivers/ide
parent74414a91204ee57528041f771da1fd1ee3ba64c4 (diff)
ide: move IRQ clearing from ack_intr() method to clear_irq() method (take 2)
There are now two methods that clear the port interrupt: ack_intr() method, implemented only on M680x0 machines, that is called at the start of ide_intr(), and clear_irq() method, that is called somewhat later in this function. In order to stop this duplication, delegate the task of clearing the interrupt to clear_irq() method, only leaving to ack_intr() the task of testing for the port interrupt. Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/buddha.c27
-rw-r--r--drivers/ide/gayle.c23
-rw-r--r--drivers/ide/ide-io.c2
-rw-r--r--drivers/ide/macide.c18
4 files changed, 38 insertions, 32 deletions
diff --git a/drivers/ide/buddha.c b/drivers/ide/buddha.c
index e3c6a5913305..9cd7b115763d 100644
--- a/drivers/ide/buddha.c
+++ b/drivers/ide/buddha.c
@@ -109,16 +109,12 @@ static int buddha_ack_intr(ide_hwif_t *hwif)
109 return 1; 109 return 1;
110} 110}
111 111
112static int xsurf_ack_intr(ide_hwif_t *hwif) 112static void xsurf_clear_irq(ide_drive_t *drive)
113{ 113{
114 unsigned char ch; 114 /*
115 115 * X-Surf needs 0 written to IRQ register to ensure ISA bit A11 stays at 0
116 ch = z_readb(hwif->io_ports.irq_addr); 116 */
117 /* X-Surf needs a 0 written to IRQ register to ensure ISA bit A11 stays at 0 */ 117 z_writeb(0, drive->hwif->io_ports.irq_addr);
118 z_writeb(0, hwif->io_ports.irq_addr);
119 if (!(ch & 0x80))
120 return 0;
121 return 1;
122} 118}
123 119
124static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base, 120static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base,
@@ -141,6 +137,10 @@ static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base,
141 hw->ack_intr = ack_intr; 137 hw->ack_intr = ack_intr;
142} 138}
143 139
140static const struct ide_port_ops xsurf_port_ops = {
141 .clear_irq = xsurf_clear_irq,
142};
143
144static const struct ide_port_info buddha_port_info = { 144static const struct ide_port_info buddha_port_info = {
145 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 145 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
146 .irq_flags = IRQF_SHARED, 146 .irq_flags = IRQF_SHARED,
@@ -161,6 +161,7 @@ static int __init buddha_init(void)
161 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { 161 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
162 unsigned long board; 162 unsigned long board;
163 struct ide_hw hw[MAX_NUM_HWIFS], *hws[MAX_NUM_HWIFS]; 163 struct ide_hw hw[MAX_NUM_HWIFS], *hws[MAX_NUM_HWIFS];
164 struct ide_port_info d = buddha_port_info;
164 165
165 if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { 166 if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
166 buddha_num_hwifs = BUDDHA_NUM_HWIFS; 167 buddha_num_hwifs = BUDDHA_NUM_HWIFS;
@@ -171,6 +172,7 @@ static int __init buddha_init(void)
171 } else if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF) { 172 } else if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF) {
172 buddha_num_hwifs = XSURF_NUM_HWIFS; 173 buddha_num_hwifs = XSURF_NUM_HWIFS;
173 type=BOARD_XSURF; 174 type=BOARD_XSURF;
175 d.port_ops = &xsurf_port_ops;
174 } else 176 } else
175 continue; 177 continue;
176 178
@@ -203,28 +205,25 @@ fail_base2:
203 205
204 for (i = 0; i < buddha_num_hwifs; i++) { 206 for (i = 0; i < buddha_num_hwifs; i++) {
205 unsigned long base, ctl, irq_port; 207 unsigned long base, ctl, irq_port;
206 ide_ack_intr_t *ack_intr;
207 208
208 if (type != BOARD_XSURF) { 209 if (type != BOARD_XSURF) {
209 base = buddha_board + buddha_bases[i]; 210 base = buddha_board + buddha_bases[i];
210 ctl = base + BUDDHA_CONTROL; 211 ctl = base + BUDDHA_CONTROL;
211 irq_port = buddha_board + buddha_irqports[i]; 212 irq_port = buddha_board + buddha_irqports[i];
212 ack_intr = buddha_ack_intr;
213 } else { 213 } else {
214 base = buddha_board + xsurf_bases[i]; 214 base = buddha_board + xsurf_bases[i];
215 /* X-Surf has no CS1* (Control/AltStat) */ 215 /* X-Surf has no CS1* (Control/AltStat) */
216 ctl = 0; 216 ctl = 0;
217 irq_port = buddha_board + xsurf_irqports[i]; 217 irq_port = buddha_board + xsurf_irqports[i];
218 ack_intr = xsurf_ack_intr;
219 } 218 }
220 219
221 buddha_setup_ports(&hw[i], base, ctl, irq_port, 220 buddha_setup_ports(&hw[i], base, ctl, irq_port,
222 ack_intr); 221 buddha_ack_intr);
223 222
224 hws[i] = &hw[i]; 223 hws[i] = &hw[i];
225 } 224 }
226 225
227 ide_host_add(&buddha_port_info, hws, i, NULL); 226 ide_host_add(&d, hws, i, NULL);
228 } 227 }
229 228
230 return 0; 229 return 0;
diff --git a/drivers/ide/gayle.c b/drivers/ide/gayle.c
index 4451a6a5dfe0..c5dd1e5cca4d 100644
--- a/drivers/ide/gayle.c
+++ b/drivers/ide/gayle.c
@@ -66,7 +66,7 @@ MODULE_PARM_DESC(doubler, "enable support for IDE doublers");
66 * Check and acknowledge the interrupt status 66 * Check and acknowledge the interrupt status
67 */ 67 */
68 68
69static int gayle_ack_intr_a4000(ide_hwif_t *hwif) 69static int gayle_ack_intr(ide_hwif_t *hwif)
70{ 70{
71 unsigned char ch; 71 unsigned char ch;
72 72
@@ -76,16 +76,12 @@ static int gayle_ack_intr_a4000(ide_hwif_t *hwif)
76 return 1; 76 return 1;
77} 77}
78 78
79static int gayle_ack_intr_a1200(ide_hwif_t *hwif) 79static void gayle_a1200_clear_irq(ide_drive_t *drive)
80{ 80{
81 unsigned char ch; 81 ide_hwif_t *hwif = drive->hwif;
82 82
83 ch = z_readb(hwif->io_ports.irq_addr);
84 if (!(ch & GAYLE_IRQ_IDE))
85 return 0;
86 (void)z_readb(hwif->io_ports.status_addr); 83 (void)z_readb(hwif->io_ports.status_addr);
87 z_writeb(0x7c, hwif->io_ports.irq_addr); 84 z_writeb(0x7c, hwif->io_ports.irq_addr);
88 return 1;
89} 85}
90 86
91static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base, 87static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base,
@@ -108,6 +104,10 @@ static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base,
108 hw->ack_intr = ack_intr; 104 hw->ack_intr = ack_intr;
109} 105}
110 106
107static const struct ide_port_ops gayle_a1200_port_ops = {
108 .clear_irq = gayle_a1200_clear_irq,
109};
110
111static const struct ide_port_info gayle_port_info = { 111static const struct ide_port_info gayle_port_info = {
112 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | 112 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
113 IDE_HFLAG_NO_DMA, 113 IDE_HFLAG_NO_DMA,
@@ -123,9 +123,9 @@ static int __init gayle_init(void)
123{ 123{
124 unsigned long phys_base, res_start, res_n; 124 unsigned long phys_base, res_start, res_n;
125 unsigned long base, ctrlport, irqport; 125 unsigned long base, ctrlport, irqport;
126 ide_ack_intr_t *ack_intr;
127 int a4000, i, rc; 126 int a4000, i, rc;
128 struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS]; 127 struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS];
128 struct ide_port_info d = gayle_port_info;
129 129
130 if (!MACH_IS_AMIGA) 130 if (!MACH_IS_AMIGA)
131 return -ENODEV; 131 return -ENODEV;
@@ -148,11 +148,10 @@ found:
148 if (a4000) { 148 if (a4000) {
149 phys_base = GAYLE_BASE_4000; 149 phys_base = GAYLE_BASE_4000;
150 irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000); 150 irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000);
151 ack_intr = gayle_ack_intr_a4000;
152 } else { 151 } else {
153 phys_base = GAYLE_BASE_1200; 152 phys_base = GAYLE_BASE_1200;
154 irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_1200); 153 irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_1200);
155 ack_intr = gayle_ack_intr_a1200; 154 d.port_ops = &gayle_a1200_port_ops;
156 } 155 }
157 156
158 res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1); 157 res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1);
@@ -165,12 +164,12 @@ found:
165 base = (unsigned long)ZTWO_VADDR(phys_base + i * GAYLE_NEXT_PORT); 164 base = (unsigned long)ZTWO_VADDR(phys_base + i * GAYLE_NEXT_PORT);
166 ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; 165 ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0;
167 166
168 gayle_setup_ports(&hw[i], base, ctrlport, irqport, ack_intr); 167 gayle_setup_ports(&hw[i], base, ctrlport, irqport, gayle_ack_intr);
169 168
170 hws[i] = &hw[i]; 169 hws[i] = &hw[i];
171 } 170 }
172 171
173 rc = ide_host_add(&gayle_port_info, hws, i, NULL); 172 rc = ide_host_add(&d, hws, i, NULL);
174 if (rc) 173 if (rc)
175 release_mem_region(res_start, res_n); 174 release_mem_region(res_start, res_n);
176 175
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index c569d56eadc6..9e53efe9fb2d 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -683,8 +683,6 @@ void ide_timer_expiry (unsigned long data)
683 } else if (drive_is_ready(drive)) { 683 } else if (drive_is_ready(drive)) {
684 if (drive->waiting_for_dma) 684 if (drive->waiting_for_dma)
685 hwif->dma_ops->dma_lost_irq(drive); 685 hwif->dma_ops->dma_lost_irq(drive);
686 if (hwif->ack_intr)
687 hwif->ack_intr(hwif);
688 if (hwif->port_ops && hwif->port_ops->clear_irq) 686 if (hwif->port_ops && hwif->port_ops->clear_irq)
689 hwif->port_ops->clear_irq(drive); 687 hwif->port_ops->clear_irq(drive);
690 688
diff --git a/drivers/ide/macide.c b/drivers/ide/macide.c
index 1447c8c90565..05cdab35a75c 100644
--- a/drivers/ide/macide.c
+++ b/drivers/ide/macide.c
@@ -55,13 +55,16 @@ volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR);
55 55
56int macide_ack_intr(ide_hwif_t* hwif) 56int macide_ack_intr(ide_hwif_t* hwif)
57{ 57{
58 if (*ide_ifr & 0x20) { 58 if (*ide_ifr & 0x20)
59 *ide_ifr &= ~0x20;
60 return 1; 59 return 1;
61 }
62 return 0; 60 return 0;
63} 61}
64 62
63static void macide_clear_irq(ide_drive_t *drive)
64{
65 *ide_ifr &= ~0x20;
66}
67
65static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base, 68static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
66 int irq, ide_ack_intr_t *ack_intr) 69 int irq, ide_ack_intr_t *ack_intr)
67{ 70{
@@ -78,7 +81,12 @@ static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
78 hw->ack_intr = ack_intr; 81 hw->ack_intr = ack_intr;
79} 82}
80 83
84static const struct ide_port_ops macide_port_ops = {
85 .clear_irq = macide_clear_irq,
86};
87
81static const struct ide_port_info macide_port_info = { 88static const struct ide_port_info macide_port_info = {
89 .port_ops = &macide_port_ops,
82 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 90 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
83 .irq_flags = IRQF_SHARED, 91 .irq_flags = IRQF_SHARED,
84 .chipset = ide_generic, 92 .chipset = ide_generic,
@@ -97,6 +105,7 @@ static int __init macide_init(void)
97 unsigned long base; 105 unsigned long base;
98 int irq; 106 int irq;
99 struct ide_hw hw, *hws[] = { &hw }; 107 struct ide_hw hw, *hws[] = { &hw };
108 struct ide_port_info d = macide_port_info;
100 109
101 if (!MACH_IS_MAC) 110 if (!MACH_IS_MAC)
102 return -ENODEV; 111 return -ENODEV;
@@ -115,6 +124,7 @@ static int __init macide_init(void)
115 case MAC_IDE_BABOON: 124 case MAC_IDE_BABOON:
116 base = BABOON_BASE; 125 base = BABOON_BASE;
117 ack_intr = NULL; 126 ack_intr = NULL;
127 d.port_ops = NULL;
118 irq = IRQ_BABOON_1; 128 irq = IRQ_BABOON_1;
119 break; 129 break;
120 default: 130 default:
@@ -126,7 +136,7 @@ static int __init macide_init(void)
126 136
127 macide_setup_ports(&hw, base, irq, ack_intr); 137 macide_setup_ports(&hw, base, irq, ack_intr);
128 138
129 return ide_host_add(&macide_port_info, hws, 1, NULL); 139 return ide_host_add(&d, hws, 1, NULL);
130} 140}
131 141
132module_init(macide_init); 142module_init(macide_init);