View | Details | Raw Unified | Return to bug 18528
Collapse All | Expand All

(-)if_xe.c (-77 / +76 lines)
Lines 33-39 Link Here
33
 * I've pushed this fairly far, but there are some things that need to be
33
 * I've pushed this fairly far, but there are some things that need to be
34
 * done here.  I'm documenting them here in case I get destracted. -- imp
34
 * done here.  I'm documenting them here in case I get destracted. -- imp
35
 *
35
 *
36
 * xe_memwrite -- maybe better handled pccard layer?
37
 * xe_cem56fix -- need to figure out how to map the extra stuff.
36
 * xe_cem56fix -- need to figure out how to map the extra stuff.
38
 */
37
 */
39
38
Lines 205-210 Link Here
205
/*
204
/*
206
 * Debug functions
205
 * Debug functions
207
 */
206
 */
207
#define XE_DEBUG 2
208
#ifdef XE_DEBUG
208
#ifdef XE_DEBUG
209
#define XE_REG_DUMP(scp)		xe_reg_dump((scp))
209
#define XE_REG_DUMP(scp)		xe_reg_dump((scp))
210
#define XE_MII_DUMP(scp)		xe_mii_dump((scp))
210
#define XE_MII_DUMP(scp)		xe_mii_dump((scp))
Lines 216-306 Link Here
216
#endif
216
#endif
217
217
218
/*
218
/*
219
 * Two routines to read from/write to the attribute memory
219
 * Fixing for RealPort cards - they need a little furtling to get the
220
 * the write portion is used only for fixing up the RealPort cards,
220
 * ethernet working
221
 * the reader portion was needed for debugging info, and duplicated some
222
 * code in xe_card_init(), so it appears here instead with suitable
223
 * modifications to xe_card_init()
224
 * -aDe Lovett
225
 */
221
 */
226
static int
222
static int
227
xe_memwrite(device_t dev, off_t offset, u_char byte)
223
xe_cem56fix(device_t dev)
228
{
224
{
229
	/* XXX */
225
  struct xe_softc *sc = (struct xe_softc *) device_get_softc(dev);
230
  return (-1);
226
  bus_space_tag_t bst;
231
}
227
  bus_space_handle_t bsh;
232
228
  struct resource *r;
233
/*
229
  int rid;
234
 * Hacking for RealPort cards
230
  int ioport;
235
 */
236
static int
237
xe_cem56fix(struct xe_softc *scp)
238
{
239
#if XXX		/* Need to revisit */
240
  int ioport, fail;
241
242
  /* allocate a new I/O slot for the ethernet */
243
  /* XXX: ctrl->mapio() always appears to return 0 (success), so
244
   *      this may cause problems if another device is listening
245
   *	  on 0x300 already.  In this case, you should choose a
246
   *      known free I/O port address in the kernel config line
247
   *      for the driver.  It will be picked up here and used
248
   *      instead of the autodetected value.
249
   */
250
  slt->io[1].window = 1;
251
  slt->io[1].flags = IODF_WS|IODF_16BIT|IODF_ZEROWS|IODF_ACTIVE;
252
  slt->io[1].size = 0x10;
253
254
#ifdef	XE_IOBASE
255
256
  device_printf(scp->dev, "user requested ioport 0x%x\n", XE_IOBASE );
257
  ioport = XE_IOBASE;
258
  slt->io[1].start = ioport;
259
  fail = ctrl->mapio(slt, 1);
260
261
#else
262
231
263
  for (ioport = 0x300; ioport < 0x400; ioport += 0x10) {
232
#ifdef XE_DEBUG
264
    slt->io[1].start = ioport;
233
  device_printf(dev, "Hacking your Realport, master\n");
265
    if ((fail = ctrl->mapio( slt, 1 )) == 0)
234
#endif
266
      break;
267
  }
268
235
236
#if XE_DEBUG > 1
237
  device_printf(dev, "Realport port 0x%0lx, size 0x%0lx\n",
238
      bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid),
239
      bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid));
269
#endif
240
#endif
270
241
271
  /* did we find one? */
242
  rid = 0;
272
  if (fail) {
243
  r = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 4 << 10, RF_ACTIVE);
273
    device_printf(scp->dev, "xe_cem56fix: no free address space\n");
244
  if (!r) {
245
#if XE_DEBUG > 0
246
    device_printf(dev, "Can't map in attribute memory\n");
247
#endif
274
    return -1;
248
    return -1;
275
  }
249
  }
276
250
251
  bsh = rman_get_bushandle(r);
252
  bst = rman_get_bustag(r);
277
253
278
  /* munge the id_iobase entry for use by the rest of the driver */
254
  CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, rid,
279
#if XE_DEBUG > 1
255
      PCCARD_A_MEM_ATTR);
280
  device_printf(scp->dev, "using 0x%x for RealPort ethernet\n", ioport);
