Lines Matching defs:ourport
158 static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport);
246 struct s3c24xx_uart_port *ourport = to_ourport(port);
264 ourport->rx_enabled = 1;
270 struct s3c24xx_uart_port *ourport = to_ourport(port);
280 ourport->rx_enabled = 0;
286 struct s3c24xx_uart_port *ourport = to_ourport(port);
287 struct s3c24xx_uart_dma *dma = ourport->dma;
291 if (!ourport->tx_enabled)
294 switch (ourport->info->type) {
302 disable_irq_nosync(ourport->tx_irq);
306 if (dma && dma->tx_chan && ourport->tx_in_progress == S3C24XX_TX_DMA) {
318 ourport->tx_enabled = 0;
319 ourport->tx_in_progress = 0;
324 ourport->tx_mode = 0;
327 static void s3c24xx_serial_start_next_tx(struct s3c24xx_uart_port *ourport);
331 struct s3c24xx_uart_port *ourport = args;
332 struct uart_port *port = &ourport->port;
334 struct s3c24xx_uart_dma *dma = ourport->dma;
350 ourport->tx_in_progress = 0;
355 s3c24xx_serial_start_next_tx(ourport);
359 static void enable_tx_dma(struct s3c24xx_uart_port *ourport)
361 const struct uart_port *port = &ourport->port;
365 switch (ourport->info->type) {
373 disable_irq_nosync(ourport->tx_irq);
384 ourport->tx_mode = S3C24XX_TX_DMA;
387 static void enable_tx_pio(struct s3c24xx_uart_port *ourport)
389 const struct uart_port *port = &ourport->port;
393 ourport->tx_in_progress = S3C24XX_TX_PIO;
404 switch (ourport->info->type) {
414 enable_irq(ourport->tx_irq);
418 ourport->tx_mode = S3C24XX_TX_PIO;
424 if (ourport->info->type == TYPE_APPLE_S5L)
425 s3c24xx_serial_tx_chars(ourport);
428 static void s3c24xx_serial_start_tx_pio(struct s3c24xx_uart_port *ourport)
430 if (ourport->tx_mode != S3C24XX_TX_PIO)
431 enable_tx_pio(ourport);
434 static int s3c24xx_serial_start_tx_dma(struct s3c24xx_uart_port *ourport,
437 struct uart_port *port = &ourport->port;
439 struct s3c24xx_uart_dma *dma = ourport->dma;
441 if (ourport->tx_mode != S3C24XX_TX_DMA)
442 enable_tx_dma(ourport);
455 dev_err(ourport->port.dev, "Unable to get desc for Tx\n");
460 dma->tx_desc->callback_param = ourport;
463 ourport->tx_in_progress = S3C24XX_TX_DMA;
469 static void s3c24xx_serial_start_next_tx(struct s3c24xx_uart_port *ourport)
471 struct uart_port *port = &ourport->port;
483 if (!ourport->dma || !ourport->dma->tx_chan ||
484 count < ourport->min_dma_size ||
486 s3c24xx_serial_start_tx_pio(ourport);
488 s3c24xx_serial_start_tx_dma(ourport, count);
493 struct s3c24xx_uart_port *ourport = to_ourport(port);
496 if (!ourport->tx_enabled) {
500 ourport->tx_enabled = 1;
501 if (!ourport->dma || !ourport->dma->tx_chan)
502 s3c24xx_serial_start_tx_pio(ourport);
505 if (ourport->dma && ourport->dma->tx_chan) {
506 if (!uart_circ_empty(xmit) && !ourport->tx_in_progress)
507 s3c24xx_serial_start_next_tx(ourport);
511 static void s3c24xx_uart_copy_rx_to_tty(struct s3c24xx_uart_port *ourport,
514 struct s3c24xx_uart_dma *dma = ourport->dma;
523 ourport->port.icount.rx += count;
525 dev_err(ourport->port.dev, "No tty port\n");
529 ((unsigned char *)(ourport->dma->rx_buf)), count);
532 dev_err(ourport->port.dev, "RxData copy to tty layer failed\n");
538 struct s3c24xx_uart_port *ourport = to_ourport(port);
539 struct s3c24xx_uart_dma *dma = ourport->dma;
545 if (ourport->rx_enabled) {
547 switch (ourport->info->type) {
557 disable_irq_nosync(ourport->rx_irq);
560 ourport->rx_enabled = 0;
570 s3c24xx_uart_copy_rx_to_tty(ourport, t, received);
584 const struct s3c24xx_uart_port *ourport;
589 ourport = container_of(port, struct s3c24xx_uart_port, port);
590 return ourport->cfg;
593 static int s3c24xx_serial_rx_fifocnt(const struct s3c24xx_uart_port *ourport,
596 const struct s3c24xx_uart_info *info = ourport->info;
599 return ourport->port.fifosize;
604 static void s3c64xx_start_rx_dma(struct s3c24xx_uart_port *ourport);
607 struct s3c24xx_uart_port *ourport = args;
608 struct uart_port *port = &ourport->port;
610 struct s3c24xx_uart_dma *dma = ourport->dma;
612 struct tty_struct *tty = tty_port_tty_get(&ourport->port.state->port);
625 s3c24xx_uart_copy_rx_to_tty(ourport, t, received);
632 s3c64xx_start_rx_dma(ourport);
637 static void s3c64xx_start_rx_dma(struct s3c24xx_uart_port *ourport)
639 struct s3c24xx_uart_dma *dma = ourport->dma;
648 dev_err(ourport->port.dev, "Unable to get desc for Rx\n");
653 dma->rx_desc->callback_param = ourport;
663 static void enable_rx_dma(struct s3c24xx_uart_port *ourport)
665 struct uart_port *port = &ourport->port;
683 ourport->rx_mode = S3C24XX_RX_DMA;
686 static void enable_rx_pio(struct s3c24xx_uart_port *ourport)
688 struct uart_port *port = &ourport->port;
697 if (ourport->info->type != TYPE_APPLE_S5L) {
707 ourport->rx_mode = S3C24XX_RX_PIO;
710 static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport);
715 struct s3c24xx_uart_port *ourport = dev_id;
716 struct uart_port *port = &ourport->port;
717 struct s3c24xx_uart_dma *dma = ourport->dma;
718 struct tty_struct *tty = tty_port_tty_get(&ourport->port.state->port);
728 s3c64xx_start_rx_dma(ourport);
729 if (ourport->rx_mode == S3C24XX_RX_PIO)
730 enable_rx_dma(ourport);
734 if (ourport->rx_mode == S3C24XX_RX_DMA) {
739 s3c24xx_uart_copy_rx_to_tty(ourport, t, received);
741 enable_rx_pio(ourport);
744 s3c24xx_serial_rx_drain_fifo(ourport);
759 static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport)
761 struct uart_port *port = &ourport->port;
774 fifocnt = s3c24xx_serial_rx_fifocnt(ourport, ufstat);
786 if (ourport->rx_enabled) {
788 ourport->rx_enabled = 0;
796 ourport->rx_enabled = 1;
849 struct s3c24xx_uart_port *ourport = dev_id;
850 struct uart_port *port = &ourport->port;
853 s3c24xx_serial_rx_drain_fifo(ourport);
861 struct s3c24xx_uart_port *ourport = dev_id;
863 if (ourport->dma && ourport->dma->rx_chan)
868 static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport)
870 struct uart_port *port = &ourport->port;
876 if (ourport->dma && ourport->dma->tx_chan &&
877 count >= ourport->min_dma_size) {
880 if (count - align >= ourport->min_dma_size) {
910 if (rd_regl(port, S3C2410_UFSTAT) & ourport->info->tx_fifofull)
919 s3c24xx_serial_start_tx_dma(ourport, dma_count);
932 struct s3c24xx_uart_port *ourport = id;
933 struct uart_port *port = &ourport->port;
937 s3c24xx_serial_tx_chars(ourport);
946 const struct s3c24xx_uart_port *ourport = id;
947 const struct uart_port *port = &ourport->port;
965 const struct s3c24xx_uart_port *ourport = id;
966 const struct uart_port *port = &ourport->port;
1170 struct s3c24xx_uart_port *ourport = to_ourport(port);
1172 if (ourport->tx_claimed) {
1173 free_irq(ourport->tx_irq, ourport);
1174 ourport->tx_enabled = 0;
1175 ourport->tx_claimed = 0;
1176 ourport->tx_mode = 0;
1179 if (ourport->rx_claimed) {
1180 free_irq(ourport->rx_irq, ourport);
1181 ourport->rx_claimed = 0;
1182 ourport->rx_enabled = 0;
1185 if (ourport->dma)
1186 s3c24xx_serial_release_dma(ourport);
1188 ourport->tx_in_progress = 0;
1193 struct s3c24xx_uart_port *ourport = to_ourport(port);
1195 ourport->tx_enabled = 0;
1196 ourport->tx_mode = 0;
1197 ourport->rx_enabled = 0;
1199 free_irq(port->irq, ourport);
1204 if (ourport->dma)
1205 s3c24xx_serial_release_dma(ourport);
1207 ourport->tx_in_progress = 0;
1212 struct s3c24xx_uart_port *ourport = to_ourport(port);
1224 free_irq(port->irq, ourport);
1226 ourport->tx_enabled = 0;
1227 ourport->tx_mode = 0;
1228 ourport->rx_enabled = 0;
1230 if (ourport->dma)
1231 s3c24xx_serial_release_dma(ourport);
1233 ourport->tx_in_progress = 0;
1238 struct s3c24xx_uart_port *ourport = to_ourport(port);
1241 ourport->rx_enabled = 1;
1243 ret = request_irq(ourport->rx_irq, s3c24xx_serial_rx_irq, 0,
1244 s3c24xx_serial_portname(port), ourport);
1247 dev_err(port->dev, "cannot get irq %d\n", ourport->rx_irq);
1251 ourport->rx_claimed = 1;
1255 ourport->tx_enabled = 1;
1257 ret = request_irq(ourport->tx_irq, s3c24xx_serial_tx_irq, 0,
1258 s3c24xx_serial_portname(port), ourport);
1261 dev_err(port->dev, "cannot get irq %d\n", ourport->tx_irq);
1265 ourport->tx_claimed = 1;
1280 struct s3c24xx_uart_port *ourport = to_ourport(port);
1286 if (ourport->dma) {
1287 ret = s3c24xx_serial_request_dma(ourport);
1289 devm_kfree(port->dev, ourport->dma);
1290 ourport->dma = NULL;
1295 s3c24xx_serial_portname(port), ourport);
1302 ourport->rx_enabled = 1;
1303 ourport->tx_enabled = 0;
1313 enable_rx_pio(ourport);
1325 struct s3c24xx_uart_port *ourport = to_ourport(port);
1333 s3c24xx_serial_portname(port), ourport);
1340 ourport->rx_enabled = 1;
1341 ourport->tx_enabled = 0;
1351 enable_rx_pio(ourport);
1367 struct s3c24xx_uart_port *ourport = to_ourport(port);
1370 ourport->pm_level = level;
1377 if (!IS_ERR(ourport->baudclk))
1378 clk_disable_unprepare(ourport->baudclk);
1380 clk_disable_unprepare(ourport->clk);
1384 clk_prepare_enable(ourport->clk);
1386 if (!IS_ERR(ourport->baudclk))
1387 clk_prepare_enable(ourport->baudclk);
1440 static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport,
1444 const struct s3c24xx_uart_info *info = ourport->info;
1453 if (ourport->cfg->clk_sel &&
1454 !(ourport->cfg->clk_sel & (1 << cnt)))
1458 clk = clk_get(ourport->port.dev, clkname);
1464 dev_err(ourport->port.dev,
1470 if (ourport->info->has_divslot) {
1539 struct s3c24xx_uart_port *ourport = to_ourport(port);
1558 quot = s3c24xx_serial_getclk(ourport, baud, &clk, &clk_sel);
1566 if (ourport->baudclk != clk) {
1571 if (!IS_ERR(ourport->baudclk)) {
1572 clk_disable_unprepare(ourport->baudclk);
1573 ourport->baudclk = ERR_PTR(-EINVAL);
1576 ourport->baudclk = clk;
1577 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0;
1580 if (ourport->info->has_divslot) {
1581 unsigned int div = ourport->baudclk_rate / baud;
1650 if (ourport->info->has_divslot)
1691 const struct s3c24xx_uart_port *ourport = to_ourport(port);
1693 switch (ourport->info->type) {
1865 static int s3c24xx_serial_enable_baudclk(struct s3c24xx_uart_port *ourport)
1867 struct device *dev = ourport->port.dev;
1868 const struct s3c24xx_uart_info *info = ourport->info;
1875 clk_sel = ourport->cfg->clk_sel ? : info->def_clk_sel;
1891 ourport->baudclk = clk;
1892 ourport->baudclk_rate = clk_get_rate(clk);
1893 s3c24xx_serial_setsource(&ourport->port, clk_num);
1906 static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1909 struct uart_port *port = &ourport->port;
1910 const struct s3c2410_uartcfg *cfg = ourport->cfg;
1952 ourport->rx_irq = ret;
1953 ourport->tx_irq = ret + 1;
1956 switch (ourport->info->type) {
1960 ourport->tx_irq = ret;
1972 ourport->dma = devm_kzalloc(port->dev,
1973 sizeof(*ourport->dma),
1975 if (!ourport->dma) {
1981 ourport->clk = clk_get(&platdev->dev, "uart");
1982 if (IS_ERR(ourport->clk)) {
1985 ret = PTR_ERR(ourport->clk);
1989 ret = clk_prepare_enable(ourport->clk);
1992 clk_put(ourport->clk);
1996 ret = s3c24xx_serial_enable_baudclk(ourport);
2001 switch (ourport->info->type) {
2025 ourport->rx_irq, ourport->tx_irq, port->uartclk);
2054 struct s3c24xx_uart_port *ourport;
2068 ourport = &s3c24xx_serial_ports[index];
2072 ourport->drv_data = s3c24xx_get_driver_data(pdev);
2073 if (!ourport->drv_data) {
2078 ourport->baudclk = ERR_PTR(-EINVAL);
2079 ourport->info = &ourport->drv_data->info;
2080 ourport->cfg = (dev_get_platdata(&pdev->dev)) ?
2082 &ourport->drv_data->def_cfg;
2084 switch (ourport->info->type) {
2086 ourport->port.ops = &s3c24xx_serial_ops;
2089 ourport->port.ops = &s3c64xx_serial_ops;
2092 ourport->port.ops = &apple_s5l_serial_ops;
2098 "samsung,uart-fifosize", &ourport->port.fifosize);
2103 ourport->port.iotype = UPIO_MEM;
2106 ourport->port.iotype = UPIO_MEM32;
2116 if (ourport->drv_data->fifosize[index])
2117 ourport->port.fifosize = ourport->drv_data->fifosize[index];
2118 else if (ourport->info->fifosize)
2119 ourport->port.fifosize = ourport->info->fifosize;
2120 ourport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SAMSUNG_CONSOLE);
2126 ourport->min_dma_size = max_t(int, ourport->port.fifosize,
2129 dev_dbg(&pdev->dev, "%s: initialising port %p...\n", __func__, ourport);
2131 ret = s3c24xx_serial_init_port(ourport, pdev);
2144 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
2145 platform_set_drvdata(pdev, &ourport->port);
2152 clk_disable_unprepare(ourport->clk);
2153 if (!IS_ERR(ourport->baudclk))
2154 clk_disable_unprepare(ourport->baudclk);
2189 struct s3c24xx_uart_port *ourport = to_ourport(port);
2192 clk_prepare_enable(ourport->clk);
2193 if (!IS_ERR(ourport->baudclk))
2194 clk_prepare_enable(ourport->baudclk);
2196 if (!IS_ERR(ourport->baudclk))
2197 clk_disable_unprepare(ourport->baudclk);
2198 clk_disable_unprepare(ourport->clk);
2209 struct s3c24xx_uart_port *ourport = to_ourport(port);
2213 switch (ourport->info->type) {
2217 if (ourport->tx_enabled)
2219 if (ourport->rx_enabled)
2221 clk_prepare_enable(ourport->clk);
2222 if (!IS_ERR(ourport->baudclk))
2223 clk_prepare_enable(ourport->baudclk);
2225 if (!IS_ERR(ourport->baudclk))
2226 clk_disable_unprepare(ourport->baudclk);
2227 clk_disable_unprepare(ourport->clk);
2234 ret = clk_prepare_enable(ourport->clk);
2239 if (!IS_ERR(ourport->baudclk)) {
2240 ret = clk_prepare_enable(ourport->baudclk);
2243 clk_disable_unprepare(ourport->clk);
2254 if (ourport->tx_enabled)
2256 if (ourport->rx_enabled)
2262 if (!IS_ERR(ourport->baudclk))
2263 clk_disable_unprepare(ourport->baudclk);
2264 clk_disable_unprepare(ourport->clk);
2326 const struct s3c24xx_uart_port *ourport = to_ourport(port);
2330 if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0)