コード例 #1
0
ファイル: isic_isapnp.c プロジェクト: ryo/netbsd-src
static void
generic_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc)
{
	sc->sc_num_mappings = 1;	/* most cards have just one mapping */
	MALLOC_MAPS(sc);		/* malloc the maps */
	sc->sc_maps[0].t = ipa->ipa_iot;	/* copy the access handles */
	sc->sc_maps[0].h = ipa->ipa_io[0].h;
	sc->sc_maps[0].size = 0;	/* foreign mapping, leave it alone */
}
コード例 #2
0
ファイル: isic_isapnp.c プロジェクト: ryo/netbsd-src
static void
ngo_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc)
{
	sc->sc_num_mappings = 2;	/* one data, one address mapping */
	MALLOC_MAPS(sc);		/* malloc the maps */
	sc->sc_maps[0].t = ipa->ipa_iot;	/* copy the access handles */
	sc->sc_maps[0].h = ipa->ipa_io[0].h;
	sc->sc_maps[0].size = 0;	/* foreign mapping, leave it alone */
		sc->sc_maps[1].t = ipa->ipa_iot;
		sc->sc_maps[1].h = ipa->ipa_io[1].h;
		sc->sc_maps[1].size = 0;
}
コード例 #3
0
ファイル: isic_isapnp.c プロジェクト: ryo/netbsd-src
static void
tls_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc)
{
	sc->sc_num_mappings = 4;	/* config, isac, 2 * hscx */
	MALLOC_MAPS(sc);		/* malloc the maps */
	sc->sc_maps[0].t = ipa->ipa_iot;	/* copy the access handles */
	sc->sc_maps[0].h = ipa->ipa_io[0].h;
	sc->sc_maps[0].size = 0;	/* foreign mapping, leave it alone */
		sc->sc_maps[1].t = ipa->ipa_iot;
		sc->sc_maps[1].h = ipa->ipa_io[0].h;
		sc->sc_maps[1].size = 0;
		sc->sc_maps[1].offset = - 0x20;
		sc->sc_maps[2].t = ipa->ipa_iot;
		sc->sc_maps[2].offset = - 0x20;
		sc->sc_maps[2].h = ipa->ipa_io[1].h;
		sc->sc_maps[2].size = 0;
		sc->sc_maps[3].t = ipa->ipa_iot;
		sc->sc_maps[3].offset = 0;
		sc->sc_maps[3].h = ipa->ipa_io[1].h;
		sc->sc_maps[3].size = 0;
}
コード例 #4
0
/*
 * Attach the card
 */