256
281
#endif
257
  bus_space_write_1(bst, bsh, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL |
282
#if 0
258
					  DINGO_ECOR_INT_ENABLE |
283
  scp->dev->id_iobase = ioport;
259
					  DINGO_ECOR_IOB_ENABLE |
284
#endif
260
               				  DINGO_ECOR_ETH_ENABLE);
261
  ioport = bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid);
262
  bus_space_write_1(bst, bsh, DINGO_EBAR0, ioport & 0xff);
263
  bus_space_write_1(bst, bsh, DINGO_EBAR1, (ioport >> 8) & 0xff);
264
265
  bus_space_write_1(bst, bsh, DINGO_DCOR0, DINGO_DCOR0_SF_INT);
266
  bus_space_write_1(bst, bsh, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL |
267
  					   DINGO_DCOR1_EEDIO);
268
  bus_space_write_1(bst, bsh, DINGO_DCOR2, 0x00);
269
  bus_space_write_1(bst, bsh, DINGO_DCOR3, 0x00);
270
  bus_space_write_1(bst, bsh, DINGO_DCOR4, 0x00);
285
271
286
  /* magic to set up the ethernet */
272
  bus_release_resource(dev, SYS_RES_MEMORY, rid, r);
287
  xe_memwrite( scp->dev, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL|
288
               DINGO_ECOR_INT_ENABLE|DINGO_ECOR_IOB_ENABLE|
289
               DINGO_ECOR_ETH_ENABLE );
290
  xe_memwrite( scp->dev, DINGO_EBAR0, ioport & 0xff );
291
  xe_memwrite( scp->dev, DINGO_EBAR1, (ioport >> 8) & 0xff );
292
293
  xe_memwrite( scp->dev, DINGO_DCOR0, DINGO_DCOR0_SF_INT );
294
  xe_memwrite( scp->dev, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL|DINGO_DCOR1_EEDIO );
295
  xe_memwrite( scp->dev, DINGO_DCOR2, 0x00 );
296
  xe_memwrite( scp->dev, DINGO_DCOR3, 0x00 );
297
  xe_memwrite( scp->dev, DINGO_DCOR4, 0x00 );
298
273
299
  /* success! */
300
  return 0;
274
  return 0;
301
#else
302
  return -1;
303
#endif /* XXX */
304
}
275
}
305
	
276
	
306
/*
277
/*
Lines 532-538 Link Here
532
  scp->autoneg_status = 0;
503
  scp->autoneg_status = 0;
533
504
534
  /* Hack RealPorts into submission */
505
  /* Hack RealPorts into submission */
535
  if (scp->dingo && xe_cem56fix(scp) < 0) {
506
  if (scp->dingo && xe_cem56fix(dev) < 0) {
536
    device_printf(dev, "Unable to fix your RealPort\n");
507
    device_printf(dev, "Unable to fix your RealPort\n");
537
    xe_deactivate(dev);
508
    xe_deactivate(dev);
538
    return ENODEV;
509
    return ENODEV;
Lines 2210-2220 Link Here
2210
xe_activate(device_t dev)
2181
xe_activate(device_t dev)
2211
{
2182
{
2212
	struct xe_softc *sc = device_get_softc(dev);
2183
	struct xe_softc *sc = device_get_softc(dev);
2213
	int err;
2184
	int start, err;
2214
2185
2215
	sc->port_rid = 0;
2186
	if (!sc->dingo) {
2216
	sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
2187
		sc->port_rid = 0;	/* 0 is managed by pccard */
2217
	    0, ~0, 16, RF_ACTIVE);
2188
		sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
2189
		    &sc->port_rid, 0, ~0, 16, RF_ACTIVE);
2190
	} else {
2191
		/*
2192
		 * Find a 16 byte aligned ioport for the card.
2193
		 */
2194
#if XE_DEBUG > 0
2195
		device_printf(dev, "Finding an aligned port for RealPort\n");
2196
#endif /* XE_DEBUG */
2197
		sc->port_rid = 1;	/* 0 is managed by pccard */
2198
		start = 0x100;
2199
		do {
2200
			sc->port_res = bus_alloc_resource(dev,
2201
			    SYS_RES_IOPORT, &sc->port_rid, start, 0x3ff, 16,
2202
			    RF_ACTIVE);
2203
			if (sc->port_res == 0)
2204
				break;		/* we failed */
2205
			if ((rman_get_start(sc->port_res) & 0xf) == 0)
2206
				break;		/* good */
2207
			bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, 
2208
			    sc->port_res);
2209
			start = (rman_get_start(sc->port_res) + 15) & ~0xf;
2210
		} while (1);
2211
#if XE_DEBUG > 2
2212
		device_printf(dev, "port 0x%0lx, size 0x%0lx\n",
2213
		    bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid),
2214
		    bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid));
2215
#endif /* XE_DEBUG */
2216
	}
2218
	if (!sc->port_res) {
2217
	if (!sc->port_res) {
2219
#if XE_DEBUG > 0
2218
#if XE_DEBUG > 0
2220
		device_printf(dev, "Cannot allocate ioport\n");
2219
		device_printf(dev, "Cannot allocate ioport\n");

Return to bug 18528