Lines Matching defs:ssp
348 lombus_trace(struct lombus_state *ssp, char code, const char *caller,
355 if (ssp->debug & (1 << (code-'@'))) {
366 (void) strlog(ssp->majornum, ssp->instance, code, SL_TRACE,
374 struct lombus_state *ssp = NULL;
397 ssp = ddi_get_soft_state(lombus_statep, instance);
398 if (ssp != NULL) {
399 sdip = ssp->dip;
401 ssp = NULL;
407 ssp = NULL;
411 return (ssp);
419 sio_put_reg(struct lombus_state *ssp, uint_t reg, uint8_t val)
421 lombus_trace(ssp, 'P', "sio_put_reg", "REG[%d] <- $%02x", reg, val);
423 if (ssp->sio_handle != NULL && !ssp->sio_fault) {
450 ddi_put8(ssp->sio_handle, ssp->sio_regs + reg, val);
451 ddi_put8(ssp->sio_handle, ssp->sio_regs + SIO_SCR, val);
453 (void) ddi_get8(ssp->sio_handle, ssp->sio_regs + SIO_SCR);
458 sio_get_reg(struct lombus_state *ssp, uint_t reg)
462 if (ssp->sio_handle && !ssp->sio_fault)
463 val = ddi_get8(ssp->sio_handle, ssp->sio_regs + reg);
467 lombus_trace(ssp, 'G', "sio_get_reg", "$%02x <- REG[%d]", val, reg);
473 sio_check_fault_status(struct lombus_state *ssp)
475 ssp->sio_fault = ddi_check_acc_handle(ssp->sio_handle) != DDI_SUCCESS;
479 sio_faulty(struct lombus_state *ssp)
481 if (!ssp->sio_fault)
482 sio_check_fault_status(ssp);
483 return (ssp->sio_fault);
491 sio_data_ready(struct lombus_state *ssp)
499 status = sio_get_reg(ssp, SIO_LSR);
500 return ((status & SIO_LSR_RXDA) != 0 && !sio_faulty(ssp));
507 sio_lom_ready(struct lombus_state *ssp)
519 status = sio_get_reg(ssp, SIO_MSR);
520 rslt = (status & SIO_MSR_CTS) != 0 && !sio_faulty(ssp);
522 lombus_trace(ssp, 'R', "sio_lom_ready", "S $%02x R %d F %d",
523 status, rslt, ssp->fake_cts);
525 return (rslt || ssp->fake_cts);
533 sio_irq_pending(struct lombus_state *ssp)
546 status = sio_get_reg(ssp, SIO_EIR);
548 rslt = (status & SIO_EIR_IPF) == 0 && !sio_faulty(ssp);
549 lombus_trace(ssp, 'I', "sio_irq_pending", "S $%02x R %d",
560 ASSERT(ssp->hw_int_enabled);
570 lombus_set_irq(struct lombus_state *ssp, boolean_t newstate)
575 sio_put_reg(ssp, SIO_IER, SIO_IER_STD | val);
576 ssp->hw_int_enabled = newstate;
583 lombus_toggle_rts(struct lombus_state *ssp)
587 val = sio_get_reg(ssp, SIO_MCR);
591 sio_put_reg(ssp, SIO_MCR, val);
619 struct lombus_state *ssp = (void *)arg;
623 if (ssp->cycid != NULL) {
624 mutex_enter(ssp->hw_mutex);
625 if (ssp->hw_int_enabled) {
626 lombus_set_irq(ssp, B_FALSE);
627 ddi_trigger_softintr(ssp->softid);
630 mutex_exit(ssp->hw_mutex);
644 lombus_receive(struct lombus_state *ssp)
651 lombus_trace(ssp, 'S', "lombus_receive",
653 ssp->cmdstate, ssp->error);
660 if (!sio_faulty(ssp)) {
666 mutex_enter(ssp->hw_mutex);
667 while (sio_data_ready(ssp)) {
668 data = sio_get_reg(ssp, SIO_RXD);
669 ssp->reply[rcvd = ssp->index] = data;
672 ssp->index = rcvd;
676 lombus_set_irq(ssp, B_TRUE);
677 mutex_exit(ssp->hw_mutex);
680 lombus_trace(ssp, 'S', "lombus_receive",
683 ssp->reply[0], ssp->reply[1],
684 ssp->reply[2], ssp->reply[3],
685 ssp->reply[4], ssp->reply[5],
686 ssp->reply[6], ssp->reply[7]);
688 if (ssp->cmdstate != LOMBUS_CMDSTATE_WAITING) {
694 ssp->index = 0;
702 if (ddi_get_lbolt() > ssp->deadline) {
703 ssp->cmdstate = LOMBUS_CMDSTATE_ERROR;
704 ssp->error = LOMBUS_ERR_TIMEOUT;
713 ssp->index = 0;
714 ssp->cmdstate = LOMBUS_CMDSTATE_ERROR;
715 ssp->error = LOMBUS_ERR_OFLOW;
737 if (ssp->allow_echo) {
738 lombus_trace(ssp, 'E', "lombus_receive",
741 ssp->reply[0], ssp->reply[1],
742 ssp->reply[2], ssp->reply[3],
743 ssp->reply[4], ssp->reply[5],
744 ssp->reply[6], ssp->reply[7]);
745 ssp->index = 0;
747 ssp->cmdstate = LOMBUS_CMDSTATE_ERROR;
748 ssp->error = LOMBUS_ERR_BADSTATUS;
751 } else if ((data & LOMBUS_SEQ) != ssp->sequence) {
755 ssp->cmdstate = LOMBUS_CMDSTATE_ERROR;
756 ssp->error = LOMBUS_ERR_SEQUENCE;
769 ssp->async = (data & LOMBUS_STATUS_ASYNC) ? 1 : 0;
770 tmp = ((data & LOMBUS_STATUS_MSB) ? 0x80 : 0) | ssp->reply[0];
772 ssp->cmdstate = LOMBUS_CMDSTATE_ERROR;
773 ssp->error = tmp;
775 ssp->cmdstate = LOMBUS_CMDSTATE_READY;
776 ssp->result = tmp;
781 lombus_trace(ssp, 'T', "lombus_receive",
783 rcvd, data, ssp->cmdstate, ssp->error, ready);
786 cv_broadcast(ssp->lo_cv);
797 struct lombus_state *ssp = (void *)arg;
799 mutex_enter(ssp->lo_mutex);
800 lombus_receive(ssp);
801 mutex_exit(ssp->lo_mutex);
813 struct lombus_state *ssp = (void *)arg;
815 mutex_enter(ssp->lo_mutex);
816 lombus_receive(ssp);
817 mutex_exit(ssp->lo_mutex);
829 struct lombus_state *ssp;
839 ssp = HANDLE_PRIVATE(hdlp);
840 mutex_enter(ssp->lo_mutex);
841 while (ssp->cmdstate != LOMBUS_CMDSTATE_IDLE && !panicstr)
842 cv_wait(ssp->lo_cv, ssp->lo_mutex);
844 ssp->cmdstate = LOMBUS_CMDSTATE_BUSY;
845 ssp->sequence = (ssp->sequence + LOMBUS_SEQ_LSB) & LOMBUS_SEQ;
855 p = &ssp->cmdbuf[0];
856 *p++ = LOMBUS_CMD | ssp->sequence | cmd;
861 ssp->cmdbuf[0] |= LOMBUS_CMD_WMSB;
866 ssp->cmdbuf[0] |= LOMBUS_CMD_XADDR;
882 sio_check_fault_status(ssp);
892 ssp->deadline = start + drv_usectohz(LOMBUS_CTS_TIMEOUT/1000);
893 while (!sio_lom_ready(ssp)) {
894 if (ddi_get_lbolt() > ssp->deadline)
897 (void) cv_reltimedwait(ssp->lo_cv, ssp->lo_mutex,
912 lombus_receive(ssp);
913 mutex_enter(ssp->hw_mutex);
914 while (p > ssp->cmdbuf)
915 sio_put_reg(ssp, SIO_TXD, *--p);
916 mutex_exit(ssp->hw_mutex);
924 ssp->deadline = start + drv_usectohz(LOMBUS_CMD_TIMEOUT/1000);
925 ssp->error = 0;
926 ssp->index = 0;
927 ssp->result = DUMMY_VALUE;
928 ssp->cmdstate = LOMBUS_CMDSTATE_WAITING;
929 while (ssp->cmdstate == LOMBUS_CMDSTATE_WAITING) {
930 if (cv_reltimedwait(ssp->lo_cv, ssp->lo_mutex,
932 lombus_receive(ssp);
938 val = ssp->result;
939 if (sio_faulty(ssp)) {
942 } else if (ssp->cmdstate != LOMBUS_CMDSTATE_READY) {
948 if (ssp->error != 0)
949 HANDLE_FAULT(hdlp) = ssp->error;
957 ssp->index = 0;
958 ssp->cmdstate = LOMBUS_CMDSTATE_IDLE;
959 cv_broadcast(ssp->lo_cv);
960 mutex_exit(ssp->lo_mutex);
1083 struct lombus_state *ssp;
1102 ssp = HANDLE_PRIVATE(hdlp);
1103 mutex_enter(ssp->hw_mutex);
1105 if ((now - ssp->hw_last_pat) >= LOMBUS_MIN_PAT) {
1106 lombus_toggle_rts(ssp);
1107 ssp->hw_last_pat = now;
1109 mutex_exit(ssp->hw_mutex);
1142 struct lombus_state *ssp;
1162 ssp = HANDLE_PRIVATE(hdlp);
1163 return (ssp->async);
1222 struct lombus_state *ssp;
1260 ssp = HANDLE_PRIVATE(hdlp);
1261 return (ssp->async);
1495 lombus_hw_reset(struct lombus_state *ssp)
1503 lombus_set_irq(ssp, B_FALSE);
1504 sio_put_reg(ssp, SIO_FCR, SIO_FCR_RXSR | SIO_FCR_TXSR);
1505 sio_put_reg(ssp, SIO_LCR, SIO_LCR_STD);
1513 if (ssp->baud < SIO_BAUD_MIN || ssp->baud > SIO_BAUD_MAX)
1516 divisor = SIO_BAUD_TO_DIVISOR(ssp->baud);
1529 sio_put_reg(ssp, SIO_BSR, SIO_BSR_BANK1);
1530 sio_put_reg(ssp, SIO_LBGDL, 0xff);
1531 sio_put_reg(ssp, SIO_LBGDH, divisor >> 8);
1532 sio_put_reg(ssp, SIO_LBGDL, divisor & 0xff);
1533 sio_put_reg(ssp, SIO_BSR, SIO_BSR_BANK0);
1538 sio_put_reg(ssp, SIO_MCR, SIO_MCR_STD);
1539 sio_put_reg(ssp, SIO_FCR, SIO_FCR_STD);
1548 lombus_offline(struct lombus_state *ssp)
1550 if (ssp->sio_handle != NULL)
1551 ddi_regs_map_free(&ssp->sio_handle);
1552 ssp->sio_handle = NULL;
1553 ssp->sio_regs = NULL;
1557 lombus_online(struct lombus_state *ssp)
1564 if (ddi_dev_nregs(ssp->dip, &nregs) != DDI_SUCCESS)
1573 err = ddi_regs_map_setup(ssp->dip, 0, &p, 0, 0,
1575 lombus_trace(ssp, 'O', "online",
1580 ssp->sio_handle = h;
1581 ssp->sio_regs = (void *)p;
1595 lombus_hw_reset(ssp);
1688 lombus_map_handle(struct lombus_state *ssp, ddi_map_op_t op,
1715 hdlp->ah_bus_private = ssp;
1728 lombus_map_handle(struct lombus_state *ssp, ddi_map_op_t op,
1817 hdlp->ah_bus_private = ssp;
1834 struct lombus_state *ssp;
1837 if ((ssp = lombus_getstate(dip, -1, "lombus_map")) == NULL)
1866 return (lombus_map_handle(ssp, mp->map_op,
1876 struct lombus_state *ssp;
1887 if ((ssp = lombus_getstate(dip, -1, "lombus_ctlops")) == NULL)
1911 lombus_trace(ssp, 'C', "initchild",
2008 lombus_unattach(struct lombus_state *ssp, int instance)
2010 if (ssp != NULL) {
2011 lombus_hw_reset(ssp);
2012 if (ssp->cycid != NULL) {
2013 ddi_periodic_delete(ssp->cycid);
2014 ssp->cycid = NULL;
2015 if (ssp->sio_handle != NULL)
2016 ddi_remove_intr(ssp->dip, 0, ssp->hw_iblk);
2017 ddi_remove_softintr(ssp->softid);
2018 cv_destroy(ssp->lo_cv);
2019 mutex_destroy(ssp->lo_mutex);
2020 mutex_destroy(ssp->hw_mutex);
2022 lombus_offline(ssp);
2023 ddi_set_driver_private(ssp->dip, NULL);
2037 struct lombus_state *ssp = NULL;
2055 if ((ssp = lombus_getstate(dip, instance, "lombus_attach")) == NULL)
2056 return (lombus_unattach(ssp, instance));
2057 ddi_set_driver_private(dip, ssp);
2062 ssp->dip = dip;
2063 ssp->majornum = ddi_driver_major(dip);
2064 ssp->instance = instance;
2069 ssp->allow_echo = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2071 ssp->baud = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2073 ssp->debug = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2075 ssp->fake_cts = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2081 ssp->cmdstate = LOMBUS_CMDSTATE_IDLE;
2082 ssp->hw_last_pat = gethrtime();
2083 ssp->cycid = NULL;
2088 err = lombus_online(ssp);
2090 return (lombus_unattach(ssp, instance));
2098 err = ddi_add_softintr(dip, DDI_SOFTINT_LOW, &ssp->softid,
2099 &ssp->lo_iblk, NULL, lombus_softint, (caddr_t)ssp);
2101 return (lombus_unattach(ssp, instance));
2103 if (ssp->sio_handle != NULL)
2104 err = ddi_add_intr(dip, 0, &ssp->hw_iblk, NULL,
2105 lombus_hi_intr, (caddr_t)ssp);
2107 mutex_init(ssp->hw_mutex, NULL, MUTEX_DRIVER, ssp->hw_iblk);
2108 mutex_init(ssp->lo_mutex, NULL, MUTEX_DRIVER, ssp->lo_iblk);
2109 cv_init(ssp->lo_cv, NULL, CV_DRIVER, NULL);
2114 ssp->cycid = ddi_periodic_add(lombus_cyclic, ssp, LOMBUS_ONE_SEC,
2122 return (lombus_unattach(ssp, instance));
2124 lombus_set_irq(ssp, B_TRUE);
2137 struct lombus_state *ssp;
2149 if ((ssp = lombus_getstate(dip, instance, "lombus_detach")) == NULL)
2152 (void) lombus_unattach(ssp, instance);
2159 struct lombus_state *ssp;
2163 if ((ssp = lombus_getstate(dip, -1, "lombus_reset")) == NULL)
2166 lombus_hw_reset(ssp);