static void
isic_isa_attach(device_t parent, device_t self, void *aux)
{
	struct isic_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;
	int flags = device_cfdata(self)->cf_flags;
	int ret = 0, iobase, iosize, maddr, msize;
	struct isic_attach_args args;

	if (ia->ia_nio > 0) {
		iobase = ia->ia_io[0].ir_addr;
		iosize = ia->ia_io[0].ir_size;
	} else {
		iobase = ISA_UNKNOWN_PORT;
		iosize = 0;
	}
	if (ia->ia_niomem > 0) {
		maddr = ia->ia_iomem[0].ir_addr;
		msize = ia->ia_iomem[0].ir_size;
	} else {
		maddr = ISA_UNKNOWN_IOMEM;
		msize = 0;
	}

	/* Setup parameters */
	sc->sc_dev = self;
	sc->sc_irq = ia->ia_irq[0].ir_irq;
	sc->sc_maddr = maddr;
	sc->sc_num_mappings = 0;
	sc->sc_maps = NULL;
	switch(flags)
	{
		case FLAG_TELES_S0_8:
		case FLAG_TELES_S0_16:
		case FLAG_TELES_S0_163:
		case FLAG_AVM_A1:
		case FLAG_USR_ISDN_TA_INT:
			setup_io_map(flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&(sc->sc_num_mappings), NULL, NULL, NULL);
			MALLOC_MAPS(sc);
			setup_io_map(flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&(sc->sc_num_mappings), &(sc->sc_maps[0]), NULL, NULL);
			break;

		default:
			/* No card type given, try to figure ... */

			/* setup MI attach args */
			memset(&args, 0, sizeof(args));
			args.ia_flags = flags;

			/* Probe cards */
			if (iobase == ISA_UNKNOWN_PORT) {
				ret = 0;
#ifdef ISICISA_TEL_S0_8
				/* only Teles S0/8 will work without IO */
				args.ia_flags = FLAG_TELES_S0_8;
				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
				ret = isic_probe_s08(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_TEL_S0_8 */
			} else if (maddr == ISA_UNKNOWN_IOMEM) {
				/* no shared memory, only a 16.3 based card,
				   AVM A1, the usr sportster or an ITK would work */
				ret = 0;
#ifdef	ISICISA_TEL_S0_16_3
				args.ia_flags = FLAG_TELES_S0_163;
				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
				ret = isic_probe_s0163(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_TEL_S0_16_3 */
#ifdef ISICISA_AVM_A1
				args.ia_flags = FLAG_AVM_A1;
				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
				ret = isic_probe_avma1(&args);
 				if (ret)
 					goto found;
 				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_AVM_A1 */
#ifdef ISICISA_USR_STI
 				args.ia_flags = FLAG_USR_ISDN_TA_INT;
 				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
 					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
 				ret = isic_probe_usrtai(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_USR_STI */
#ifdef ISICISA_ITKIX1
 				args.ia_flags = FLAG_ITK_IX1;
 				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
 					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
 				ret = isic_probe_itkix1(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_ITKIX1 */
			} else {
				/* could be anything */
				ret = 0;
#ifdef	ISICISA_TEL_S0_16_3
				args.ia_flags = FLAG_TELES_S0_163;
				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
				ret = isic_probe_s0163(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif	/* ISICISA_TEL_S0_16_3 */
#ifdef	ISICISA_TEL_S0_16
				args.ia_flags = FLAG_TELES_S0_16;
				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
				ret = isic_probe_s016(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_TEL_S0_16 */
#ifdef ISICISA_AVM_A1
				args.ia_flags = FLAG_AVM_A1;
				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
				ret = isic_probe_avma1(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_AVM_A1 */
#ifdef ISICISA_TEL_S0_8
				args.ia_flags = FLAG_TELES_S0_8;
				setup_io_map(args.ia_flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&args.ia_num_mappings, &args.ia_maps[0], NULL, NULL);
				ret = isic_probe_s08(&args);
				if (ret)
					goto found;
				args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
#endif /* ISICISA_TEL_S0_8 */
			}
			break;

		found:
			flags = args.ia_flags;
			sc->sc_num_mappings = args.ia_num_mappings;
			args_unmap(&args.ia_num_mappings, &args.ia_maps[0]);
			if (ret) {
				MALLOC_MAPS(sc);
				setup_io_map(flags, ia->ia_iot, ia->ia_memt, iobase, maddr,
					&(sc->sc_num_mappings), &(sc->sc_maps[0]), NULL, NULL);
			} else {
				printf(": could not determine card type - not configured!\n");
				return;
			}
			break;
	}

	/* MI initialization of card */
	isicattach(flags, sc);

	/*
	 * Try to get a level-triggered interrupt first. If that doesn't
	 * work (like on NetBSD/Atari, try to establish an edge triggered
	 * interrupt.
	 */
	if (isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_LEVEL,
				IPL_NET, isicintr, sc) == NULL) {
		if(isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE,
				IPL_NET, isicintr, sc) == NULL) {
			args_unmap(&(sc->sc_num_mappings), &(sc->sc_maps[0]));
			free((sc)->sc_maps, M_DEVBUF);
		}
		else {
			/*
			 * XXX: This is a hack that probably needs to be
			 * solved by setting an interrupt type in the sc
			 * structure. I don't feel familiar enough with the
			 * code to do this currently. Feel free to contact
			 * me about it ([email protected]).
			 */
			isicintr(sc);
		}
	}
}
コード例 #5
0
int
isic_attach_fritzpcmcia(struct pcmcia_isic_softc *psc, struct pcmcia_config_entry *cfe, struct pcmcia_attach_args *pa)
{
	struct isic_softc *sc = &psc->sc_isic;
	bus_space_tag_t t;
	bus_space_handle_t h;
	int i;

	/* Validate config info */
	if (cfe->num_memspace != 0)
		printf(": unexpected number of memory spaces %d should be 0\n",
			cfe->num_memspace);
	if (cfe->num_iospace != 1)
		printf(": unexpected number of memory spaces %d should be 1\n",
			cfe->num_iospace);

	/* Allocate pcmcia space - but don't listen to the card, it's lying
	   about the size needed! */
	for (i = 0; i < cfe->num_iospace; i++)
	    if (pcmcia_io_alloc(pa->pf, cfe->iospace[i].start, cfe->iospace[i].length, 1, &psc->sc_pcioh) == 0)
	    	break;
	if (i >= cfe->num_iospace) {
		printf(": can't allocate i/o space\n");
		return 0;
	}

	/* map the selected space */
	if (pcmcia_io_map(pa->pf, ((cfe->flags & PCMCIA_CFE_IO16) ?
	    PCMCIA_WIDTH_IO16 : PCMCIA_WIDTH_IO8), &psc->sc_pcioh,
	    &psc->sc_io_window)) {
		printf(": can't map i/o space\n");
		return 0;
	}

	/* Setup bus space maps */
	sc->sc_num_mappings = 1;
	MALLOC_MAPS(sc);

	/* Copy our handles/tags to the MI maps */
	sc->sc_maps[0].t = psc->sc_pcioh.iot;
	sc->sc_maps[0].h = psc->sc_pcioh.ioh;
	sc->sc_maps[0].offset = 0;
	sc->sc_maps[0].size = 0;	/* not our mapping */

	t = sc->sc_maps[0].t;
	h = sc->sc_maps[0].h;

	sc->clearirq = NULL;
	sc->readreg = avma1_pcmcia_read_reg;
	sc->writereg = avma1_pcmcia_write_reg;

	sc->readfifo = avma1_pcmcia_read_fifo;
	sc->writefifo = avma1_pcmcia_write_fifo;

	/* setup IOM bus type */

	sc->sc_bustyp = BUS_TYPE_IOM2;

	sc->sc_ipac = 0;
	sc->sc_bfifolen = HSCX_FIFO_LEN;

	/* Reset controller again just to make sure... */

	bus_space_write_1(t, h, STAT0_OFFSET, 0x00);
	DELAY(SEC_DELAY / 10);
	bus_space_write_1(t, h, STAT0_OFFSET, 0x01);
	DELAY(SEC_DELAY / 10);
	bus_space_write_1(t, h, STAT0_OFFSET, 0x00);
	DELAY(SEC_DELAY / 10);

	/* enable IRQ, disable counter IRQ */

	bus_space_write_1(t, h, STAT0_OFFSET, ASL_TIMERDISABLE |
		ASL_TIMERRESET | ASL_ENABLE_INT);

	return 1;
}