From: Stefan Agner Date: Tue, 05 Sep 2017 09:02:11 -0700 Subject: [U-Boot] [PATCH v1 1/2] imx: add macro to detect whether USB has been initialized In-Reply-To: References: <20170905012144.4833-1-stefan@agner.ch> Message-ID: <450511321b098820cdb0c673bf6527db@agner.ch> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 2017-09-05 04:13, Fabio Estevam wrote: > Hi Stefan, > > On Mon, Sep 4, 2017 at 10:21 PM, Stefan Agner wrote: >> From: Stefan Agner >> >> This macro allows to detect whether the boot ROM initialized USB >> already (serial downloader). This is helpful to reliably detect >> if the system has been recovered via USB serial downloader. >> >> Signed-off-by: Stefan Agner >> Acked-by: Marcel Ziswiler > > This allows Serial Download Protocol to work on imx6q sabresd: > > Tested-by: Fabio Estevam > >> --- >> Hi Stefano, >> >> I noted already in my initial post that detection of serial >> downloader mode is somewhat brittle: >> https://lists.denx.de/pipermail/u-boot/2017-August/301952.html >> >> This came up quite fast now also for other boards: >> https://www.mail-archive.com/u-boot at lists.denx.de/msg262234.html >> >> We use this patches since quite some time. Also NXP uses this >> detection method to start their mfgr tools... Altough a hack, >> maybe we should still add it upstream? >> >> -- >> Stefan >> >> >> arch/arm/include/asm/arch-mx6/imx-regs.h | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h b/arch/arm/include/asm/arch-mx6/imx-regs.h >> index 86e267087a..895ef4de83 100644 >> --- a/arch/arm/include/asm/arch-mx6/imx-regs.h >> +++ b/arch/arm/include/asm/arch-mx6/imx-regs.h >> @@ -985,5 +985,12 @@ struct pwm_regs { >> u32 pr; >> u32 cnr; >> }; >> + >> +/* >> + * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB >> + * If boot from the other mode, USB0_PWD will keep reset value >> + */ >> +#define is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20))) > > Minor nit: imx-regs.h is better suited for storing register layout definitions. > > I think that arch/arm/include/asm/mach-imx/sys_proto.h would be a > more appropriate location for this macro. Makes sense, will move it. > > Also you could remove that tab between 'define' and the macro name. Agreed. -- Stefan