예제 #1
0
파일: com_ioc.c 프로젝트: ajinkya93/OpenBSD
int
com_ioc_probe(struct device *parent, void *match, void *aux)
{
	struct cfdata *cf = match;
	struct ioc_attach_args *iaa = aux;
	bus_space_tag_t iot = iaa->iaa_memt;
	bus_space_handle_t ioh;
	int rv = 0, console = 0;

	if (strcmp(iaa->iaa_name, com_cd.cd_name) != 0)
		return 0;

	if (comconsiot != NULL)
		console = iaa->iaa_memh + iaa->iaa_base ==
		    comconsiot->bus_base + comconsaddr;

	/* if it's in use as console, it's there. */
	if (!(console && !comconsattached)) {
		if (bus_space_subregion(iot, iaa->iaa_memh,
		    iaa->iaa_base, COM_NPORTS, &ioh) == 0)
			rv = comprobe1(iot, ioh);
	} else
		rv = 1;

	/* make a config stanza with exact locators match over a generic line */
	if (cf->cf_loc[0] != -1)
		rv += rv;

	return rv;
}
예제 #2
0
int
com_commulti_probe(struct device *parent, void *match, void *aux)
{
	struct commulti_attach_args *ca = aux;
	struct cfdata *cf = match;
	bus_space_handle_t ioh;
	bus_space_tag_t iot;
	int iobase;

	if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave)
		return (0);

	iot = ca->ca_iot;
	iobase = ca->ca_iobase;
	ioh = ca->ca_ioh;

#ifdef KGDB
	if (iobase == com_kgdb_addr)
		return (1);
#endif
	/* if it's in use as console, it's there. */
	if (iobase == comconsaddr && !comconsattached)
		return (1);

	return (comprobe1(iot, ioh));
}
예제 #3
0
int
com_isa_probe(struct device *parent, void *match, void *aux)
{
	struct isa_attach_args *ia = aux;
	bus_space_handle_t ioh;
	bus_space_tag_t iot;
	int iobase;
	int rv;

	iot = ia->ia_iot;
	iobase = ia->ia_iobase;

#ifdef KGDB
	if (iobase == com_kgdb_addr)
		goto out;
#endif
	if (iobase == comconsaddr && !comconsattached)
		goto out;

	if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh))
		return (0);

	rv = comprobe1(iot, ioh);

	bus_space_unmap(iot, ioh, COM_NPORTS);

	if (rv == 0)
		return (0);

