1414 * Wax ASIC also includes a PS/2 and RS-232 controller, but those are
1515 * dealt with elsewhere; this file is concerned only with the EISA portions
1616 * of Wax.
17- *
18- *
17+ *
18+ *
1919 * HINT:
2020 * -----
2121 * To allow an ISA card to work properly in the EISA slot you need to
22- * set an edge trigger level. This may be done on the palo command line
23- * by adding the kernel parameter "eisa_irq_edge=n,n2,[...]]", with
22+ * set an edge trigger level. This may be done on the palo command line
23+ * by adding the kernel parameter "eisa_irq_edge=n,n2,[...]]", with
2424 * n and n2 as the irq levels you want to use.
25- *
26- * Example: "eisa_irq_edge=10,11" allows ISA cards to operate at
25+ *
26+ * Example: "eisa_irq_edge=10,11" allows ISA cards to operate at
2727 * irq levels 10 and 11.
2828 */
2929
4646#include <asm/eisa_eeprom.h>
4747
4848#if 0
49- #define EISA_DBG (msg , arg ... ) printk(KERN_DEBUG "eisa: " msg , ## arg )
49+ #define EISA_DBG (msg , arg ...) printk(KERN_DEBUG "eisa: " msg, ## arg)
5050#else
51- #define EISA_DBG (msg , arg ... )
51+ #define EISA_DBG (msg , arg ...)
5252#endif
5353
5454#define SNAKES_EEPROM_BASE_ADDR 0xF0810400
@@ -108,7 +108,7 @@ void eisa_out8(unsigned char data, unsigned short port)
108108
109109void eisa_out16 (unsigned short data , unsigned short port )
110110{
111- if (EISA_bus )
111+ if (EISA_bus )
112112 gsc_writew (cpu_to_le16 (data ), eisa_permute (port ));
113113}
114114
@@ -135,9 +135,9 @@ static int master_mask;
135135static int slave_mask ;
136136
137137/* the trig level can be set with the
138- * eisa_irq_edge=n,n,n commandline parameter
139- * We should really read this from the EEPROM
140- * in the furure.
138+ * eisa_irq_edge=n,n,n commandline parameter
139+ * We should really read this from the EEPROM
140+ * in the furure.
141141 */
142142/* irq 13,8,2,1,0 must be edge */
143143static unsigned int eisa_irq_level __read_mostly ; /* default to edge triggered */
@@ -170,7 +170,7 @@ static void eisa_unmask_irq(struct irq_data *d)
170170 unsigned int irq = d -> irq ;
171171 unsigned long flags ;
172172 EISA_DBG ("enable irq %d\n" , irq );
173-
173+
174174 spin_lock_irqsave (& eisa_irq_lock , flags );
175175 if (irq & 8 ) {
176176 slave_mask &= ~(1 << (irq & 7 ));
@@ -194,39 +194,39 @@ static irqreturn_t eisa_irq(int wax_irq, void *intr_dev)
194194{
195195 int irq = gsc_readb (0xfc01f000 ); /* EISA supports 16 irqs */
196196 unsigned long flags ;
197-
197+
198198 spin_lock_irqsave (& eisa_irq_lock , flags );
199199 /* read IRR command */
200200 eisa_out8 (0x0a , 0x20 );
201201 eisa_out8 (0x0a , 0xa0 );
202202
203203 EISA_DBG ("irq IAR %02x 8259-1 irr %02x 8259-2 irr %02x\n" ,
204204 irq , eisa_in8 (0x20 ), eisa_in8 (0xa0 ));
205-
205+
206206 /* read ISR command */
207207 eisa_out8 (0x0a , 0x20 );
208208 eisa_out8 (0x0a , 0xa0 );
209209 EISA_DBG ("irq 8259-1 isr %02x imr %02x 8259-2 isr %02x imr %02x\n" ,
210210 eisa_in8 (0x20 ), eisa_in8 (0x21 ), eisa_in8 (0xa0 ), eisa_in8 (0xa1 ));
211-
211+
212212 irq &= 0xf ;
213-
213+
214214 /* mask irq and write eoi */
215215 if (irq & 8 ) {
216216 slave_mask |= (1 << (irq & 7 ));
217217 eisa_out8 (slave_mask , 0xa1 );
218218 eisa_out8 (0x60 | (irq & 7 ),0xa0 );/* 'Specific EOI' to slave */
219- eisa_out8 (0x62 ,0x20 ); /* 'Specific EOI' to master-IRQ2 */
220-
219+ eisa_out8 (0x62 , 0x20 ); /* 'Specific EOI' to master-IRQ2 */
220+
221221 } else {
222222 master_mask |= (1 << (irq & 7 ));
223223 eisa_out8 (master_mask , 0x21 );
224- eisa_out8 (0x60 |irq ,0x20 ); /* 'Specific EOI' to master */
224+ eisa_out8 (0x60 |irq , 0x20 ); /* 'Specific EOI' to master */
225225 }
226226 spin_unlock_irqrestore (& eisa_irq_lock , flags );
227227
228228 generic_handle_irq (irq );
229-
229+
230230 spin_lock_irqsave (& eisa_irq_lock , flags );
231231 /* unmask */
232232 if (irq & 8 ) {
@@ -254,44 +254,44 @@ static struct irqaction irq2_action = {
254254static void init_eisa_pic (void )
255255{
256256 unsigned long flags ;
257-
257+
258258 spin_lock_irqsave (& eisa_irq_lock , flags );
259259
260260 eisa_out8 (0xff , 0x21 ); /* mask during init */
261261 eisa_out8 (0xff , 0xa1 ); /* mask during init */
262-
262+
263263 /* master pic */
264- eisa_out8 (0x11 ,0x20 ); /* ICW1 */
265- eisa_out8 (0x00 ,0x21 ); /* ICW2 */
266- eisa_out8 (0x04 ,0x21 ); /* ICW3 */
267- eisa_out8 (0x01 ,0x21 ); /* ICW4 */
268- eisa_out8 (0x40 ,0x20 ); /* OCW2 */
269-
264+ eisa_out8 (0x11 , 0x20 ); /* ICW1 */
265+ eisa_out8 (0x00 , 0x21 ); /* ICW2 */
266+ eisa_out8 (0x04 , 0x21 ); /* ICW3 */
267+ eisa_out8 (0x01 , 0x21 ); /* ICW4 */
268+ eisa_out8 (0x40 , 0x20 ); /* OCW2 */
269+
270270 /* slave pic */
271- eisa_out8 (0x11 ,0xa0 ); /* ICW1 */
272- eisa_out8 (0x08 ,0xa1 ); /* ICW2 */
273- eisa_out8 (0x02 ,0xa1 ); /* ICW3 */
274- eisa_out8 (0x01 ,0xa1 ); /* ICW4 */
275- eisa_out8 (0x40 ,0xa0 ); /* OCW2 */
276-
271+ eisa_out8 (0x11 , 0xa0 ); /* ICW1 */
272+ eisa_out8 (0x08 , 0xa1 ); /* ICW2 */
273+ eisa_out8 (0x02 , 0xa1 ); /* ICW3 */
274+ eisa_out8 (0x01 , 0xa1 ); /* ICW4 */
275+ eisa_out8 (0x40 , 0xa0 ); /* OCW2 */
276+
277277 udelay (100 );
278-
279- slave_mask = 0xff ;
280- master_mask = 0xfb ;
278+
279+ slave_mask = 0xff ;
280+ master_mask = 0xfb ;
281281 eisa_out8 (slave_mask , 0xa1 ); /* OCW1 */
282282 eisa_out8 (master_mask , 0x21 ); /* OCW1 */
283-
283+
284284 /* setup trig level */
285285 EISA_DBG ("EISA edge/level %04x\n" , eisa_irq_level );
286-
286+
287287 eisa_out8 (eisa_irq_level & 0xff , 0x4d0 ); /* Set all irq's to edge */
288- eisa_out8 ((eisa_irq_level >> 8 ) & 0xff , 0x4d1 );
289-
288+ eisa_out8 ((eisa_irq_level >> 8 ) & 0xff , 0x4d1 );
289+
290290 EISA_DBG ("pic0 mask %02x\n" , eisa_in8 (0x21 ));
291291 EISA_DBG ("pic1 mask %02x\n" , eisa_in8 (0xa1 ));
292292 EISA_DBG ("pic0 edge/level %02x\n" , eisa_in8 (0x4d0 ));
293293 EISA_DBG ("pic1 edge/level %02x\n" , eisa_in8 (0x4d1 ));
294-
294+
295295 spin_unlock_irqrestore (& eisa_irq_lock , flags );
296296}
297297
@@ -305,7 +305,7 @@ static int __init eisa_probe(struct parisc_device *dev)
305305
306306 char * name = is_mongoose (dev ) ? "Mongoose" : "Wax" ;
307307
308- printk (KERN_INFO "%s EISA Adapter found at 0x%08lx\n" ,
308+ printk (KERN_INFO "%s EISA Adapter found at 0x%08lx\n" ,
309309 name , (unsigned long )dev -> hpa .start );
310310
311311 eisa_dev .hba .dev = dev ;
@@ -334,16 +334,16 @@ static int __init eisa_probe(struct parisc_device *dev)
334334 result = request_irq (dev -> irq , eisa_irq , IRQF_SHARED , "EISA" , & eisa_dev );
335335 if (result ) {
336336 printk (KERN_ERR "EISA: request_irq failed!\n" );
337- return result ;
337+ goto error_release ;
338338 }
339-
339+
340340 /* Reserve IRQ2 */
341341 setup_irq (2 , & irq2_action );
342342 for (i = 0 ; i < 16 ; i ++ ) {
343343 irq_set_chip_and_handler (i , & eisa_interrupt_type ,
344344 handle_simple_irq );
345345 }
346-
346+
347347 EISA_bus = 1 ;
348348
349349 if (dev -> num_addrs ) {
@@ -358,6 +358,11 @@ static int __init eisa_probe(struct parisc_device *dev)
358358 }
359359 }
360360 eisa_eeprom_addr = ioremap_nocache (eisa_dev .eeprom_addr , HPEE_MAX_LENGTH );
361+ if (!eisa_eeprom_addr ) {
362+ result = - ENOMEM ;
363+ printk (KERN_ERR "EISA: ioremap_nocache failed!\n" );
364+ goto error_free_irq ;
365+ }
361366 result = eisa_enumerator (eisa_dev .eeprom_addr , & eisa_dev .hba .io_space ,
362367 & eisa_dev .hba .lmmio_space );
363368 init_eisa_pic ();
@@ -372,11 +377,20 @@ static int __init eisa_probe(struct parisc_device *dev)
372377 eisa_dev .root .dma_mask = 0xffffffff ; /* wild guess */
373378 if (eisa_root_register (& eisa_dev .root )) {
374379 printk (KERN_ERR "EISA: Failed to register EISA root\n" );
375- return -1 ;
380+ result = - ENOMEM ;
381+ goto error_iounmap ;
376382 }
377383 }
378-
384+
379385 return 0 ;
386+
387+ error_iounmap :
388+ iounmap (eisa_eeprom_addr );
389+ error_free_irq :
390+ free_irq (dev -> irq , & eisa_dev );
391+ error_release :
392+ release_resource (& eisa_dev .hba .io_space );
393+ return result ;
380394}
381395
382396static const struct parisc_device_id eisa_tbl [] = {
@@ -404,7 +418,7 @@ void eisa_make_irq_level(int num)
404418{
405419 if (eisa_irq_configured & (1 <<num )) {
406420 printk (KERN_WARNING
407- "IRQ %d polarity configured twice (last to level)\n" ,
421+ "IRQ %d polarity configured twice (last to level)\n" ,
408422 num );
409423 }
410424 eisa_irq_level |= (1 <<num ); /* set the corresponding bit */
@@ -414,7 +428,7 @@ void eisa_make_irq_level(int num)
414428void eisa_make_irq_edge (int num )
415429{
416430 if (eisa_irq_configured & (1 <<num )) {
417- printk (KERN_WARNING
431+ printk (KERN_WARNING
418432 "IRQ %d polarity configured twice (last to edge)\n" ,
419433 num );
420434 }
@@ -430,18 +444,18 @@ static int __init eisa_irq_setup(char *str)
430444 EISA_DBG ("IRQ setup\n" );
431445 while (cur != NULL ) {
432446 char * pe ;
433-
447+
434448 val = (int ) simple_strtoul (cur , & pe , 0 );
435449 if (val > 15 || val < 0 ) {
436450 printk (KERN_ERR "eisa: EISA irq value are 0-15\n" );
437451 continue ;
438452 }
439- if (val == 2 ) {
453+ if (val == 2 ) {
440454 val = 9 ;
441455 }
442456 eisa_make_irq_edge (val ); /* clear the corresponding bit */
443457 EISA_DBG ("setting IRQ %d to edge-triggered mode\n" , val );
444-
458+
445459 if ((cur = strchr (cur , ',' ))) {
446460 cur ++ ;
447461 } else {
0 commit comments