Esempio n. 1
0
void
com_mainbus_attach(device_t parent, device_t self, void *aux)
{
	struct com_mainbus_softc *msc = device_private(self);
	struct com_softc *sc = &msc->sc_com;
	struct mainbus_attach_args *ma = aux;
	bus_space_handle_t ioh;

	sc->sc_dev = self;
	if (com_is_console(ma->ma_st, ma->ma_addr, &ioh) == 0 &&
	    bus_space_map(ma->ma_st, ma->ma_addr, COM_NPORTS, 0, &ioh) != 0) {
		aprint_error(": can't map i/o space\n");
		return;
	}
	COM_INIT_REGS(sc->sc_regs, ma->ma_st, ioh, ma->ma_addr);
	sc->sc_frequency = COM_FREQ;

	com_attach_subr(sc);

	msc->sc_ih = (*algor_intr_establish)(ma->ma_irq, comintr, sc);
	if (msc->sc_ih == NULL) {
		aprint_error_dev(self, "unable to establish interrupt\n");
		return;
	}

	if (!pmf_device_register1(self, com_suspend, com_resume, com_cleanup)) {
		aprint_error_dev(self, "could not establish shutdown hook");
	}

}
Esempio n. 2
0
static void
com_acemidi_attach(device_t parent, device_t self, void *aux)
{
	struct com_acemidi_softc *sc = device_private(self);
	struct com_softc *csc = &sc->sc_com;
	struct podulebus_attach_args *pa = aux;
	bus_space_handle_t ioh;
	bus_space_tag_t iot;
	bus_addr_t iobase;

	iot = pa->pa_fast_t;
	iobase = pa->pa_fast_base + ACEMIDI_16550_BASE;

	bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh);
	COM_INIT_REGS(csc->sc_regs, iot, ioh, iobase);

	csc->sc_frequency = ACEMIDI_16550_FREQ;

	com_attach_subr(csc);

	evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
	    device_xname(self), "intr");
	podulebus_irq_establish(pa->pa_ih, IPL_SERIAL, comintr, sc,
	    &sc->sc_intrcnt);
}
static void
pxauart_attach(device_t parent, device_t self, void *aux)
{
	struct com_softc *sc = device_private(self);
	struct pxaip_attach_args *pxa = aux;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_addr_t iobase;
	int cken = 0;

	sc->sc_dev = self;
	iot = &pxa2x0_a4x_bs_tag;	/* XXX: This sucks */
	iobase = pxa->pxa_addr;
	sc->sc_frequency = PXA2X0_COM_FREQ;
	sc->sc_type = COM_TYPE_PXA2x0;

	if (com_is_console(iot, iobase, &ioh) == 0 &&
	    bus_space_map(iot, iobase, pxa->pxa_size, 0, &ioh)) {
		aprint_error(": can't map registers\n");
		return;
	}
	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	switch (pxa->pxa_addr) {
	case PXA2X0_FFUART_BASE: cken = CKEN_FFUART; break;
	case PXA2X0_STUART_BASE: cken = CKEN_STUART; break;
	case PXA2X0_BTUART_BASE: cken = CKEN_BTUART; break;
	case PXA2X0_HWUART_BASE: cken = CKEN_HWUART; break;
	}
	pxa2x0_clkman_config(cken, 1);

	com_attach_subr(sc);

	pxa2x0_intr_establish(pxa->pxa_intr, IPL_SERIAL, comintr, sc);
}
Esempio n. 4
0
static void
com_mace_attach(device_t parent, device_t self, void *aux)
{
	struct com_mace_softc *msc = device_private(self);
	struct com_softc *sc = &msc->sc_com;
	struct mace_attach_args *maa = aux;
	bus_space_handle_t	ioh;

	sc->sc_dev = self;

	/*
	 * XXX should check com_is_console() and 
	 * XXX use bus_space_map().
	 */
	ioh = maa->maa_sh + maa->maa_offset;
	/* note that ioh on mac is *also* the iobase address */
	COM_INIT_REGS(sc->sc_regs, maa->maa_st, ioh, ioh);

	sc->sc_frequency = COM_FREQ;

	delay(10000);
	com_attach_subr(sc);
	delay(10000);

	cpu_intr_establish(maa->maa_intr, maa->maa_intrmask, comintr, sc);

	return;
}
Esempio n. 5
0
static void
obiouart_attach(device_t parent, device_t self, void *aux)
{
	struct com_obio_softc *osc = device_private(self);
	struct com_softc *sc = &osc->sc_sc;
	struct obio_attach_args *obio = aux;
	bus_space_tag_t bst;
	bus_space_handle_t bsh = 0;
	bus_addr_t iobase;

	sc->sc_dev = self;

	bst = obio->obio_bst;
	iobase = obio->obio_base + obio->obio_offset;
	sc->sc_frequency = ROCKCHIP_UART_FREQ;
	sc->sc_type = COM_TYPE_NORMAL;

	if (com_is_console(bst, iobase, &bsh) == 0 &&
	    bus_space_subregion(bst, obio->obio_bsh, obio->obio_size, 0, &bsh)) {
		panic(": can't map registers\n");
		return;
	}
	COM_INIT_REGS(sc->sc_regs, bst, bsh, iobase);

	com_attach_subr(sc);
	aprint_naive("\n");

	KASSERT(obio->obio_intr != OBIOCF_INTR_DEFAULT);
	osc->sc_ih = intr_establish(obio->obio_intr, IPL_SERIAL, IST_LEVEL,
			comintr, sc);
	if (osc->sc_ih == NULL)
		panic("%s: failed to establish interrup %d",
		    device_xname(self), obio->obio_intr);
}
Esempio n. 6
0
void
com_obio_attach(device_t parent, device_t self, void *aux)
{
	struct obio_attach_args *oba = aux;
	struct com_obio_softc *osc = device_private(self);
	struct com_softc *sc = &osc->sc_com;
	bus_space_handle_t ioh;
	int error;

	sc->sc_dev = self;
	sc->sc_frequency = COM_FREQ;
	sc->sc_hwflags = COM_HW_NO_TXPRELOAD;
	error = bus_space_map(oba->oba_st, oba->oba_addr, 8, 0, &ioh);

	if (error) {
		aprint_error(": failed to map registers: %d\n", error);
		return;
	}
	COM_INIT_REGS(sc->sc_regs, oba->oba_st, ioh, oba->oba_addr);

	com_attach_subr(sc);

	osc->sc_ih = i80321_intr_establish(oba->oba_irq, IPL_SERIAL,
	    comintr, sc);
	if (osc->sc_ih == NULL)
		aprint_error_dev(self,
		    "unable to establish interrupt at irq %d\n", oba->oba_irq);
}
Esempio n. 7
0
void
ralink_com_attach(device_t parent, device_t self, void *aux)
{
	const struct mainbus_attach_args *ma = aux;
	struct ralink_com_softc * const rtsc = device_private(self);
	struct com_softc * const sc = &rtsc->sc_com;
	bus_space_handle_t ioh;
	int error;

	if ((error = bus_space_map(ma->ma_memt, RA_UART_LITE_BASE,
	    0x1000, 0, &ioh)) != 0) {
		aprint_error(": can't map registers, error=%d\n", error);
		return;
	}

	COM_INIT_REGS(sc->sc_regs, ma->ma_memt, ioh, RA_UART_LITE_BASE);
	sc->sc_dev = self;
	sc->sc_frequency = RA_UART_FREQ;
	sc->sc_regs.cr_nports = 0x1000;
	sc->sc_type = COM_TYPE_AU1x00;
	sc->enabled = 1;

	ralink_com_initmap(&sc->sc_regs);

	rtsc->sc_ih = ra_intr_establish(RA_IRQ_UARTL, comintr, sc, 1);

	com_attach_subr(sc);
}
Esempio n. 8
0
void
pxauart_attach(struct device *parent, struct device *self, void *aux)
{
	struct com_softc *sc = (struct com_softc *)self;
	struct pxaip_attach_args *pxa = aux;

	sc->sc_iot = &pxa2x0_a4x_bs_tag;	/* XXX: This sucks */
	sc->sc_iobase = pxa->pxa_addr;
	sc->sc_frequency = PXA2X0_COM_FREQ;
	sc->sc_uarttype = COM_UART_PXA2X0;

#if 0
	if (com_is_console(sc->sc_iot, sc->sc_iobase, &sc->sc_ioh) == 0 &&
	    bus_space_map(sc->sc_iot, sc->sc_iobase, pxa->pxa_size, 0,
			  &sc->sc_ioh)) {
		printf(": can't map registers\n");
		return;
	}
#endif
	bus_space_map(sc->sc_iot, sc->sc_iobase, pxa->pxa_size, 0, &sc->sc_ioh);

	com_attach_subr(sc);

	(void)pxa2x0_intr_establish(pxa->pxa_intr, IPL_TTY, comintr,
	    sc, sc->sc_dev.dv_xname);

	(void)powerhook_establish(&pxauart_power, sc);
}
static void
gemini_com_attach(device_t parent, device_t self, void *aux)
{
	struct com_softc *sc = device_private(self);
	struct obio_attach_args *obio = aux;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_addr_t iobase;

	sc->sc_dev = self;
	iot = obio->obio_iot;
	iobase = obio->obio_addr;
	sc->sc_frequency = GEMINI_COM_FREQ;
	sc->sc_type = COM_TYPE_16550_NOERS;

	if (com_is_console(iot, iobase, &ioh) == 0 &&
	    bus_space_map(iot, iobase, obio->obio_size, 0, &ioh)) {
		panic(": can't map registers\n");
		return;
	}
	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	com_attach_subr(sc);
	aprint_naive("\n");

	intr_establish(obio->obio_intr, IPL_SERIAL, IST_LEVEL_HIGH,
		comintr, sc);
}
static void
ixsipcom_attach(device_t parent, device_t self, void *aux)
{
	struct com_softc *sc = device_private(self);
	struct ixpsip_attach_args *sa = aux;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_addr_t iobase;

	sc->sc_dev = self;
	iot = &ixp425_a4x_bs_tag;
	iobase = sa->sa_addr;
	sc->sc_frequency = IXP425_UART_FREQ;
	sc->sc_type = COM_TYPE_PXA2x0;

	if (com_is_console(iot, iobase, &ioh) == 0 &&
	    bus_space_map(iot, iobase, sa->sa_size, 0, &ioh)) {
		aprint_error(": can't map registers\n");
		return;
	}
	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	com_attach_subr(sc);

	ixp425_intr_establish(uart_irq[sa->sa_index], IPL_SERIAL, comintr, sc);
}
Esempio n. 11
0
void
com_jensenio_attach(device_t parent, device_t self, void *aux)
{
	struct com_jensenio_softc *jsc = device_private(self);
	struct com_softc *sc = &jsc->sc_com;
	struct jensenio_attach_args *ja = aux;
	bus_space_handle_t ioh;

	sc->sc_dev = self;
	if (com_is_console(ja->ja_iot, ja->ja_ioaddr, &ioh) == 0 &&
	    bus_space_map(ja->ja_iot, ja->ja_ioaddr, COM_NPORTS, 0,
		&ioh) != 0) {
		aprint_error(": can't map i/o space\n");
		return;
	}
	COM_INIT_REGS(sc->sc_regs, ja->ja_iot, ioh, ja->ja_ioaddr);

	sc->sc_frequency = COM_FREQ;

	com_attach_subr(sc);

	scb_set(ja->ja_irq[0], com_jensenio_intr, sc, IPL_VM);
	aprint_normal_dev(self, "interrupting at vector 0x%x\n",
	    ja->ja_irq[0]);

	sprintf(jsc->sc_vecstr, "0x%x", ja->ja_irq[0]);
	evcnt_attach_dynamic(&jsc->sc_ev_intr, EVCNT_TYPE_INTR,
	    NULL, "vector", jsc->sc_vecstr);

	if (!pmf_device_register1(self, com_suspend, com_resume, com_cleanup)) {
		aprint_error_dev(self, "could not establish shutdown hook");
	}
}
static void
amlogic_com_attach(device_t parent, device_t self, void *aux)
{
	struct amlogic_com_softc * const asc = device_private(self);
	struct com_softc * const sc = &asc->asc_sc;
	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;
	const bus_addr_t iobase = AMLOGIC_CORE_BASE + loc->loc_offset;
	bus_space_handle_t ioh;

	amlogic_com_ports |= __BIT(loc->loc_port);

	sc->sc_dev = self;
	sc->sc_frequency = AMLOGIC_UART_FREQ;
	sc->sc_type = COM_TYPE_NORMAL;

	if (com_is_console(iot, iobase, &ioh) == 0
	    && bus_space_subregion(iot, aio->aio_bsh,
		loc->loc_offset / 4, loc->loc_size, &ioh)) {
		panic(": can't map registers");
	}
	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	com_attach_subr(sc);
	aprint_naive("\n");

	KASSERT(loc->loc_intr != AMLOGICIO_INTR_DEFAULT);
	asc->asc_ih = intr_establish(loc->loc_intr, IPL_SERIAL,
	    IST_EDGE | IST_MPSAFE, comintr, sc);
	if (asc->asc_ih == NULL)
		panic("%s: failed to establish interrupt %d",
		    device_xname(self), loc->loc_intr);
}
Esempio n. 13
0
void
com_cpc_attach(struct device *parent, struct device *self, void *aux)
{
	struct cpcbus_attach_args *caa = aux;
	struct com_cpc_softc *sc = (struct com_cpc_softc *)self;
	int iobase = caa->cpca_addr;
	int irq = caa->cpca_irq;

	sc->sc_com.sc_iot = caa->cpca_tag;
	sc->sc_com.sc_iobase = iobase;

	if (!com_is_console(sc->sc_com.sc_iot, iobase, &sc->sc_com.sc_ioh) &&
	    bus_space_map(sc->sc_com.sc_iot, iobase, COM_NPORTS, 0,
			  &sc->sc_com.sc_ioh)) {
		printf("%s: can't map i/o space\n", self->dv_xname);
		return;
	}

	sc->sc_com.sc_frequency = CPC_COM_SPEED(caa->cpca_freq);

	com_attach_subr(&sc->sc_com);

	sc->sc_ih = intr_establish(irq, IST_LEVEL, IPL_SERIAL, comintr,
				   &sc->sc_com);
}
Esempio n. 14
0
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);
}
Esempio n. 15
0
void
com_macebus_attach(struct device *parent, struct device *self, void *aux)
{
	struct com_softc *sc = (void *)self;
	struct macebus_attach_args *maa = aux;

	sc->sc_iot = maa->maa_iot;
	sc->sc_hwflags = 0;
	sc->sc_swflags = 0;
	sc->sc_iobase = maa->maa_baseaddr;
	sc->sc_frequency = 1843200;

	/* If it's in use as the console, then it's there. */
	if (maa->maa_baseaddr == comconsaddr && !comconsattached) {
		if (comcnattach(sc->sc_iot, sc->sc_iobase, comconsrate,
		    sc->sc_frequency, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
			panic("failed to setup serial console!");
		sc->sc_ioh = comconsioh;
	} else {
		if (bus_space_map(sc->sc_iot, maa->maa_baseaddr, COM_NPORTS, 0,
		    &sc->sc_ioh)) {
			printf(": can't map i/o space\n");
			return;
		}
	}

	com_attach_subr(sc);

	macebus_intr_establish(maa->maa_intr, maa->maa_mace_intr,
	    IST_EDGE, IPL_TTY, comintr, (void *)sc, sc->sc_dev.dv_xname);
}
Esempio n. 16
0
void
com_isa_attach(struct device *parent, struct device *self, void *aux)
{
	struct com_softc *sc = (struct com_softc *)self;
	struct isa_attach_args *ia = aux;
	bus_space_handle_t ioh;
	bus_space_tag_t iot;
	int iobase, irq;

	sc->sc_hwflags = 0;
	sc->sc_swflags = 0;

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

#ifdef KGBD
	if ((iobase != comconsaddr) &&
	    (iobase != com_kgdb_addr)) {
#else
	if (iobase != comconsaddr) {
#endif
		if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh))
			panic("com_isa_attach: mapping failed");
	} else {
#ifdef KGDB
		if (iobase == comconsaddr)
			ioh = comconsioh;
		else
			ioh = com_kgdb_ioh;
#else
		ioh = comconsioh;
#endif
	}

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_iobase = iobase;
	sc->sc_frequency = COM_FREQ;

	com_attach_subr(sc);

	irq = ia->ia_irq;
	if (irq != IRQUNK) {
#ifdef KGDB     
		if (iobase == com_kgdb_addr) {
			sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
				IST_EDGE, IPL_HIGH, kgdbintr, sc,
				sc->sc_dev.dv_xname);
		} else {
			sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
				IST_EDGE, IPL_TTY, comintr, sc,
				sc->sc_dev.dv_xname);
		}
#else   
		sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
			IST_EDGE, IPL_TTY, comintr, sc,
			sc->sc_dev.dv_xname);
