public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: Pete Batard <pete@akeo.ie>, devel@edk2.groups.io
Cc: leif@nuviainc.com, awarkentin@vmware.com,
	Andrei Warkentin <andrey.warkentin@gmail.com>
Subject: Re: [edk2-platforms][PATCH 2/3] Platform/RPi/DualSerialPortLib: Fix miniUART serial divisor computation
Date: Tue, 5 May 2020 12:05:28 +0200	[thread overview]
Message-ID: <905f3a90-276d-85a8-d7ed-669d10f99c17@arm.com> (raw)
In-Reply-To: <20200504111548.11112-3-pete@akeo.ie>

On 5/4/20 1:15 PM, Pete Batard wrote:
> From: Andrei Warkentin <andrey.warkentin@gmail.com>
> 
> Fix for https://github.com/raspberrypi/firmware/issues/1376.
> 
> For the Pi 3, to properly configure miniUART, we need the core clock,
> which can be vary between VideoCore firmare release or config.txt options.
> 
> Unfortunately, it's painful to get - it's only available via the mailbox
> interface. Additionally, SerialLib is a very limited environment, even
> when linked in a DXE-mode component, because as part of a DebugLib
> implementation it ends being the base prerequisite of everything.
> That means a "normal" mailbox implementation like the one from
> RpiFirmwareDxe (with dependencies on DmaLib) is out of the question.
> Using a basic implementation such as the one in PlatformLib doesn't work
> either because it operates in both environments with MMU on (DXE phase)
> and MMU off (SEC/PrePi).
> 
> Ideally, we read the value via mbox exactly once at boot (PlatformLib),
> and then somehow stash it. A GUID Hob sounds appropriate, yet when
> SerialPortLib operates in DXE components, we can't use the HobLib to
> *locate* the Hob list itself (remember, SerialPortLib initializes
> before any of HobLib's dependencies, like UeflLib...).
> 

Yeah, the gift that keeps on giving :-) NXP are struggling with a 
similar issue.

So the problem is that SerialPortInitialize() is called before we know 
what value to program, and we cannot rely on other libraries to discover 
this value because they may not work before their constructor has been 
called.

So can we break the contents of SerialPortInitialize() into things that 
need to happen once (program the divisors etc) and things that need to 
happen each and every time (figure out which UART we are using in the 
first place)? If the second set does not suffer from the same issue, can 
we just move the entire logic that programs the UART block into PrePi, 
so that all subsequent users don't have to touch those registers at all?

This means we may need two versions of DualSerialPortLib, where the one 
that PrePi uses may need to be attached to SerialDxe as well, so that it 
can reprogram the baud rate as needed. But for all the remaining 
DebugLib related uses, we don't really need to reprogram the UART at all 
afaics.


  reply	other threads:[~2020-05-05 10:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 11:15 [edk2-platforms][PATCH 0/3] Platform/RPi: Fix compatibility with recent start.elf Pete Batard
2020-05-04 11:15 ` [edk2-platforms][PATCH 1/3] Platform/RPi: Fortify mailbox code Pete Batard
2020-05-06 12:39   ` Ard Biesheuvel
2020-05-04 11:15 ` [edk2-platforms][PATCH 2/3] Platform/RPi/DualSerialPortLib: Fix miniUART serial divisor computation Pete Batard
2020-05-05 10:05   ` Ard Biesheuvel [this message]
2020-05-05 11:54     ` Pete Batard
2020-05-05 12:05       ` Ard Biesheuvel
2020-05-05 12:09         ` Pete Batard
2020-05-04 11:15 ` [edk2-platforms][PATCH 3/3] Platform/RPi: Report core clock frequency during early init Pete Batard
2020-05-04 11:37   ` [edk2-devel] " Philippe Mathieu-Daudé
2020-05-05  6:04   ` Andrei Warkentin

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-list 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=905f3a90-276d-85a8-d7ed-669d10f99c17@arm.com \
    --to=devel@edk2.groups.io \
    /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