Now I am able to set /dev/ttyTHS0 baud_rate up to 4000000(4M),but the documents say that speed of TK1 UART supports is up to 12.75Mbps.So I really want to know how to do that.
btw,I used this
setserial /dev/ttyTHS0 baud_base 12000000
(ps: the divisor is 1 )but the baud_rate is not really 12Mbps,I can see that from my oscilloscope.
any suspicious kernel messages shown when setting the higher the baud rate?
moreover, could you please dump the baud rate at below kernel function?
/kernel/drivers/tty/serial/serial-tegra.c
HI JerryChang,sorry for the late post.I found one way using termios2 ,and successfully set the baud_rate to 6Mbps,and may set to 12.5Mbps.
I learn that from a post on stackoverflow,here is my code :
/*
* Allows to set arbitrary speed for the serial device on Linux.
* stty allows to set only predefined values: 9600, 19200, 38400, 57600, 115200, 230400, 460800.
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <asm/termios.h>
int main(int argc, char* argv[]) {
if (argc != 3) {
printf("%s device speed\n\nSet speed for a serial device.\nFor instance:\n %s /dev/ttyUSB0 75000\n", argv[0], argv[0]);
return -1;
}
int fd = open(argv[1], O_RDONLY);
// int speed =*(argv[2]);
int speed = atoi(argv[2]);
struct termios2 tio;
printf("%d\n",sizeof(tio));
ioctl(fd, TCGETS2, &tio);
tio.c_cflag &= ~CBAUD;
tio.c_cflag |= BOTHER;
tio.c_cflag |=CLOCAL;
tio.c_ispeed = speed;
tio.c_ospeed = speed;
int r = ioctl(fd, TCSETS2, &tio);
close(fd);
if (r == 0) {
printf("Changed successfully.\n");
} else {
perror("ioctl");
}
}