Browse Source

[phantom] Change register space abstraction to match other drivers

Most other Phantom drivers define a register space in terms of a 64M
virtual address space.  While this doesn't map in any meaningful way
to the actual addresses used on the latest cards, it makes maintenance
easier if we do the same.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
d4c8273569
2 changed files with 46 additions and 54 deletions
  1. 39
    47
      src/drivers/net/phantom/phantom.c
  2. 7
    7
      src/drivers/net/phantom/phantom.h

+ 39
- 47
src/drivers/net/phantom/phantom.c View File

228
  */
228
  */
229
 static unsigned long phantom_crb_access_128m ( struct phantom_nic *phantom,
229
 static unsigned long phantom_crb_access_128m ( struct phantom_nic *phantom,
230
 					       unsigned long reg ) {
230
 					       unsigned long reg ) {
231
-	static const uint32_t reg_window[] = {
232
-		[UNM_CRB_BLK_PCIE]	= 0x0000000,
233
-		[UNM_CRB_BLK_CAM]	= 0x2000000,
234
-		[UNM_CRB_BLK_ROMUSB]	= 0x2000000,
235
-		[UNM_CRB_BLK_TEST]	= 0x0000000,
236
-	};
237
-	static const uint32_t reg_bases[] = {
238
-		[UNM_CRB_BLK_PCIE]	= 0x6100000,
239
-		[UNM_CRB_BLK_CAM]	= 0x6200000,
240
-		[UNM_CRB_BLK_ROMUSB]	= 0x7300000,
241
-		[UNM_CRB_BLK_TEST]	= 0x6200000,
242
-	};
243
-	unsigned int block = UNM_CRB_BLK ( reg );
244
-	unsigned long offset = UNM_CRB_OFFSET ( reg );
245
-	uint32_t window = reg_window[block];
231
+	unsigned long offset = ( 0x6000000 + ( reg & 0x1ffffff ) );
232
+	uint32_t window = ( reg & 0x2000000 );
246
 	uint32_t verify_window;
233
 	uint32_t verify_window;
247
 
234
 
248
 	if ( phantom->crb_window != window ) {
235
 	if ( phantom->crb_window != window ) {
258
 		phantom->crb_window = window;
245
 		phantom->crb_window = window;
259
 	}
246
 	}
260
 
247
 
261
-	return ( reg_bases[block] + offset );
248
+	return offset;
262
 }
249
 }
263
 
250
 
264
 /**
251
 /**
270
  */
257
  */
271
 static unsigned long phantom_crb_access_32m ( struct phantom_nic *phantom,
258
 static unsigned long phantom_crb_access_32m ( struct phantom_nic *phantom,
272
 					      unsigned long reg ) {
259
 					      unsigned long reg ) {
273
-	static const uint32_t reg_window[] = {
274
-		[UNM_CRB_BLK_PCIE]	= 0x0000000,
275
-		[UNM_CRB_BLK_CAM]	= 0x2000000,
276
-		[UNM_CRB_BLK_ROMUSB]	= 0x2000000,
277
-		[UNM_CRB_BLK_TEST]	= 0x0000000,
278
-	};
279
-	static const uint32_t reg_bases[] = {
280
-		[UNM_CRB_BLK_PCIE]	= 0x0100000,
281
-		[UNM_CRB_BLK_CAM]	= 0x0200000,
282
-		[UNM_CRB_BLK_ROMUSB]	= 0x1300000,
283
-		[UNM_CRB_BLK_TEST]	= 0x0200000,
284
-	};
285
-	unsigned int block = UNM_CRB_BLK ( reg );
286
-	unsigned long offset = UNM_CRB_OFFSET ( reg );
287
-	uint32_t window = reg_window[block];
260
+	unsigned long offset = ( reg & 0x1ffffff );
261
+	uint32_t window = ( reg & 0x2000000 );
288
 	uint32_t verify_window;
262
 	uint32_t verify_window;
289
 
263
 
290
 	if ( phantom->crb_window != window ) {
264
 	if ( phantom->crb_window != window ) {
300
 		phantom->crb_window = window;
274
 		phantom->crb_window = window;
301
 	}
275
 	}
302
 
276
 
303
-	return ( reg_bases[block] + offset );
277
+	return offset;
304
 }
278
 }
305
 
279
 
306
 /**
280
 /**
312
  */
286
  */
