Lines Matching refs:asy

138 #define	ASY_DEBUG(asy, x) (asy->asy_debug & (x))  argument
139 #define ASY_DPRINTF(asy, fac, format, ...) \ argument
140 if (ASY_DEBUG(asy, fac)) \
141 asyerror(asy, CE_CONT, "!%s: " format, __func__, ##__VA_ARGS__)
143 #define ASY_DEBUG(asy, x) B_FALSE argument
144 #define ASY_DPRINTF(asy, fac, format, ...) argument
201 static void async_txint(struct asycom *asy);
202 static void async_rxint(struct asycom *asy, uchar_t lsr);
203 static void async_msint(struct asycom *asy);
204 static void async_softint(struct asycom *asy);
212 static void asy_program(struct asycom *asy, int mode);
213 static void asyinit(struct asycom *asy);
214 static void asy_waiteot(struct asycom *asy);
224 static void asy_parse_mode(dev_info_t *devi, struct asycom *asy);
226 static char *asy_hw_name(struct asycom *asy);
230 static int asy_identify_chip(dev_info_t *devi, struct asycom *asy);
231 static void asy_reset_fifo(struct asycom *asy, uchar_t flags);
233 static int asy_getproperty(dev_info_t *devi, struct asycom *asy,
235 static boolean_t async_flowcontrol_sw_input(struct asycom *asy,
237 static void async_flowcontrol_sw_output(struct asycom *asy,
239 static void async_flowcontrol_hw_input(struct asycom *asy,
241 static void async_flowcontrol_hw_output(struct asycom *asy,
530 asy_put_idx(const struct asycom *asy, asy_reg_t reg, uint8_t val) in asy_put_idx() argument
532 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_put_idx()
547 asy_put(asy, ASY_SPR, asy_reg_table[reg].asy_reg_off); in asy_put_idx()
550 asy_put(asy, ASY_ICR, val); in asy_put_idx()
554 asy_get_idx(const struct asycom *asy, asy_reg_t reg) in asy_get_idx() argument
558 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_get_idx()
564 asy_put(asy, ASY_ACR, ASY_ACR_ICR | asy->asy_acr); in asy_get_idx()
567 asy_put(asy, ASY_SPR, asy_reg_table[reg].asy_reg_off); in asy_get_idx()
570 val = asy_get(asy, ASY_ICR); in asy_get_idx()
573 asy_put(asy, ASY_ACR, asy->asy_acr); in asy_get_idx()
579 asy_put_add(const struct asycom *asy, asy_reg_t reg, uint8_t val) in asy_put_add() argument
581 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_put_add()
593 asy_put(asy, ASY_ACR, ASY_ACR_ASR | asy->asy_acr); in asy_put_add()
596 asy_put_reg(asy, reg, val); in asy_put_add()
599 asy_put(asy, ASY_ACR, asy->asy_acr); in asy_put_add()
603 asy_get_add(const struct asycom *asy, asy_reg_t reg) in asy_get_add() argument
607 ASSERT(asy->asy_hwtype >= ASY_16950); in asy_get_add()
622 asy_put(asy, ASY_ACR, ASY_ACR_ASR | asy->asy_acr); in asy_get_add()
625 val = asy_get_reg(asy, reg); in asy_get_add()
628 asy_put(asy, ASY_ACR, 0 | asy->asy_acr); in asy_get_add()
634 asy_put_ext(const struct asycom *asy, asy_reg_t reg, uint8_t val) in asy_put_ext() argument
645 ASSERT(asy->asy_hwtype >= ASY_16650); in asy_put_ext()
651 lcr = asy_get(asy, ASY_LCR); in asy_put_ext()
654 asy_put(asy, ASY_LCR, ASY_LCR_EFRACCESS); in asy_put_ext()
657 asy_put_reg(asy, reg, val); in asy_put_ext()
660 asy_put(asy, ASY_LCR, lcr); in asy_put_ext()
664 asy_get_ext(const struct asycom *asy, asy_reg_t reg) in asy_get_ext() argument
675 ASSERT(asy->asy_hwtype >= ASY_16650); in asy_get_ext()
681 lcr = asy_get(asy, ASY_LCR); in asy_get_ext()
684 asy_put(asy, ASY_LCR, ASY_LCR_EFRACCESS); in asy_get_ext()
687 val = asy_get_reg(asy, reg); in asy_get_ext()
690 asy_put(asy, ASY_LCR, lcr); in asy_get_ext()
696 asy_put_reg(const struct asycom *asy, asy_reg_t reg, uint8_t val) in asy_put_reg() argument
698 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_put_reg()
700 ddi_put8(asy->asy_iohandle, in asy_put_reg()
701 asy->asy_ioaddr + asy_reg_table[reg].asy_reg_off, val); in asy_put_reg()
705 asy_get_reg(const struct asycom *asy, asy_reg_t reg) in asy_get_reg() argument
707 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_get_reg()
709 return (ddi_get8(asy->asy_iohandle, in asy_get_reg()
710 asy->asy_ioaddr + asy_reg_table[reg].asy_reg_off)); in asy_get_reg()
714 asy_put(const struct asycom *asy, asy_reg_t reg, uint8_t val) in asy_put() argument
716 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_put()
721 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_put()
724 asy_reg_table[reg].asy_put_reg(asy, reg, val); in asy_put()
728 asy_get(const struct asycom *asy, asy_reg_t reg) in asy_get() argument
732 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_get()
737 ASSERT(asy->asy_hwtype >= asy_reg_table[reg].asy_min_hwtype); in asy_get()
740 val = asy_reg_table[reg].asy_get_reg(asy, reg); in asy_get()
746 asy_set(const struct asycom *asy, asy_reg_t reg, uint8_t bits) in asy_set() argument
748 uint8_t val = asy_get(asy, reg); in asy_set()
750 asy_put(asy, reg, val | bits); in asy_set()
754 asy_clr(const struct asycom *asy, asy_reg_t reg, uint8_t bits) in asy_clr() argument
756 uint8_t val = asy_get(asy, reg); in asy_clr()
758 asy_put(asy, reg, val & ~bits); in asy_clr()
762 asy_enable_interrupts(const struct asycom *asy, uint8_t intr) in asy_enable_interrupts() argument
767 asy_set(asy, ASY_IER, intr); in asy_enable_interrupts()
771 asy_disable_interrupts(const struct asycom *asy, uint8_t intr) in asy_disable_interrupts() argument
776 asy_clr(asy, ASY_IER, intr); in asy_disable_interrupts()
780 asy_set_baudrate(const struct asycom *asy, int baudrate) in asy_set_baudrate() argument
792 if (tcr != 0 && asy->asy_hwtype < ASY_16950) in asy_set_baudrate()
795 if (asy->asy_hwtype >= ASY_16950) { in asy_set_baudrate()
798 asy_put(asy, ASY_CKS, in asy_set_baudrate()
800 asy_put(asy, ASY_TCR, 0); in asy_set_baudrate()
803 asy_put(asy, ASY_CKS, 0); in asy_set_baudrate()
806 asy_put(asy, ASY_TCR, tcr); in asy_set_baudrate()
808 ASY_DPRINTF(asy, ASY_DEBUG_IOCTL, in asy_set_baudrate()
810 baudrate, asy_get(asy, ASY_CKS), asy_get(asy, ASY_TCR)); in asy_set_baudrate()
813 ASY_DPRINTF(asy, ASY_DEBUG_IOCTL, in asy_set_baudrate()
818 asy_set(asy, ASY_LCR, ASY_LCR_DLAB); in asy_set_baudrate()
820 asy_put(asy, ASY_DLL, asy_baud_tab[baudrate].asy_dll); in asy_set_baudrate()
821 asy_put(asy, ASY_DLH, asy_baud_tab[baudrate].asy_dlh); in asy_set_baudrate()
823 asy_clr(asy, ASY_LCR, ASY_LCR_DLAB); in asy_set_baudrate()
832 asy_wait_baudrate(struct asycom *asy) in asy_wait_baudrate() argument
834 struct asyncline *async = asy->asy_priv; in asy_wait_baudrate()
840 ASSERT(mutex_owned(&asy->asy_excl)); in asy_wait_baudrate()
841 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_wait_baudrate()
843 while ((asy_get(asy, ASY_LSR) & ASY_LSR_TEMT) == 0) { in asy_wait_baudrate()
844 mutex_exit(&asy->asy_excl_hi); in asy_wait_baudrate()
845 mutex_exit(&asy->asy_excl); in asy_wait_baudrate()
847 mutex_enter(&asy->asy_excl); in asy_wait_baudrate()
848 mutex_enter(&asy->asy_excl_hi); in asy_wait_baudrate()
850 asy_set(asy, ASY_LCR, ASY_LCR_SETBRK); in asy_wait_baudrate()
854 async_put_suspq(struct asycom *asy, mblk_t *mp) in async_put_suspq() argument
856 struct asyncline *async = asy->asy_priv; in async_put_suspq()
858 ASSERT(mutex_owned(&asy->asy_excl)); in async_put_suspq()
869 async_get_suspq(struct asycom *asy) in async_get_suspq() argument
871 struct asyncline *async = asy->asy_priv; in async_get_suspq()
874 ASSERT(mutex_owned(&asy->asy_excl)); in async_get_suspq()
886 async_process_suspq(struct asycom *asy) in async_process_suspq() argument
888 struct asyncline *async = asy->asy_priv; in async_process_suspq()
891 ASSERT(mutex_owned(&asy->asy_excl)); in async_process_suspq()
893 while ((mp = async_get_suspq(asy)) != NULL) { in async_process_suspq()
898 mutex_exit(&asy->asy_excl); in async_process_suspq()
900 mutex_enter(&asy->asy_excl); in async_process_suspq()
936 asy_get_io_regnum_pci(dev_info_t *devi, struct asycom *asy) in asy_get_io_regnum_pci() argument
976 asy_get_io_regnum_isa(dev_info_t *devi, struct asycom *asy) in asy_get_io_regnum_isa() argument
1015 asy_get_io_regnum(dev_info_t *devinfo, struct asycom *asy) in asy_get_io_regnum() argument
1019 return (asy_get_io_regnum_isa(devinfo, asy)); in asy_get_io_regnum()
1021 return (asy_get_io_regnum_pci(devinfo, asy)); in asy_get_io_regnum()
1028 asy_intr_free(struct asycom *asy) in asy_intr_free() argument
1032 for (i = 0; i < asy->asy_intr_cnt; i++) { in asy_intr_free()
1033 if (asy->asy_inth[i] == NULL) in asy_intr_free()
1036 if ((asy->asy_intr_cap & DDI_INTR_FLAG_BLOCK) != 0) in asy_intr_free()
1037 (void) ddi_intr_block_disable(&asy->asy_inth[i], 1); in asy_intr_free()
1039 (void) ddi_intr_disable(asy->asy_inth[i]); in asy_intr_free()
1041 (void) ddi_intr_remove_handler(asy->asy_inth[i]); in asy_intr_free()
1042 (void) ddi_intr_free(asy->asy_inth[i]); in asy_intr_free()
1045 kmem_free(asy->asy_inth, asy->asy_inth_sz); in asy_intr_free()
1046 asy->asy_inth = NULL; in asy_intr_free()
1047 asy->asy_inth_sz = 0; in asy_intr_free()
1051 asy_intr_setup(struct asycom *asy, int intr_type) in asy_intr_setup() argument
1057 if (asy->asy_intr_types == 0) { in asy_intr_setup()
1058 ret = ddi_intr_get_supported_types(asy->asy_dip, in asy_intr_setup()
1059 &asy->asy_intr_types); in asy_intr_setup()
1061 asyerror(asy, CE_WARN, in asy_intr_setup()
1067 if ((asy->asy_intr_types & intr_type) == 0) in asy_intr_setup()
1070 ret = ddi_intr_get_nintrs(asy->asy_dip, intr_type, &nintrs); in asy_intr_setup()
1072 asyerror(asy, CE_WARN, "ddi_intr_get_nintrs failed, type %d", in asy_intr_setup()
1078 asyerror(asy, CE_WARN, "no interrupts of type %d", intr_type); in asy_intr_setup()
1082 ret = ddi_intr_get_navail(asy->asy_dip, intr_type, &navail); in asy_intr_setup()
1084 asyerror(asy, CE_WARN, "ddi_intr_get_navail failed, type %d", in asy_intr_setup()
1090 asyerror(asy, CE_WARN, "no available interrupts, type %d", in asy_intr_setup()
1099 asy->asy_inth_sz = sizeof (ddi_intr_handle_t); in asy_intr_setup()
1100 asy->asy_inth = kmem_zalloc(asy->asy_inth_sz, KM_SLEEP); in asy_intr_setup()
1101 ret = ddi_intr_alloc(asy->asy_dip, asy->asy_inth, intr_type, 0, 1, in asy_intr_setup()
1104 asyerror(asy, CE_WARN, "ddi_intr_alloc failed, count %d, " in asy_intr_setup()
1110 asyerror(asy, CE_WARN, "ddi_intr_alloc returned not 1 but %d " in asy_intr_setup()
1115 asy->asy_intr_cnt = count; in asy_intr_setup()
1117 ret = ddi_intr_get_pri(asy->asy_inth[0], &asy->asy_intr_pri); in asy_intr_setup()
1119 asyerror(asy, CE_WARN, "ddi_intr_get_pri failed, type %d", in asy_intr_setup()
1125 ret = ddi_intr_add_handler(asy->asy_inth[i], asyintr, in asy_intr_setup()
1126 (void *)asy, (void *)(uintptr_t)i); in asy_intr_setup()
1128 asyerror(asy, CE_WARN, "ddi_intr_add_handler failed, " in asy_intr_setup()
1134 (void) ddi_intr_get_cap(asy->asy_inth[0], &asy->asy_intr_cap); in asy_intr_setup()
1137 if (asy->asy_intr_cap & DDI_INTR_FLAG_BLOCK) in asy_intr_setup()
1138 ret = ddi_intr_block_enable(&asy->asy_inth[i], 1); in asy_intr_setup()
1140 ret = ddi_intr_enable(asy->asy_inth[i]); in asy_intr_setup()
1143 asyerror(asy, CE_WARN, in asy_intr_setup()
1150 asy->asy_intr_type = intr_type; in asy_intr_setup()
1154 asy_intr_free(asy); in asy_intr_setup()
1159 asy_softintr_free(struct asycom *asy) in asy_softintr_free() argument
1161 (void) ddi_intr_remove_softint(asy->asy_soft_inth); in asy_softintr_free()
1165 asy_softintr_setup(struct asycom *asy) in asy_softintr_setup() argument
1169 ret = ddi_intr_add_softint(asy->asy_dip, &asy->asy_soft_inth, in asy_softintr_setup()
1170 ASY_SOFT_INT_PRI, asysoftintr, asy); in asy_softintr_setup()
1172 asyerror(asy, CE_WARN, "ddi_intr_add_softint failed"); in asy_softintr_setup()
1182 ret = ddi_intr_get_softint_pri(asy->asy_soft_inth, in asy_softintr_setup()
1183 &asy->asy_soft_intr_pri); in asy_softintr_setup()
1185 asyerror(asy, CE_WARN, "ddi_intr_get_softint_pri failed"); in asy_softintr_setup()
1197 struct asycom *asy; in asy_resume() local
1204 asy = ddi_get_soft_state(asy_soft_state, instance); in asy_resume()
1205 if (asy == NULL) in asy_resume()
1208 mutex_enter(&asy->asy_soft_sr); in asy_resume()
1209 mutex_enter(&asy->asy_excl); in asy_resume()
1210 mutex_enter(&asy->asy_excl_hi); in asy_resume()
1212 async = asy->asy_priv; in asy_resume()
1213 asy_disable_interrupts(asy, ASY_IER_ALL); in asy_resume()
1214 if (asy_identify_chip(devi, asy) != DDI_SUCCESS) { in asy_resume()
1215 mutex_exit(&asy->asy_excl_hi); in asy_resume()
1216 mutex_exit(&asy->asy_excl); in asy_resume()
1217 mutex_exit(&asy->asy_soft_sr); in asy_resume()
1218 asyerror(asy, CE_WARN, "Cannot identify UART chip at %p", in asy_resume()
1219 (void *)asy->asy_ioaddr); in asy_resume()
1222 asy->asy_flags &= ~ASY_DDI_SUSPENDED; in asy_resume()
1224 asy_program(asy, ASY_INIT); in asy_resume()
1229 mutex_exit(&asy->asy_excl_hi); in asy_resume()
1234 mutex_enter(&asy->asy_excl_hi); in asy_resume()
1236 asysetsoft(asy); in asy_resume()
1238 mutex_exit(&asy->asy_excl_hi); in asy_resume()
1239 mutex_exit(&asy->asy_excl); in asy_resume()
1240 mutex_exit(&asy->asy_soft_sr); in asy_resume()
1242 mutex_enter(&asy->asy_excl); in asy_resume()
1249 async_process_suspq(asy); in asy_resume()
1250 mutex_exit(&asy->asy_excl); in asy_resume()
1255 asy_suspend(struct asycom *asy) in asy_suspend() argument
1257 struct asyncline *async = asy->asy_priv; in asy_suspend()
1265 mutex_enter(&asy->asy_excl); in asy_suspend()
1269 cv_wait(&async->async_ops_cv, &asy->asy_excl); in asy_suspend()
1275 if (cv_wait_sig(&async->async_flags_cv, &asy->asy_excl) == 0) { in asy_suspend()
1276 async_process_suspq(asy); in asy_suspend()
1277 mutex_exit(&asy->asy_excl); in asy_suspend()
1286 mutex_exit(&asy->asy_excl); in asy_suspend()
1288 mutex_enter(&asy->asy_soft_sr); in asy_suspend()
1289 mutex_enter(&asy->asy_excl); in asy_suspend()
1294 mutex_exit(&asy->asy_excl); in asy_suspend()
1296 mutex_enter(&asy->asy_excl); in asy_suspend()
1298 mutex_enter(&asy->asy_excl_hi); in asy_suspend()
1300 asy_disable_interrupts(asy, ASY_IER_ALL); in asy_suspend()
1301 asy->asy_flags |= ASY_DDI_SUSPENDED; in asy_suspend()
1307 mutex_exit(&asy->asy_excl_hi); in asy_suspend()
1310 lsr = asy_get(asy, ASY_LSR); in asy_suspend()
1311 async_rxint(asy, lsr); in asy_suspend()
1315 lsr = asy_get(asy, ASY_LSR); in asy_suspend()
1322 asyerror(asy, CE_WARN, "transmitter wasn't drained before " in asy_suspend()
1325 mutex_exit(&asy->asy_excl); in asy_suspend()
1326 mutex_exit(&asy->asy_soft_sr); in asy_suspend()
1335 struct asycom *asy; in asydetach() local
1339 asy = ddi_get_soft_state(asy_soft_state, instance); in asydetach()
1340 if (asy == NULL) in asydetach()
1348 return (asy_suspend(asy)); in asydetach()
1354 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "%s shutdown", asy_hw_name(asy)); in asydetach()
1360 if ((asy->asy_progress & ASY_PROGRESS_INT) != 0) in asydetach()
1361 asy_intr_free(asy); in asydetach()
1363 if ((asy->asy_progress & ASY_PROGRESS_SOFTINT) != 0) in asydetach()
1364 asy_softintr_free(asy); in asydetach()
1366 if ((asy->asy_progress & ASY_PROGRESS_ASYNC) != 0) { in asydetach()
1367 struct asyncline *async = asy->asy_priv; in asydetach()
1369 asy->asy_priv = NULL; in asydetach()
1379 if ((asy->asy_progress & ASY_PROGRESS_MINOR) != 0) in asydetach()
1382 if ((asy->asy_progress & ASY_PROGRESS_MUTEX) != 0) { in asydetach()
1383 mutex_destroy(&asy->asy_excl); in asydetach()
1384 mutex_destroy(&asy->asy_excl_hi); in asydetach()
1385 mutex_destroy(&asy->asy_soft_lock); in asydetach()
1388 if ((asy->asy_progress & ASY_PROGRESS_REGS) != 0) in asydetach()
1389 ddi_regs_map_free(&asy->asy_iohandle); in asydetach()
1391 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "shutdown complete"); in asydetach()
1392 asy_soft_state_free(asy); in asydetach()
1421 struct asycom *asy; in asyattach() local
1466 asy = ddi_get_soft_state(asy_soft_state, instance); in asyattach()
1468 asy->asy_dip = devi; in asyattach()
1470 asy->asy_debug = debug; in asyattach()
1472 asy->asy_unit = instance; in asyattach()
1474 regnum = asy_get_io_regnum(devi, asy); in asyattach()
1477 ddi_regs_map_setup(devi, regnum, (caddr_t *)&asy->asy_ioaddr, in asyattach()
1478 (offset_t)0, (offset_t)0, &ioattr, &asy->asy_iohandle) in asyattach()
1480 asyerror(asy, CE_WARN, "could not map UART registers @ %p", in asyattach()
1481 (void *)asy->asy_ioaddr); in asyattach()
1485 asy->asy_progress |= ASY_PROGRESS_REGS; in asyattach()
1487 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "UART @ %p", (void *)asy->asy_ioaddr); in asyattach()
1497 if (asy->asy_ioaddr == (uint8_t *)(uintptr_t)com_ports[i]) { in asyattach()
1498 asy->asy_com_port = i + 1; in asyattach()
1511 ddi_put8(asy->asy_iohandle, in asyattach()
1512 asy->asy_ioaddr + asy_reg_table[ASY_IER].asy_reg_off, 0); in asyattach()
1520 asy->asy_mcr |= ASY_MCR_RTS | ASY_MCR_DTR; in asyattach()
1521 asy->asy_lcr = ASY_LCR_STOP1 | ASY_LCR_BITS8; in asyattach()
1522 asy->asy_bidx = B9600; in asyattach()
1523 asy->asy_fifo_buf = 1; in asyattach()
1524 asy->asy_use_fifo = ASY_FCR_FIFO_OFF; in asyattach()
1527 asy->asy_msint_cnt = 0; /* # of times in async_msint */ in asyattach()
1531 if (asy->asy_com_port != 0) { in asyattach()
1537 switch (asy_getproperty(devi, asy, "ignore-cd")) { in asyattach()
1539 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyattach()
1541 asy->asy_flags &= ~ASY_IGNORE_CD; /* wait for cd */ in asyattach()
1551 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyattach()
1553 mcr = asy->asy_mcr; /* rts/dtr on */ in asyattach()
1554 asy->asy_flags |= ASY_IGNORE_CD; /* ignore cd */ in asyattach()
1559 switch (asy_getproperty(devi, asy, "rts-dtr-off")) { in asyattach()
1561 asy->asy_flags |= ASY_RTS_DTR_OFF; /* OFF */ in asyattach()
1562 mcr = asy->asy_mcr; /* rts/dtr on */ in asyattach()
1563 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyattach()
1573 asy_parse_mode(devi, asy); in asyattach()
1575 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyattach()
1577 asy->asy_flags &= ~ASY_IGNORE_CD; /* wait for cd */ in asyattach()
1583 if (asy_softintr_setup(asy) != DDI_SUCCESS) { in asyattach()
1584 asyerror(asy, CE_WARN, "Cannot set soft interrupt"); in asyattach()
1588 asy->asy_progress |= ASY_PROGRESS_SOFTINT; in asyattach()
1593 if ((asy_intr_setup(asy, DDI_INTR_TYPE_MSIX) != DDI_SUCCESS) && in asyattach()
1594 (asy_intr_setup(asy, DDI_INTR_TYPE_MSI) != DDI_SUCCESS) && in asyattach()
1595 (asy_intr_setup(asy, DDI_INTR_TYPE_FIXED) != DDI_SUCCESS)) { in asyattach()
1596 asyerror(asy, CE_WARN, "Cannot set device interrupt"); in asyattach()
1600 asy->asy_progress |= ASY_PROGRESS_INT; in asyattach()
1605 mutex_init(&asy->asy_soft_lock, NULL, MUTEX_DRIVER, in asyattach()
1606 DDI_INTR_PRI(asy->asy_soft_intr_pri)); in asyattach()
1607 mutex_init(&asy->asy_soft_sr, NULL, MUTEX_DRIVER, in asyattach()
1608 DDI_INTR_PRI(asy->asy_soft_intr_pri)); in asyattach()
1610 mutex_init(&asy->asy_excl, NULL, MUTEX_DRIVER, NULL); in asyattach()
1611 mutex_init(&asy->asy_excl_hi, NULL, MUTEX_DRIVER, in asyattach()
1612 DDI_INTR_PRI(asy->asy_intr_pri)); in asyattach()
1614 asy->asy_progress |= ASY_PROGRESS_MUTEX; in asyattach()
1616 mutex_enter(&asy->asy_excl); in asyattach()
1617 mutex_enter(&asy->asy_excl_hi); in asyattach()
1619 if (asy_identify_chip(devi, asy) != DDI_SUCCESS) { in asyattach()
1620 asyerror(asy, CE_WARN, "Cannot identify UART chip at %p", in asyattach()
1621 (void *)asy->asy_ioaddr); in asyattach()
1625 asy_disable_interrupts(asy, ASY_IER_ALL); in asyattach()
1626 asy_put(asy, ASY_LCR, asy->asy_lcr); in asyattach()
1627 asy_set_baudrate(asy, asy->asy_bidx); in asyattach()
1628 asy_put(asy, ASY_MCR, mcr); in asyattach()
1630 mutex_exit(&asy->asy_excl_hi); in asyattach()
1631 mutex_exit(&asy->asy_excl); in asyattach()
1633 asyinit(asy); /* initialize the asyncline structure */ in asyattach()
1634 asy->asy_progress |= ASY_PROGRESS_ASYNC; in asyattach()
1637 if (asy->asy_com_port != 0) { in asyattach()
1642 name[0] = asy->asy_com_port + 'a' - 1; in asyattach()
1652 asy->asy_com_port != 0 ? DDI_NT_SERIAL_MB : DDI_NT_SERIAL, 0); in asyattach()
1657 asy->asy_com_port != 0 ? DDI_NT_SERIAL_MB_DO : in asyattach()
1664 asy->asy_progress |= ASY_PROGRESS_MINOR; in asyattach()
1669 asy->polledio.cons_polledio_version = CONSPOLLEDIO_V0; in asyattach()
1670 asy->polledio.cons_polledio_argument = (cons_polledio_arg_t)asy; in asyattach()
1671 asy->polledio.cons_polledio_putchar = asyputchar; in asyattach()
1672 asy->polledio.cons_polledio_getchar = asygetchar; in asyattach()
1673 asy->polledio.cons_polledio_ischar = asyischar; in asyattach()
1674 asy->polledio.cons_polledio_enter = NULL; in asyattach()
1675 asy->polledio.cons_polledio_exit = NULL; in asyattach()
1678 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "done"); in asyattach()
1692 struct asycom *asy; in asyinfo() local
1698 asy = ddi_get_soft_state(asy_soft_state, instance); in asyinfo()
1699 if ((asy == NULL) || (asy->asy_dip == NULL)) in asyinfo()
1702 *result = (void *) asy->asy_dip; in asyinfo()
1719 asy_getproperty(dev_info_t *devi, struct asycom *asy, const char *property) in asy_getproperty() argument
1723 char letter = asy->asy_com_port + 'a' - 1; /* for ttya */ in asy_getproperty()
1724 char number = asy->asy_com_port + '0'; /* for COM1 */ in asy_getproperty()
1757 asy_soft_state_free(struct asycom *asy) in asy_soft_state_free() argument
1759 if (asy->asy_priv != NULL) { in asy_soft_state_free()
1760 kmem_free(asy->asy_priv, sizeof (struct asyncline)); in asy_soft_state_free()
1761 asy->asy_priv = NULL; in asy_soft_state_free()
1763 ddi_soft_state_free(asy_soft_state, asy->asy_unit); in asy_soft_state_free()
1767 asy_hw_name(struct asycom *asy) in asy_hw_name() argument
1769 switch (asy->asy_hwtype) { in asy_hw_name()
1784 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "unknown asy_hwtype: %d", in asy_hw_name()
1785 asy->asy_hwtype); in asy_hw_name()
1790 asy_is_devid(struct asycom *asy, char *venprop, char *devprop, in asy_is_devid() argument
1793 if (ddi_prop_get_int(DDI_DEV_T_ANY, asy->asy_dip, DDI_PROP_DONTPASS, in asy_is_devid()
1798 if (ddi_prop_get_int(DDI_DEV_T_ANY, asy->asy_dip, DDI_PROP_DONTPASS, in asy_is_devid()
1807 asy_check_loopback(struct asycom *asy) in asy_check_loopback() argument
1809 if (asy_get_bus_type(asy->asy_dip) != ASY_BUS_PCI) in asy_check_loopback()
1813 if (asy_is_devid(asy, "vendor-id", "device-id", 0x11c1, 0x0480) || in asy_check_loopback()
1814 asy_is_devid(asy, "subsystem-vendor-id", "subsystem-id", 0x11c1, in asy_check_loopback()
1816 asy->asy_flags2 |= ASY2_NO_LOOPBACK; in asy_check_loopback()
1820 asy_identify_chip(dev_info_t *devi, struct asycom *asy) in asy_identify_chip() argument
1830 asy->asy_hwtype = ASY_MAXCHIP; in asy_identify_chip()
1836 asy_check_loopback(asy); in asy_identify_chip()
1842 asy_put(asy, ASY_SPR, ASY_SPR_TEST); in asy_identify_chip()
1844 asy_put(asy, ASY_FCR, 0x00); in asy_identify_chip()
1846 spr = asy_get(asy, ASY_SPR); in asy_identify_chip()
1854 asyerror(asy, CE_WARN, "UART @ %p " in asy_identify_chip()
1856 (void *)asy->asy_ioaddr, spr); in asy_identify_chip()
1864 asy_put(asy, ASY_FCR, 0x00); /* disable */ in asy_identify_chip()
1865 asy_put(asy, ASY_FCR, ASY_FCR_FIFO_EN); /* enable */ in asy_identify_chip()
1866 asy_put(asy, ASY_FCR, ASY_FCR_FIFO_EN | ASY_FCR_RHR_FL); /* reset */ in asy_identify_chip()
1871 asy_put(asy, ASY_EFR, 0); in asy_identify_chip()
1879 asy->asy_fifor = 0; in asy_identify_chip()
1881 asy->asy_fifor |= in asy_identify_chip()
1889 asy->asy_fifor |= ASY_FCR_FIFO64; in asy_identify_chip()
1891 asy_reset_fifo(asy, ASY_FCR_THR_FL | ASY_FCR_RHR_FL); in asy_identify_chip()
1893 mcr = asy_get(asy, ASY_MCR); in asy_identify_chip()
1894 isr = asy_get(asy, ASY_ISR); in asy_identify_chip()
1901 asyerror(asy, CE_WARN, "UART @ %p interrupt register: got 0xff", in asy_identify_chip()
1902 (void *)asy->asy_ioaddr); in asy_identify_chip()
1906 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, in asy_identify_chip()
1908 asy->asy_fifor | ASY_FCR_THR_FL | ASY_FCR_RHR_FL, isr, mcr); in asy_identify_chip()
1924 asy->asy_fifor = 0; in asy_identify_chip()
1929 asy->asy_fifo_buf = 16; in asy_identify_chip()
1930 asy->asy_use_fifo = ASY_FCR_FIFO_EN; in asy_identify_chip()
1931 asy->asy_fifor &= ~ASY_FCR_FIFO64; in asy_identify_chip()
1936 asy->asy_fifo_buf = 64; in asy_identify_chip()
1937 asy->asy_use_fifo = ASY_FCR_FIFO_EN; in asy_identify_chip()
1942 asy->asy_fifor = 0; in asy_identify_chip()
1946 asyerror(asy, CE_WARN, "UART @ %p " in asy_identify_chip()
1949 (void *)asy->asy_ioaddr, in asy_identify_chip()
1950 asy->asy_fifor | ASY_FCR_THR_FL | ASY_FCR_RHR_FL, isr, mcr); in asy_identify_chip()
1960 asy_reset_fifo(asy, 0); in asy_identify_chip()
1972 asy_put(asy, ASY_XOFF2, 0); in asy_identify_chip()
1975 spr = asy_get(asy, ASY_SPR); in asy_identify_chip()
1980 asy_put(asy, ASY_EFR, ASY_EFR_ENH_EN); in asy_identify_chip()
1987 if (asy->asy_fifo_buf < 32) in asy_identify_chip()
1988 asy->asy_fifo_buf = 32; in asy_identify_chip()
1995 if (asy_max_tx_fifo >= asy->asy_fifo_buf) in asy_identify_chip()
1996 asy->asy_fifor |= ASY_FCR_THR_TRIG_24; in asy_identify_chip()
1997 asy_reset_fifo(asy, 0); in asy_identify_chip()
2013 asy_put(asy, ASY_IER, 0); in asy_identify_chip()
2014 ier = asy_get(asy, ASY_IER); in asy_identify_chip()
2016 dev_err(asy->asy_dip, CE_WARN, "!%s: UART @ %p " in asy_identify_chip()
2018 (void *)asy->asy_ioaddr, ier); in asy_identify_chip()
2036 asr = asy_get(asy, ASY_ASR); in asy_identify_chip()
2042 asy->asy_fifo_buf = 128; in asy_identify_chip()
2044 asy->asy_fifo_buf = 16; in asy_identify_chip()
2046 asy_reset_fifo(asy, 0); in asy_identify_chip()
2052 asy->asy_acr = ASY_ACR_TRIG | ASY_ACR_DTR_NORM; in asy_identify_chip()
2053 asy_put(asy, ASY_ACR, asy->asy_acr); in asy_identify_chip()
2056 asy_put(asy, ASY_RTL, asy->asy_fifo_buf/2); in asy_identify_chip()
2067 asy_put(asy, ASY_TTL, 1); in asy_identify_chip()
2069 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "ASR 0x%02x", asr); in asy_identify_chip()
2070 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "RFL 0x%02x", in asy_identify_chip()
2071 asy_get(asy, ASY_RFL)); in asy_identify_chip()
2072 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "TFL 0x%02x", in asy_identify_chip()
2073 asy_get(asy, ASY_TFL)); in asy_identify_chip()
2075 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "ACR 0x%02x", in asy_identify_chip()
2076 asy_get(asy, ASY_ACR)); in asy_identify_chip()
2077 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "CPR 0x%02x", in asy_identify_chip()
2078 asy_get(asy, ASY_CPR)); in asy_identify_chip()
2079 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "TCR 0x%02x", in asy_identify_chip()
2080 asy_get(asy, ASY_TCR)); in asy_identify_chip()
2081 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "CKS 0x%02x", in asy_identify_chip()
2082 asy_get(asy, ASY_CKS)); in asy_identify_chip()
2083 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "TTL 0x%02x", in asy_identify_chip()
2084 asy_get(asy, ASY_TTL)); in asy_identify_chip()
2085 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "RTL 0x%02x", in asy_identify_chip()
2086 asy_get(asy, ASY_RTL)); in asy_identify_chip()
2087 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "FCL 0x%02x", in asy_identify_chip()
2088 asy_get(asy, ASY_FCL)); in asy_identify_chip()
2089 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "FCH 0x%02x", in asy_identify_chip()
2090 asy_get(asy, ASY_FCH)); in asy_identify_chip()
2092 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, in asy_identify_chip()
2094 asy_get(asy, ASY_ID1), asy_get(asy, ASY_ID2), in asy_identify_chip()
2095 asy_get(asy, ASY_ID3), asy_get(asy, ASY_REV)); in asy_identify_chip()
2100 asy->asy_hwtype = hwtype; in asy_identify_chip()
2107 !(asy->asy_flags2 & ASY2_NO_LOOPBACK) && in asy_identify_chip()
2108 (asy->asy_fifo_buf > 16 || in asy_identify_chip()
2109 (asy_fifo_test > 1 && asy->asy_use_fifo == ASY_FCR_FIFO_EN) || in asy_identify_chip()
2110 ASY_DEBUG(asy, ASY_DEBUG_CHIP))) { in asy_identify_chip()
2114 asy_set_baudrate(asy, B57600); in asy_identify_chip()
2116 asy_put(asy, ASY_LCR, ASY_LCR_STOP1 | ASY_LCR_BITS8); in asy_identify_chip()
2118 asy_put(asy, ASY_MCR, ASY_MCR_LOOPBACK); in asy_identify_chip()
2121 for (i = 0; i < asy->asy_fifo_buf * 2; i++) { in asy_identify_chip()
2122 asy_put(asy, ASY_THR, i); in asy_identify_chip()
2147 delay(drv_usectohz(400 * asy->asy_fifo_buf * 3)); in asy_identify_chip()
2150 for (i = 0; i < asy->asy_fifo_buf * 3; i++) { in asy_identify_chip()
2151 lsr = asy_get(asy, ASY_LSR); in asy_identify_chip()
2154 (void) asy_get(asy, ASY_RHR); /* lose another */ in asy_identify_chip()
2157 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, in asy_identify_chip()
2159 asy->asy_fifo_buf, i); in asy_identify_chip()
2161 hwtype = asy->asy_hwtype; in asy_identify_chip()
2162 if (i < asy->asy_fifo_buf) { in asy_identify_chip()
2171 if (i >= 16 && asy->asy_fifo_buf >= 16) { in asy_identify_chip()
2174 asy->asy_fifo_buf = 16; in asy_identify_chip()
2175 asy->asy_fifor &= in asy_identify_chip()
2180 asy->asy_fifo_buf = 1; in asy_identify_chip()
2181 asy->asy_use_fifo = ASY_FCR_FIFO_OFF; in asy_identify_chip()
2182 asy->asy_fifor = 0; in asy_identify_chip()
2184 } else if (i > asy->asy_fifo_buf) { in asy_identify_chip()
2190 asy->asy_fifo_buf = i; in asy_identify_chip()
2201 if (asy->asy_hwtype >= ASY_16650 && hwtype < ASY_16650) { in asy_identify_chip()
2203 asy_put(asy, ASY_EFR, 0); in asy_identify_chip()
2205 asy_reset_fifo(asy, ASY_FCR_THR_FL | ASY_FCR_RHR_FL); in asy_identify_chip()
2206 asy->asy_hwtype = hwtype; in asy_identify_chip()
2209 asy_put(asy, ASY_MCR, mcr); in asy_identify_chip()
2212 ASY_DPRINTF(asy, ASY_DEBUG_CHIP, "%s @ %p", in asy_identify_chip()
2213 asy_hw_name(asy), (void *)asy->asy_ioaddr); in asy_identify_chip()
2216 dev = makedevice(DDI_MAJOR_T_UNKNOWN, asy->asy_unit); in asy_identify_chip()
2217 (void) ddi_prop_update_string(dev, devi, "uart", asy_hw_name(asy)); in asy_identify_chip()
2219 if (asy->asy_hwtype == ASY_16550) /* for broken 16550's, */ in asy_identify_chip()
2220 asy->asy_hwtype = ASY_8250A; /* drive them as 8250A */ in asy_identify_chip()
2230 asyinit(struct asycom *asy) in asyinit() argument
2234 asy->asy_priv = kmem_zalloc(sizeof (struct asyncline), KM_SLEEP); in asyinit()
2235 async = asy->asy_priv; in asyinit()
2236 mutex_enter(&asy->asy_excl); in asyinit()
2237 async->async_common = asy; in asyinit()
2239 mutex_exit(&asy->asy_excl); in asyinit()
2245 struct asycom *asy; in asyopen() local
2252 asy = ddi_get_soft_state(asy_soft_state, unit); in asyopen()
2253 if (asy == NULL) in asyopen()
2255 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "enter"); in asyopen()
2256 async = asy->asy_priv; in asyopen()
2257 mutex_enter(&asy->asy_excl); in asyopen()
2260 mutex_enter(&asy->asy_excl_hi); in asyopen()
2270 mutex_exit(&asy->asy_excl_hi); in asyopen()
2279 asyerror(asy, CE_WARN, in asyopen()
2282 mutex_enter(&asy->asy_excl_hi); in asyopen()
2285 if (asy->asy_cflag) in asyopen()
2286 async->async_ttycommon.t_cflag = asy->asy_cflag; in asyopen()
2299 asy_program(asy, ASY_INIT); in asyopen()
2302 mutex_exit(&asy->asy_excl_hi); in asyopen()
2303 mutex_exit(&asy->asy_excl); in asyopen()
2306 mutex_exit(&asy->asy_excl_hi); in asyopen()
2307 mutex_exit(&asy->asy_excl); in asyopen()
2316 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyopen()
2318 mutex_exit(&asy->asy_excl_hi); in asyopen()
2320 &asy->asy_excl) == 0) { in asyopen()
2321 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyopen()
2323 mutex_exit(&asy->asy_excl); in asyopen()
2326 mutex_enter(&asy->asy_excl_hi); in asyopen()
2329 asy_set(asy, ASY_MCR, asy->asy_mcr & ASY_MCR_DTR); in asyopen()
2331 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "\"Raise DTR on every open\": " in asyopen()
2332 "make mcr = %x, make TS_SOFTCAR = %s", asy_get(asy, ASY_MCR), in asyopen()
2333 (asy->asy_flags & ASY_IGNORE_CD) ? "ON" : "OFF"); in asyopen()
2335 if (asy->asy_flags & ASY_IGNORE_CD) { in asyopen()
2336 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyopen()
2346 asy->asy_msr = asy_get(asy, ASY_MSR); in asyopen()
2347 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "TS_SOFTCAR is %s, MSR & DCD is %s", in asyopen()
2349 (asy->asy_msr & ASY_MSR_DCD) ? "set" : "clear"); in asyopen()
2351 if (asy->asy_msr & ASY_MSR_DCD) in asyopen()
2355 mutex_exit(&asy->asy_excl_hi); in asyopen()
2369 &asy->asy_excl) == B_FALSE) { in asyopen()
2371 mutex_exit(&asy->asy_excl); in asyopen()
2378 mutex_exit(&asy->asy_excl); in asyopen()
2385 mutex_exit(&asy->asy_excl); in asyopen()
2394 ASY_DPRINTF(asy, ASY_DEBUG_INIT, "done"); in asyopen()
2402 struct asycom *asy = async->async_common; in async_progress_check() local
2410 mutex_enter(&asy->asy_excl); in async_progress_check()
2411 mutex_enter(&asy->asy_excl_hi); in async_progress_check()
2418 mutex_exit(&asy->asy_excl_hi); in async_progress_check()
2433 mutex_exit(&asy->asy_excl_hi); in async_progress_check()
2435 mutex_exit(&asy->asy_excl); in async_progress_check()
2444 struct asycom *asy = async->async_common; in async_dtr_free() local
2446 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in async_dtr_free()
2448 mutex_enter(&asy->asy_excl); in async_dtr_free()
2452 mutex_exit(&asy->asy_excl); in async_dtr_free()
2462 struct asycom *asy; in asyclose() local
2467 asy = async->async_common; in asyclose()
2469 ASY_DPRINTF(asy, ASY_DEBUG_CLOSE, "enter"); in asyclose()
2471 mutex_enter(&asy->asy_excl); in asyclose()
2478 mutex_enter(&asy->asy_excl_hi); in asyclose()
2479 asy->asy_flags &= ~(ASY_PPS | ASY_PPS_EDGE); in asyclose()
2480 mutex_exit(&asy->asy_excl_hi); in asyclose()
2496 mutex_enter(&asy->asy_excl_hi); in asyclose()
2497 (void) asy_clr(asy, ASY_LCR, ASY_LCR_SETBRK); in asyclose()
2498 mutex_exit(&asy->asy_excl_hi); in asyclose()
2544 if (cv_wait_sig(&async->async_flags_cv, &asy->asy_excl) == 0) in asyclose()
2562 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "next check HUPCL flag"); in asyclose()
2563 mutex_enter(&asy->asy_excl_hi); in asyclose()
2566 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyclose()
2573 if (asy->asy_flags & (ASY_IGNORE_CD|ASY_RTS_DTR_OFF)) { in asyclose()
2574 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyclose()
2577 asy->asy_flags & ASY_IGNORE_CD, in asyclose()
2578 asy->asy_flags & ASY_RTS_DTR_OFF); in asyclose()
2580 asy_put(asy, ASY_MCR, asy->asy_mcr | ASY_MCR_OUT2); in asyclose()
2582 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asyclose()
2584 asy_put(asy, ASY_MCR, ASY_MCR_OUT2); in asyclose()
2594 asy_disable_interrupts(asy, ASY_IER_RIEN); in asyclose()
2596 mutex_exit(&asy->asy_excl_hi); in asyclose()
2619 mutex_exit(&asy->asy_excl); in asyclose()
2621 ASY_DPRINTF(asy, ASY_DEBUG_CLOSE, "done"); in asyclose()
2626 asy_isbusy(struct asycom *asy) in asy_isbusy() argument
2630 ASY_DPRINTF(asy, ASY_DEBUG_EOT, "enter"); in asy_isbusy()
2631 async = asy->asy_priv; in asy_isbusy()
2632 ASSERT(mutex_owned(&asy->asy_excl)); in asy_isbusy()
2633 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_isbusy()
2638 ((asy_get(asy, ASY_LSR) & (ASY_LSR_TEMT | ASY_LSR_THRE)) == 0)); in asy_isbusy()
2642 asy_waiteot(struct asycom *asy) in asy_waiteot() argument
2649 ASY_DPRINTF(asy, ASY_DEBUG_EOT, "enter"); in asy_waiteot()
2650 ASSERT(mutex_owned(&asy->asy_excl)); in asy_waiteot()
2651 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_waiteot()
2652 while (asy_isbusy(asy)) { in asy_waiteot()
2653 mutex_exit(&asy->asy_excl_hi); in asy_waiteot()
2654 mutex_exit(&asy->asy_excl); in asy_waiteot()
2656 mutex_enter(&asy->asy_excl); in asy_waiteot()
2657 mutex_enter(&asy->asy_excl_hi); in asy_waiteot()
2663 asy_reset_fifo(struct asycom *asy, uchar_t flush) in asy_reset_fifo() argument
2665 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_reset_fifo()
2668 if (asy->asy_hwtype >= ASY_16750) in asy_reset_fifo()
2669 asy_set(asy, ASY_LCR, ASY_LCR_DLAB); in asy_reset_fifo()
2671 asy_put(asy, ASY_FCR, asy->asy_fifor | flush); in asy_reset_fifo()
2674 if (asy->asy_hwtype >= ASY_16750) in asy_reset_fifo()
2675 asy_clr(asy, ASY_LCR, ASY_LCR_DLAB); in asy_reset_fifo()
2683 asy_program(struct asycom *asy, int mode) in asy_program() argument
2691 ASSERT(mutex_owned(&asy->asy_excl)); in asy_program()
2692 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asy_program()
2694 async = asy->asy_priv; in asy_program()
2695 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "mode = 0x%08X, enter", mode); in asy_program()
2714 asy_disable_interrupts(asy, ASY_IER_ALL); in asy_program()
2716 ocflags = asy->asy_ocflag; in asy_program()
2719 (void) asy_get(asy, ASY_ISR); in asy_program()
2720 (void) asy_get(asy, ASY_LSR); in asy_program()
2721 asy->asy_msr = flush_reg = asy_get(asy, ASY_MSR); in asy_program()
2730 async_flowcontrol_hw_output(asy, FLOW_STOP); in asy_program()
2756 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asy_program()
2757 for (flush_reg = asy->asy_fifo_buf; flush_reg-- > 0; ) { in asy_program()
2758 (void) asy_get(asy, ASY_RHR); in asy_program()
2761 flush_reg = asy_get(asy, ASY_RHR); in asy_program()
2793 asy_clr(asy, ASY_LCR, ASY_LCR_WLS0 | ASY_LCR_WLS1 | in asy_program()
2795 asy_set(asy, ASY_LCR, lcr); in asy_program()
2796 asy_set_baudrate(asy, baudrate); in asy_program()
2805 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) in asy_program()
2806 asy_reset_fifo(asy, ASY_FCR_RHR_FL); in asy_program()
2810 asy->asy_ocflag = c_flag & ~CLOCAL; in asy_program()
2814 asy_put(asy, ASY_MCR, in asy_program()
2815 (asy->asy_mcr & ASY_MCR_RTS) | ASY_MCR_OUT2); in asy_program()
2817 asy_put(asy, ASY_MCR, asy->asy_mcr | ASY_MCR_OUT2); in asy_program()
2824 async_msint(asy); in asy_program()
2827 ASY_DPRINTF(asy, ASY_DEBUG_MODM2, in asy_program()
2846 asy_enable_interrupts(asy, ier); in asy_program()
2847 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "done"); in asy_program()
2851 asy_baudok(struct asycom *asy) in asy_baudok() argument
2853 struct asyncline *async = asy->asy_priv; in asy_baudok()
2881 struct asycom *asy = (struct asycom *)argasy; in asyintr() local
2885 mutex_enter(&asy->asy_excl_hi); in asyintr()
2886 async = asy->asy_priv; in asyintr()
2889 const uint8_t intr_id = asy_get(asy, ASY_ISR); in asyintr()
2891 ASY_DPRINTF(asy, ASY_DEBUG_INTR, in asyintr()
2902 (void) asy_get(asy, ASY_LSR); in asyintr()
2903 (void) asy_get(asy, ASY_RHR); in asyintr()
2904 asy->asy_msr = asy_get(asy, ASY_MSR); in asyintr()
2907 mutex_exit(&asy->asy_excl_hi); in asyintr()
2918 if (asy->asy_flags & ASY_DDI_SUSPENDED) { in asyintr()
2919 mutex_exit(&asy->asy_excl_hi); in asyintr()
2928 const uint8_t intr_id = asy_get(asy, ASY_ISR); in asyintr()
2938 const uint8_t lsr = asy_get(asy, ASY_LSR); in asyintr()
2940 ASY_DPRINTF(asy, ASY_DEBUG_INTR, in asyintr()
2952 async_rxint(asy, lsr); in asyintr()
2970 async_txint(asy); in asyintr()
2980 async_msint(asy); in asyintr()
2987 async_txint(asy); in asyintr()
2990 mutex_exit(&asy->asy_excl_hi); in asyintr()
3003 async_txint(struct asycom *asy) in async_txint() argument
3005 struct asyncline *async = asy->asy_priv; in async_txint()
3008 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in async_txint()
3019 fifo_len = asy->asy_fifo_buf; /* with FIFO buffers */ in async_txint()
3023 if (async_flowcontrol_sw_input(asy, FLOW_CHECK, IN_FLOW_NULL)) in async_txint()
3030 asy_put(asy, ASY_THR, *async->async_optr++); in async_txint()
3038 asysetsoft(asy); in async_txint()
3046 asy_ppsevent(struct asycom *asy, int msr) in asy_ppsevent() argument
3048 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in asy_ppsevent()
3050 if (asy->asy_flags & ASY_PPS_EDGE) { in asy_ppsevent()
3053 asy->asy_flags &= ~ASY_PPS_EDGE; in asy_ppsevent()
3074 asy->asy_flags |= ASY_PPS_EDGE; in asy_ppsevent()
3115 async_rxint(struct asycom *asy, uchar_t lsr) in async_rxint() argument
3117 struct asyncline *async = asy->asy_priv; in async_rxint()
3121 int looplim = asy->asy_fifo_buf * 2; in async_rxint()
3123 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in async_rxint()
3129 (void) asy_get(asy, ASY_RHR); in async_rxint()
3130 lsr = asy_get(asy, ASY_LSR); in async_rxint()
3141 c = asy_get(asy, ASY_RHR); in async_rxint()
3151 async_flowcontrol_sw_output(asy, in async_rxint()
3156 async_flowcontrol_sw_output(asy, in async_rxint()
3163 async_flowcontrol_sw_output(asy, in async_rxint()
3174 (asy->asy_flags & ASY_CONSOLE)) { in async_rxint()
3211 if ((asy->asy_flags & ASY_CONSOLE) && in async_rxint()
3228 lsr = asy_get(asy, ASY_LSR); in async_rxint()
3234 async_flowcontrol_hw_input(asy, FLOW_STOP, IN_FLOW_RINGBUFF); in async_rxint()
3235 (void) async_flowcontrol_sw_input(asy, FLOW_STOP, in async_rxint()
3241 asysetsoft(asy); /* need a soft interrupt */ in async_rxint()
3252 async_msint(struct asycom *asy) in async_msint() argument
3254 struct asyncline *async = asy->asy_priv; in async_msint()
3257 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in async_msint()
3261 msr = asy_get(asy, ASY_MSR); in async_msint()
3262 ASY_DPRINTF(asy, ASY_DEBUG_STATE, "call #%d:", in async_msint()
3263 ++(asy->asy_msint_cnt)); in async_msint()
3264 ASY_DPRINTF(asy, ASY_DEBUG_STATE, " transition: %3s %3s %3s %3s", in async_msint()
3269 ASY_DPRINTF(asy, ASY_DEBUG_STATE, "current state: %3s %3s %3s %3s", in async_msint()
3276 if ((t_cflag & CRTSCTS) && (((asy->asy_msr ^ msr) & ASY_MSR_CTS) != 0)) in async_msint()
3277 async_flowcontrol_hw_output(asy, in async_msint()
3284 asy->asy_msr = (uchar_t)msr; in async_msint()
3287 if (asy->asy_flags & ASY_PPS) in async_msint()
3288 asy_ppsevent(asy, msr); in async_msint()
3291 asysetsoft(asy); in async_msint()
3300 msr = asy_get(asy, ASY_MSR); in async_msint()
3301 if (ASY_MSR_STATES(msr) != ASY_MSR_STATES(asy->asy_msr)) in async_msint()
3309 asysetsoft(struct asycom *asy) in asysetsoft() argument
3311 ASSERT(MUTEX_HELD(&asy->asy_excl_hi)); in asysetsoft()
3313 if (mutex_tryenter(&asy->asy_soft_lock) == 0) in asysetsoft()
3316 asy->asy_flags |= ASY_NEEDSOFT; in asysetsoft()
3317 if (!asy->asysoftpend) { in asysetsoft()
3318 asy->asysoftpend = 1; in asysetsoft()
3319 mutex_exit(&asy->asy_soft_lock); in asysetsoft()
3320 (void) ddi_intr_trigger_softint(asy->asy_soft_inth, NULL); in asysetsoft()
3322 mutex_exit(&asy->asy_soft_lock); in asysetsoft()
3331 asy_carrier_check(struct asycom *asy) in asy_carrier_check() argument
3333 struct asyncline *async = asy->asy_priv; in asy_carrier_check()
3339 ASY_DPRINTF(asy, ASY_DEBUG_MODM2, in asy_carrier_check()
3341 asy->asy_msr & ASY_MSR_DCD, tp->t_flags & TS_SOFTCAR); in asy_carrier_check()
3343 if (asy->asy_msr & ASY_MSR_DCD) { in asy_carrier_check()
3351 ASY_DPRINTF(asy, ASY_DEBUG_MODM2, "set ASYNC_CARR_ON"); in asy_carrier_check()
3354 mutex_exit(&asy->asy_excl_hi); in asy_carrier_check()
3355 mutex_exit(&asy->asy_excl); in asy_carrier_check()
3357 mutex_enter(&asy->asy_excl); in asy_carrier_check()
3358 mutex_enter(&asy->asy_excl_hi); in asy_carrier_check()
3384 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "carrier dropped, so drop DTR"); in asy_carrier_check()
3385 asy_clr(asy, ASY_MCR, ASY_MCR_DTR); in asy_carrier_check()
3388 ASY_DPRINTF(asy, ASY_DEBUG_BUSY, in asy_carrier_check()
3400 mutex_exit(&asy->asy_excl_hi); in asy_carrier_check()
3401 mutex_exit(&asy->asy_excl); in asy_carrier_check()
3403 mutex_enter(&asy->asy_excl); in asy_carrier_check()
3404 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "putctl(q, M_HANGUP)"); in asy_carrier_check()
3409 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asy_carrier_check()
3410 mutex_enter(&asy->asy_excl_hi); in asy_carrier_check()
3411 asy_reset_fifo(asy, ASY_FCR_THR_FL); in asy_carrier_check()
3412 mutex_exit(&asy->asy_excl_hi); in asy_carrier_check()
3419 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asy_carrier_check()
3431 mutex_enter(&asy->asy_excl_hi); in asy_carrier_check()
3447 struct asycom *asy = (struct asycom *)intarg; in asysoftintr() local
3455 mutex_enter(&asy->asy_soft_lock); in asysoftintr()
3456 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "enter"); in asysoftintr()
3457 rv = asy->asysoftpend; in asysoftintr()
3459 asy->asysoftpend = 0; in asysoftintr()
3460 mutex_exit(&asy->asy_soft_lock); in asysoftintr()
3463 if (asy->asy_priv == NULL) in asysoftintr()
3465 async = (struct asyncline *)asy->asy_priv; in asysoftintr()
3466 mutex_enter(&asy->asy_excl_hi); in asysoftintr()
3467 if (asy->asy_flags & ASY_NEEDSOFT) { in asysoftintr()
3468 asy->asy_flags &= ~ASY_NEEDSOFT; in asysoftintr()
3469 mutex_exit(&asy->asy_excl_hi); in asysoftintr()
3470 async_softint(asy); in asysoftintr()
3471 mutex_enter(&asy->asy_excl_hi); in asysoftintr()
3482 mutex_exit(&asy->asy_excl_hi); in asysoftintr()
3484 (void) async_softint(asy); in asysoftintr()
3493 async_softint(struct asycom *asy) in async_softint() argument
3495 struct asyncline *async = asy->asy_priv; in async_softint()
3503 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "enter"); in async_softint()
3504 mutex_enter(&asy->asy_excl_hi); in async_softint()
3505 if (asy->asy_flags & ASY_DOINGSOFT) { in async_softint()
3506 asy->asy_flags |= ASY_DOINGSOFT_RETRY; in async_softint()
3507 mutex_exit(&asy->asy_excl_hi); in async_softint()
3510 asy->asy_flags |= ASY_DOINGSOFT; in async_softint()
3512 asy->asy_flags &= ~ASY_DOINGSOFT_RETRY; in async_softint()
3513 mutex_exit(&asy->asy_excl_hi); in async_softint()
3514 mutex_enter(&asy->asy_excl); in async_softint()
3520 mutex_enter(&asy->asy_excl_hi); in async_softint()
3522 mutex_exit(&asy->asy_excl_hi); in async_softint()
3532 mutex_enter(&asy->asy_excl_hi); in async_softint()
3535 asy_carrier_check(asy); in async_softint()
3537 mutex_exit(&asy->asy_excl_hi); in async_softint()
3546 mutex_enter(&asy->asy_excl_hi); in async_softint()
3553 mutex_exit(&asy->asy_excl_hi); in async_softint()
3556 mutex_enter(&asy->asy_excl_hi); in async_softint()
3558 async_flowcontrol_hw_input(asy, FLOW_STOP, in async_softint()
3560 (void) async_flowcontrol_sw_input(asy, FLOW_STOP, in async_softint()
3566 mutex_enter(&asy->asy_excl_hi); in async_softint()
3567 async_flowcontrol_hw_input(asy, FLOW_START, in async_softint()
3569 (void) async_flowcontrol_sw_input(asy, FLOW_START, in async_softint()
3571 mutex_exit(&asy->asy_excl_hi); in async_softint()
3574 ASY_DPRINTF(asy, ASY_DEBUG_INPUT, "%d char(s) in queue", cc); in async_softint()
3577 mutex_exit(&asy->asy_excl); in async_softint()
3579 mutex_enter(&asy->asy_excl); in async_softint()
3580 mutex_enter(&asy->asy_excl_hi); in async_softint()
3583 mutex_enter(&asy->asy_excl_hi); in async_softint()
3593 mutex_exit(&asy->asy_excl_hi); in async_softint()
3594 mutex_exit(&asy->asy_excl); in async_softint()
3597 asyerror(asy, CE_WARN, "local queue full"); in async_softint()
3613 mutex_enter(&asy->asy_excl); in async_softint()
3614 mutex_enter(&asy->asy_excl_hi); in async_softint()
3616 asysetsoft(asy); /* finish cc chars */ in async_softint()
3621 async_flowcontrol_hw_input(asy, FLOW_START, IN_FLOW_RINGBUFF); in async_softint()
3622 (void) async_flowcontrol_sw_input(asy, FLOW_START, in async_softint()
3634 mutex_exit(&asy->asy_excl_hi); in async_softint()
3635 mutex_exit(&asy->asy_excl); in async_softint()
3638 mutex_enter(&asy->asy_excl); in async_softint()
3639 mutex_enter(&asy->asy_excl_hi); in async_softint()
3643 ASY_DPRINTF(asy, ASY_DEBUG_BUSY, in async_softint()
3646 mutex_exit(&asy->asy_excl_hi); in async_softint()
3658 mutex_enter(&asy->asy_excl_hi); in async_softint()
3669 mutex_exit(&asy->asy_excl_hi); in async_softint()
3670 mutex_exit(&asy->asy_excl); in async_softint()
3671 asyerror(asy, CE_WARN, "silo overflow"); in async_softint()
3672 mutex_enter(&asy->asy_excl); in async_softint()
3673 mutex_enter(&asy->asy_excl_hi); in async_softint()
3679 mutex_exit(&asy->asy_excl_hi); in async_softint()
3680 mutex_exit(&asy->asy_excl); in async_softint()
3681 asyerror(asy, CE_WARN, "ring buffer overflow"); in async_softint()
3682 mutex_enter(&asy->asy_excl); in async_softint()
3683 mutex_enter(&asy->asy_excl_hi); in async_softint()
3687 if (asy->asy_flags & ASY_DOINGSOFT_RETRY) { in async_softint()
3688 mutex_exit(&asy->asy_excl); in async_softint()
3691 asy->asy_flags &= ~ASY_DOINGSOFT; in async_softint()
3692 mutex_exit(&asy->asy_excl_hi); in async_softint()
3693 mutex_exit(&asy->asy_excl); in async_softint()
3694 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "done"); in async_softint()
3704 struct asycom *asy = async->async_common; in async_restart() local
3706 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "enter"); in async_restart()
3712 mutex_enter(&asy->asy_excl); in async_restart()
3719 mutex_enter(&asy->asy_excl_hi); in async_restart()
3720 asy_clr(asy, ASY_LCR, ASY_LCR_SETBRK); in async_restart()
3721 mutex_exit(&asy->asy_excl_hi); in async_restart()
3727 mutex_exit(&asy->asy_excl); in async_restart()
3736 struct asycom *asy = async->async_common; in async_start() local
3745 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "enter"); in async_start()
3747 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in async_start()
3748 fifo_len = asy->asy_fifo_buf; /* with FIFO buffers */ in async_start()
3753 ASSERT(mutex_owned(&asy->asy_excl)); in async_start()
3761 ASY_DPRINTF(asy, ASY_DEBUG_OUT, "%s", in async_start()
3769 mutex_enter(&asy->asy_excl_hi); in async_start()
3770 if (async_flowcontrol_sw_input(asy, FLOW_CHECK, IN_FLOW_NULL)) in async_start()
3772 mutex_exit(&asy->asy_excl_hi); in async_start()
3779 ASY_DPRINTF(asy, ASY_DEBUG_OUT, "start ASYNC_DELAY"); in async_start()
3784 ASY_DPRINTF(asy, ASY_DEBUG_OUT, "start writeq is null"); in async_start()
3807 mutex_enter(&asy->asy_excl_hi); in async_start()
3808 asy_set(asy, ASY_LCR, ASY_LCR_SETBRK); in async_start()
3809 mutex_exit(&asy->asy_excl_hi); in async_start()
3834 mutex_exit(&asy->asy_excl); in async_start()
3836 mutex_enter(&asy->asy_excl); in async_start()
3881 mutex_enter(&asy->asy_excl_hi); in async_start()
3888 if (!(asy_get(asy, ASY_LSR) & ASY_LSR_THRE)) in async_start()
3890 asy_put(asy, ASY_THR, *xmit_addr++); in async_start()
3898 ASY_DPRINTF(asy, ASY_DEBUG_BUSY, "Set ASYNC_BUSY, async_ocnt=%d", in async_start()
3901 mutex_exit(&asy->asy_excl_hi); in async_start()
3910 struct asycom *asy = async->async_common; in async_resume() local
3912 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "enter"); in async_resume()
3913 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_resume()
3915 if (asy_get(asy, ASY_LSR) & ASY_LSR_THRE) { in async_resume()
3916 if (async_flowcontrol_sw_input(asy, FLOW_CHECK, IN_FLOW_NULL)) in async_resume()
3921 asy_put(asy, ASY_THR, *async->async_optr++); in async_resume()
3935 struct asycom *asy = async->async_common; in async_hold_utbrk() local
3937 mutex_enter(&asy->asy_excl); in async_hold_utbrk()
3941 mutex_exit(&asy->asy_excl); in async_hold_utbrk()
3950 struct asycom *asy = async->async_common; in async_resume_utbrk() local
3951 ASSERT(mutex_owned(&asy->asy_excl)); in async_resume_utbrk()
3958 cv_wait(&async->async_flags_cv, &asy->asy_excl); in async_resume_utbrk()
3960 mutex_enter(&asy->asy_excl_hi); in async_resume_utbrk()
3967 asy_clr(asy, ASY_LCR, ASY_LCR_SETBRK); in async_resume_utbrk()
3973 mutex_exit(&asy->asy_excl_hi); in async_resume_utbrk()
3976 mutex_exit(&asy->asy_excl_hi); in async_resume_utbrk()
3995 struct asycom *asy = async->async_common; in async_ioctl() local
4002 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "enter"); in async_ioctl()
4026 ASY_DPRINTF(asy, ASY_DEBUG_IOCTL, "%s", in async_ioctl()
4067 mutex_enter(&asy->asy_excl); in async_ioctl()
4077 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4078 if (asy_baudok(asy)) in async_ioctl()
4079 asy_program(asy, ASY_NOINIT); in async_ioctl()
4082 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4089 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4090 if (!asy_baudok(asy)) in async_ioctl()
4093 if (asy_isbusy(asy)) in async_ioctl()
4094 asy_waiteot(asy); in async_ioctl()
4095 asy_program(asy, ASY_NOINIT); in async_ioctl()
4097 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4119 if (asy->asy_flags & ASY_PPS) in async_ioctl()
4136 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4138 asy->asy_flags |= ASY_PPS; in async_ioctl()
4140 asy->asy_flags &= ~ASY_PPS; in async_ioctl()
4142 asy->asy_flags &= ~ASY_PPS_EDGE; in async_ioctl()
4143 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4164 if ((asy->asy_flags & ASY_PPS) == 0) { in async_ioctl()
4170 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4172 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4219 &asy->asy_excl); in async_ioctl()
4221 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4230 asy_wait_baudrate(asy); in async_ioctl()
4237 asy_set(asy, ASY_LCR, ASY_LCR_SETBRK); in async_ioctl()
4238 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4242 ASY_DPRINTF(asy, ASY_DEBUG_OUT, in async_ioctl()
4244 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4245 asy_waiteot(asy); in async_ioctl()
4246 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4247 ASY_DPRINTF(asy, ASY_DEBUG_OUT, in async_ioctl()
4254 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4257 asy_wait_baudrate(asy); in async_ioctl()
4258 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4278 ASY_DPRINTF(asy, ASY_DEBUG_IOCTL, in async_ioctl()
4285 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4286 (void) asymctl(asy, in async_ioctl()
4287 dmtoasy(asy, *(int *)mp->b_cont->b_rptr), in async_ioctl()
4289 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4293 ASY_DPRINTF(asy, ASY_DEBUG_IOCTL, in async_ioctl()
4306 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4307 *(int *)datamp->b_rptr = asymctl(asy, 0, TIOCMGET); in async_ioctl()
4308 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4311 ASY_DPRINTF(asy, ASY_DEBUG_IOCTL, in async_ioctl()
4315 ASY_DPRINTF(asy, ASY_DEBUG_IOCTL, in async_ioctl()
4327 &asy->polledio; in async_ioctl()
4348 mutex_enter(&asy->asy_excl_hi); in async_ioctl()
4350 asy->asy_flags |= ASY_CONSOLE; in async_ioctl()
4352 asy->asy_flags &= ~ASY_CONSOLE; in async_ioctl()
4353 mutex_exit(&asy->asy_excl_hi); in async_ioctl()
4369 (asy->asy_flags & ASY_CONSOLE) != 0; in async_ioctl()
4384 mutex_exit(&asy->asy_excl); in async_ioctl()
4386 ASY_DPRINTF(asy, ASY_DEBUG_PROCS, "done"); in async_ioctl()
4394 struct asycom *asy; in asyrsrv() local
4397 asy = (struct asycom *)async->async_common; in asyrsrv()
4401 mutex_enter(&asy->asy_excl_hi); in asyrsrv()
4402 asysetsoft(asy); in asyrsrv()
4403 mutex_exit(&asy->asy_excl_hi); in asyrsrv()
4432 struct asycom *asy; in asywputdo() local
4436 asy = async->async_common; in asywputdo()
4445 mutex_enter(&asy->asy_excl); in asywputdo()
4447 mutex_exit(&asy->asy_excl); in asywputdo()
4452 mutex_enter(&asy->asy_excl); in asywputdo()
4462 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4464 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4470 mutex_exit(&asy->asy_excl); in asywputdo()
4485 ASY_DPRINTF(asy, ASY_DEBUG_OUT, in asywputdo()
4489 mutex_enter(&asy->asy_excl); in asywputdo()
4500 mutex_exit(&asy->asy_excl); in asywputdo()
4518 mutex_enter(&asy->asy_excl); in asywputdo()
4529 mutex_exit(&asy->asy_excl); in asywputdo()
4536 mutex_enter(&asy->asy_excl); in asywputdo()
4538 mutex_exit(&asy->asy_excl); in asywputdo()
4542 async_put_suspq(asy, mp); in asywputdo()
4543 mutex_exit(&asy->asy_excl); in asywputdo()
4550 mutex_enter(&asy->asy_excl); in asywputdo()
4555 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4557 ASY_DPRINTF(asy, ASY_DEBUG_BUSY, in asywputdo()
4566 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asywputdo()
4567 asy_reset_fifo(asy, ASY_FCR_THR_FL); in asywputdo()
4570 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4580 mutex_exit(&asy->asy_excl); in asywputdo()
4585 mutex_enter(&asy->asy_excl); in asywputdo()
4586 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4588 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asywputdo()
4589 asy_reset_fifo(asy, ASY_FCR_RHR_FL); in asywputdo()
4591 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4592 mutex_exit(&asy->asy_excl); in asywputdo()
4605 mutex_enter(&asy->asy_excl); in asywputdo()
4607 mutex_exit(&asy->asy_excl); in asywputdo()
4620 mutex_enter(&asy->asy_excl); in asywputdo()
4622 mutex_exit(&asy->asy_excl); in asywputdo()
4627 mutex_enter(&asy->asy_excl); in asywputdo()
4629 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4631 async_flowcontrol_hw_input(asy, FLOW_STOP, in asywputdo()
4633 (void) async_flowcontrol_sw_input(asy, in asywputdo()
4636 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4637 mutex_exit(&asy->asy_excl); in asywputdo()
4641 async_put_suspq(asy, mp); in asywputdo()
4642 mutex_exit(&asy->asy_excl); in asywputdo()
4646 mutex_enter(&asy->asy_excl); in asywputdo()
4648 mutex_enter(&asy->asy_excl_hi); in asywputdo()
4650 async_flowcontrol_hw_input(asy, FLOW_START, in asywputdo()
4652 (void) async_flowcontrol_sw_input(asy, in asywputdo()
4655 mutex_exit(&asy->asy_excl_hi); in asywputdo()
4656 mutex_exit(&asy->asy_excl); in asywputdo()
4660 async_put_suspq(asy, mp); in asywputdo()
4661 mutex_exit(&asy->asy_excl); in asywputdo()
4667 mutex_enter(&asy->asy_excl); in asywputdo()
4671 mutex_exit(&asy->asy_excl); in asywputdo()
4675 async_put_suspq(asy, mp); in asywputdo()
4686 mutex_enter(&asy->asy_excl); in asywputdo()
4697 mutex_exit(&asy->asy_excl); in asywputdo()
4703 mutex_enter(&asy->asy_excl); in asywputdo()
4705 mutex_exit(&asy->asy_excl); in asywputdo()
4709 async_put_suspq(asy, mp); in asywputdo()
4710 mutex_exit(&asy->asy_excl); in asywputdo()
4735 struct asycom *asy; in async_reioctl() local
4739 asy = ddi_get_soft_state(asy_soft_state, instance); in async_reioctl()
4740 ASSERT(asy != NULL); in async_reioctl()
4741 async = asy->asy_priv; in async_reioctl()
4746 mutex_enter(&asy->asy_excl); in async_reioctl()
4749 mutex_exit(&asy->asy_excl); in async_reioctl()
4755 mutex_exit(&asy->asy_excl); in async_reioctl()
4758 mutex_exit(&asy->asy_excl); in async_reioctl()
4765 struct asycom *asy; in async_iocdata() local
4769 asy = async->async_common; in async_iocdata()
4780 mutex_enter(&asy->asy_excl); in async_iocdata()
4781 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "case %s", in async_iocdata()
4803 mutex_enter(&asy->asy_excl_hi); in async_iocdata()
4804 (void) asymctl(asy, dmtoasy(asy, *(int *)mp->b_cont->b_rptr), in async_iocdata()
4806 mutex_exit(&asy->asy_excl_hi); in async_iocdata()
4816 mutex_exit(&asy->asy_excl); in async_iocdata()
4830 struct asycom *asy = (struct asycom *)arg; in asyputchar() local
4835 while ((asy_get_reg(asy, ASY_LSR) & ASY_LSR_THRE) == 0) { in asyputchar()
4841 asy_put_reg(asy, ASY_THR, c); in asyputchar()
4851 struct asycom *asy = (struct asycom *)arg; in asyischar() local
4853 return ((asy_get_reg(asy, ASY_LSR) & ASY_LSR_DR) != 0); in asyischar()
4862 struct asycom *asy = (struct asycom *)arg; in asygetchar() local
4866 return (asy_get_reg(asy, ASY_RHR)); in asygetchar()
4873 asymctl(struct asycom *asy, int bits, int how) in asymctl() argument
4877 ASSERT(mutex_owned(&asy->asy_excl_hi)); in asymctl()
4878 ASSERT(mutex_owned(&asy->asy_excl)); in asymctl()
4881 mcr_r = asy_get(asy, ASY_MCR); in asymctl()
4886 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "TIOCMSET, bits = %x", bits); in asymctl()
4891 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "TIOCMBIS, bits = %x", bits); in asymctl()
4896 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "TIOCMBIC, bits = %x", bits); in asymctl()
4906 if (asy_get(asy, ASY_IER) & ASY_IER_MIEN) { in asymctl()
4907 msr_r = asy->asy_msr; in asymctl()
4908 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asymctl()
4911 msr_r = asy_get(asy, ASY_MSR); in asymctl()
4912 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, in asymctl()
4915 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "modem_lines = %x", in asymctl()
4920 asy_put(asy, ASY_MCR, mcr_r); in asymctl()
4953 dmtoasy(struct asycom *asy, int bits) in dmtoasy() argument
4957 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "bits = %x", bits); in dmtoasy()
4970 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "set b & RTS"); in dmtoasy()
4974 ASY_DPRINTF(asy, ASY_DEBUG_MODEM, "set b & DTR"); in dmtoasy()
4982 asyerror(const struct asycom *asy, int level, const char *fmt, ...) in asyerror() argument
5006 vdev_err(asy->asy_dip, level, fmt, adx); in asyerror()
5022 asy_parse_mode(dev_info_t *devi, struct asycom *asy) in asy_parse_mode() argument
5031 ASSERT(asy->asy_com_port != 0); in asy_parse_mode()
5036 (void) sprintf(name, "tty%c-mode", asy->asy_com_port + 'a' - 1); in asy_parse_mode()
5040 (void) sprintf(name, "com%c-mode", asy->asy_com_port + '0'); in asy_parse_mode()
5046 asy->asy_cflag = 0; in asy_parse_mode()
5052 asy->asy_cflag = CREAD|B9600; /* initial default */ in asy_parse_mode()
5056 asy->asy_cflag |= ASY_LCR_BITS8; /* add default bits */ in asy_parse_mode()
5061 asy->asy_bidx = B110; in asy_parse_mode()
5063 asy->asy_bidx = B150; in asy_parse_mode()
5065 asy->asy_bidx = B300; in asy_parse_mode()
5067 asy->asy_bidx = B600; in asy_parse_mode()
5069 asy->asy_bidx = B1200; in asy_parse_mode()
5071 asy->asy_bidx = B2400; in asy_parse_mode()
5073 asy->asy_bidx = B4800; in asy_parse_mode()
5075 asy->asy_bidx = B9600; in asy_parse_mode()
5077 asy->asy_bidx = B19200; in asy_parse_mode()
5079 asy->asy_bidx = B38400; in asy_parse_mode()
5081 asy->asy_bidx = B57600; in asy_parse_mode()
5083 asy->asy_bidx = B115200; in asy_parse_mode()
5085 asy->asy_bidx = B9600; in asy_parse_mode()
5087 asy->asy_cflag &= ~CBAUD; in asy_parse_mode()
5088 if (asy->asy_bidx > CBAUD) { /* > 38400 uses the CBAUDEXT bit */ in asy_parse_mode()
5089 asy->asy_cflag |= CBAUDEXT; in asy_parse_mode()
5090 asy->asy_cflag |= asy->asy_bidx - CBAUD - 1; in asy_parse_mode()
5092 asy->asy_cflag |= asy->asy_bidx; in asy_parse_mode()
5095 ASSERT(asy->asy_bidx == BAUDINDEX(asy->asy_cflag)); in asy_parse_mode()
5102 asy->asy_cflag |= ASY_LCR_BITS8; /* add default bits */ in asy_parse_mode()
5108 asy->asy_cflag |= CS8; in asy_parse_mode()
5109 asy->asy_lcr = ASY_LCR_BITS8; in asy_parse_mode()
5112 asy->asy_cflag |= CS7; in asy_parse_mode()
5113 asy->asy_lcr = ASY_LCR_BITS7; in asy_parse_mode()
5116 asy->asy_cflag |= CS6; in asy_parse_mode()
5117 asy->asy_lcr = ASY_LCR_BITS6; in asy_parse_mode()
5121 asy->asy_cflag |= CS5; in asy_parse_mode()
5122 asy->asy_lcr = ASY_LCR_BITS5; in asy_parse_mode()
5138 asy->asy_cflag |= PARENB; in asy_parse_mode()
5139 asy->asy_lcr |= ASY_LCR_PEN; in asy_parse_mode()
5142 asy->asy_cflag |= PARENB|PARODD; in asy_parse_mode()
5143 asy->asy_lcr |= ASY_LCR_PEN | ASY_LCR_EPS; in asy_parse_mode()
5155 asy->asy_cflag |= CSTOPB; in asy_parse_mode()
5156 asy->asy_lcr |= ASY_LCR_STB; in asy_parse_mode()
5166 asy->asy_cflag |= CRTSCTS; in asy_parse_mode()
5168 asy->asy_cflag |= CRTSXOFF; in asy_parse_mode()
5216 async_flowcontrol_sw_input(struct asycom *asy, async_flowc_action onoff, in async_flowcontrol_sw_input() argument
5219 struct asyncline *async = asy->asy_priv; in async_flowcontrol_sw_input()
5222 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_sw_input()
5245 ASY_DPRINTF(asy, ASY_DEBUG_SFLOW, "input sflow stop, type = %x", in async_flowcontrol_sw_input()
5253 ASY_DPRINTF(asy, ASY_DEBUG_SFLOW, "input sflow start"); in async_flowcontrol_sw_input()
5262 (asy_get(asy, ASY_LSR) & ASY_LSR_THRE)) { in async_flowcontrol_sw_input()
5269 asy_put(asy, ASY_THR, in async_flowcontrol_sw_input()
5289 async_flowcontrol_sw_output(struct asycom *asy, async_flowc_action onoff) in async_flowcontrol_sw_output() argument
5291 struct asyncline *async = asy->asy_priv; in async_flowcontrol_sw_output()
5293 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_sw_output()
5302 ASY_DPRINTF(asy, ASY_DEBUG_SFLOW, "output sflow stop"); in async_flowcontrol_sw_output()
5308 ASY_DPRINTF(asy, ASY_DEBUG_SFLOW, "output sflow start"); in async_flowcontrol_sw_output()
5330 async_flowcontrol_hw_input(struct asycom *asy, async_flowc_action onoff, in async_flowcontrol_hw_input() argument
5335 struct asyncline *async = asy->asy_priv; in async_flowcontrol_hw_input()
5337 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_hw_input()
5348 ASY_DPRINTF(asy, ASY_DEBUG_HFLOW, "input hflow stop, type = %x", in async_flowcontrol_hw_input()
5355 ASY_DPRINTF(asy, ASY_DEBUG_HFLOW, "input hflow start"); in async_flowcontrol_hw_input()
5361 mcr = asy_get(asy, ASY_MCR); in async_flowcontrol_hw_input()
5365 asy_put(asy, ASY_MCR, (mcr ^ ASY_MCR_RTS)); in async_flowcontrol_hw_input()
5383 async_flowcontrol_hw_output(struct asycom *asy, async_flowc_action onoff) in async_flowcontrol_hw_output() argument
5385 struct asyncline *async = asy->asy_priv; in async_flowcontrol_hw_output()
5387 ASSERT(mutex_owned(&asy->asy_excl_hi)); in async_flowcontrol_hw_output()
5396 ASY_DPRINTF(asy, ASY_DEBUG_HFLOW, "output hflow stop"); in async_flowcontrol_hw_output()
5402 ASY_DPRINTF(asy, ASY_DEBUG_HFLOW, "output hflow start"); in async_flowcontrol_hw_output()
5423 struct asycom *asy; in asyquiesce() local
5427 asy = ddi_get_soft_state(asy_soft_state, instance); in asyquiesce()
5428 if (asy == NULL) in asyquiesce()
5431 asy_disable_interrupts(asy, ASY_IER_ALL); in asyquiesce()
5434 if (asy->asy_use_fifo == ASY_FCR_FIFO_EN) { in asyquiesce()
5435 asy_reset_fifo(asy, ASY_FCR_THR_FL | ASY_FCR_RHR_FL); in asyquiesce()