From patchwork Wed Sep 13 21:29:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 813627 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=agner.ch header.i=@agner.ch header.b="gCQTRhQu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xsvwB4ZqBz9s81 for ; Thu, 14 Sep 2017 07:30:34 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EEE91C2253F; Wed, 13 Sep 2017 21:30:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id F0B93C2238D; Wed, 13 Sep 2017 21:30:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A6156C22188; Wed, 13 Sep 2017 21:30:28 +0000 (UTC) Received: from mail.kmu-office.ch (mail.kmu-office.ch [178.209.48.109]) by lists.denx.de (Postfix) with ESMTPS id 44C9CC224C1 for ; Wed, 13 Sep 2017 21:29:55 +0000 (UTC) Received: from trochilidae.toradex.int (75-146-58-181-Washington.hfc.comcastbusiness.net [75.146.58.181]) by mail.kmu-office.ch (Postfix) with ESMTPSA id CE4825C0ED9; Wed, 13 Sep 2017 23:26:04 +0200 (CEST) From: Stefan Agner To: sbabic@denx.de, fabio.estevam@nxp.com, eric@nelint.com Date: Wed, 13 Sep 2017 14:29:44 -0700 Message-Id: <20170913212945.5659-1-stefan@agner.ch> X-Mailer: git-send-email 2.14.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1505337967; bh=QeZ4YLtrmTF588jJypU5J+tuULbQTTd1VSJDGbEDFAo=; h=From:To:Cc:Subject:Date:Message-Id; b=gCQTRhQu68wLc/db5LOoZ1X1h5d4vFc7u1tP37sAvZTPZ/leutm2gyuiE9M6koa9q2DgHkTcmY2gdBTH8a3dOQp2A0sdndACRgxArYPGJrWDc8xyINJstjrgSRsq1CTmmaL4w6xbfWMwlnDzGRuH95AMCk0iFfrhvkxS2N4MZk4= Cc: marex@denx.de, albert.u.boot@aribaud.net, Stefan Agner , gary.bisson@boundarydevices.com, Marcel Ziswiler , joel.esponde@honeywell.com, u-boot@lists.denx.de, Max Krummenacher , jagan@openedev.com Subject: [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Stefan Agner This macro allows to detect whether the USB PHY is active. This is helpful to detect if the boot ROM has previously started the USB serial downloader. The idea is taken from the mfgtool support in the NXP U-Boot: http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga&id=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412 Signed-off-by: Stefan Agner Acked-by: Marcel Ziswiler Tested-by: Fabio Estevam Reviewed-by: Eric Nelson --- Changes in v4: - Rename macro to is_usbotg_phy_active() Changes in v3: None Changes in v2: - Move macro to sys_proto.h - Renamed from is_boot_from_usb() to is_usbphy_active() - Use defines for register offset and field - Remove tab after define - Remove comment since the actual "magic" is happening and documented at usage side arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h index 14f5d948c9..ba73943260 100644 --- a/arch/arm/include/asm/arch-mx6/sys_proto.h +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h @@ -6,3 +6,10 @@ */ #include + +#define USBPHY_PWD 0x00000000 + +#define USBPHY_PWD_RXPWDRX (1 << 20) /* receiver block power down */ + +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \ + USBPHY_PWD_RXPWDRX))