Skip to content

Instantly share code, notes, and snippets.

@tomaskrcka
Created November 16, 2015 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaskrcka/7480aa08d72f6bd40ccc to your computer and use it in GitHub Desktop.
Save tomaskrcka/7480aa08d72f6bd40ccc to your computer and use it in GitHub Desktop.
diff -uprN linux-3.2.bach.orig/arch/arm/mach-omap2/board-pcm051.c linux-3.2.bach/arch/arm/mach-omap2/board-pcm051.c
--- linux-3.2.bach.orig/arch/arm/mach-omap2/board-pcm051.c 2015-10-05 08:23:24.019166904 +0200
+++ linux-3.2.bach/arch/arm/mach-omap2/board-pcm051.c 2015-10-05 14:18:41.834012970 +0200
@@ -1317,9 +1317,32 @@ static struct omap_board_data uart1_boar
.pads_cnt = 0,
};
+static struct omap_uart_port_info omap_serial_uart3_info[] __initdata = {
+ {
+ .dma_enabled = false,
+ .init_termios_enabled = true,
+ .init_termios = {
+ .c_iflag = IGNBRK | IGNPAR,
+ .c_cflag = B115200 | CS8 | CREAD | CLOCAL,
+ .c_lflag = ICANON,
+ .c_cc = INIT_C_CC,
+ .c_ispeed = 115200,
+ .c_ospeed = 115200
+ },
+ .dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
+ .dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
+ .dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
+ .autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
+ .rs485 = {
+ .flags = 0,
+ },
+ },
+};
+
static struct omap_uart_port_info omap_serial_uart1_info[] __initdata = {
{
.dma_enabled = false,
+ .init_termios_enabled = false,
.dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
.dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
.dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
@@ -1334,6 +1357,7 @@ static struct omap_uart_port_info omap_s
};
#define UART1_RS485 1
+#define UART3_SMU 3
/*
* Inicialization for UART
@@ -1350,6 +1374,8 @@ static void openmatics_serial_init(void)
bdata.id = i;
if (i == UART1_RS485)
omap_serial_init_port(&bdata, omap_serial_uart1_info);
+ else if (i == UART3_SMU)
+ omap_serial_init_port(&bdata, omap_serial_uart3_info);
else
omap_serial_init_port(&bdata, NULL);
}
diff -uprN linux-3.2.bach.orig/arch/arm/mach-omap2/serial.c linux-3.2.bach/arch/arm/mach-omap2/serial.c
--- linux-3.2.bach.orig/arch/arm/mach-omap2/serial.c 2015-10-05 08:23:24.019166904 +0200
+++ linux-3.2.bach/arch/arm/mach-omap2/serial.c 2015-10-02 14:19:05.962915974 +0200
@@ -69,6 +69,7 @@ static u8 uart_debug;
static struct omap_uart_port_info omap_serial_default_info[] __initdata = {
{
.dma_enabled = false,
+ .init_termios_enabled = false,
.dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
.dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
.dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
@@ -356,6 +357,8 @@ void __init omap_serial_init_port(struct
omap_up.autosuspend_timeout = info->autosuspend_timeout;
omap_up.rs485_rts_gpio = info->rs485_rts_gpio;
omap_up.rs485 = info->rs485;
+ omap_up.init_termios_enabled = info->init_termios_enabled;
+ omap_up.init_termios = info->init_termios;
/* Enable the MDR1 Errata i202 for OMAP2430/3xxx/44xx */
if (!cpu_is_omap2420() && !cpu_is_ti816x())
diff -uprN linux-3.2.bach.orig/arch/arm/plat-omap/include/plat/omap-serial.h linux-3.2.bach/arch/arm/plat-omap/include/plat/omap-serial.h
--- linux-3.2.bach.orig/arch/arm/plat-omap/include/plat/omap-serial.h 2015-10-05 08:23:24.019166904 +0200
+++ linux-3.2.bach/arch/arm/plat-omap/include/plat/omap-serial.h 2015-10-05 13:40:09.347727041 +0200
@@ -73,6 +73,8 @@ struct omap_uart_port_info {
unsigned int dma_rx_timeout;
unsigned int autosuspend_timeout;
unsigned int dma_rx_poll_rate;
+ struct ktermios init_termios;
+ bool init_termios_enabled; /* init_termios feature flags */
int (*get_context_loss_count)(struct device *);
void (*set_forceidle)(struct platform_device *);
diff -uprN linux-3.2.bach.orig/drivers/tty/serial/omap-serial.c linux-3.2.bach/drivers/tty/serial/omap-serial.c
--- linux-3.2.bach.orig/drivers/tty/serial/omap-serial.c 2015-10-05 08:23:24.019166904 +0200
+++ linux-3.2.bach/drivers/tty/serial/omap-serial.c 2015-10-05 13:40:42.815728257 +0200
@@ -1389,6 +1389,7 @@ static struct omap_uart_port_info *of_ge
static int serial_omap_probe(struct platform_device *pdev)
{
struct uart_omap_port *up;
+ struct ktermios *tp;
struct resource *mem, *irq, *dma_tx, *dma_rx;
struct omap_uart_port_info *omap_up_info = pdev->dev.platform_data;
int ret = -ENOSPC;
@@ -1531,7 +1532,23 @@ static int serial_omap_probe(struct plat
ui[up->port.line] = up;
serial_omap_add_console_port(up);
+ if (omap_up_info->init_termios_enabled) {
+ tp = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
+ if (tp == NULL) {
+ dev_err(&pdev->dev, "can't alloc termios structure UART, init termios won't be set\n");
+ } else {
+ memcpy(tp, &omap_up_info->init_termios,
+ sizeof(struct ktermios));
+
+ if (serial_omap_reg.tty_driver->termios != NULL) {
+ serial_omap_reg.tty_driver->termios[up->port.line] = tp;
+ dev_info(&pdev->dev, "Applied init termios settings for line %d\n", up->port.line);
+ }
+ }
+ }
+
ret = uart_add_one_port(&serial_omap_reg, &up->port);
+
if (ret != 0)
goto do_release_region;
@tomaskrcka
Copy link
Author

Overwriting default baudrate of ttyO3 and default parameters. So the serial interface has the correct settings directly after start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment