if (!ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) {  CLR(sc->sc_lcr, LCR_SBREAK); bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr); bus_space_write_1(iot, ioh, com_ier, 0); if (ISSET(tp->t_cflag, HUPCL) && !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) {  bus_space_write_1(iot, ioh, com_mcr, 0); }   bus_space_write_1(iot, ioh, com_fifo, 0); delay(100); (void) bus_space_read_1(iot, ioh, com_data); delay(100); bus_space_write_1(iot, ioh, com_fifo, FIFO_RCV_RST | FIFO_XMT_RST);  switch (sc->sc_uarttype) { case COM_UART_ST16650: case COM_UART_ST16650V2: case COM_UART_XR16850: bus_space_write_1(iot, ioh, com_lcr, LCR_EFR); bus_space_write_1(iot, ioh, com_efr, EFR_ECB); bus_space_write_1(iot, ioh, com_ier, IER_SLEEP); bus_space_write_1(iot, ioh, com_lcr, 0); break; #ifdef notyet case COM_UART_TI16750: bus_space_write_1(iot, ioh, com_ier, IER_SLEEP); break; #endif } }
if (!ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) compwroff(sc);
comclose(dev, flag, mode, p)	dev_t dev;	int flag, mode;	struct proc *p;{	int unit = DEVUNIT(dev);	struct com_softc *sc = pccom_cd.cd_devs[unit];	struct tty *tp = sc->sc_tty;	bus_space_tag_t iot = sc->sc_iot;	bus_space_handle_t ioh = sc->sc_ioh;	int s;	/* XXX This is for cons.c. */	if (!ISSET(tp->t_state, TS_ISOPEN))		return 0;	(*linesw[tp->t_line].l_close)(tp, flag);	s = spltty();	if (!ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) {		/* can't do any of this stuff .... */		CLR(sc->sc_lcr, LCR_SBREAK);		bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr);		bus_space_write_1(iot, ioh, com_ier, 0);		if (ISSET(tp->t_cflag, HUPCL) &&		    !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) {			/* XXX perhaps only clear DTR */			bus_space_write_1(iot, ioh, com_mcr, 0);		}		/*	 	 * Turn FIFO off; enter sleep mode if possible.	 	 */		bus_space_write_1(iot, ioh, com_fifo, 0);		delay(100);		(void) bus_space_read_1(iot, ioh, com_data);		delay(100);		bus_space_write_1(iot, ioh, com_fifo,		    FIFO_RCV_RST | FIFO_XMT_RST);		switch (sc->sc_uarttype) {		case COM_UART_ST16650:		case COM_UART_ST16650V2:		case COM_UART_XR16850:			bus_space_write_1(iot, ioh, com_lcr, LCR_EFR);			bus_space_write_1(iot, ioh, com_efr, EFR_ECB);			bus_space_write_1(iot, ioh, com_ier, IER_SLEEP);			bus_space_write_1(iot, ioh, com_lcr, 0);			break;#ifdef notyet		case COM_UART_TI16750:			bus_space_write_1(iot, ioh, com_ier, IER_SLEEP);			break;#endif		}	}	CLR(tp->t_state, TS_BUSY | TS_FLUSH);	sc->sc_cua = 0;	splx(s);	ttyclose(tp);#ifdef PCCOM_DEBUG	/* mark it ready for more use if reattached earlier */	if (ISSET(sc->sc_hwflags, COM_HW_ABSENT_PENDING)) {	    printf("comclose pending cleared\n");	}#endif	CLR(sc->sc_hwflags, COM_HW_ABSENT_PENDING);#ifdef notyet /* XXXX */	if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {		ttyfree(tp);		sc->sc_tty = 0;	}#endif	return 0;}