313
 static unsigned long phantom_crb_access_2m ( struct phantom_nic *phantom,
287
 static unsigned long phantom_crb_access_2m ( struct phantom_nic *phantom,
314
 					     unsigned long reg ) {
288
 					     unsigned long reg ) {
315
-	static const uint32_t reg_window_hi[] = {
316
-		[UNM_CRB_BLK_PCIE]	= 0x77300000,
317
-		[UNM_CRB_BLK_CAM]	= 0x41600000,
318
-		[UNM_CRB_BLK_ROMUSB]	= 0x42100000,
319
-		[UNM_CRB_BLK_TEST]	= 0x29500000,
289
+	static const struct {
290
+		uint8_t block;
291
+		uint16_t window_hi;
292
+	} reg_window_hi[] = {
293
+		{ UNM_CRB_BLK_PCIE,	0x773 },
294
+		{ UNM_CRB_BLK_CAM,	0x416 },
295
+		{ UNM_CRB_BLK_ROMUSB,	0x421 },
296
+		{ UNM_CRB_BLK_TEST,	0x295 },
320
 	};
297
 	};
321
 	unsigned int block = UNM_CRB_BLK ( reg );
298
 	unsigned int block = UNM_CRB_BLK ( reg );
322
 	unsigned long offset = UNM_CRB_OFFSET ( reg );
299
 	unsigned long offset = UNM_CRB_OFFSET ( reg );
323
-	uint32_t window = ( reg_window_hi[block] | ( offset & 0x000f0000 ) );
300
+	uint32_t window;
324
 	uint32_t verify_window;
301
 	uint32_t verify_window;
302
+	unsigned int i;
325
 
303
 
326
-	if ( phantom->crb_window != window ) {
304
+	for ( i = 0 ; i < ( sizeof ( reg_window_hi ) /
305
+			    sizeof ( reg_window_hi[0] ) ) ; i++ ) {
327
 
306
 
328
-		/* Write to the CRB window register */
329
-		writel ( window, phantom->bar0 + UNM_2M_CRB_WINDOW );
307
+		if ( reg_window_hi[i].block != block )
308
+			continue;
330
 
309
 
331
-		/* Ensure that the write has reached the card */
332
-		verify_window = readl ( phantom->bar0 + UNM_2M_CRB_WINDOW );
333
-		assert ( verify_window == window );
310
+		window = ( ( reg_window_hi[i].window_hi << 20 ) |
311
+			   ( offset & 0x000f0000 ) );
334
 
312
 
335
-		/* Record new window */
336
-		phantom->crb_window = window;
313
+		if ( phantom->crb_window != window ) {
314
+
315
+			/* Write to the CRB window register */
316
+			writel ( window, phantom->bar0 + UNM_2M_CRB_WINDOW );
317
+
318
+			/* Ensure that the write has reached the card */
319
+			verify_window = readl ( phantom->bar0 +
320
+						UNM_2M_CRB_WINDOW );
321
+			assert ( verify_window == window );
322
+
323
+			/* Record new window */
324
+			phantom->crb_window = window;
325
+		}
326
+
327
+		return ( 0x1e0000 + ( offset & 0xffff ) );
337
 	}
328
 	}
338
 
329
 
339
-	return ( 0x1e0000 + ( offset & 0xffff ) );
330
+	assert ( 0 );
331
+	return 0;
340
 }
332
 }
341
 
333
 
342
 /**
334
 /**

+ 7
- 7
src/drivers/net/phantom/phantom.h View File

76
  * address by the phantom_crb_access_xxx() methods.
76
  * address by the phantom_crb_access_xxx() methods.
77
  */
77
  */
78
 enum unm_reg_blocks {
78
 enum unm_reg_blocks {
79
-	UNM_CRB_BLK_PCIE,
80
-	UNM_CRB_BLK_CAM,
81
-	UNM_CRB_BLK_ROMUSB,
82
-	UNM_CRB_BLK_TEST,
79
+	UNM_CRB_BLK_PCIE	= 0x01,
80
+	UNM_CRB_BLK_CAM		= 0x22,
81
+	UNM_CRB_BLK_ROMUSB	= 0x33,
82
+	UNM_CRB_BLK_TEST	= 0x02,
83
 };
83
 };
84
-#define UNM_CRB_BASE(blk)		( (blk) << 24 )
85
-#define UNM_CRB_BLK(reg)		( (reg) >> 24 )
86
-#define UNM_CRB_OFFSET(reg)		( (reg) & 0x00ffffff )
84
+#define UNM_CRB_BASE(blk)		( (blk) << 20 )
85
+#define UNM_CRB_BLK(reg)		( (reg) >> 20 )
86
+#define UNM_CRB_OFFSET(reg)		( (reg) & 0x000fffff )
87
 
87
 
88
 #define UNM_CRB_PCIE			UNM_CRB_BASE ( UNM_CRB_BLK_PCIE )
88
 #define UNM_CRB_PCIE			UNM_CRB_BASE ( UNM_CRB_BLK_PCIE )
89
 #define UNM_PCIE_SEM2_LOCK		( UNM_CRB_PCIE + 0x1c010 )
89
 #define UNM_PCIE_SEM2_LOCK		( UNM_CRB_PCIE + 0x1c010 )

Loading…
Cancel
Save