From patchwork Tue Oct 18 10:37:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 13010236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53649C433FE for ; Tue, 18 Oct 2022 10:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=amw5nZWpcmcdmh3KhTz5SAUwyFb2EVarOr+cWQuN8xk=; b=SOmYeA1zAApV0N Cv2kesfS1+kzqLVU0ih3MmjfiZQFb413kE3ryY/mYKhBI3a9+iAHBwbKvCjw3Z2k80Xu/sYHjGunK DZSKN3iPwnP5SMk7u9E1YPav9H02ri2ZYB0FHsR4JBNNj4XDCN8PjDV8eq5zXdT5nEW5QRt7XIktS iOBsj3798Xkjj7+r3aUnxX0GBGnVRHt4I3z5JvoAaF485C+CpbVD2/trUufJZB26rritLtiu+r6bs AFOUyGFs4VWKWY9NDGXMMLpAhB0N+lqr79nYf72O1zS+z+TkgXpIOn7L0TmudWpBWMtOjUY9dit4O GyIfSExDBcHBU0y4cYNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjyv-005Z2R-BG; Tue, 18 Oct 2022 10:37:57 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjyb-005YyW-Ie for linux-arm-kernel@lists.infradead.org; Tue, 18 Oct 2022 10:37:40 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okjyU-0002Gl-Ae; Tue, 18 Oct 2022 12:37:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1okjyR-002G14-Rr; Tue, 18 Oct 2022 12:37:27 +0200 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1okjyQ-00BIQn-O8; Tue, 18 Oct 2022 12:37:26 +0200 From: Sascha Hauer To: linux-usb@vger.kernel.org Cc: Peng Fan , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, Xu Yang , Sascha Hauer , Xu Yang Subject: [PATCH v2 1/4] usb: chipidea: usbmisc_imx: Fix i.MX53 clock sel masks Date: Tue, 18 Oct 2022 12:37:22 +0200 Message-Id: <20221018103725.2580679-2-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018103725.2580679-1-s.hauer@pengutronix.de> References: <20221018103725.2580679-1-s.hauer@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221018_033737_674030_8A66C601 X-CRM114-Status: GOOD ( 11.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org According to the reference manual the masks for the MX53_USB_CTRL_1_H*_XCVR_CLK_SEL bits are 0x3, not 0x11 (which were probably meant as 0b11). Signed-off-by: Sascha Hauer Reviewed-by: Xu Yang Link: https://lore.kernel.org/r/20221011082924.884123-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/usbmisc_imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index bac0f5458cab9..8f805aa9c383c 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -42,9 +42,9 @@ #define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08 #define MX53_USB_OTG_PHY_CTRL_1_OFFSET 0x0c #define MX53_USB_CTRL_1_OFFSET 0x10 -#define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_MASK (0x11 << 2) +#define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_MASK (0x3 << 2) #define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_ULPI BIT(2) -#define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_MASK (0x11 << 6) +#define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_MASK (0x3 << 6) #define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_ULPI BIT(6) #define MX53_USB_UH2_CTRL_OFFSET 0x14 #define MX53_USB_UH3_CTRL_OFFSET 0x18 From patchwork Tue Oct 18 10:37:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 13010238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C2D2C4332F for ; Tue, 18 Oct 2022 10:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Puo0HuBUothW567Lr/56cEyUn8KqUCzvrKfs1lApWXw=; b=biq/0bZFemIYJs 2L7HHgleS5H5ual7pVilHLJH5RodgqnYlBq7bxej1ktaAzgrnmSH3KqXnwc01gaVLAlcUiaJ/nSqj KM88fjUGa8FYCCpHJtNmbfo3JmtvojRxx14FHu+SMJs+jjb24dg07nul1338NVOAcBHEn/WVQibQB aRrym++d5DSm1MhEe2gJTsBelw1fsGxv+agKyiKdq2yju+YA2Vvk70M7apC10W+IgMRk8KDBX6bkZ S2Igk38K/A25ryGuu83Vr5y5lBuSjRCHrRll7LxAft5Hdn4FBbk2TG8LnM3T75fQwlwYkw8yZ6lsi WS3NaLHuCEBOd+gCOfvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjzB-005ZBB-A4; Tue, 18 Oct 2022 10:38:13 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjyb-005YyV-Ih for linux-arm-kernel@lists.infradead.org; Tue, 18 Oct 2022 10:37:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okjyU-0002Go-Af; Tue, 18 Oct 2022 12:37:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1okjyS-002G1D-6v; Tue, 18 Oct 2022 12:37:28 +0200 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1okjyQ-00BIRN-Po; Tue, 18 Oct 2022 12:37:26 +0200 From: Sascha Hauer To: linux-usb@vger.kernel.org Cc: Peng Fan , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, Xu Yang , Sascha Hauer , Xu Yang Subject: [PATCH v2 2/4] usb: chipidea: usbmisc_imx: Fix setting i.MX6SX wakeup source Date: Tue, 18 Oct 2022 12:37:23 +0200 Message-Id: <20221018103725.2580679-3-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018103725.2580679-1-s.hauer@pengutronix.de> References: <20221018103725.2580679-1-s.hauer@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221018_033737_679613_CBC12176 X-CRM114-Status: GOOD ( 11.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org MX6SX_USB_VBUS_WAKEUP_SOURCE are two bits containing an enum value, so when read/modify/write that we have to clear both bits bits before setting the desired bits. The clearing of the bits was forgotten, add it. Signed-off-by: Sascha Hauer Reviewed-by: Xu Yang Link: https://lore.kernel.org/r/20221011082924.884123-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/usbmisc_imx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 8f805aa9c383c..e1b4b7f9b3f31 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -551,6 +551,7 @@ static int usbmisc_imx6sx_init(struct imx_usbmisc_data *data) spin_lock_irqsave(&usbmisc->lock, flags); /* Set vbus wakeup source as bvalid */ val = readl(reg); + val &= ~MX6SX_USB_VBUS_WAKEUP_SOURCE(3); writel(val | MX6SX_USB_VBUS_WAKEUP_SOURCE_BVALID, reg); /* * Disable dp/dm wakeup in device mode when vbus is From patchwork Tue Oct 18 10:37:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 13010239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E0D5C433FE for ; Tue, 18 Oct 2022 10:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kg4QMdV/TsOmYe9feB6oaQYEM1H6b8ztp6RyJiUVna8=; b=sDbi4vpC5DfNoS u2YVxagZTFSUaynhx1b4tq4TlyKE1BiFBwth/F31vbjh2Q/iaHKgwvrBJEq0Yl+SBioOnL/9ozALa dkZ4+FRYC/97googCCp+zQ7pzLz/1R7tpnR22MNBUgLlTASie/zB980WsmOaBq8HCZN4cDx0JvYK2 RlKBJd0D06z8FKmxHbBPSakFngAIXL38ewzpoR7NSlnq9QAtZLvwhUPGONwckHKIelklZhDEjzHwS cscMJlyuYDVTSq2lZeTyzhmvlhKDGvb/2YCKvcc53pxhiE9AC6C1aPq6L61C2TTHtFjtpqimiumUf +4ytbULgNJiWwgaIOKBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjzL-005ZKA-CN; Tue, 18 Oct 2022 10:38:23 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjyb-005YyX-Ij for linux-arm-kernel@lists.infradead.org; Tue, 18 Oct 2022 10:37:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okjyU-0002Gm-8m; Tue, 18 Oct 2022 12:37:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1okjyS-002G17-0n; Tue, 18 Oct 2022 12:37:28 +0200 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1okjyQ-00BIRj-Rs; Tue, 18 Oct 2022 12:37:26 +0200 From: Sascha Hauer To: linux-usb@vger.kernel.org Cc: Peng Fan , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, Xu Yang , Sascha Hauer Subject: [PATCH v2 3/4] usb: chipidea: usbmisc_imx: Use GENMASK/FIELD_PREP for bitfields Date: Tue, 18 Oct 2022 12:37:24 +0200 Message-Id: <20221018103725.2580679-4-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018103725.2580679-1-s.hauer@pengutronix.de> References: <20221018103725.2580679-1-s.hauer@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221018_033737_837302_07910924 X-CRM114-Status: GOOD ( 16.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org GENMASK and FIELD_PREP offer a convenient unified way to manipulate bitfields in registers without having to define mask and shift separately. Broaden the use of this mechanism by converting usbmisc_imx over to it. No functional change intended. Signed-off-by: Sascha Hauer Link: https://lore.kernel.org/r/20221011082924.884123-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer Reviewed-by: Xu Yang --- drivers/usb/chipidea/usbmisc_imx.c | 116 +++++++++++++++-------------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index e1b4b7f9b3f31..09979264958fc 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -9,24 +9,23 @@ #include #include #include +#include +#include #include "ci_hdrc_imx.h" #define MX25_USB_PHY_CTRL_OFFSET 0x08 #define MX25_BM_EXTERNAL_VBUS_DIVIDER BIT(23) -#define MX25_EHCI_INTERFACE_SINGLE_UNI (2 << 0) -#define MX25_EHCI_INTERFACE_DIFF_UNI (0 << 0) -#define MX25_EHCI_INTERFACE_MASK (0xf) +#define MX25_EHCI_INTERFACE_SINGLE_UNI 2 +#define MX25_EHCI_INTERFACE_DIFF_UNI 0 -#define MX25_OTG_SIC_SHIFT 29 -#define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT) +#define MX25_OTG_SIC GENMASK(30, 29) #define MX25_OTG_PM_BIT BIT(24) #define MX25_OTG_PP_BIT BIT(11) #define MX25_OTG_OCPOL_BIT BIT(3) -#define MX25_H1_SIC_SHIFT 21 -#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT) +#define MX25_H1_SIC GENMASK(22, 21) #define MX25_H1_PP_BIT BIT(18) #define MX25_H1_PM_BIT BIT(16) #define MX25_H1_IPPUE_UP_BIT BIT(7) @@ -42,10 +41,10 @@ #define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08 #define MX53_USB_OTG_PHY_CTRL_1_OFFSET 0x0c #define MX53_USB_CTRL_1_OFFSET 0x10 -#define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_MASK (0x3 << 2) -#define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_ULPI BIT(2) -#define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_MASK (0x3 << 6) -#define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_ULPI BIT(6) +#define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL GENMASK(3, 2) +#define MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_ULPI 1 +#define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL GENMASK(7, 6) +#define MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_ULPI 1 #define MX53_USB_UH2_CTRL_OFFSET 0x14 #define MX53_USB_UH3_CTRL_OFFSET 0x18 #define MX53_USB_CLKONOFF_CTRL_OFFSET 0x24 @@ -85,26 +84,24 @@ #define MX6_USB_OTG1_PHY_CTRL 0x18 /* For imx6dql, it is host-only controller, for later imx6, it is otg's */ #define MX6_USB_OTG2_PHY_CTRL 0x1c -#define MX6SX_USB_VBUS_WAKEUP_SOURCE(v) (v << 8) -#define MX6SX_USB_VBUS_WAKEUP_SOURCE_VBUS MX6SX_USB_VBUS_WAKEUP_SOURCE(0) -#define MX6SX_USB_VBUS_WAKEUP_SOURCE_AVALID MX6SX_USB_VBUS_WAKEUP_SOURCE(1) -#define MX6SX_USB_VBUS_WAKEUP_SOURCE_BVALID MX6SX_USB_VBUS_WAKEUP_SOURCE(2) -#define MX6SX_USB_VBUS_WAKEUP_SOURCE_SESS_END MX6SX_USB_VBUS_WAKEUP_SOURCE(3) +#define MX6SX_USB_VBUS_WAKEUP_SOURCE GENMASK(9, 8) +#define MX6SX_USB_VBUS_WAKEUP_SOURCE_VBUS 0 +#define MX6SX_USB_VBUS_WAKEUP_SOURCE_AVALID 1 +#define MX6SX_USB_VBUS_WAKEUP_SOURCE_BVALID 2 +#define MX6SX_USB_VBUS_WAKEUP_SOURCE_SESS_END 3 #define VF610_OVER_CUR_DIS BIT(7) #define MX7D_USBNC_USB_CTRL2 0x4 -#define MX7D_USB_VBUS_WAKEUP_SOURCE_MASK 0x3 -#define MX7D_USB_VBUS_WAKEUP_SOURCE(v) (v << 0) -#define MX7D_USB_VBUS_WAKEUP_SOURCE_VBUS MX7D_USB_VBUS_WAKEUP_SOURCE(0) -#define MX7D_USB_VBUS_WAKEUP_SOURCE_AVALID MX7D_USB_VBUS_WAKEUP_SOURCE(1) -#define MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID MX7D_USB_VBUS_WAKEUP_SOURCE(2) -#define MX7D_USB_VBUS_WAKEUP_SOURCE_SESS_END MX7D_USB_VBUS_WAKEUP_SOURCE(3) +#define MX7D_USB_VBUS_WAKEUP_SOURCE GENMASK(1, 0) +#define MX7D_USB_VBUS_WAKEUP_SOURCE_VBUS 0 +#define MX7D_USB_VBUS_WAKEUP_SOURCE_AVALID 1 +#define MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID 2 +#define MX7D_USB_VBUS_WAKEUP_SOURCE_SESS_END 3 #define MX7D_USBNC_AUTO_RESUME BIT(2) /* The default DM/DP value is pull-down */ -#define MX7D_USBNC_USB_CTRL2_OPMODE(v) (v << 6) -#define MX7D_USBNC_USB_CTRL2_OPMODE_NON_DRIVING MX7D_USBNC_USB_CTRL2_OPMODE(1) -#define MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK (BIT(7) | BIT(6)) +#define MX7D_USBNC_USB_CTRL2_OPMODE GENMASK(7, 6) +#define MX7D_USBNC_USB_CTRL2_OPMODE_NON_DRIVING 1 #define MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN BIT(8) #define MX7D_USBNC_USB_CTRL2_DP_OVERRIDE_VAL BIT(12) #define MX7D_USBNC_USB_CTRL2_DP_OVERRIDE_EN BIT(13) @@ -129,10 +126,8 @@ #define MX7D_USB_OTG_PHY_STATUS_CHRGDET BIT(29) #define MX7D_USB_OTG_PHY_CFG1 0x30 -#define TXPREEMPAMPTUNE0_BIT 28 -#define TXPREEMPAMPTUNE0_MASK (3 << 28) -#define TXVREFTUNE0_BIT 20 -#define TXVREFTUNE0_MASK (0xf << 20) +#define TXPREEMPAMPTUNE0 GENMASK(29, 28) +#define TXVREFTUNE0 GENMASK(23, 20) #define MX6_USB_OTG_WAKEUP_BITS (MX6_BM_WAKEUP_ENABLE | MX6_BM_VBUS_WAKEUP | \ MX6_BM_ID_WAKEUP) @@ -173,8 +168,8 @@ static int usbmisc_imx25_init(struct imx_usbmisc_data *data) switch (data->index) { case 0: val = readl(usbmisc->base); - val &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PP_BIT); - val |= (MX25_EHCI_INTERFACE_DIFF_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT; + val &= ~(MX25_OTG_SIC | MX25_OTG_PP_BIT); + val |= FIELD_PREP(MX25_OTG_SIC, MX25_EHCI_INTERFACE_DIFF_UNI); val |= (MX25_OTG_PM_BIT | MX25_OTG_OCPOL_BIT); /* @@ -188,8 +183,8 @@ static int usbmisc_imx25_init(struct imx_usbmisc_data *data) break; case 1: val = readl(usbmisc->base); - val &= ~(MX25_H1_SIC_MASK | MX25_H1_PP_BIT | MX25_H1_IPPUE_UP_BIT); - val |= (MX25_EHCI_INTERFACE_SINGLE_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT; + val &= ~(MX25_H1_SIC | MX25_H1_PP_BIT | MX25_H1_IPPUE_UP_BIT); + val |= FIELD_PREP(MX25_H1_SIC, MX25_EHCI_INTERFACE_SINGLE_UNI); val |= (MX25_H1_PM_BIT | MX25_H1_OCPOL_BIT | MX25_H1_TLL_BIT | MX25_H1_USBTE_BIT | MX25_H1_IPPUE_DOWN_BIT); @@ -308,8 +303,9 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data) reg = usbmisc->base + MX53_USB_CTRL_1_OFFSET; val = readl(reg) | MX53_USB_CTRL_1_UH2_ULPI_EN; /* select ULPI clock */ - val &= ~MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_MASK; - val |= MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_ULPI; + val &= ~MX53_USB_CTRL_1_H2_XCVR_CLK_SEL; + val |= FIELD_PREP(MX53_USB_CTRL_1_H2_XCVR_CLK_SEL, + MX53_USB_CTRL_1_H2_XCVR_CLK_SEL_ULPI); writel(val, reg); /* Set interrupt wake up enable */ reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET; @@ -338,8 +334,9 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data) reg = usbmisc->base + MX53_USB_CTRL_1_OFFSET; val = readl(reg) | MX53_USB_CTRL_1_UH3_ULPI_EN; /* select ULPI clock */ - val &= ~MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_MASK; - val |= MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_ULPI; + val &= ~MX53_USB_CTRL_1_H3_XCVR_CLK_SEL; + val |= FIELD_PREP(MX53_USB_CTRL_1_H3_XCVR_CLK_SEL, + MX53_USB_CTRL_1_H3_XCVR_CLK_SEL_ULPI); writel(val, reg); /* Set interrupt wake up enable */ reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET; @@ -551,8 +548,10 @@ static int usbmisc_imx6sx_init(struct imx_usbmisc_data *data) spin_lock_irqsave(&usbmisc->lock, flags); /* Set vbus wakeup source as bvalid */ val = readl(reg); - val &= ~MX6SX_USB_VBUS_WAKEUP_SOURCE(3); - writel(val | MX6SX_USB_VBUS_WAKEUP_SOURCE_BVALID, reg); + val &= ~MX6SX_USB_VBUS_WAKEUP_SOURCE; + val |= FIELD_PREP(MX6SX_USB_VBUS_WAKEUP_SOURCE, + MX6SX_USB_VBUS_WAKEUP_SOURCE_BVALID); + writel(val, reg); /* * Disable dp/dm wakeup in device mode when vbus is * not there. @@ -652,22 +651,23 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) if (!data->hsic) { reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); - reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK; - writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID - | MX7D_USBNC_AUTO_RESUME, - usbmisc->base + MX7D_USBNC_USB_CTRL2); + reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE; + reg |= FIELD_PREP(MX7D_USB_VBUS_WAKEUP_SOURCE, + MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID); + reg |= MX7D_USBNC_AUTO_RESUME; + writel(reg, usbmisc->base + MX7D_USBNC_USB_CTRL2); /* PHY tuning for signal quality */ reg = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG1); - if (data->emp_curr_control && data->emp_curr_control <= - (TXPREEMPAMPTUNE0_MASK >> TXPREEMPAMPTUNE0_BIT)) { - reg &= ~TXPREEMPAMPTUNE0_MASK; - reg |= (data->emp_curr_control << TXPREEMPAMPTUNE0_BIT); + if (data->emp_curr_control && + FIELD_FIT(TXPREEMPAMPTUNE0, data->emp_curr_control)) { + reg &= ~TXPREEMPAMPTUNE0; + reg |= FIELD_PREP(TXPREEMPAMPTUNE0, data->emp_curr_control); } - if (data->dc_vol_level_adjust && data->dc_vol_level_adjust <= - (TXVREFTUNE0_MASK >> TXVREFTUNE0_BIT)) { - reg &= ~TXVREFTUNE0_MASK; - reg |= (data->dc_vol_level_adjust << TXVREFTUNE0_BIT); + if (data->dc_vol_level_adjust && + FIELD_FIT(TXVREFTUNE0, data->dc_vol_level_adjust)) { + reg &= ~TXVREFTUNE0; + reg |= FIELD_PREP(TXVREFTUNE0, data->dc_vol_level_adjust); } writel(reg, usbmisc->base + MX7D_USB_OTG_PHY_CFG1); @@ -742,7 +742,7 @@ static void imx7_disable_charger_detector(struct imx_usbmisc_data *data) /* Set OPMODE to be 2'b00 and disable its override */ val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); - val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK; + val &= ~MX7D_USBNC_USB_CTRL2_OPMODE; writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2); val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); @@ -852,8 +852,9 @@ static int imx7d_charger_detection(struct imx_usbmisc_data *data) */ spin_lock_irqsave(&usbmisc->lock, flags); val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); - val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK; - val |= MX7D_USBNC_USB_CTRL2_OPMODE_NON_DRIVING; + val &= ~MX7D_USBNC_USB_CTRL2_OPMODE; + val |= FIELD_PREP(MX7D_USBNC_USB_CTRL2_OPMODE, + MX7D_USBNC_USB_CTRL2_OPMODE_NON_DRIVING); writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2); val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); @@ -926,9 +927,10 @@ static int usbmisc_imx7ulp_init(struct imx_usbmisc_data *data) usbmisc->base + MX7D_USBNC_USB_CTRL2); } else { reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); - reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK; - writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID, - usbmisc->base + MX7D_USBNC_USB_CTRL2); + reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE; + reg |= FIELD_PREP(MX7D_USB_VBUS_WAKEUP_SOURCE, + MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID); + writel(reg, usbmisc->base + MX7D_USBNC_USB_CTRL2); } spin_unlock_irqrestore(&usbmisc->lock, flags); From patchwork Tue Oct 18 10:37:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 13010237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4087FC4332F for ; Tue, 18 Oct 2022 10:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rux1aIBsnznYuyc8B+2Il6fOkLvWulHwQ6xzDPrMH3k=; b=K6iliugrw9WOFT uxM8MfG/WOa03Yx8p8HduLXW9Dtdc4MWEhSofZy7tmAk/H7c9OMYXjrLx/KUQlsHinKTOPNXaN4Oh tn/6pJbJ9xYFHezfPFc2UXZ7za4I/HrAc+iSQEEe9gUYjH+GgZjnsOWGI1V6KqUv718QVr4Co1Z6i 3TADZq/LeP9pWp6gpNrXCqGZvIrPOeYfTNpgw+SUhMCJYRP69cZGnxd0lZCCVpZ/nyWET7pv1Zdvr ObQzsUt3XubERuFI7OuoT9nwjxFFdAVixw1gIgztTHxfWYWtqHswAUFTTifsYluZLlPbbBqSkIQpQ K9VjuCUBZO+D91GU4SxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjz3-005Z3X-4L; Tue, 18 Oct 2022 10:38:05 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okjyb-005YyS-Ii for linux-arm-kernel@lists.infradead.org; Tue, 18 Oct 2022 10:37:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okjyU-0002Gn-Af; Tue, 18 Oct 2022 12:37:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1okjyS-002G1A-36; Tue, 18 Oct 2022 12:37:28 +0200 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1okjyQ-00BISB-US; Tue, 18 Oct 2022 12:37:26 +0200 From: Sascha Hauer To: linux-usb@vger.kernel.org Cc: Peng Fan , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, Xu Yang , Sascha Hauer , Xu Yang Subject: [PATCH v2 4/4] usb: chipidea: usbmisc_imx: Add prefix to register defines Date: Tue, 18 Oct 2022 12:37:25 +0200 Message-Id: <20221018103725.2580679-5-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018103725.2580679-1-s.hauer@pengutronix.de> References: <20221018103725.2580679-1-s.hauer@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221018_033737_680222_3EBD4B9A X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver is used for a broad range of i.MX SoCs and most of the register defines have a SoC/regname specific prefix to make clear in which context they should be used. Add such a prefix to the MX7D_USB_OTG_PHY_CFG1 defines as well. Signed-off-by: Sascha Hauer Reviewed-by: Xu Yang Link: https://lore.kernel.org/r/20221011082924.884123-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/usbmisc_imx.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 09979264958fc..4e8c7c4952f0b 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -126,8 +126,8 @@ #define MX7D_USB_OTG_PHY_STATUS_CHRGDET BIT(29) #define MX7D_USB_OTG_PHY_CFG1 0x30 -#define TXPREEMPAMPTUNE0 GENMASK(29, 28) -#define TXVREFTUNE0 GENMASK(23, 20) +#define MX7D_USB_OTG_PHY_CFG1_TXPREEMPAMPTUNE0 GENMASK(29, 28) +#define MX7D_USB_OTG_PHY_CFG1_TXVREFTUNE0 GENMASK(23, 20) #define MX6_USB_OTG_WAKEUP_BITS (MX6_BM_WAKEUP_ENABLE | MX6_BM_VBUS_WAKEUP | \ MX6_BM_ID_WAKEUP) @@ -659,15 +659,19 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) /* PHY tuning for signal quality */ reg = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG1); if (data->emp_curr_control && - FIELD_FIT(TXPREEMPAMPTUNE0, data->emp_curr_control)) { - reg &= ~TXPREEMPAMPTUNE0; - reg |= FIELD_PREP(TXPREEMPAMPTUNE0, data->emp_curr_control); + FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_TXPREEMPAMPTUNE0, + data->emp_curr_control)) { + reg &= ~MX7D_USB_OTG_PHY_CFG1_TXPREEMPAMPTUNE0; + reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_TXPREEMPAMPTUNE0, + data->emp_curr_control); } if (data->dc_vol_level_adjust && - FIELD_FIT(TXVREFTUNE0, data->dc_vol_level_adjust)) { - reg &= ~TXVREFTUNE0; - reg |= FIELD_PREP(TXVREFTUNE0, data->dc_vol_level_adjust); + FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_TXVREFTUNE0, + data->dc_vol_level_adjust)) { + reg &= ~MX7D_USB_OTG_PHY_CFG1_TXVREFTUNE0; + reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_TXVREFTUNE0, + data->dc_vol_level_adjust); } writel(reg, usbmisc->base + MX7D_USB_OTG_PHY_CFG1);