Thread (10 messages) 10 messages, 2 authors, 2018-07-11

[PATCH v4 3/3] serial: 8250_dw: add fractional divisor support

From: andriy.shevchenko@linux.intel.com (Andy Shevchenko)
Date: 2018-07-11 14:23:20
Also in: linux-serial, lkml

On Wed, 2018-07-11 at 14:41 +0800, Jisheng Zhang wrote:
On Tue, 10 Jul 2018 19:19:21 +0300 Andy Shevchenko wrote:
quoted
quoted
+/*
+ * divisor = div(I) + div(F)
+ * "I" means integer, "F" means fractional
+ * quot = div(I) = clk / (16 * baud)
+ * frac = div(F) * 2^dlf_size
+ *
+ * let rem = clk % (16 * baud)
+ * we have: div(F) * (16 * baud) = rem
+ * so frac = 2^dlf_size * rem / (16 * baud) = (rem << dlf_size) /
(16
* baud)
+ */
quoted
quoted
+	quot = p->uartclk / (16 * baud);
+	rem = p->uartclk % (16 * baud);
+	*frac = DIV_ROUND_CLOSEST(rem << d->dlf_size, 16 * baud
My python coding skill is limited. So I wrote a simple c program to
do the check for common clks and baudrate combination. All passed. I
paste the code here:
OK, I wrote test case in Python:
https://gist.github.com/andy-shev/5e980f1d752617ba814725248556ac19

Looks good to me.

Please, send v6 and assume my Reviewed-by for entire series.

-- 
Andy Shevchenko [off-list ref]
Intel Finland Oy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help