From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] serial: add BCM283x mini UART driver
Date: Sun, 10 Apr 2016 20:58:45 -0400 [thread overview]
Message-ID: <20160411005845.GA13577@bill-the-cat> (raw)
In-Reply-To: <5709CC60.1010801@wwwdotorg.org>
On Sat, Apr 09, 2016 at 09:45:36PM -0600, Stephen Warren wrote:
> On 04/09/2016 12:34 PM, Simon Glass wrote:
> >Hi Stephen,
> >
> >On 16 March 2016 at 21:46, Stephen Warren <swarren@wwwdotorg.org> wrote:
> >>The RPi3 typically uses the regular UART for high-speed communication with
> >>the Bluetooth device, leaving us the mini UART to use for the serial
> >>console. Add support for this UART so we can use it.
> >>
> >>Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> >>---
> >>(This will be a dependency for the RPi 3 patches, so it'd be good if it
> >>could make it into mainline pretty quickly if acceptable.)
> >
> >Reviewed-by: Simon Glass <sjg@chromium.org>
> >
> >Not sure if this went in already. But see comment below.
>
> It has, but I can send a fix.
>
> >>diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c
>
> >>+static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate)
> >>+{
> >>+ struct bcm283x_mu_priv *priv = dev_get_priv(dev);
> >>+ struct bcm283x_mu_regs *regs = priv->regs;
> >>+ /* FIXME: Get this from plat data later */
> >>+ u32 clock_rate = 250000000;
> >
> >Or device tree?
>
> Well even if DT were used on this platform, the code right here
> would get the clock rate from platform data. Now, whether the
> platform data came from a board file or was parsed from DT is
> another matter.
>
> >>+static int bcm283x_mu_serial_pending(struct udevice *dev, bool input)
> >>+{
> >>+ struct bcm283x_mu_priv *priv = dev_get_priv(dev);
> >>+ struct bcm283x_mu_regs *regs = priv->regs;
> >>+ unsigned int lsr = readl(®s->lsr);
> >>+
> >>+ if (input) {
> >>+ WATCHDOG_RESET();
> >>+ return lsr & BCM283X_MU_LSR_RX_READY;
> >>+ } else {
> >>+ return !(lsr & BCM283X_MU_LSR_TX_IDLE);
> >
> >These look like flags - be care to return 1 if there is an unknown
> >number of characters, rather than (e.g. 4). The latter might cause the
> >uclass to expect 4 characters to be present.
> >
> >Suggest putting ? 1 : 0 or ? 0 : 1 on the end.
>
> Luckily BCM283X_MU_LSR_RX_READY is BIT(0) so there's no practical
> issue. A !! would make this more obvious at this point in the code
> though. Do you think that warrants a patch? The ! on the second
> return also ensure the correct return value.
I hate the '!!' operator, how bad would it be to spell things out in the
code in a bit less compact way but such that the compiler will still
optimize things well.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160410/14e68d74/attachment.sig>
next prev parent reply other threads:[~2016-04-11 0:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 3:46 [U-Boot] [PATCH] serial: add BCM283x mini UART driver Stephen Warren
2016-04-09 18:34 ` Simon Glass
2016-04-10 3:45 ` Stephen Warren
2016-04-11 0:58 ` Tom Rini [this message]
2016-04-11 1:17 ` Simon Glass
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=20160411005845.GA13577@bill-the-cat \
--to=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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