Lines Matching +full:- +full:uart

1 // SPDX-License-Identifier: GPL-2.0
3 * Serial port driver for NXP LPC18xx/43xx UART
43 if (rs485->flags & SER_RS485_ENABLED) { in lpc18xx_rs485_config()
47 if (rs485->flags & SER_RS485_RTS_ON_SEND) in lpc18xx_rs485_config()
51 if (rs485->delay_rts_after_send) { in lpc18xx_rs485_config()
52 baud_clk = port->uartclk / up->dl_read(up); in lpc18xx_rs485_config()
53 rs485_dly_reg = DIV_ROUND_UP(rs485->delay_rts_after_send in lpc18xx_rs485_config()
60 rs485->delay_rts_after_send = (rs485_dly_reg * MSEC_PER_SEC) in lpc18xx_rs485_config()
80 offset = offset << p->regshift; in lpc18xx_uart_serial_out()
81 writel(value, p->membase + offset); in lpc18xx_uart_serial_out()
93 struct uart_8250_port uart; in lpc18xx_serial_probe() local
103 dev_err(&pdev->dev, "memory resource not found"); in lpc18xx_serial_probe()
104 return -EINVAL; in lpc18xx_serial_probe()
107 memset(&uart, 0, sizeof(uart)); in lpc18xx_serial_probe()
109 uart.port.membase = devm_ioremap(&pdev->dev, res->start, in lpc18xx_serial_probe()
111 if (!uart.port.membase) in lpc18xx_serial_probe()
112 return -ENOMEM; in lpc18xx_serial_probe()
114 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in lpc18xx_serial_probe()
116 return -ENOMEM; in lpc18xx_serial_probe()
118 data->clk_uart = devm_clk_get(&pdev->dev, "uartclk"); in lpc18xx_serial_probe()
119 if (IS_ERR(data->clk_uart)) { in lpc18xx_serial_probe()
120 dev_err(&pdev->dev, "uart clock not found\n"); in lpc18xx_serial_probe()
121 return PTR_ERR(data->clk_uart); in lpc18xx_serial_probe()
124 data->clk_reg = devm_clk_get(&pdev->dev, "reg"); in lpc18xx_serial_probe()
125 if (IS_ERR(data->clk_reg)) { in lpc18xx_serial_probe()
126 dev_err(&pdev->dev, "reg clock not found\n"); in lpc18xx_serial_probe()
127 return PTR_ERR(data->clk_reg); in lpc18xx_serial_probe()
130 ret = clk_prepare_enable(data->clk_reg); in lpc18xx_serial_probe()
132 dev_err(&pdev->dev, "unable to enable reg clock\n"); in lpc18xx_serial_probe()
136 ret = clk_prepare_enable(data->clk_uart); in lpc18xx_serial_probe()
138 dev_err(&pdev->dev, "unable to enable uart clock\n"); in lpc18xx_serial_probe()
142 ret = of_alias_get_id(pdev->dev.of_node, "serial"); in lpc18xx_serial_probe()
144 uart.port.line = ret; in lpc18xx_serial_probe()
146 data->dma.rx_param = data; in lpc18xx_serial_probe()
147 data->dma.tx_param = data; in lpc18xx_serial_probe()
149 spin_lock_init(&uart.port.lock); in lpc18xx_serial_probe()
150 uart.port.dev = &pdev->dev; in lpc18xx_serial_probe()
151 uart.port.irq = irq; in lpc18xx_serial_probe()
152 uart.port.iotype = UPIO_MEM32; in lpc18xx_serial_probe()
153 uart.port.mapbase = res->start; in lpc18xx_serial_probe()
154 uart.port.regshift = 2; in lpc18xx_serial_probe()
155 uart.port.type = PORT_16550A; in lpc18xx_serial_probe()
156 uart.port.flags = UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_SKIP_TEST; in lpc18xx_serial_probe()
157 uart.port.uartclk = clk_get_rate(data->clk_uart); in lpc18xx_serial_probe()
158 uart.port.private_data = data; in lpc18xx_serial_probe()
159 uart.port.rs485_config = lpc18xx_rs485_config; in lpc18xx_serial_probe()
160 uart.port.rs485_supported = lpc18xx_rs485_supported; in lpc18xx_serial_probe()
161 uart.port.serial_out = lpc18xx_uart_serial_out; in lpc18xx_serial_probe()
163 uart.dma = &data->dma; in lpc18xx_serial_probe()
164 uart.dma->rxconf.src_maxburst = 1; in lpc18xx_serial_probe()
165 uart.dma->txconf.dst_maxburst = 1; in lpc18xx_serial_probe()
167 ret = serial8250_register_8250_port(&uart); in lpc18xx_serial_probe()
169 dev_err(&pdev->dev, "unable to register 8250 port\n"); in lpc18xx_serial_probe()
173 data->line = ret; in lpc18xx_serial_probe()
179 clk_disable_unprepare(data->clk_uart); in lpc18xx_serial_probe()
181 clk_disable_unprepare(data->clk_reg); in lpc18xx_serial_probe()
189 serial8250_unregister_port(data->line); in lpc18xx_serial_remove()
190 clk_disable_unprepare(data->clk_uart); in lpc18xx_serial_remove()
191 clk_disable_unprepare(data->clk_reg); in lpc18xx_serial_remove()
197 { .compatible = "nxp,lpc1850-uart" },
206 .name = "lpc18xx-uart",