out:
	ia->ia_iosize = COM_NPORTS;
	ia->ia_msize = 0;
	return (1);
}
예제 #4
0
int
cn30xxuart_probe(struct device *parent, void *match, void *aux)
{
	struct cfdata *cf = match;
	struct uartbus_attach_args *uba = aux;
	bus_space_tag_t iot = uba->uba_memt;
	bus_space_handle_t ioh;
	int rv = 0, console;

	if (strcmp(uba->uba_name, com_cd.cd_name) != 0)
		return 0;

	console = 1;

	/* if it's in use as console, it's there. */
	if (!(console && !comconsattached)) {
		if (bus_space_map(iot, uba->uba_baseaddr, COM_NPORTS, 0, &ioh)) {
			printf(": can't map uart registers\n");
			return 1;
		}
		rv = comprobe1(iot, ioh);
	} else
		rv = 1;

	/* make a config stanza with exact locators match over a generic line */
	if (cf->cf_loc[0] != -1)
		rv += rv;

	return rv;
}
static int
gemini_com_match(device_t parent, cfdata_t cf, void *aux)
{
	struct obio_attach_args *obio = aux;
	bus_space_handle_t bh;
	int rv;

	if (obio->obio_addr == -1 || obio->obio_intr == -1)
	    panic("gemini_com must have addr and intr specified in config.");

	if (obio->obio_size == 0)
		obio->obio_size = GEMINI_UART_SIZE;

	if (com_is_console(obio->obio_iot, obio->obio_addr, NULL))
		return (1);

	if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size,
			  0, &bh))
		return (0);

	rv = comprobe1(obio->obio_iot, bh);

	bus_space_unmap(obio->obio_iot, bh, obio->obio_size);

	return (rv);
}
예제 #6
0
파일: hd64465uart.c 프로젝트: MarginC/kame
void
hd64465uart_attach(struct device *parent, struct device *self, void *aux)
{
	struct hd64465_attach_args *ha = aux;
	struct hd64465uart_softc *sc = (struct hd64465uart_softc *)self;
	struct com_softc *csc = &sc->sc_com;

	sc->sc_chip = &hd64465uart_chip;

	sc->sc_module_id = ha->ha_module_id;

	if (!sc->sc_chip->console)
		hd64465uart_init();

	csc->sc_iot = sc->sc_chip->io_tag;
	bus_space_map(csc->sc_iot, 0, 8, 0, &csc->sc_ioh);
	csc->sc_iobase = 0;
	csc->sc_frequency = COM_FREQ;

	/* supply clock XXX notyet */

	/* sanity check */
	if (!comprobe1(csc->sc_iot, csc->sc_ioh)) {
		printf(": device problem. don't attach.\n");

		/* stop clock XXX notyet */
		return;
	}

	com_attach_subr(csc);

	/* register interrupt handler */
	hd64465_intr_establish(HD64465_UART, IST_LEVEL, IPL_TTY,
	    comintr, self);
}
static int
ixsipcom_match(device_t parent, cfdata_t match, void *aux)
{
	struct ixpsip_attach_args *sa = aux;
	bus_space_tag_t bt = &ixp425_a4x_bs_tag;
	bus_space_handle_t bh;
	int rv;

	if (strcmp(match->cf_name, "ixsipcom") == 0)
		return 1;

	if (com_is_console(bt, sa->sa_addr, NULL))
		return (1);

	if (bus_space_map(bt, sa->sa_addr, sa->sa_size, 0, &bh))
		return (0);

	/* Make sure the UART is enabled */
	bus_space_write_1(bt, bh, com_ier, IER_EUART);

	rv = comprobe1(bt, bh);
	bus_space_unmap(bt, bh, sa->sa_size);

	return (rv);
}
예제 #8
0
static int
com_obio_match(device_t parent, cfdata_t cf, void *aux)
{
	union obio_attach_args *uoba = aux;
	struct sbus_attach_args *sa = &uoba->uoba_sbus;
	int tadpole = 0;
	int need_probe = 0;
	int rv = 0;
	uint8_t auxregval = 0;

	if (uoba->uoba_isobio4 != 0) {
		return (0);
	}

	/*
	 * Tadpole 3GX/3GS uses "modem" for a 16450 port
	 * (We need to enable it before probing)
	 */
	if (strcmp("modem", sa->sa_name) == 0) {
		auxregval = *AUXIO4M_REG;
		*AUXIO4M_REG = auxregval | (AUXIO4M_LED|AUXIO4M_LTE);
		DELAY(100);
		tadpole = 1;
		need_probe = 1;
	}

	/*
	 * Sun JavaStation 1 uses "su" for a 16550 port
	 */
	if (strcmp("su", sa->sa_name) == 0) {
		need_probe = 1;
	}

	if (need_probe) {
		bus_space_handle_t ioh;

		if (sbus_bus_map(sa->sa_bustag,
				 sa->sa_slot, sa->sa_offset, sa->sa_size,
				 BUS_SPACE_MAP_LINEAR, &ioh) == 0) {
			rv = comprobe1(sa->sa_bustag, ioh);
#if 0
			printf("modem: probe: lcr=0x%02x iir=0x%02x\n",
				bus_space_read_1(sa->sa_bustag, ioh, 3),
				bus_space_read_1(sa->sa_bustag, ioh, 2));
#endif
			bus_space_unmap(sa->sa_bustag, ioh, sa->sa_size);
		}
	}

	/* Disable the com port if tadpole */
	if (tadpole)
		*AUXIO4M_REG = auxregval;

	return (rv);
}
예제 #9
0
파일: com.c 프로젝트: lacombar/netbsd-alc
int
comprobe(struct device *parent, struct cfdata *cfp, void *aux)
{
	int iobase = (int)&IODEVbase->psx16550;

	if (strcmp(aux, "com") || com_attached)
		return 0;

	if (!comprobe1(iobase))
		return 0;

	return 1;
}
예제 #10
0
파일: com_isa.c 프로젝트: ryo/netbsd-src
int
com_isa_probe(device_t parent, cfdata_t match, void *aux)
{
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	int iobase;
	int rv = 1;
	struct isa_attach_args *ia = aux;

	if (ia->ia_nio < 1)
		return (0);
	if (ia->ia_nirq < 1)
		return (0);

	if (ISA_DIRECT_CONFIG(ia))
		return (0);

	/* Disallow wildcarded i/o address. */
	if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
		return (0);

	/* Don't allow wildcarded IRQ. */
	if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ)
		return (0);

	iot = ia->ia_iot;
	iobase = ia->ia_io[0].ir_addr;

	/* if it's in use as console, it's there. */
	if (!com_is_console(iot, iobase, 0)) {
		if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
			return 0;
		}
		rv = comprobe1(iot, ioh);
		bus_space_unmap(iot, ioh, COM_NPORTS);
	}

	if (rv) {
		ia->ia_nio = 1;
		ia->ia_io[0].ir_size = COM_NPORTS;

		ia->ia_nirq = 1;

		ia->ia_niomem = 0;
		ia->ia_ndrq = 0;
	}
	return (rv);
}
예제 #11
0
static int
awin_com_match(device_t parent, cfdata_t cf, void *aux)
{
	struct awinio_attach_args * const aio = aux;
	const struct awin_locators * const loc = &aio->aio_loc;
	bus_space_tag_t iot = aio->aio_core_a4x_bst;
	bus_space_handle_t bsh;
	const struct awin_gpio_pinset *pinset;

	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
		pinset = awin_com_pinsets_a31;
	} else if (awin_chip_id() == AWIN_CHIP_ID_A80) {
		pinset = awin_com_pinsets_a80;
	} else {
		pinset = loc->loc_port + ((cf->cf_flags & 1) ?
		    awin_com_alt_pinsets : awin_com_pinsets);
	}

	KASSERT(!strcmp(cf->cf_name, loc->loc_name));
