From patchwork Thu Feb 1 12:12:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 13540953 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0210A160866; Thu, 1 Feb 2024 12:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789550; cv=none; b=V9/tTwodrc50ES3QzRZenZPMTl0HKst3J1QVmpa/EuXrvk4/jK46Wytf+48fb9PMYhWPsVyW5wbmQj3YRHsezrPfZHg/2qnyBqpD3eldDCXmn7uWKS7O/Mecu9wq/LCdzx50E2R9Uw01xSCilOahUcOj2NxiqGDCdfA0dKdyTkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789550; c=relaxed/simple; bh=1vbfNovCyxvWc1PBLYclGrDiXSIWmEZA5YvornwGSpI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=inP2K4ZeiDJjpbQwoPQo/Yd9AFe31snr25/c3r4aclVxufD2j1jt3Ew9gpJxQ8n0F7ljVfJPgKVMl/BmobU1KEhYySz+OGyU+HkN4QEzr/GZXzVNf3wfwC6Lz8ve7ImGnaWAL9MhijKjbRPIFEV79IYTPGxT2C8EYsGgyO9gXD8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=do8gZS2U; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="do8gZS2U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86E5AC433C7; Thu, 1 Feb 2024 12:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706789549; bh=1vbfNovCyxvWc1PBLYclGrDiXSIWmEZA5YvornwGSpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=do8gZS2U9kvnSFjL9B0q0/fwnJAocRkD4uK1LgS1keLJMDw9mm8X9zfEHzXqWgkZj NrenoEnFL1lKPRX7kHcX08wyiWcjZX0a4SGQZmrcYD4CkbHs64sHBCG4NZesHGAi3f gwrmsyVvRDriufzGHZ6RDpukpAcTmn5kWrV5DrY2WA7NNFYQhvfo/tcUTmsUZdeQcp Q77Z+lucpbAmGiwAVTNSl8bZ3G6l0ky6X8bISZw4MYsHum2eAwM/br6Ivccxp+6RJj 5Ndo3JCeni0wE4vZvPa3tYZ8Obl+hmBlrHetEkZ9IQYU305dWqQxo6UtDaqy3h7EV0 34I4wIbNxAqmQ== From: Roger Quadros To: Thinh.Nguyen@synopsys.com Cc: gregkh@linuxfoundation.org, r-gunasekaran@ti.com, b-liu@ti.com, srk@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 1/4] usb: dwc3-am62: call of_platform_depopulate in .remove() Date: Thu, 1 Feb 2024 14:12:17 +0200 Message-Id: <20240201121220.5523-2-rogerq@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240201121220.5523-1-rogerq@kernel.org> References: <20240201121220.5523-1-rogerq@kernel.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We called of_platform_populate() in .probe() so call the cleanup function of_platform_depopulate() in .remove(). Get rid of the now unnnecessary dwc3_ti_remove_core(). Signed-off-by: Roger Quadros --- drivers/usb/dwc3/dwc3-am62.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c index 90a587bc29b7..1bfc9e67614f 100644 --- a/drivers/usb/dwc3/dwc3-am62.c +++ b/drivers/usb/dwc3/dwc3-am62.c @@ -267,21 +267,13 @@ static int dwc3_ti_probe(struct platform_device *pdev) return ret; } -static int dwc3_ti_remove_core(struct device *dev, void *c) -{ - struct platform_device *pdev = to_platform_device(dev); - - platform_device_unregister(pdev); - return 0; -} - static void dwc3_ti_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct dwc3_am62 *am62 = platform_get_drvdata(pdev); u32 reg; - device_for_each_child(dev, NULL, dwc3_ti_remove_core); + of_platform_depopulate(dev); /* Clear mode valid bit */ reg = dwc3_ti_readl(am62, USBSS_MODE_CONTROL); From patchwork Thu Feb 1 12:12:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 13540954 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C87A16088F; Thu, 1 Feb 2024 12:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789552; cv=none; b=H8Yhtzmtudn0sflidhGiJpYnn7kJKZBvRxLGLhrjZwqRMG+k2oxTODwJ+TfF1nwdarGbU+gXRpMZzqj+EhjbAjgEkVRmC4O2+kmMm58FNTIxcuZrNii9AusflXDx03ksosquDZZ5inE+FXrgZRvX10HdWdOVv42I0ajdFvju4k8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789552; c=relaxed/simple; bh=U0KOgz6nOgOjNNhuSJI9UM8ClADua2irwTRLMiXXge0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g3SMPx8SCp6L68FwZj2HvF+PPubKmrtw4ABnixr0NL6fSHgFhpfsGk/nyP6/N9QXwvNcuIT2rexwvJlrKkvcnkSSXTqLQ+5vknLYfhKTvqbvCLYxxtmLIefi+tnWzEHZCvbHRM92Jn4Ldvvdy+DItZErbi45fZqoCMBTWJUoZQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=urvYrxUW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="urvYrxUW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 119FEC43399; Thu, 1 Feb 2024 12:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706789552; bh=U0KOgz6nOgOjNNhuSJI9UM8ClADua2irwTRLMiXXge0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=urvYrxUWsMAFZTUvGyLBQVD3pWRgURGRXvf8giZcgNy4TQ8rhNMfJPHktBC0RXDzH 288iRyPCfec97Ogu5T12whCkNPH9UtbHJpYYhZRjZnotrOZsoxHotS+5Iw1Hl5fun6 4Uhnbrb+U03wYPhQQH+CBcAoVFQIi6ezE1C3au44gThPiGc4jPe008PPoQhP76BQ2i Jn/acVTuhMClwChUy0zJEm5jPwQPcvj8e/pnXa+Ay6jIn04nAZWQslJLUpkBEVKWjn 0ZmiGwJxtYVs5Lor46tD7eMVzhJ9K1Dd0V7fSDoBAlfxM9F4PqPrWalc21jLUy8w4e o5tynXZTmYGJQ== From: Roger Quadros To: Thinh.Nguyen@synopsys.com Cc: gregkh@linuxfoundation.org, r-gunasekaran@ti.com, b-liu@ti.com, srk@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 2/4] usb: dwc3-am62: fix error on module removal Date: Thu, 1 Feb 2024 14:12:18 +0200 Message-Id: <20240201121220.5523-3-rogerq@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240201121220.5523-1-rogerq@kernel.org> References: <20240201121220.5523-1-rogerq@kernel.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As runtime PM is enabled, the module can be runtime suspended when .remove() is called. Do a pm_runtime_get_sync() to make sure module is active before doing any register operations. Doing a pm_runtime_put_sync() should disable the refclk so no need to disable it again. Fixes the below warning at module removel. [ 39.705310] ------------[ cut here ]------------ [ 39.710004] clk:162:3 already disabled [ 39.713941] WARNING: CPU: 0 PID: 921 at drivers/clk/clk.c:1090 clk_core_disable+0xb0/0xb8 Signed-off-by: Roger Quadros --- drivers/usb/dwc3/dwc3-am62.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c index 1bfc9e67614f..600ba9cfefea 100644 --- a/drivers/usb/dwc3/dwc3-am62.c +++ b/drivers/usb/dwc3/dwc3-am62.c @@ -273,6 +273,11 @@ static void dwc3_ti_remove(struct platform_device *pdev) struct dwc3_am62 *am62 = platform_get_drvdata(pdev); u32 reg; + pm_runtime_get_sync(dev); + + device_wakeup_disable(dev); + device_set_wakeup_capable(dev, false); + of_platform_depopulate(dev); /* Clear mode valid bit */ @@ -281,7 +286,6 @@ static void dwc3_ti_remove(struct platform_device *pdev) dwc3_ti_writel(am62, USBSS_MODE_CONTROL, reg); pm_runtime_put_sync(dev); - clk_disable_unprepare(am62->usb2_refclk); pm_runtime_disable(dev); pm_runtime_set_suspended(dev); } From patchwork Thu Feb 1 12:12:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 13540955 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5C44160899; Thu, 1 Feb 2024 12:12:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789554; cv=none; b=YD52ayZpGpU4uG5RQmtnujtYJCQPW7oQRLWMhA6p0/HYj1LcGCGFlRxfmzHf7HfVrIsW8cFnOKJT0UHuKL9blB7I0WTwDM5OMSrj5hvmJu1wVg/ceFA+Y8qsOhKEzyjGwrqIl4wZcUwrojN2YTbaHQAXiixTJYQQDwWFA3IEw50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789554; c=relaxed/simple; bh=Qfbq+sSZxjAM/hD8kTbPYklUiveqLxLWC3K9/YiS0nA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WCSRILlNeAe+IzncV6r2a/9LSViEAlw6AVkmH3w7z6FT8NLTwIWZOkXXjmCWdRumhD2+0TwZTVJiXIn9DL2n4xpIWDe69jK/uwlME2VI2ljYRNqCXd6aKwqV38C43x1hWMYT5mc2Fd2q6CBthMbQ6WzS43Lab+KmFDT5uJbTdzU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z476S7EF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z476S7EF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91FCAC433F1; Thu, 1 Feb 2024 12:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706789554; bh=Qfbq+sSZxjAM/hD8kTbPYklUiveqLxLWC3K9/YiS0nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z476S7EFyvaNHyNGCa3WqeFNbLqRxCzcnu5y+ulWZ3GlLGBKVnFxa2yremgbIkQFt OpNscSzEANRIH3vI7cTo8XXbSZb5nMCgHsCreqla9060r5IlAVc3iL/SZ0frpc/LFa oFTRQs9m+RSz+TepjBeqUJioiO1StzsCmQzjOMGpViBgq+Zwf/lwv2fTqILUFwFBrm q+uWKkEhwewRrgWfLv53uLqzDuQ8wGEcldlNzwfBWcoru7LpUxp9vhbNf+R0qJQZzE afsK8CvHj20puC6AuQKKl1kD8HPYmA6M9HSa6GZh9pcXljFoqln5zpZKFx5TGfUjJv JANEIODaR8VMQ== From: Roger Quadros To: Thinh.Nguyen@synopsys.com Cc: gregkh@linuxfoundation.org, r-gunasekaran@ti.com, b-liu@ti.com, srk@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 3/4] usb: dwc3-am62: Fix PHY core voltage selection Date: Thu, 1 Feb 2024 14:12:19 +0200 Message-Id: <20240201121220.5523-4-rogerq@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240201121220.5523-1-rogerq@kernel.org> References: <20240201121220.5523-1-rogerq@kernel.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 TRM information is outdated and design team has confirmed that PHY_CORE_VOLTAGE should be 0 irrespective of VDD_CORE voltage. Signed-off-by: Roger Quadros --- drivers/usb/dwc3/dwc3-am62.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c index 600ba9cfefea..af1ce934e7fb 100644 --- a/drivers/usb/dwc3/dwc3-am62.c +++ b/drivers/usb/dwc3/dwc3-am62.c @@ -97,7 +97,8 @@ #define USBSS_VBUS_STAT_SESSVALID BIT(2) #define USBSS_VBUS_STAT_VBUSVALID BIT(0) -/* Mask for PHY PLL REFCLK */ +/* USB_PHY_CTRL register bits in CTRL_MMR */ +#define PHY_CORE_VOLTAGE_MASK BIT(31) #define PHY_PLL_REFCLK_MASK GENMASK(3, 0) #define DWC3_AM62_AUTOSUSPEND_DELAY 100 @@ -162,6 +163,13 @@ static int phy_syscon_pll_refclk(struct dwc3_am62 *am62) am62->offset = args.args[0]; + /* Core voltage. PHY_CORE_VOLTAGE bit Recommended to be 0 always */ + ret = regmap_update_bits(am62->syscon, am62->offset, PHY_CORE_VOLTAGE_MASK, 0); + if (ret) { + dev_err(dev, "failed to set phy core voltage\n"); + return ret; + } + ret = regmap_update_bits(am62->syscon, am62->offset, PHY_PLL_REFCLK_MASK, am62->rate_code); if (ret) { dev_err(dev, "failed to set phy pll reference clock rate\n"); From patchwork Thu Feb 1 12:12:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 13540956 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDF1D161B6E; Thu, 1 Feb 2024 12:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789557; cv=none; b=WCxQUxyw7p2t2bVJFRpBX/MZ8ChDK3qetbmfNIAjOYwBpm3Vyl/SxOahtQAck0O6li4Y3dIcEHTi3r57OkJ+Fi2Phjtyt9Ua2m/A8acMHsQApfEVX9NmY9CNCb5CVSbW2tyK2sUHELZjkzHzKyzNt0947gzu64PDShVOxr6Gk58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706789557; c=relaxed/simple; bh=ENALJ+0xsMIiiXqnLcbkuuaHj/9Uu77rAWI6PeJZuEc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qA51ydCoiBN12cLs7zu0+s5SgI1RaQHklyltMs92ywZjwkkcT4kdD7MWm984S9/2LXr/6Mktgn6KjDr4VbYF0EP7H773SrVY6rWc3Uop5O4BLPU/fCBSdVGQBCUDeCRTmUzvQuuDukMpjczpLHCbB6fVlof137Cyr4hv72s0CAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ts9C4TN7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ts9C4TN7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43B8EC43394; Thu, 1 Feb 2024 12:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706789557; bh=ENALJ+0xsMIiiXqnLcbkuuaHj/9Uu77rAWI6PeJZuEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ts9C4TN78P1HEMN2kCav6hkD9vQFUJa0dzInFOV55bhGr5OVukk8Vtrs/Wfz0gFEl GaxVX60eDEIFMxxdUEY9d3fvdRdax5AmNQ5Rn7QKesF/GYVC7UDNrDVNtQyMPtRmVY ps8TG4Aiy9vRzwn7zfkqET4Bk0QIOft50VytiBEwSmPxwVakRA6ehy5R31nTBx9LBe /vcwmfZoZC9t/BwW1qPfodrgZDMCnz3K2a8EZrJKYwjpiOToS3XWX3de7A46aAxLQ2 cln5KPtVr3ZlQ7KvLuCDelxoi7EN9O0ebGcnCsrypfKqcTvMh5kLaB8ijEuCRUmfOz +iycFlHXnXG7Q== From: Roger Quadros To: Thinh.Nguyen@synopsys.com Cc: gregkh@linuxfoundation.org, r-gunasekaran@ti.com, b-liu@ti.com, srk@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH 4/4] usb: dwc3-am62: add workaround for Errata i2409 Date: Thu, 1 Feb 2024 14:12:20 +0200 Message-Id: <20240201121220.5523-5-rogerq@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240201121220.5523-1-rogerq@kernel.org> References: <20240201121220.5523-1-rogerq@kernel.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All AM62 devices have Errata i2409 [1] due to which USB2 PHY may lock up due to short suspend. Workaround involves setting bit 5 and 4 PLL_REG12 in PHY2 register space after USB controller is brought out of LPSC reset but before controller initialization. Handle this workaround. [1] - https://www.ti.com/lit/er/sprz487d/sprz487d.pdf Signed-off-by: Roger Quadros --- drivers/usb/dwc3/dwc3-am62.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c index af1ce934e7fb..35d7a2fb128e 100644 --- a/drivers/usb/dwc3/dwc3-am62.c +++ b/drivers/usb/dwc3/dwc3-am62.c @@ -101,11 +101,17 @@ #define PHY_CORE_VOLTAGE_MASK BIT(31) #define PHY_PLL_REFCLK_MASK GENMASK(3, 0) +/* USB PHY2 register offsets */ +#define USB_PHY_PLL_REG12 0x130 +#define USB_PHY_PLL_LDO_REF_EN BIT(5) +#define USB_PHY_PLL_LDO_REF_EN_EN BIT(4) + #define DWC3_AM62_AUTOSUSPEND_DELAY 100 struct dwc3_am62 { struct device *dev; void __iomem *usbss; + void __iomem *phy; struct clk *usb2_refclk; int rate_code; struct regmap *syscon; @@ -140,6 +146,16 @@ static inline void dwc3_ti_writel(struct dwc3_am62 *am62, u32 offset, u32 value) writel(value, (am62->usbss) + offset); } +static inline u32 dwc3_ti_phy_readl(struct dwc3_am62 *am62, u32 offset) +{ + return readl((am62->phy) + offset); +} + +static inline void dwc3_ti_phy_writel(struct dwc3_am62 *am62, u32 offset, u32 value) +{ + writel(value, (am62->phy) + offset); +} + static int phy_syscon_pll_refclk(struct dwc3_am62 *am62) { struct device *dev = am62->dev; @@ -201,6 +217,12 @@ static int dwc3_ti_probe(struct platform_device *pdev) return PTR_ERR(am62->usbss); } + am62->phy = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(am62->phy)) { + dev_err(dev, "can't map PHY IOMEM resource. Won't apply i2409 fix.\n"); + am62->phy = NULL; + } + am62->usb2_refclk = devm_clk_get(dev, "ref"); if (IS_ERR(am62->usb2_refclk)) { dev_err(dev, "can't get usb2_refclk\n"); @@ -227,6 +249,13 @@ static int dwc3_ti_probe(struct platform_device *pdev) if (ret) return ret; + /* Workaround Errata i2409 */ + if (am62->phy) { + reg = dwc3_ti_phy_readl(am62, USB_PHY_PLL_REG12); + reg |= USB_PHY_PLL_LDO_REF_EN | USB_PHY_PLL_LDO_REF_EN_EN; + dwc3_ti_phy_writel(am62, USB_PHY_PLL_REG12, reg); + } + /* VBUS divider select */ am62->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); reg = dwc3_ti_readl(am62, USBSS_PHY_CONFIG);