Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp396851ybl; Tue, 28 Jan 2020 05:18:32 -0800 (PST) X-Google-Smtp-Source: APXvYqy9qD3WiZ5ZRkQHL/ago6FdM0onSlo2zROkZICPTvJVThpg3Y/B1IsiCzBK7Bkrm/KkDpDz X-Received: by 2002:aca:c646:: with SMTP id w67mr2667494oif.171.1580217511902; Tue, 28 Jan 2020 05:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580217511; cv=none; d=google.com; s=arc-20160816; b=riwaRmGXQfb2rMxJb1gfBpDkF2iQlKIo/w5UFmahWCDfR0V1VJ3JLqhEUfcO3qYuAf TG7PJtDPcMlXXtyHypJutQTgkT9q5mtPTAnCl5PfgpLPD/PmuInDJJs7aP/DLaxYDBsk nNQ67Z4RkzzdpZLdfpww5cfrD7RdImbzRfA1n8AWxION+nBbvk5OW6HyTizqI7LvzsNg KLY69u2gU+qColetwBvjfycM88sU8IUK4f+evuf1KA8xmCu9/iyjA+zZCEzFpIPv1Mwg WiqHPW2+/0HmeUY5+sGfKIJlrc4rJ2wPRv87oRgzONsguUO8DN71YAfAzCtcmm2ASsh/ pKaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:cc:to:from:subject:date :in-reply-to:content-transfer-encoding; bh=XEQJEhPzOeiYy/+ErtVRha4vxjwoee3KbucRebpOCYo=; b=Fj4trBW+Mnd0pRgDb6XXkguuY7yku0YjViUXzY9gxTLPg89DSnBbluUVLC8v4QE6jm rIgh6Cu39exyeTVpi1GZIf11jHLYnUAZXB3bWvGV+xcjiS8ZqeICBkhKVbxkPmhznKIK rcHMsuSq2SyEliZuBMLlkXQDpT2CYp56Blcz0/n1nT/DCj4BUVFU8VsrfbCwxaz5pm1I n0yHIUJeO/hVYkJ8mxhlMUN9d0fms8yNC6JuQam5qMMl5ABCtyxd8NAMGD3yZG9Nv0JV 2SlG1JZruQWpdsZU6bTPpWtKNANlUgRQiBNjo5pQVbI4UXKSAu/t2b9n7Lt3NIypemcp 4g7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i124si4857630oif.214.2020.01.28.05.18.14; Tue, 28 Jan 2020 05:18:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726057AbgA1NRJ (ORCPT + 99 others); Tue, 28 Jan 2020 08:17:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:32842 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbgA1NRJ (ORCPT ); Tue, 28 Jan 2020 08:17:09 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 18C54B246; Tue, 28 Jan 2020 13:17:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 In-Reply-To: <88af0fca-90d1-58ff-406d-73f185eb8b7e@gmail.com> Date: Tue, 28 Jan 2020 13:42:21 +0100 Subject: Re: [PATCH] serial: 8250_early: Add earlycon for BCM2835 aux uart From: "Nicolas Saenz Julienne" To: "Matthias Brugger" , "Lukas Wunner" , Cc: , "Matthias Brugger" , "Scott Branden" , , , "Ray Jui" , "Stephen Boyd" , "Florian Fainelli" , , , , , Message-Id: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun Jan 26, 2020 at 9:20 PM, Matthias Brugger wrote: > > > On 26/01/2020 14:12, Lukas Wunner wrote: > > On Sun, Jan 26, 2020 at 01:33:14PM +0100, matthias.bgg@kernel.org wrote= : > >> +#ifdef CONFIG_SERIAL_8250_CONSOLE > >> + > >> +static int __init early_bcm2835aux_setup(struct earlycon_device *devi= ce, > >> + const char *options) > >> +{ > >> + if (!device->port.membase) > >> + return -ENODEV; > >> + > >> + device->port.iotype =3D UPIO_MEM32; > >> + device->port.regshift =3D 2; > >> + > >> + return early_serial8250_setup(device, NULL); > >> +} > >> + > >> +OF_EARLYCON_DECLARE(bcm2835aux, "brcm,bcm2835-aux-uart", > >> + early_bcm2835aux_setup); > >> +#endif > >=20 > > Does this really work? I also tried to get it working recently and > > the system just hung on boot. Looking at it with a JTAG debugger > > showed that the bcm2835aux registers were inaccessible because > > the mini UART wasn't enabled in the AUXENB register. > >=20 > > Maybe if you use OF_EARLYCON_DECLARE, the firmware recognizes that > > serial1 is set as stdout-path and performs enablement of the mini UART? > > Or are you using U-Boot which perhaps does the enablement? > > Yes I'm using U-Boot which enables the console for me. My understanding > is that > the early console is thought as a re-use of the console the boot FW used > for > logging. AFAIK for example it does not enable any needed clocks but > expects > these to be enabled already. > > Looking on the source code of U-Boot [1] I don't see that the AUXENB is > written > somewhere, so I suppose that the FW should already has enabled the > aux-uart. > > I any case if it's just to set one bit, I think we can do that in > early_bcm2835aux_setup(). > > [1] > https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/serial/serial_bc= m283x_mu.c > > >=20 > > I also saw in the JTAG debugger that the uartclk member contained > > an incorrect value, so I'd expect that it has to be set as well in > > early_bcm2835aux_setup(). > > In my case the clock was set by U-Boot already. I'm testing this by booting directly from RPi4's bootloader. And it works as long as I add this to config.txt: enable_uart=3D1 gpu_freq=3D500 Which AFAIK blocks frequency scalin on the GPU and fixes the clock to a point where the serial is set at 115200 bauds. Ideally it'd be nice to be able to query the clock frequency, and recalculate the divisors based on that. But I don't know if it's feasible at that point in the boot process. We could maybe leave a comment explaining what is expected from the bootloader, given the different options around. Regards, Nicolas