non-standard baud rate for the uart

Hi,
I need the serial port supports non-standard baud rate,in the nano system
such as 250000
How do I do it?
the following code, I can not set the baut

//set the non-standard baud rate,lg:250000
int serial_set_speci_baud(int fd,int baud)
{
int ret =-1;
struct termios options;
struct serial_struct ss,ss_set;
memset(&options,0,sizeof(options));
tcgetattr(fd,&options);
cfsetispeed(&options,B38400);
cfsetospeed(&options,B38400);
tcflush(fd,TCIFLUSH);/handle unrecevie char/
tcsetattr(fd,TCSANOW,&options);
if((ioctl(fd,TIOCGSERIAL,&ss)) < 0)
{
printf(“BAUD: error to get the serial_struct info:%s\n”,strerror(errno));
return -1;
}
ss.flags = ASYNC_SPD_CUST;
ss.custom_divisor = ss.baud_base / baud;
printf(“ss.custom_divisor = %d \r\n”,ss.custom_divisor);
if((ioctl(fd,TIOCSSERIAL,&ss)) < 0)
{
printf(“BAUD: error to set serial_struct:%s\n”,strerror(errno));
return -1;
}

ret = ioctl(fd,TIOCGSERIAL,&ss_set);
tcgetattr(fd,&options);
int boudrate11 = cfgetospeed(&options);
printf("ret= %d,BAUD: success set baud to %d,custom_divisor=%d,baud_base=%d\n",ret,baud,ss_set.custom_divisor,ss_set.baud_base);

return 0;

}

hello tpwang2000,

you might refer to Technical Reference Manual, please refer to divisor values for the MSB and LSB bits of the baud rate generator.
you might refer to below for default clock sources, and also adjust baud-rate settings.
for example,
$l4t-r32.2/public_sources/kernel_src/hardware/nvidia/soc/t210/kernel-dts/tegra210-soc/tegra210-soc-base.dtsi

you might also refer to discussion thread, Topic 1069632.
you’ll need to use termios2 struct settings and TCGET2/TCSET2 to set higher (>4Mbps) baudrates,
thanks