您尚未登录。

楼主 # 2021-08-07 19:57:55

XIVN1987
会员
注册时间: 2019-08-30
已发帖子: 82
积分: 60.5

dw-apb-uart ff0a0000.serial: set rate:3686400, but get rate:3428572

linux console设置波特率115200,逻辑分析仪实测为107142,,开机打印信息如下:

[    0.199149] Serial: 8250/16550 driver, 5 ports, IRQ sharing disabled
[    0.201430] console [ttyS0] disabled
[    0.201514] ff0a0000.serial: ttyS0 at MMIO 0xff0a0000 (irq = 10, base_baud = 1500000) is a 16550A
[    0.201693] clk_uart0_frac parent_rate(24000000) is low than rate(3686400)*20, fractional div is not allowed
[    0.201789] clk_uart0_frac parent_rate(24000000) is low than rate(3760128)*20, fractional div is not allowed
[    0.201811] dw-apb-uart ff0a0000.serial: set rate:3686400, but get rate:3428572
[    1.240605] console [ttyS0] enabled

是不是因为UART0时钟除以115200波特率商不是整数导致的?如果换个其他波特率的话,应该能得到准确波特率

不过如果希望继续用115200的话,,请问应该怎么设置?

离线

楼主 #1 2021-09-02 22:32:53

XIVN1987
会员
注册时间: 2019-08-30
已发帖子: 82
积分: 60.5

Re: dw-apb-uart ff0a0000.serial: set rate:3686400, but get rate:3428572

问题解决了,,解决方法:
将 drivers/tty/serial/8250/8250_dw.c 中函数 dw8250_set_termios() 里面的

#ifdef CONFIG_ARCH_ROCKCHIP
	if ((baud * 16) <= 4000000) {
		/*
		 * Make sure uart sclk is high enough
		 */
		div = 4000000 / baud / 16;
		rate = baud * 16 * div;
	} else {
		rate = baud * 16;
	}

	ret = clk_set_rate(d->clk, rate);
	rate_temp = clk_get_rate(d->clk);
	diff = rate * 20 / 1000;
	/*
	 * If rate_temp is not equal to rate, is means fractional frequency
	 * division is failed. Then use Integer frequency division, and
	 * the buad rate error must be under -+2%
	 */
	if ((rate_temp < rate) && ((rate - rate_temp) > diff)) {
		ret = clk_set_rate(d->clk, rate + diff);
		rate_temp = clk_get_rate(d->clk);
		if ((rate_temp < rate) && ((rate - rate_temp) > diff))
			dev_info(p->dev, "set rate:%d, but get rate:%d\n",
				 rate, rate_temp);
		else if ((rate < rate_temp) && ((rate_temp - rate) > diff))
			dev_info(p->dev, "set rate:%d, but get rate:%d\n",
				 rate, rate_temp);
	}
#else

替换为:

#ifdef CONFIG_ARCH_ROCKCHIP
	rate = clk_get_rate(clk_get_parent(d->clk));
	ret = clk_set_rate(d->clk, rate);
#else

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn