linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH v4 3/3] serial: 8250_dw: add fractional divisor support
Date: Wed, 11 Jul 2018 17:23:13 +0300	[thread overview]
Message-ID: <d2ba8f992c272543d689d87006e99c3bcf343605.camel@linux.intel.com> (raw)
In-Reply-To: <20180711144125.7d4e6a73@xhacker.debian>

On Wed, 2018-07-11 at 14:41 +0800, Jisheng Zhang wrote:
> On Tue, 10 Jul 2018 19:19:21 +0300 Andy Shevchenko wrote:

> > > +/*
> > > + * 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)
> > > + */

> > > +	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 <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2018-07-11 14:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-10  3:09 [PATCH v4 0/3] serial: 8250_dw: add fractional divisor support Jisheng Zhang
2018-07-10  3:12 ` [PATCH v4 1/3] serial: 8250: introduce get_divisor() and set_divisor() hook Jisheng Zhang
2018-07-10  3:13 ` [PATCH v4 2/3] serial: 8250: export serial8250_do_set_divisor() Jisheng Zhang
2018-07-10 13:56   ` Andy Shevchenko
2018-07-10  3:15 ` [PATCH v4 3/3] serial: 8250_dw: add fractional divisor support Jisheng Zhang
2018-07-10 16:19   ` Andy Shevchenko
2018-07-11  6:41     ` Jisheng Zhang
2018-07-11 14:23       ` Andy Shevchenko [this message]
2018-07-11  7:11   ` [PATCH v5 " Jisheng Zhang
2018-07-11 11:31     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2ba8f992c272543d689d87006e99c3bcf343605.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Jisheng.Zhang@synaptics.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).