Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp125582rdb; Thu, 1 Feb 2024 04:15:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFcASLnXD1XcFRJM3toVQDQvnbqkVnB7N+69NPeJJfmAgt6ikOUVaVw1E8il/bHnpfVQYE X-Received: by 2002:a17:902:eac6:b0:1d9:4834:e1b8 with SMTP id p6-20020a170902eac600b001d94834e1b8mr1831271pld.33.1706789738809; Thu, 01 Feb 2024 04:15:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706789738; cv=pass; d=google.com; s=arc-20160816; b=v9OGrzeOonFSSOYjeHSRLtPHlI1RFHau+mPkhyB8YpTygB0/QJ3hx/0JNVR7e7B8k5 94A9zraXReQ9Orywk7peJMRz3SUXeRuqksemEgLIrR597D51lY2ymlO0AtMZ3OUOc+qf 6Qb8KpoW/EcAGEYnERpdJJXK0Dd83F0adrGkA0HONkUY/TCgQdSw36sQUDlWwqEr3fuV NyRMASXYQyloHCD6v0UD3kDpm1ccDBs2TN7qJOqgpF43msCmzeoQXZ+xfa9sHh9zSED5 CoVMMiCQn5cDw0i/wllNcIyfPyT1OkJ68a12ojDeqX65KCAogwAXhrE38xD2k37Tt4ow EPJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=IAsYpujapfH/+CoAyKMLk6KZVFZ7ztr5lL8ONia7HbA=; fh=YGpA0YruClSh/oZyJystQ0/l7CnEaNX8wzTRRsFiOlE=; b=FWYYGkaAD4ij5/z8F5V8L5Qg2TG75xKpvqt1r2Simwtn2E7i/5VPNoC1IUY08q1EvX ebtPuY8vn0aZ/xtEybutrUNG5raeUVOxz7j4pd69UzHVwzkuWOqOc/I5vp/LEo4vYzNa 0gUYoxsZM8LBC+DH/pPTzxNPQQgJXjfjGjWWgrW9dm20IRXMw1Qt2jejHmUCzt+Xf+3D fC7CnA5Jq0wMJQmazu3xeui0roDdsakXCkZampSdpqz6nQGt4Bo+2Kgu9DXtMbUXcVFN cJq0YUiNPXNqbFXHuqyGSgNJOUxqotGh7Fpyg0re1N0gbEineULJPtomN4uJx3qQSr4w UigQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ts9C4TN7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXysCuvW8YdAI684VaGmZJQkElz9l0nJNQ+a6bNrLJ/vw1zf9Q6dxhDCllwp76xwZrWbB0zAUWOJiA3wKkyEe+phOUsnHRlRJOOqvVBbA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k18-20020a170902c41200b001d8d6c3762fsi8729604plk.374.2024.02.01.04.15.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:15:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ts9C4TN7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 00F7E28246C for ; Thu, 1 Feb 2024 12:14:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99F4B163A82; Thu, 1 Feb 2024 12:12:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ts9C4TN7" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.34.1