VCOM Linux Driver
Advantech Inc.
Loading...
Searching...
No Matches
adv_uart_init.h
Go to the documentation of this file.
1#ifndef _ADV_UART_INIT_H
2#define _ADV_UART_INIT_H
3#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,5,0)
4//@ current
5#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)
6int adv_uart_init(struct adv_vcom * vcomdata, int index)
7{
8 int ret;
9 struct adv_uart_port * adv_serial_port;
10
11// printk("%s(%d)\n", __func__, __LINE__);
12// adv_serial_port = &adv_serial_ports[index];
13 adv_serial_port = kmalloc(sizeof(struct adv_uart_port), GFP_KERNEL);
14
15 memset(adv_serial_port, 0, sizeof(struct adv_uart_port));
16
17 spin_lock_init(&adv_serial_port->port.lock);
18
19 adv_serial_port->port.flags = UPF_SKIP_TEST|UPF_HARD_FLOW|UPF_SOFT_FLOW;
20 adv_serial_port->port.type = PORT_16850;
21 adv_serial_port->port.ops = &adv_uart_ops;
22 adv_serial_port->port.line = index;
23 adv_serial_port->port.fifosize = 2048;
24// these values are set in set_termios, don't need to set here
25// otherwise, we would need to make adv_uart_ops global, which we really don't want.
26// adv_serial_port->port.status |= (UPSTAT_AUTOCTS|UPSTAT_AUTORTS|UPSTAT_AUTOXOFF);
27
28 ret = uart_add_one_port(&adv_uart_driver, &adv_serial_port->port);
29
30 vcomdata->adv_uart = (struct uart_port *)adv_serial_port;
31 adv_serial_port->attr = &vcomdata->attr;
32 adv_serial_port->tx = &vcomdata->rx;
33 adv_serial_port->rx = &vcomdata->tx;
34
35 INIT_LIST_HEAD(&adv_serial_port->list);
36 list_add(&adv_serial_port->list, &uart_list);
37
38 return ret;
39}
40#else
41int adv_uart_init(struct adv_vcom * vcomdata, int index);
42#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)
43
44#endif //_ADV_UART_INIT_H
int adv_uart_init(struct adv_vcom *vcomdata, int index)
Definition adv_uart.c:618
Definition adv_uart.h:3
struct list_head list
Definition adv_uart.h:8
struct ring_buf * rx
Definition adv_uart.h:6
struct uart_port port
Definition adv_uart.h:4
struct ring_buf * tx
Definition adv_uart.h:7
struct adv_port_att * attr
Definition adv_uart.h:5
Definition advvcom.h:52
struct uart_port * adv_uart
Definition advvcom.h:53
struct adv_port_att attr
Definition advvcom.h:54
struct ring_buf rx
Definition advvcom.h:56
struct ring_buf tx
Definition advvcom.h:55