#endif /* KGDB */
	}
}
Esempio n. 17
0
void
com_eumb_attach(device_t parent, device_t self, void *aux)
{
	struct com_softc *sc = device_private(self);
	struct eumb_attach_args *eaa = aux;
	int comaddr, epicirq;
	bus_space_handle_t ioh;
	extern u_long ticks_per_sec;

	sc->sc_dev = self;
	found = 1;

	comaddr = (eaa->eumb_unit == 1) ? 0x4600 : 0x4500;
	if (comaddr == cnregs.cr_iobase)
		sc->sc_regs = cnregs;
	else {
		ioh = comaddr;
		bus_space_map(eaa->eumb_bt, comaddr, COM_NPORTS, 0, &ioh);
		COM_INIT_REGS(sc->sc_regs, eaa->eumb_bt, ioh, comaddr);
	}
	sc->sc_frequency = 4 * ticks_per_sec;
	epicirq = (eaa->eumb_unit == 1) ? 25 : 24;

	com_attach_subr(sc);
	intr_establish(epicirq + 16, IST_LEVEL, IPL_SERIAL, comintr, sc);
}
Esempio n. 18
0
void
com_isa_attach(device_t parent, device_t self, void *aux)
{
	struct com_isa_softc *isc = device_private(self);
	struct com_softc *sc = &isc->sc_com;
	int iobase, irq;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	struct isa_attach_args *ia = aux;
#ifdef COM_HAYESP
	int	hayesp_ports[] = { 0x140, 0x180, 0x280, 0x300, 0 };
	int	*hayespp;
#endif

	/*
	 * We're living on an isa.
	 */
	iobase = ia->ia_io[0].ir_addr;
	iot = ia->ia_iot;

	if (!com_is_console(iot, iobase, &ioh) &&
	    bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
		printf(": can't map i/o space\n");
		return;
	}

	sc->sc_dev = self;

	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	sc->sc_frequency = COM_FREQ;
	irq = ia->ia_irq[0].ir_irq;

#ifdef COM_HAYESP
	for (hayespp = hayesp_ports; *hayespp != 0; hayespp++) {
		bus_space_handle_t	hayespioh;
#define	HAYESP_NPORTS	8
		if (bus_space_map(iot, *hayespp, HAYESP_NPORTS, 0, &hayespioh))
			continue;
		if (com_isa_isHAYESP(hayespioh, sc)) {
			break;
		}
		bus_space_unmap(iot, hayespioh, HAYESP_NPORTS);
	}
#endif

	com_attach_subr(sc);

	if (!pmf_device_register1(self, com_isa_suspend, com_isa_resume,
	    com_cleanup))
		aprint_error_dev(self, "couldn't establish power handler\n");

	isc->sc_ic = ia->ia_ic;
	isc->sc_irq = irq;
	isc->sc_ih = isa_intr_establish_xname(ia->ia_ic, irq, IST_EDGE,
	    IPL_SERIAL, comintr, sc, device_xname(sc->sc_dev));
}
Esempio n. 19
0
void
com_cardbus_attach(struct device *parent, struct device *self, void *aux)
{
	struct com_softc *sc = (struct com_softc*)self;
	struct com_cardbus_softc *csc = (struct com_cardbus_softc*)self;
	struct cardbus_attach_args *ca = aux;

	csc->cc_ct = ca->ca_ct;
	csc->cc_tag = Cardbus_make_tag(csc->cc_ct);

	if (com_cardbus_gofigure(ca, csc) != 0)
		return;

	if (Cardbus_mapreg_map(ca->ca_ct, csc->cc_reg, csc->cc_type, 0,
	    &sc->sc_iot, &sc->sc_ioh, &csc->cc_addr, &csc->cc_size) != 0) {
		printf("failed to map memory");
		return;
	}

	csc->cc_base = csc->cc_addr;
	csc->cc_csr = CARDBUS_COMMAND_MASTER_ENABLE;
	if (csc->cc_type == CARDBUS_MAPREG_TYPE_IO) {
		csc->cc_base |= CARDBUS_MAPREG_TYPE_IO;
		csc->cc_csr |= CARDBUS_COMMAND_IO_ENABLE;
		csc->cc_cben = CARDBUS_IO_ENABLE;
	} else {
		csc->cc_csr |= CARDBUS_COMMAND_MEM_ENABLE;
		csc->cc_cben = CARDBUS_MEM_ENABLE;
	}

	sc->sc_iobase = csc->cc_addr;
	sc->sc_frequency = COM_FREQ;

	sc->enable = com_cardbus_enable;
	sc->disable = com_cardbus_disable;
	sc->enabled = 0;

	if (ca->ca_cis.cis1_info[0] && ca->ca_cis.cis1_info[1]) {
		printf(": %s %s\n", ca->ca_cis.cis1_info[0],
		    ca->ca_cis.cis1_info[1]);
		printf("%s", DEVNAME(csc));
	}

	if (com_cardbus_enable(sc))
		printf(": function enable failed\n");
	sc->enabled = 1;

	sc->sc_hwflags = 0;
	sc->sc_swflags = 0;

	if (csc->cc_bug & BUG_BROADCOM)
		sc->sc_fifolen = 15;

	com_attach_subr(sc);
}
Esempio n. 20
0
void
com_gsc_attach(device_t parent, device_t self, void *aux)
{
	struct com_gsc_softc *gsc = device_private(self);
	struct com_softc *sc = &gsc->sc_com;
	struct gsc_attach_args *ga = aux;
	int pagezero_cookie;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_addr_t iobase;

	sc->sc_dev = self;
	sc->sc_hwflags = 0;
	sc->sc_swflags = 0;
	iot = ga->ga_iot;
	iobase = (bus_addr_t)ga->ga_hpa + COMGSC_OFFSET;
	sc->sc_frequency = COMGSC_FREQUENCY;

	/* Test if this is the console.  Compare either HPA or device path. */
	pagezero_cookie = hp700_pagezero_map();
	if ((hppa_hpa_t)PAGE0->mem_cons.pz_hpa == ga->ga_hpa ) {

		/*
		 * This port is the console.  In this case we must call
		 * comcnattach() and later com_is_console() to initialize
		 * everything properly.
		 */

		if (comcnattach(iot, iobase, B9600,
			sc->sc_frequency, COM_TYPE_NORMAL,
			(TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8) != 0) {
			aprint_error(": can't comcnattach\n");
			hp700_pagezero_unmap(pagezero_cookie);
			return;
		}
	}
	hp700_pagezero_unmap(pagezero_cookie);

	/*
	 * Get the already initialized console ioh via com_is_console() if
	 * this is the console or map the I/O space if this isn't the console.
	 */

	if (!com_is_console(iot, iobase, &ioh) &&
	    bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh) != 0) {
		aprint_error(": can't map I/O space\n");
		return;
	}
	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	com_attach_subr(sc);
	gsc->sc_ih = hp700_intr_establish(sc->sc_dev, IPL_TTY,
	    comintr, sc, ga->ga_int_reg, ga->ga_irq);
}
Esempio n. 21
0
static void
com_upc_attach(device_t parent, device_t self, void *aux)
{
	struct com_softc *sc = device_private(self);
	struct upc_attach_args *ua = aux;

	sc->sc_dev = self;
	sc->sc_frequency = COM_FREQ;

	COM_INIT_REGS(sc->sc_regs, ua->ua_iot, ua->ua_ioh, ua->ua_offset);
	com_attach_subr(sc);
	upc_intr_establish(ua->ua_irqhandle, IPL_SERIAL, comintr, sc);
}
Esempio n. 22
0
void
com_mca_attach(device_t parent, device_t self, void *aux)
{
	struct com_mca_softc *isc = device_private(self);
	struct com_softc *sc = &isc->sc_com;
	int iobase, irq;
	struct mca_attach_args *ma = aux;
	const struct com_mca_product *cpp;
	bus_space_handle_t ioh;

	sc->sc_dev = self;
	cpp = com_mca_lookup(ma->ma_id);

	/* get iobase and irq */
	if ((*cpp->cp_getcfg)(ma, &iobase, &irq))
		return;

	if (bus_space_map(ma->ma_iot, iobase, COM_NPORTS, 0, &ioh)) {
		aprint_error(": can't map i/o space\n");
		return;
	}

	COM_INIT_REGS(sc->sc_regs, ma->ma_iot, ioh, iobase);
	sc->sc_frequency = COM_FREQ;

	aprint_normal(" slot %d i/o %#x-%#x irq %d", ma->ma_slot + 1,
		iobase, iobase + COM_NPORTS - 1, irq);

	com_attach_subr(sc);

	aprint_normal_dev(self, "%s\n", cpp->cp_name);

	isc->sc_ih = mca_intr_establish(ma->ma_mc, irq, IPL_SERIAL,
			comintr, sc);
	if (isc->sc_ih == NULL) {
                aprint_error_dev(self,
		    "couldn't establish interrupt handler\n");
                return;
        }

	/*
	 * com_cleanup: shutdown hook for buggy BIOSs that don't
	 * recognize the UART without a disabled FIFO.
	 * XXX is this necessary on MCA ? --- jdolecek
	 */
	if (!pmf_device_register1(self, com_suspend, com_resume, com_cleanup))
		aprint_error_dev(self, "could not establish shutdown hook\n");
}
Esempio n. 23
0
void
com_ioc_attach(struct device *parent, struct device *self, void *aux)
{
	struct com_softc *sc = (void *)self;
	struct ioc_attach_args *iaa = aux;
	bus_space_handle_t ioh;
	int console = 0;

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

	sc->sc_hwflags = 0;
	sc->sc_swflags = 0;
	sc->sc_frequency = 22000000 / 3;

	/* if it's in use as console, it's there. */
	if (!(console && !comconsattached)) {
		sc->sc_iot = iaa->iaa_memt;
		sc->sc_iobase = iaa->iaa_base;

		if (bus_space_subregion(iaa->iaa_memt, iaa->iaa_memh,
		    iaa->iaa_base, COM_NPORTS, &ioh) != 0) {
			printf(": can't map registers\n");
			return;
		}
	} else {
		/*
		 * If we are the console, reuse the existing bus_space
		 * information, so that comcnattach() invokes bus_space_map()
		 * with correct parameters.
		 */
		sc->sc_iot = comconsiot;
		sc->sc_iobase = comconsaddr;

		if (comcnattach(sc->sc_iot, sc->sc_iobase, comconsrate,
		    sc->sc_frequency, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
			panic("can't setup serial console");
		ioh = comconsioh;
	}

	sc->sc_ioh = ioh;

	com_attach_subr(sc);

	ioc_intr_establish(parent, iaa->iaa_dev, IPL_TTY, comintr,
	    (void *)sc, sc->sc_dev.dv_xname);
}
static void
awin_com_attach(device_t parent, device_t self, void *aux)
{
	cfdata_t cf = device_cfdata(self);
	struct awin_com_softc * const asc = device_private(self);
	struct com_softc * const sc = &asc->asc_sc;
	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;
	const bus_addr_t iobase = AWIN_CORE_PBASE + loc->loc_offset;
	const struct awin_gpio_pinset *pinset;
	bus_space_handle_t ioh;

	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);
	}

	awin_com_ports |= __BIT(loc->loc_port);

	awin_gpio_pinset_acquire(pinset);

	sc->sc_dev = self;
	sc->sc_frequency = AWIN_UART_FREQ;
	sc->sc_type = COM_TYPE_NORMAL;

	if (com_is_console(iot, iobase, &ioh) == 0
	    && bus_space_subregion(iot, aio->aio_core_bsh,
		loc->loc_offset / 4, loc->loc_size, &ioh)) {
		panic(": can't map registers");
	}
	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	com_attach_subr(sc);
	aprint_naive("\n");

	KASSERT(loc->loc_intr != AWINIO_INTR_DEFAULT);
	asc->asc_ih = intr_establish(loc->loc_intr, IPL_SERIAL,
	    IST_EDGE | IST_MPSAFE, comintr, sc);
	if (asc->asc_ih == NULL)
		panic("%s: failed to establish interrupt %d",
		    device_xname(self), loc->loc_intr);
}
Esempio n. 25
0
void
com_commulti_attach(struct device *parent, struct device *self, void *aux)
{
	struct commulti_attach_args *ca = aux;
	struct com_softc *sc = (void *)self;

	sc->sc_hwflags = 0;
	sc->sc_swflags = 0;
	sc->sc_iot = ca->ca_iot;
	sc->sc_ioh = ca->ca_ioh;
	sc->sc_iobase = ca->ca_iobase;
	sc->sc_frequency = COM_FREQ;
	if (ca->ca_noien)
		SET(sc->sc_hwflags, COM_HW_NOIEN);

	com_attach_subr(sc);
}
STATIC void
hd64461uart_attach(device_t parent, device_t self, void *aux)
{
	struct hd64461_attach_args *ha = aux;
	struct hd64461uart_softc *sc = device_private(self);
	struct com_softc *csc = &sc->sc_com;
	uint16_t r16, or16;
	bus_space_handle_t ioh;

	csc->sc_dev = self;
	sc->sc_chip = &hd64461uart_chip;

	sc->sc_module_id = ha->ha_module_id;

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

	bus_space_map(sc->sc_chip->io_tag, 0x0, 8, 0, &ioh);
	csc->sc_frequency = COM_FREQ;
	HD64461UART_INIT_REGS(csc->sc_regs, sc->sc_chip->io_tag, ioh, 0x0);

	/* switch port to UART */

	/* supply clock */
	r16 = or16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16);
	r16 &= ~HD64461_SYSSTBCR_SURTSD;
	if (platid_match(&platid, &platid_mask_MACH_HITACHI_PERSONA))
		r16 &= ~(HD64461_SYSSTBCR_SAFECKE_IST |
		    HD64461_SYSSTBCR_SAFECKE_OST);
	hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16);

	/* sanity check */
	if (!com_probe_subr(&csc->sc_regs)) {
		aprint_error(": device problem. don't attach.\n");

		/* restore old clock */
		hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, or16);
		return;
	}

	com_attach_subr(csc);

	hd6446x_intr_establish(HD64461_INTC_UART, IST_LEVEL, IPL_TTY,
	    comintr, csc);
}
Esempio n. 27
0
void
com_pnpbios_attach(device_t parent, device_t self, void *aux)
{
	struct com_pnpbios_softc *psc = device_private(self);
	struct com_softc *sc = &psc->sc_com;
	struct pnpbiosdev_attach_args *aa = aux;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	int iobase;

	sc->sc_dev = self;

	if (pnpbios_getiobase(aa->pbt, aa->resc, 0, &iot, &iobase)) {
		aprint_error(": can't get iobase\n");
		return;
	}

	if ((!com_is_console(iot, iobase, &ioh)) &&
	    pnpbios_io_map(aa->pbt, aa->resc, 0, &iot, &ioh)) { 	
		aprint_error(": can't map i/o space\n");
		return;
	}

	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	aprint_normal("\n");
	pnpbios_print_devres(self, aa);

	aprint_normal("%s", device_xname(self));

	/*
	 * if the chip isn't something we recognise skip it.
	 */
	if (com_probe_subr(&sc->sc_regs) == 0) {
		aprint_error(": com probe failed\n");
		return;
	}

	sc->sc_frequency = 115200 * 16;

	com_attach_subr(sc);

	psc->sc_ih = pnpbios_intr_establish(aa->pbt, aa->resc, 0, IPL_SERIAL,
					    comintr, sc);
}
Esempio n. 28
0
void
com_ssio_attach(device_t parent, device_t self, void *aux)
{
	struct com_ssio_softc *sc_ssio = device_private(self);
	struct com_softc *sc = &sc_ssio->sc_com;
	struct ssio_attach_args *saa = aux;
	int pagezero_cookie;

	bus_addr_t iobase;
	bus_space_handle_t ioh;
	bus_space_tag_t iot;

	sc->sc_dev = self;
	iobase = saa->saa_iobase;
	iot = saa->saa_iot;
	if (bus_space_map(iot, iobase, COM_NPORTS,
	    0, &ioh)) {
		aprint_error(": can't map I/O space\n");
		return;
	}

        /* Test if this is the console. */
	pagezero_cookie = hp700_pagezero_map();
	if (PAGE0->mem_cons.pz_class == PCL_DUPLEX &&
	    PAGE0->mem_cons.pz_hpa == (struct iomod *)ioh) {
		bus_space_unmap(iot, ioh, COM_NPORTS);
		if (comcnattach(iot, iobase, B9600, COM_SSIO_FREQ,
		    COM_TYPE_NORMAL, 
		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8) != 0) {
			aprint_error(": can't comcnattach\n");
			hp700_pagezero_unmap(pagezero_cookie);
			return;
		}
	}
	hp700_pagezero_unmap(pagezero_cookie);

	sc->sc_frequency = COM_SSIO_FREQ;
	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);
	com_attach_subr(sc);

	sc_ssio->sc_ih = ssio_intr_establish(IPL_TTY, saa->saa_irq,
	    comintr, sc, device_xname(self));
}
Esempio n. 29
0
void
com_multi_attach(device_t parent, device_t self, void *aux)
{
	struct com_softc *sc = device_private(self);
	struct commulti_attach_args *ca = aux;

	sc->sc_dev = self;

	/*
	 * We're living on a commulti.
	 */
	COM_INIT_REGS(sc->sc_regs, ca->ca_iot, ca->ca_ioh, ca->ca_iobase);
	sc->sc_frequency = 115200 * 16;

	if (ca->ca_noien)
		sc->sc_hwflags |= COM_HW_NOIEN;

	com_attach_subr(sc);
}
Esempio n. 30
0
static void
com_ebus_attach(device_t parent, device_t self, void *aux)
{
	struct com_ebus_softc *ebsc = device_private(self);
	struct com_softc *sc = &ebsc->ebsc_com;
	struct ebus_attach_args *ea = aux;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_addr_t iobase;

	sc->sc_dev = self;
	iot = ea->ea_bustag;
	iobase = EBUS_ADDR_FROM_REG(&ea->ea_reg[0]);
	sc->sc_frequency = COM_FREQ;
	sc->sc_hwflags = COM_HW_NO_TXPRELOAD;

	/*
	 * XXX: It would be nice to be able to split console input and
	 * output to different devices.  For now switch to serial
	 * console if PROM stdin is on serial (so that we can use DDB).
	 */
	if (prom_instance_to_package(prom_stdin()) == ea->ea_node)
		comcnattach(iot, iobase, B9600, sc->sc_frequency,
		    COM_TYPE_NORMAL, (CLOCAL | CREAD | CS8));

	if (!com_is_console(iot, iobase, &ioh)
	    && bus_space_map(iot, iobase, ea->ea_reg[0].size,
			     0, &ioh) != 0)
	{
		aprint_error(": unable to map device registers\n");
		return;
	}

	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	com_attach_subr(sc);

	if (ea->ea_nintr != 0)
		(void)bus_intr_establish(iot, ea->ea_intr[0], IPL_SERIAL,
					 comintr, sc);
}