1/*- 2 * cyclades cyclom-y serial driver 3 * Andrew Herbert <andrew@werple.apana.org.au>, 17 August 1993 4 * 5 * Copyright (c) 1993 Andrew Herbert. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 13 unchanged lines hidden (view full) --- 22 * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * |
30 * $FreeBSD: head/sys/dev/cy/cy_isa.c 51654 1999-09-25 16:21:39Z phk $ |
31 */ 32 33#include "opt_compat.h" 34#include "cy.h" 35 36/* 37 * TODO: 38 * Atomic COR change. --- 79 unchanged lines hidden (view full) --- 118#define comparam cyparam 119#define comspeed cyspeed 120#define comstart cystart 121#define comwakeup cywakeup 122#define nsio_tty ncy_tty 123#define p_com_addr p_cy_addr 124#define sioattach cyattach 125#define sioclose cyclose |
126#define siodriver cydriver 127#define siodtrwakeup cydtrwakeup 128#define sioinput cyinput 129#define siointr cyintr 130#define siointr1 cyintr1 131#define sioioctl cyioctl 132#define sioopen cyopen 133#define siopoll cypoll 134#define sioprobe cyprobe 135#define sioread cyread 136#define siosettimeout cysettimeout 137#define siosetwater cysetwater |
138#define comstop cystop |
139#define siowrite cywrite 140#define sio_registered cy_registered 141#define sio_timeout cy_timeout 142#define sio_timeout_handle cy_timeout_handle 143#define sio_timeouts_until_log cy_timeouts_until_log 144#define sio_tty cy_tty 145 146#define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s) --- 26 unchanged lines hidden (view full) --- 173/* 174 * com state bits. 175 * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher 176 * than the other bits so that they can be tested as a group without masking 177 * off the low bits. 178 * 179 * The following com and tty flags correspond closely: 180 * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and |
181 * comstop()) |
182 * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart()) 183 * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) 184 * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) 185 * TS_FLUSH is not used. 186 * XXX I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON. 187 * XXX CS_*FLOW should be CF_*FLOW in com->flags (control flags not state). 188 */ 189#define CS_BUSY 0x80 /* output in progress */ --- 151 unchanged lines hidden (view full) --- 341static int comparam __P((struct tty *tp, struct termios *t)); 342static swihand_t siopoll; 343static int sioprobe __P((struct isa_device *dev)); 344static void siosettimeout __P((void)); 345static int siosetwater __P((struct com_s *com, speed_t speed)); 346static int comspeed __P((speed_t speed, u_long cy_clock, 347 int *prescaler_io)); 348static void comstart __P((struct tty *tp)); |
349static void comstop __P((struct tty *tp, int rw)); |
350static timeout_t comwakeup; 351static void disc_optim __P((struct tty *tp, struct termios *t, 352 struct com_s *com)); 353 354#ifdef CyDebug 355void cystatus __P((int unit)); 356#endif 357 --- 7 unchanged lines hidden (view full) --- 365 sioprobe, sioattach, driver_name 366}; 367 368static d_open_t sioopen; 369static d_close_t sioclose; 370static d_read_t sioread; 371static d_write_t siowrite; 372static d_ioctl_t sioioctl; |
373 374#define CDEV_MAJOR 48 375static struct cdevsw sio_cdevsw = { 376 /* open */ sioopen, 377 /* close */ sioclose, 378 /* read */ sioread, 379 /* write */ siowrite, 380 /* ioctl */ sioioctl, |
381 /* stop */ nostop, |
382 /* reset */ noreset, |
383 /* devtotty */ nodevtotty, 384 /* poll */ ttypoll, |
385 /* mmap */ nommap, 386 /* strategy */ nostrategy, 387 /* name */ driver_name, 388 /* parms */ noparms, 389 /* maj */ CDEV_MAJOR, 390 /* dump */ nodump, 391 /* psize */ nopsize, 392 /* flags */ D_TTY, --- 274 unchanged lines hidden (view full) --- 667 return (ENXIO); 668 if (mynor & CONTROL_MASK) 669 return (0); 670#if 0 /* XXX */ 671 tp = com->tp = sio_tty[unit] = ttymalloc(sio_tty[unit]); 672#else 673 tp = com->tp = &sio_tty[unit]; 674#endif |
675 dev->si_tty = tp; |
676 s = spltty(); 677 /* 678 * We jump to this label after all non-interrupted sleeps to pick 679 * up any changes of the device state. 680 */ 681open_top: 682 while (com->state & CS_DTR_OFF) { 683 error = tsleep(&com->dtr_wait, TTIPRI | PCATCH, "cydtr", 0); --- 31 unchanged lines hidden (view full) --- 715 } else { 716 /* 717 * The device isn't open, so there are no conflicts. 718 * Initialize it. Initialization is done twice in many 719 * cases: to preempt sleeping callin opens if we are 720 * callout, and to complete a callin open after DCD rises. 721 */ 722 tp->t_oproc = comstart; |
723 tp->t_stop = comstop; |
724 tp->t_param = comparam; 725 tp->t_dev = dev; 726 tp->t_termios = mynor & CALLOUT_MASK 727 ? com->it_out : com->it_in; 728 729 /* Encode per-board unit in LIVR for access in intr routines. */ 730 cd_setreg(com, CD1400_LIVR, 731 (unit & CD1400_xIVR_CHAN) << CD1400_xIVR_CHAN_SHIFT); --- 116 unchanged lines hidden (view full) --- 848 if (mynor & CONTROL_MASK) 849 return (0); 850 com = com_addr(MINOR_TO_UNIT(mynor)); 851 tp = com->tp; 852 s = spltty(); 853 cd_etc(com, CD1400_ETC_STOPBREAK); 854 (*linesw[tp->t_line].l_close)(tp, flag); 855 disc_optim(tp, &tp->t_termios, com); |
856 comstop(tp, FREAD | FWRITE); |
857 comhardclose(com); 858 ttyclose(tp); 859 siosettimeout(); 860 splx(s); 861#ifdef broken /* session holds a ref to the tty; can't deallocate */ 862 ttyfree(tp); 863 com->tp = sio_tty[unit] = NULL; 864#endif --- 1544 unchanged lines hidden (view full) --- 2409 siointr1(com); /* fake interrupt to start output */ 2410 enable_intr(); 2411#endif 2412 ttwwakeup(tp); 2413 splx(s); 2414} 2415 2416static void |
2417comstop(tp, rw) |
2418 struct tty *tp; 2419 int rw; 2420{ 2421 struct com_s *com; 2422 bool_t wakeup_etc; 2423 2424 com = com_addr(DEV_TO_UNIT(tp->t_dev)); 2425 wakeup_etc = FALSE; --- 23 unchanged lines hidden (view full) --- 2449 enable_intr(); 2450 if (wakeup_etc) 2451 wakeup(&com->etc); 2452 if (rw & FWRITE && com->etc == ETC_NONE) 2453 cd1400_channel_cmd(com, CD1400_CCR_CMDRESET | CD1400_CCR_FTF); 2454 comstart(tp); 2455} 2456 |
2457static int 2458commctl(com, bits, how) 2459 struct com_s *com; 2460 int bits; 2461 int how; 2462{ 2463 int mcr; 2464 int msr; --- 444 unchanged lines hidden --- |