From patchwork Thu Jul 9 10:59:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11654203 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C06913B1 for ; Thu, 9 Jul 2020 11:00:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73FA62074B for ; Thu, 9 Jul 2020 11:00:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pTo/q0h9"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="D2k19YUU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73FA62074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=X+fSTNiuor86hVe4aGFoZQ0RxJihXsCjr1YX+PyxX2c=; b=pTo/q0h9AhXWUFYcXopqKEVyU 6bVg8QK6xRW2Ap5lxc0jA2zFggT7YxM8vUxZz2uIVo1noXzIJfKngD54p83zWxz/W0RH7vNjfiUbq lz5iunR7xxi6QXSc1rmeI6qVTDOp+isRBr2EebF6g+qVTLY3WSRwnTUOlbVH2E99lMG5H/wFxokxi WHMT/HJDlyEDY8M606nF33lhb94QyyAyMMLyt+nLWMfLorMgfI6wX1MzAANz9hO/WI2wo+xFp9pOw 0hzWgewOJJvBnBMuYkbZYs6Wz57VlK340aCNRO4G2t0DAfa2WZLcwIFgBKext5iFS3odBT3TAipL5 H0qnUuIfA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtUGv-0003wu-MW; Thu, 09 Jul 2020 10:59:22 +0000 Received: from mail-eopbgr10065.outbound.protection.outlook.com ([40.107.1.65] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtUGl-0003sV-1P for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2020 10:59:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J4yFClCDLjDddCm4ll9JZGUQdIPQkOxGVxBPQHXifi8jbSK2bV1F00fYATlDd5XnCiWTzJsSxdXvaYM0QVlwnh3AFvBYLYV0lHyHitNoZ1MF6LaoZcdh8lrroXy3LqPZjL3IqKXecuDxY344coUcUfZa9TLV1FHsdXipDHzhsb+jPhft29hriT6S/XSyuBBP+KSLmt2GAh8GitGK/81eqrXrt2b3RswKyUoPUw3329nhb9bMGY7RIn2Nw5VACTsjIIAaFSdypaN46VYyrCeN6P9IOBuND10u+syTI9jXHmUJq4p097GVu3BqBAmLgW+lE4mrX8vA0XoLp50ZVzeYrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K6ePAqO/Bblr9Z0zJ3Tp+7SYqquWNtP74rVxcu0Noj8=; b=A+SPG69KcESZZDRcrcRuVvw7Bp7uuBDQAbgALH42oc6ELzo+/7nq8/5AD1v/9Ic/M7QPKpaoFGNueKB+pDDq3Scpfw59+ZZnaSTfZGcHXLzsuD01hWV9dHsBaFiGhij6ADGP9LJzh3NuFAE+uKgHMGF4SUc5Zx6rhmljFG8ob9xvU6AyxVbjx1xRZyKng3V2NFLlVwwo/yrYyv7oOjtKnZRd7A4k5O4Z6FAiJU11D7M1KqFvq2wTodsgcKVeMSHVOkY4i3YvmKxF+zSNVVL4x+wEBl0eVNZEzMSj9ELwriO0l73pOOsja+KwWhCG22kgbGn6dAKpW1YrUhOp1Mm7pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K6ePAqO/Bblr9Z0zJ3Tp+7SYqquWNtP74rVxcu0Noj8=; b=D2k19YUUxviCWgvfj8YXVSNaMtQ6+uQkaqSR3FNv+Ejbwx2dsUWAcD8xVN294MfITMFjIPNx0IDte77Q7gemMRc/HEvL8g7RW8va4TVfzeRH+QRMCeMScKHVS27tYVqK9nEpkgf08wIRCTd9RsA9mM9hMnkfs1KD4pE4Tne0Vyc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM6PR04MB4982.eurprd04.prod.outlook.com (2603:10a6:20b:5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Thu, 9 Jul 2020 10:59:08 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3174.022; Thu, 9 Jul 2020 10:59:08 +0000 From: Peter Chen To: shawnguo@kernel.org, robh+dt@kernel.org Subject: [PATCH 2/4] usb: chipidea: imx: add two picophy parameters tuning implementation Date: Thu, 9 Jul 2020 18:59:00 +0800 Message-Id: <20200709105902.23165-2-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709105902.23165-1-peter.chen@nxp.com> References: <20200709105902.23165-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.67) by SG2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:3:1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Thu, 9 Jul 2020 10:59:05 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bdbb9b6d-f8f8-41d2-b17d-08d823f71a9a X-MS-TrafficTypeDiagnostic: AM6PR04MB4982: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yfUz+zZon/09pMA39NleO5Q5/YnMpNWj2/2oZ6VPUZ/ovF1Wsx8ucwQlTffLbiAqEKHWriUaPBYA9YfslA6Ds0bzHW6GUfJU+1N0l106msA2/pI2ZwdPfvLM6lD4fn65ga7Dk7sZweUZttSfaXd7vtNNxlQAKXZIjSH7elHYI3U1Myf1WdMIo6OJSP2AgUi6PGdGVJJ3v3YUrm3gR2/wi3eWqcSQ/DLrYuIzdNeEBkQqo2oPeXqc8pr+TWv4eQ/2bqH9RKTjaqxqnaxuVO45ZCPw0QoEOEcBCVPJYtVjc5gsOfKHILjYoPPY6TyziEIn X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7157.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(39860400002)(376002)(136003)(346002)(366004)(2906002)(36756003)(478600001)(83380400001)(8936002)(5660300002)(6486002)(2616005)(86362001)(186003)(66556008)(956004)(16526019)(66476007)(4326008)(26005)(66946007)(1076003)(316002)(6666004)(6512007)(6506007)(52116002)(44832011)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: X9AT6uNEZlaYDg3L9Vy9oqcR9ZqsC43aGvbqjkufoxmBxFnLpQouAMEZSAAEnc/4X7digLhsSrNs/RhwrHN19THukLdYTrmGvM4oe8SNbdMvBUluxCPo8gLnjxSkS9bmbW9WVyvmxs7JBhQBxr0ufaGiChO4DThFW+LyKFRU5kXUWCoaCzUk+XoKzNNFF9lcrvktPwXuMkBNBflK8XO/RCYa4T3b8wW9BzURS9C/RXjCnjceuvGiYab7ii6R+rF1Az2K1rNs4Au1rzDWpGzOfqtaJOWLEZrpKxnZFDA8i7+rSYwwzIuTXJag2zztEp/gS6JsRXBKS8VjLVnxWtv9i2IXujrhHlAboMQmPUeh0WChkKj8CPUOFOV5KxDkCcxDToB3XaiTb8Iy5NFlOnQZYCqq7c4XdEWTj+QfDlO3Uoh4A3jawxToqYy4nLra9DQxTFjeEK7B+NJBJhp9gohj3ZNzDDJehptXSFh0JSAYI+M= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bdbb9b6d-f8f8-41d2-b17d-08d823f71a9a X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7157.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 10:59:08.5305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SGrDXe8tZi73Pwio7XiEZUYlUUciPtTKhBuLILy54vNBcdwaRu892YpmJgjAzGXj7udU4t2GrI6iNZu4qPTUsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4982 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200709_065911_147129_BC3DDAD9 X-CRM114-Status: GOOD ( 14.20 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.1.65 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.1.65 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Peter Chen , linux-usb@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, fabio.estevam@nxp.com, linux-arm-kernel@lists.infradead.org, jun.li@nxp.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org These two parameters are used to improve USB signal for board level, in this commit, we read it from the dtb, and write to related register during the initialization. Signed-off-by: Peter Chen --- drivers/usb/chipidea/ci_hdrc_imx.c | 5 +++++ drivers/usb/chipidea/ci_hdrc_imx.h | 2 ++ drivers/usb/chipidea/usbmisc_imx.c | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 5ae16368a0c7..58de0f3ac0e9 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -165,6 +165,11 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) if (of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) data->ulpi = 1; + of_property_read_u32(np, "picophy,pre-emp-curr-control", + &data->emp_curr_control); + of_property_read_u32(np, "picophy,dc-vol-level-adjust", + &data->dc_vol_level_adjust); + return data; } diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h index 727d02b6dbd3..367bb0d0cb6b 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.h +++ b/drivers/usb/chipidea/ci_hdrc_imx.h @@ -25,6 +25,8 @@ struct imx_usbmisc_data { unsigned int ext_id:1; /* ID from exteranl event */ unsigned int ext_vbus:1; /* Vbus from exteranl event */ struct usb_phy *usb_phy; + int emp_curr_control; + int dc_vol_level_adjust; }; int imx_usbmisc_init(struct imx_usbmisc_data *data); diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index f136876cb4a3..f9881aed468f 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -128,6 +128,12 @@ #define MX7D_USB_OTG_PHY_STATUS_VBUS_VLD BIT(3) #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 MX6_USB_OTG_WAKEUP_BITS (MX6_BM_WAKEUP_ENABLE | MX6_BM_VBUS_WAKEUP | \ MX6_BM_ID_WAKEUP) @@ -649,6 +655,21 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) writel(reg | MX7D_USB_VBUS_WAKEUP_SOURCE_BVALID | MX7D_USBNC_AUTO_RESUME, 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->dc_vol_level_adjust && data->dc_vol_level_adjust <= + (TXVREFTUNE0_MASK >> TXVREFTUNE0_BIT)) { + reg &= ~TXVREFTUNE0_MASK; + reg |= (data->dc_vol_level_adjust << TXVREFTUNE0_BIT); + } + + writel(reg, usbmisc->base + MX7D_USB_OTG_PHY_CFG1); } spin_unlock_irqrestore(&usbmisc->lock, flags);