qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Eric Blake <eblake@redhat.com>,
	qemu-devel@nongnu.org,
	Alistair Francis <alistair.francis@wdc.com>
Subject: Re: [PATCH] ibex_uart: fix XOR-as-pow
Date: Wed, 24 Jun 2020 08:33:19 +0200	[thread overview]
Message-ID: <8635411c-d3c0-6d26-c068-4fa02de98df9@redhat.com> (raw)
In-Reply-To: <e47cdd98-ee3f-a222-5bc9-6f8f7085584f@redhat.com>

On 23/06/20 22:07, Eric Blake wrote:
>>
>>              uint64_t baud = ((value & UART_CTRL_NCO) >> 16);
>>               baud *= 1000;
>> -            baud /= 2 ^ 20;
>> +            baud >>= 20;
> 
> Dividing by 1M instead of 22 seems much more logical, indeed :)

Based on the spec, the "* 1000" is the clock, in other words this is a
fixed point value relative to the clock:

f_baud = NCO * f_clock / 2^20

The example in the spec (https://docs.opentitan.org/hw/ip/uart/doc/) has
f_clock = 50 MHz, while here it's only 1 kHz.  And the register is only
16 bit, so the above would only allow a baud rate up to 62 (65535 * 1000
/ 2^20).

Should the clock be a property of the device instead?

Thanks,

Paolo

> It's odd that we are scaling up by 1000, down by 1024*1024, then
> 
>>                 s->char_tx_time = (NANOSECONDS_PER_SECOND / baud) * 10; 



  reply	other threads:[~2020-06-24  6:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 19:54 [PATCH] ibex_uart: fix XOR-as-pow Paolo Bonzini
2020-06-23 20:07 ` Eric Blake
2020-06-24  6:33   ` Paolo Bonzini [this message]
2020-06-24  9:25     ` Philippe Mathieu-Daudé
2020-06-23 20:33 ` Peter Maydell
2020-06-23 23:26 ` Alistair Francis

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=8635411c-d3c0-6d26-c068-4fa02de98df9@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.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).