Browse Source

Read current ioaddr and irqno from PnP registers.

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
888277d2d1
2 changed files with 33 additions and 2 deletions
  1. 28
    2
      src/drivers/bus/isapnp.c
  2. 5
    0
      src/include/isapnp.h

+ 28
- 2
src/drivers/bus/isapnp.c View File

87
 	return isapnp_read_data ();
87
 	return isapnp_read_data ();
88
 }
88
 }
89
 
89
 
90
+static inline uint16_t isapnp_read_word ( uint8_t address ) {
91
+	/* Yes, they're in big-endian order */
92
+	return ( ( isapnp_read_byte ( address ) << 8 )
93
+		 + isapnp_read_byte ( address + 1 ) );
94
+}
95
+
90
 static inline void isapnp_set_read_port ( void ) {
96
 static inline void isapnp_set_read_port ( void ) {
91
 	isapnp_write_byte ( ISAPNP_READPORT, isapnp_read_port >> 2 );
97
 	isapnp_write_byte ( ISAPNP_READPORT, isapnp_read_port >> 2 );
92
 }
98
 }
133
 	isapnp_write_byte ( ISAPNP_ACTIVATE, 0 );
139
 	isapnp_write_byte ( ISAPNP_ACTIVATE, 0 );
134
 }
140
 }
135
 
141
 
142
+static inline uint16_t isapnp_read_iobase ( unsigned int index ) {
143
+	return isapnp_read_word ( ISAPNP_IOBASE ( index ) );
144
+}
145
+
146
+static inline uint8_t isapnp_read_irqno ( unsigned int index ) {
147
+	return isapnp_read_byte ( ISAPNP_IRQNO ( index ) );
148
+}
149
+
136
 static void isapnp_delay ( void ) {
150
 static void isapnp_delay ( void ) {
137
 	udelay ( 1000 );
151
 	udelay ( 1000 );
138
 }
152
 }
388
 	isapnp->vendor_id = identifier.vendor_id;
402
 	isapnp->vendor_id = identifier.vendor_id;
389
 	isapnp->prod_id = identifier.prod_id;
403
 	isapnp->prod_id = identifier.prod_id;
390
 
404
 
405
+	/* I/O addresses and IRQs are associated with logical devices,
406
+	 * not with cards.  They will be assigned when
407
+	 * activate_isapnp_device() is called.
408
+	 */
409
+	isapnp->ioaddr = 0;
410
+	isapnp->irqno = 0;
411
+
391
 	/* Return all cards to Wait for Key state */
412
 	/* Return all cards to Wait for Key state */
392
 	isapnp_wait_for_key ();
413
 	isapnp_wait_for_key ();
393
 
414
 
471
 }
492
 }
472
 
493
 
473
 /*
494
 /*
474
- * Activate a logical function on an ISAPnP device
495
+ * Activate a logical function on an ISAPnP device, and fill in the
496
+ * ioaddr and irqno fields in the isapnp struct.
475
  *
497
  *
476
  * This routine simply activates the device in its current
498
  * This routine simply activates the device in its current
477
  * configuration.  It does not attempt any kind of resource
499
  * configuration.  It does not attempt any kind of resource
488
 	/* Select the specified logical device */
510
 	/* Select the specified logical device */
489
 	isapnp_activate ( logdev );
511
 	isapnp_activate ( logdev );
490
 	isapnp_delay();
512
 	isapnp_delay();
513
+
514
+	/* Read the current ioaddr and irqno */
515
+	isapnp->ioaddr = isapnp_read_iobase ( 0 );
516
+	isapnp->irqno = isapnp_read_irqno ( 0 );
491
 	
517
 	
492
 	/* Return all cards to Wait for Key state */
518
 	/* Return all cards to Wait for Key state */
493
 	isapnp_wait_for_key ();
519
 	isapnp_wait_for_key ();
498
  *
524
  *
499
  */
525
  */
500
 void deactivate_isapnp_device ( struct isapnp_device *isapnp,
526
 void deactivate_isapnp_device ( struct isapnp_device *isapnp,
501
-			      uint8_t logdev ) {
527
+				uint8_t logdev ) {
502
 	/* Wake the device */
528
 	/* Wake the device */
503
 	isapnp_wait_for_key ();
529
 	isapnp_wait_for_key ();
504
 	isapnp_send_key ();
530
 	isapnp_send_key ();

+ 5
- 0
src/include/isapnp.h View File

66
 #define ISAPNP_LOGICALDEVICENUMBER	0x07
66
 #define ISAPNP_LOGICALDEVICENUMBER	0x07
67
 #define ISAPNP_ACTIVATE			0x30
67
 #define ISAPNP_ACTIVATE			0x30
68
 #define ISAPNP_IORANGECHECK		0x31
68
 #define ISAPNP_IORANGECHECK		0x31
69
+#define ISAPNP_IOBASE(n)		( 0x60 + ( (n) * 2 ) )
70
+#define ISAPNP_IRQNO(n)			( 0x70 + ( (n) * 2 ) )
71
+#define ISAPNP_IRQTYPE(n)		( 0x71 + ( (n) * 2 ) )
69
 
72
 
70
 /* Bits in the CONFIGCONTROL register */
73
 /* Bits in the CONFIGCONTROL register */
71
 #define ISAPNP_CONFIG_RESET		( 1 << 0 )
74
 #define ISAPNP_CONFIG_RESET		( 1 << 0 )
143
 	unsigned char csn;
146
 	unsigned char csn;
144
 	uint16_t vendor_id;
147
 	uint16_t vendor_id;
145
 	uint16_t prod_id;
148
 	uint16_t prod_id;
149
+	uint16_t ioaddr;
150
+	uint8_t irqno;
146
 	int already_tried;
151
 	int already_tried;
147
 };
152
 };
148
 
153
 

Loading…
Cancel
Save