#if defined(ALLWINNER_A80)
	KASSERT(loc->loc_offset >= AWIN_A80_UART0_OFFSET);
	KASSERT(loc->loc_offset <= AWIN_A80_UART5_OFFSET);
#else
	KASSERT(loc->loc_offset >= AWIN_UART0_OFFSET);
	KASSERT(loc->loc_offset <= AWIN_UART7_OFFSET);
#endif
	KASSERT((loc->loc_offset & 0x3ff) == 0);
	KASSERT((awin_com_ports & __BIT(loc->loc_port)) == 0);
	KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT
	    || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port);

	if (!awin_gpio_pinset_available(pinset))
		return 0;

	if (com_is_console(iot, AWIN_CORE_PBASE + loc->loc_offset, NULL))
		return 1;

	awin_gpio_pinset_acquire(pinset);

	bus_space_subregion(iot, aio->aio_core_bsh,
	    loc->loc_offset, loc->loc_size, &bsh);

	const int rv = comprobe1(iot, bsh);

	awin_gpio_pinset_release(pinset);

	return rv;
}
예제 #12
0
int
pxauart_match(struct device *parent, void *cf, void *aux)
{
	struct pxaip_attach_args *pxa = aux;
	bus_space_tag_t bt = &pxa2x0_a4x_bs_tag;	/* XXX: This sucks */
	bus_space_handle_t bh;
	int rv;

	switch (pxa->pxa_addr) {
	case PXA2X0_FFUART_BASE:
		if (pxa->pxa_intr != PXA2X0_INT_FFUART)
			return (0);
		break;

	case PXA2X0_STUART_BASE:
		if (pxa->pxa_intr != PXA2X0_INT_STUART)
			return (0);
		break;

	case PXA2X0_BTUART_BASE:	/* XXX: Config file option ... */
		if (pxa->pxa_intr != PXA2X0_INT_BTUART)
			return (0);
		break;

	default:
		return (0);
	}

	pxa->pxa_size = 0x20;

	{
		extern bus_addr_t comconsaddr;

		if (comconsaddr == pxa->pxa_addr)
			return (1);
	}

	if (bus_space_map(bt, pxa->pxa_addr, pxa->pxa_size, 0, &bh))
		return (0);

	/* Make sure the UART is enabled */
	bus_space_write_1(bt, bh, com_ier, IER_EUART);

	rv = comprobe1(bt, bh);
	bus_space_unmap(bt, bh, pxa->pxa_size);

	return (rv);
}
예제 #13
0
int
com_macebus_probe(struct device *parent, void *match, void *aux)
{
	struct macebus_attach_args *maa = aux;
	bus_space_handle_t ioh;
	int rv;

	/* If it's in use as the console, then it's there. */
	if (maa->maa_baseaddr == comconsaddr && !comconsattached)
		return (1);

	if (bus_space_map(maa->maa_iot, maa->maa_baseaddr, COM_NPORTS, 0, &ioh))
		return (0);

	rv = comprobe1(maa->maa_iot, ioh);
	bus_space_unmap(maa->maa_iot, ioh, COM_NPORTS);

	return rv;
}
예제 #14
0
int
com_multi_probe(device_t parent, cfdata_t match, void *aux)
{
	int iobase;
	struct cfdata *cf = match;
	struct commulti_attach_args *ca = aux;

	if (cf->cf_loc[COMMULTICF_SLAVE] != COMMULTICF_SLAVE_DEFAULT &&
	    cf->cf_loc[COMMULTICF_SLAVE] != ca->ca_slave)
		return (0);

	iobase = ca->ca_iobase;

	/* if it's in use as console, it's there. */
	if (com_is_console(ca->ca_iot, iobase, 0))
		return 1;

	return comprobe1(ca->ca_iot, ca->ca_ioh);
}
예제 #15
0
static int
obiouart_match(device_t parent, cfdata_t cf, void *aux)
{
	struct obio_attach_args *obio = aux;
	bus_space_handle_t bsh;
	bus_addr_t ioaddr;

	switch (obio->obio_base) {
	case ROCKCHIP_CORE0_BASE:
		KASSERT(obio->obio_offset == ROCKCHIP_UART0_OFFSET ||
			obio->obio_offset == ROCKCHIP_UART1_OFFSET);
		break;
	case ROCKCHIP_CORE1_BASE:
		KASSERT(obio->obio_offset == ROCKCHIP_UART2_OFFSET ||
			obio->obio_offset == ROCKCHIP_UART3_OFFSET);
		break;
	default:
		panic("obiouart must have addr specified in config.");
	}

	ioaddr = obio->obio_base + obio->obio_offset;

#if 0
	/*
	 * XXX this should be ifdefed on a board-dependent switch
	 * We don't know what is the irq for com0 on the sdp2430 
	 */
	if (obio->obio_intr == OBIOCF_INTR_DEFAULT)
		panic("obiouart must have intr specified in config.");
#endif

	if (obio->obio_size == OBIOCF_SIZE_DEFAULT)
		obio->obio_size = ROCKCHIP_UART_SIZE;

	if (com_is_console(obio->obio_bst, ioaddr, NULL))
		return 1;

	bus_space_subregion(obio->obio_bst, obio->obio_bsh, obio->obio_size, 0,
	    &bsh);

	return comprobe1(obio->obio_bst, bsh);
}
예제 #16
0
파일: com_ebus.c 프로젝트: ryo/netbsd-src
static int
com_ebus_match(device_t parent, cfdata_t cf, void *aux)
{
	struct ebus_attach_args *ea = aux;
	bus_space_handle_t ioh;
	int match;

	if (strcmp(ea->ea_name, "su") != 0)
		return (0);

	match = 0;
	if (bus_space_map(ea->ea_bustag, EBUS_ADDR_FROM_REG(&ea->ea_reg[0]),
			  ea->ea_reg[0].size, 0, &ioh) == 0)
	{
		match = comprobe1(ea->ea_bustag, ioh);
		bus_space_unmap(ea->ea_bustag, ioh, ea->ea_reg[0].size);
	}

	return (match);
}
static int
amlogic_com_match(device_t parent, cfdata_t cf, void *aux)
{
	struct amlogicio_attach_args * const aio = aux;
	const struct amlogic_locators * const loc = &aio->aio_loc;
	bus_space_tag_t iot = aio->aio_core_a4x_bst;
	bus_space_handle_t bsh;

	KASSERT(!strcmp(cf->cf_name, loc->loc_name));
	KASSERT((amlogic_com_ports & __BIT(loc->loc_port)) == 0);
	KASSERT(cf->cf_loc[AMLOGICIOCF_PORT] == AMLOGICIOCF_PORT_DEFAULT
	    || cf->cf_loc[AMLOGICIOCF_PORT] == loc->loc_port);

	if (com_is_console(iot, AMLOGIC_CORE_BASE + loc->loc_offset, NULL))
		return 1;

	bus_space_subregion(iot, aio->aio_bsh,
	    loc->loc_offset, loc->loc_size, &bsh);

	const int rv = comprobe1(iot, bsh);

	return rv;
}
static int
pxauart_match(device_t parent, cfdata_t cf, void *aux)
{
	struct pxaip_attach_args *pxa = aux;
	bus_space_tag_t bt = &pxa2x0_a4x_bs_tag;	/* XXX: This sucks */
	bus_space_handle_t bh;
	struct pxa2x0_gpioconf *gpioconf;
	u_int gpio;
	int rv, i;

	switch (pxa->pxa_addr) {
	case PXA2X0_FFUART_BASE:
		if (pxa->pxa_intr != PXA2X0_INT_FFUART)
			return (0);
		gpioconf = CPU_IS_PXA250 ? pxa25x_com_ffuart_gpioconf :
			    pxa27x_com_ffuart_gpioconf;
		break;

	case PXA2X0_STUART_BASE:
		if (pxa->pxa_intr != PXA2X0_INT_STUART)
			return (0);
		gpioconf = CPU_IS_PXA250 ? pxa25x_com_stuart_gpioconf :
			    pxa27x_com_stuart_gpioconf;
		break;

	case PXA2X0_BTUART_BASE:	/* XXX: Config file option ... */
		if (pxa->pxa_intr != PXA2X0_INT_BTUART)
			return (0);
		gpioconf = CPU_IS_PXA250 ? pxa25x_com_btuart_gpioconf :
			    pxa27x_com_btuart_gpioconf;
		break;

	case PXA2X0_HWUART_BASE:
		if (pxa->pxa_intr != PXA2X0_INT_HWUART)
			return (0);
		if (CPU_IS_PXA270)
			return (0);
		gpioconf = pxa25x_com_hwuart_gpioconf;
		break;

	default:
		return (0);
	}
	for (i = 0; gpioconf[i].pin != -1; i++) {
		gpio = pxa2x0_gpio_get_function(gpioconf[i].pin);
		if (GPIO_FN(gpio) != GPIO_FN(gpioconf[i].value) ||
		    GPIO_FN_IS_OUT(gpio) != GPIO_FN_IS_OUT(gpioconf[i].value))
			return (0);
	}

	pxa->pxa_size = 0x20;

	if (com_is_console(bt, pxa->pxa_addr, NULL))
		return (1);

	if (bus_space_map(bt, pxa->pxa_addr, pxa->pxa_size, 0, &bh))
		return (0);

	/* Make sure the UART is enabled */
	bus_space_write_1(bt, bh, com_ier, IER_EUART);

	rv = comprobe1(bt, bh);
	bus_space_unmap(bt, bh, pxa->pxa_size);

	return (rv);
}
예제 #19
0
파일: ioat66.c 프로젝트: ryo/netbsd-src
int
ioat66probe(device_t parent, cfdata_t self, void *aux)
{
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;
	int iobase;
	int i, rv = 1;

	if (ia->ia_niomem < 1)
		return (0);
	if (ia->ia_nirq < 1)
		return (0);
	/*
	 * Do the normal com probe for the first UART and assume
	 * its presence, and the ability to map the other UARTS,
	 * means there is a multiport board there.
	 * XXX Needs more robustness.
	 */

	/* Disallow wildcarded i/o address. */
	if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
		return 0;

	if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ)
		return (0);

	iobase = ia->ia_io[0].ir_addr;
	/* if the first port is in use as console, then it. */
	if (com_is_console(iot, iobase, 0))
		goto checkmappings;

	if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
		rv = 0;
		goto out;
	}
	rv = comprobe1(iot, ioh);
	bus_space_unmap(iot, ioh, COM_NPORTS);
	if (rv == 0)
		goto out;

checkmappings:
	for (i = 1; i < NSLAVES; i++) {
		iobase = ioatbases[i];

		if (com_is_console(iot, iobase, 0))
			continue;

		if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
			rv = 0;
			goto out;
		}
		bus_space_unmap(iot, ioh, COM_NPORTS);
	}

out:
	if (rv) {
		ia->ia_nio = 1;
		ia->ia_io[0].ir_size = NSLAVES * COM_NPORTS;
		ia->ia_nirq = 1;
		ia->ia_niomem = 0;
		ia->ia_ndrq = 0;
	}
	return (rv);
}