Lines Matching defs:uap
108 struct uart_amba_port *uap = (struct uart_amba_port *)port;
110 uap->im &= ~UART011_TXIM;
111 writew(uap->im, uap->port.membase + UART011_IMSC);
116 struct uart_amba_port *uap = (struct uart_amba_port *)port;
118 uap->im |= UART011_TXIM;
119 writew(uap->im, uap->port.membase + UART011_IMSC);
124 struct uart_amba_port *uap = (struct uart_amba_port *)port;
126 uap->im &= ~(UART011_RXIM|UART011_RTIM|UART011_FEIM|
128 writew(uap->im, uap->port.membase + UART011_IMSC);
133 struct uart_amba_port *uap = (struct uart_amba_port *)port;
135 uap->im |= UART011_RIMIM|UART011_CTSMIM|UART011_DCDMIM|UART011_DSRMIM;
136 writew(uap->im, uap->port.membase + UART011_IMSC);
139 static void pl011_rx_chars(struct uart_amba_port *uap)
141 struct tty_struct *tty = uap->port.state->port.tty;
144 status = readw(uap->port.membase + UART01x_FR);
146 ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX;
148 uap->port.icount.rx++;
157 uap->port.icount.brk++;
158 if (uart_handle_break(&uap->port))
161 uap->port.icount.parity++;
163 uap->port.icount.frame++;
165 uap->port.icount.overrun++;
167 ch &= uap->port.read_status_mask;
177 if (uart_handle_sysrq_char(&uap->port, ch & 255))
180 uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
183 status = readw(uap->port.membase + UART01x_FR);
185 spin_unlock(&uap->port.lock);
187 spin_lock(&uap->port.lock);
190 static void pl011_tx_chars(struct uart_amba_port *uap)
192 struct circ_buf *xmit = &uap->port.state->xmit;
195 if (uap->port.x_char) {
196 writew(uap->port.x_char, uap->port.membase + UART01x_DR);
197 uap->port.icount.tx++;
198 uap->port.x_char = 0;
201 if (uart_circ_empty(xmit) || uart_tx_stopped(&uap->port)) {
202 pl011_stop_tx(&uap->port);
206 count = uap->port.fifosize >> 1;
208 writew(xmit->buf[xmit->tail], uap->port.membase + UART01x_DR);
210 uap->port.icount.tx++;
216 uart_write_wakeup(&uap->port);
219 pl011_stop_tx(&uap->port);
222 static void pl011_modem_status(struct uart_amba_port *uap)
226 status = readw(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
228 delta = status ^ uap->old_status;
229 uap->old_status = status;
235 uart_handle_dcd_change(&uap->port, status & UART01x_FR_DCD);
238 uap->port.icount.dsr++;
241 uart_handle_cts_change(&uap->port, status & UART01x_FR_CTS);
243 wake_up_interruptible(&uap->port.state->port.delta_msr_wait);
248 struct uart_amba_port *uap = dev_id;
252 spin_lock(&uap->port.lock);
254 status = readw(uap->port.membase + UART011_MIS);
259 uap->port.membase + UART011_ICR);
262 pl011_rx_chars(uap);
265 pl011_modem_status(uap);
267 pl011_tx_chars(uap);
272 status = readw(uap->port.membase + UART011_MIS);
277 spin_unlock(&uap->port.lock);
284 struct uart_amba_port *uap = (struct uart_amba_port *)port;
285 unsigned int status = readw(uap->port.membase + UART01x_FR);
291 struct uart_amba_port *uap = (struct uart_amba_port *)port;
293 unsigned int status = readw(uap->port.membase + UART01x_FR);
309 struct uart_amba_port *uap = (struct uart_amba_port *)port;
312 cr = readw(uap->port.membase + UART011_CR);
326 if (uap->autorts) {
332 writew(cr, uap->port.membase + UART011_CR);
337 struct uart_amba_port *uap = (struct uart_amba_port *)port;
341 spin_lock_irqsave(&uap->port.lock, flags);
342 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
347 writew(lcr_h, uap->port.membase + uap->lcrh_tx);
348 spin_unlock_irqrestore(&uap->port.lock, flags);
354 struct uart_amba_port *uap = (struct uart_amba_port *)port;
357 status = readw(uap->port.membase + UART01x_FR);
361 return readw(uap->port.membase + UART01x_DR);
367 struct uart_amba_port *uap = (struct uart_amba_port *)port;
369 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
372 writew(ch, uap->port.membase + UART01x_DR);
379 struct uart_amba_port *uap = (struct uart_amba_port *)port;
386 retval = clk_enable(uap->clk);
390 uap->port.uartclk = clk_get_rate(uap->clk);
395 retval = request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
399 writew(uap->ifls, uap->port.membase + UART011_IFLS);
405 writew(cr, uap->port.membase + UART011_CR);
406 writew(0, uap->port.membase + UART011_FBRD);
407 writew(1, uap->port.membase + UART011_IBRD);
408 writew(0, uap->port.membase + uap->lcrh_rx);
409 if (uap->lcrh_tx != uap->lcrh_rx) {
416 writew(0xff, uap->port.membase + UART011_MIS);
417 writew(0, uap->port.membase + uap->lcrh_tx);
419 writew(0, uap->port.membase + UART01x_DR);
420 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
424 writew(cr, uap->port.membase + UART011_CR);
429 uap->old_status = readw(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
434 spin_lock_irq(&uap->port.lock);
435 uap->im = UART011_RXIM | UART011_RTIM;
436 writew(uap->im, uap->port.membase + UART011_IMSC);
437 spin_unlock_irq(&uap->port.lock);
442 clk_disable(uap->clk);
447 static void pl011_shutdown_channel(struct uart_amba_port *uap,
452 val = readw(uap->port.membase + lcrh);
454 writew(val, uap->port.membase + lcrh);
459 struct uart_amba_port *uap = (struct uart_amba_port *)port;
464 spin_lock_irq(&uap->port.lock);
465 uap->im = 0;
466 writew(uap->im, uap->port.membase + UART011_IMSC);
467 writew(0xffff, uap->port.membase + UART011_ICR);
468 spin_unlock_irq(&uap->port.lock);
473 free_irq(uap->port.irq, uap);
478 uap->autorts = false;
479 writew(UART01x_CR_UARTEN | UART011_CR_TXE, uap->port.membase + UART011_CR);
484 pl011_shutdown_channel(uap, uap->lcrh_rx);
485 if (uap->lcrh_rx != uap->lcrh_tx)
486 pl011_shutdown_channel(uap, uap->lcrh_tx);
491 clk_disable(uap->clk);
498 struct uart_amba_port *uap = (struct uart_amba_port *)port;
507 port->uartclk/(uap->oversampling ? 8 : 16));
585 uap->autorts = true;
588 uap->autorts = false;
591 if (uap->oversampling) {
607 writew(lcr_h, port->membase + uap->lcrh_rx);
608 if (uap->lcrh_rx != uap->lcrh_tx) {
615 writew(0xff, uap->port.membase + UART011_MIS);
616 writew(lcr_h, port->membase + uap->lcrh_tx);
700 struct uart_amba_port *uap = (struct uart_amba_port *)port;
702 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
704 writew(ch, uap->port.membase + UART01x_DR);
710 struct uart_amba_port *uap = amba_ports[co->index];
713 clk_enable(uap->clk);
718 old_cr = readw(uap->port.membase + UART011_CR);
721 writew(new_cr, uap->port.membase + UART011_CR);
723 uart_console_write(&uap->port, s, count, pl011_console_putchar);
730 status = readw(uap->port.membase + UART01x_FR);
732 writew(old_cr, uap->port.membase + UART011_CR);
734 clk_disable(uap->clk);
738 pl011_console_get_options(struct uart_amba_port *uap, int *baud,
741 if (readw(uap->port.membase + UART011_CR) & UART01x_CR_UARTEN) {
744 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
759 ibrd = readw(uap->port.membase + UART011_IBRD);
760 fbrd = readw(uap->port.membase + UART011_FBRD);
762 *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd);
764 if (uap->oversampling) {
765 if (readw(uap->port.membase + UART011_CR)
774 struct uart_amba_port *uap;
787 uap = amba_ports[co->index];
788 if (!uap)
791 uap->port.uartclk = clk_get_rate(uap->clk);
796 pl011_console_get_options(uap, &baud, &parity, &bits);
798 return uart_set_options(&uap->port, co, baud, parity, bits, flow);
829 struct uart_amba_port *uap;
843 uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
844 if (uap == NULL) {
855 uap->clk = clk_get(&dev->dev, NULL);
856 if (IS_ERR(uap->clk)) {
857 ret = PTR_ERR(uap->clk);
861 uap->ifls = vendor->ifls;
862 uap->lcrh_rx = vendor->lcrh_rx;
863 uap->lcrh_tx = vendor->lcrh_tx;
864 uap->oversampling = vendor->oversampling;
865 uap->port.dev = &dev->dev;
866 uap->port.mapbase = dev->res.start;
867 uap->port.membase = base;
868 uap->port.iotype = UPIO_MEM;
869 uap->port.irq = dev->irq[0];
870 uap->port.fifosize = vendor->fifosize;
871 uap->port.ops = &amba_pl011_pops;
872 uap->port.flags = UPF_BOOT_AUTOCONF;
873 uap->port.line = i;
875 amba_ports[i] = uap;
877 amba_set_drvdata(dev, uap);
878 ret = uart_add_one_port(&amba_reg, &uap->port);
882 clk_put(uap->clk);
886 kfree(uap);
894 struct uart_amba_port *uap = amba_get_drvdata(dev);
899 uart_remove_one_port(&amba_reg, &uap->port);
902 if (amba_ports[i] == uap)
905 iounmap(uap->port.membase);
906 clk_put(uap->clk);
907 kfree(uap);
914 struct uart_amba_port *uap = amba_get_drvdata(dev);
916 if (!uap)
919 return uart_suspend_port(&amba_reg, &uap->port);
924 struct uart_amba_port *uap = amba_get_drvdata(dev);
926 if (!uap)
929 return uart_resume_port(&amba_reg, &uap->port);