From nobody Sun Feb 8 07:58:26 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C59AD32AAA5 for ; Tue, 23 Dec 2025 09:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766483143; cv=none; b=jVztnacNrND4tNjns03PQV2T5aQF7qLGauRfvJJJD9UJUUInE2SJH1mlLNcsgWBWW/lMNJS5/P/2THlZII/LapYTny48P35LCYd6DmWBXUhredE0ZUOvOM9ZReL0KSeSKuII9lUUfrqwbFU2s/z2eKyBhalQ0TLppepuhGYdtFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766483143; c=relaxed/simple; bh=DKeetzW3ONgxZzrSbR0sHWi+YgHN+BQmgsjoHD3eC64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pRQDk6nb9Ql7utEHjZt8H8i65dSPjvjq6LrjRQkQU8OMXmEwdghIVxL1oycgzhdgTuJyugAgzu3W7Uj5gBL/PBWKJpJ5QIkOYIil1rngMTDb5/DOz7Zrvanrk9Gu7fR3Pky8MNXCIJM331r5PvwRravlT8D8qL1Kgc0y8Nl7l50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j+QInOhJ; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j+QInOhJ" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-430f3ef2d37so3578126f8f.3 for ; Tue, 23 Dec 2025 01:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766483140; x=1767087940; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d4gxDi6v3H2DADeHS72LcwIC06VwKI575ueVFsSjhfU=; b=j+QInOhJSE8fbnpMSJSMVtWsb6AhsPwNpiK/HAVbz7t8/wFMDLxWOpCNjVQmvPkgvw GorloCZ1Pt/GIhrP24PLgbOC0DskbZF9p1gCr4O9ey3uiIpFmIBwLI24hq4OZbQjkTOm mQpdgA3E4vMCToVoIAivu5vdQh5qdjf0Ho9CWuScvy4Om1e1snl3rXGfHxZ/duUrIrrV FviR44dE375y1+S687vsQ7VltBh7ZjBUpp6VhLWxDIxiPzRzDMo9MinokcUnJzBr/Gz6 tmJn1ImyKqlWLEulV7U5+Qg4U1tJtxUYBfRJXa6Irki4Kkaa3XvIR+mHCrL/MmnwV09z 9ARg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766483140; x=1767087940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=d4gxDi6v3H2DADeHS72LcwIC06VwKI575ueVFsSjhfU=; b=jNuRbHAkxSUgUn0uFWqUM26/sr2j2iyY/uvbIIMIq2nlsvyEYoJ8jAoL7oBm0wUnCi GmXnwmK0R1nuZsX8BZSVI7EL3gDpMOZN6pXcYrqv4Beww+516hG6/TfRwaiJYTVprhgT JSpjiyV2ONkSrIKFkHk5TyAUJU8ZgLRJBRm8BbJoL91YMGTEPtKp8U9ZderHu9eABDoN l5h+yM9OYuiK0oPA2DmV7NMUXt5t68FVssCeOVopD9DrSnmmS63CaIrvzu+ubtq7i3XJ 7V3Lqskh6CDfFw7DfOdEB2jQZwM9OOByVArOAR8AHnP5FkkS5GdcyQIK5V/AihEIxXwL IJyQ== X-Forwarded-Encrypted: i=1; AJvYcCXhwRj4Zue7sZIDioe2fp6pJT+HGrLbO6i8NogPMHMolg3FFAfB5iI+Ja41v+xXzafK0bvfYVHjPYU5KjY=@vger.kernel.org X-Gm-Message-State: AOJu0YyRPf8lbkEE6uE2ekQQqRf/A+QlzI+xR+DUh9lUJSw90Ph3M8uM z4CHdBAog7XK3PEfvpSTto0ElqooTkDxy8qoUCN9lzHUBN3sRaD08DYL X-Gm-Gg: AY/fxX4EFa9EBMAKyaOMDlOR/APfXJB3sgqQgjTmxiDz5LLUsn5RcED6sa6XAk7ECe7 kQlKdbFk4QHaZ3s/bgjifGcMJK+sEWqauINETUoLdTqfybyxuhCEhGzspLUrYrU1vLdGnN8Fr4u +osC4RyDPUmQaLr5OQV7FVTY8XvI4u94hkjVJIPW5S5+rUf7SfjJSVk0QqEzDh7Q71/Xa9VHotz bV3yU45mDidrOUxiDRYldR/bBIQCe4x8rUPUwlLdo8BJ+9aID6ac9mAkZNZ1dDwjCiOzJZr1kMI InJDUaJwWGheM9fuIchnZ4Rya/OLbSAWopDmjl0W2iAH1PGfadttFR5LHo8ehXvUk3DqKjYv6aW jHSmZ5MIHxXN7muByKv91bWCFMlQ2zE4qX3A+ThRlSn+qg6ZCu569re5sCdDVxz5RunqnvNkQ4t ln X-Google-Smtp-Source: AGHT+IGjtntSpEM/XfblJzXJtwYQ7LvnZlKwUDhjMjjIEG2BTcu9fpyPlUzavrUxiMQLMRU/++RUmg== X-Received: by 2002:a05:6000:2586:b0:430:fcda:452d with SMTP id ffacd0b85a97d-4324e4cbd79mr15227367f8f.22.1766483140047; Tue, 23 Dec 2025 01:45:40 -0800 (PST) Received: from xeon ([188.163.112.70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea1ae12sm25759024f8f.6.2025.12.23.01.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 01:45:39 -0800 (PST) From: Svyatoslav Ryhel To: Greg Kroah-Hartman , Thierry Reding , Thierry Reding , Jonathan Hunter , Svyatoslav Ryhel , Dmitry Osipenko Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] usb: phy: tegra: use phy type directly Date: Tue, 23 Dec 2025 11:45:28 +0200 Message-ID: <20251223094529.7202-2-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251223094529.7202-1-clamor95@gmail.com> References: <20251223094529.7202-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor to directly use enum usb_phy_interface to determine the PHY mode. This change is in preparation for adding support for HSIC mode. Signed-off-by: Svyatoslav Ryhel --- drivers/usb/phy/phy-tegra-usb.c | 49 +++++++++++++++++++------------ include/linux/usb/tegra_usb_phy.h | 2 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-us= b.c index 1f527fcb42f6..13232b074649 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -814,15 +814,24 @@ static int ulpi_phy_power_off(struct tegra_usb_phy *p= hy) =20 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) { - int err; + int err =3D 0; =20 if (phy->powered_on) return 0; =20 - if (phy->is_ulpi_phy) - err =3D ulpi_phy_power_on(phy); - else + switch (phy->phy_type) { + case USBPHY_INTERFACE_MODE_UTMI: err =3D utmi_phy_power_on(phy); + break; + + case USBPHY_INTERFACE_MODE_ULPI: + err =3D ulpi_phy_power_on(phy); + break; + + default: + break; + } + if (err) return err; =20 @@ -841,10 +850,19 @@ static int tegra_usb_phy_power_off(struct tegra_usb_p= hy *phy) if (!phy->powered_on) return 0; =20 - if (phy->is_ulpi_phy) - err =3D ulpi_phy_power_off(phy); - else + switch (phy->phy_type) { + case USBPHY_INTERFACE_MODE_UTMI: err =3D utmi_phy_power_off(phy); + break; + + case USBPHY_INTERFACE_MODE_ULPI: + err =3D ulpi_phy_power_off(phy); + break; + + default: + break; + } + if (err) return err; =20 @@ -863,7 +881,7 @@ static void tegra_usb_phy_shutdown(struct usb_phy *u_ph= y) usb_phy_set_wakeup(u_phy, false); tegra_usb_phy_power_off(phy); =20 - if (!phy->is_ulpi_phy) + if (phy->phy_type =3D=3D USBPHY_INTERFACE_MODE_UTMI) utmip_pad_close(phy); =20 regulator_disable(phy->vbus); @@ -1049,7 +1067,7 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) goto disable_clk; } =20 - if (!phy->is_ulpi_phy) { + if (phy->phy_type =3D=3D USBPHY_INTERFACE_MODE_UTMI) { err =3D utmip_pad_open(phy); if (err) goto disable_vbus; @@ -1066,7 +1084,7 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) return 0; =20 close_phy: - if (!phy->is_ulpi_phy) + if (phy->phy_type =3D=3D USBPHY_INTERFACE_MODE_UTMI) utmip_pad_close(phy); =20 disable_vbus: @@ -1104,8 +1122,6 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra= _phy, struct resource *res; int err; =20 - tegra_phy->is_ulpi_phy =3D false; - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 1); if (!res) { dev_err(&pdev->dev, "Failed to get UTMI pad regs\n"); @@ -1280,7 +1296,6 @@ static int tegra_usb_phy_probe(struct platform_device= *pdev) { struct device_node *np =3D pdev->dev.of_node; struct tegra_usb_phy *tegra_phy; - enum usb_phy_interface phy_type; struct reset_control *reset; struct gpio_desc *gpiod; struct resource *res; @@ -1342,8 +1357,8 @@ static int tegra_usb_phy_probe(struct platform_device= *pdev) return err; } =20 - phy_type =3D of_usb_get_phy_mode(np); - switch (phy_type) { + tegra_phy->phy_type =3D of_usb_get_phy_mode(np); + switch (tegra_phy->phy_type) { case USBPHY_INTERFACE_MODE_UTMI: err =3D utmi_phy_probe(tegra_phy, pdev); if (err) @@ -1369,8 +1384,6 @@ static int tegra_usb_phy_probe(struct platform_device= *pdev) break; =20 case USBPHY_INTERFACE_MODE_ULPI: - tegra_phy->is_ulpi_phy =3D true; - tegra_phy->clk =3D devm_clk_get(&pdev->dev, "ulpi-link"); err =3D PTR_ERR_OR_ZERO(tegra_phy->clk); if (err) { @@ -1410,7 +1423,7 @@ static int tegra_usb_phy_probe(struct platform_device= *pdev) =20 default: dev_err(&pdev->dev, "phy_type %u is invalid or unsupported\n", - phy_type); + tegra_phy->phy_type); return -EINVAL; } =20 diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_us= b_phy.h index c314fad5e375..e394f4880b7e 100644 --- a/include/linux/usb/tegra_usb_phy.h +++ b/include/linux/usb/tegra_usb_phy.h @@ -73,7 +73,7 @@ struct tegra_usb_phy { struct usb_phy *ulpi; struct usb_phy u_phy; bool is_legacy_phy; - bool is_ulpi_phy; + enum usb_phy_interface phy_type; struct gpio_desc *reset_gpio; struct reset_control *pad_rst; bool wakeup_enabled; --=20 2.51.0 From nobody Sun Feb 8 07:58:26 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD32932AAC2 for ; Tue, 23 Dec 2025 09:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766483145; cv=none; b=SldeJqebqwhgAohJYknHM3SLKouY8XDVP87a/ENCr8+cYFvogc0koHQEGHh9HlcQK967BJ7v4gg9KNW7blIyVxNC6hzbIzkYdbrSODk4wSp3YPCcUXgdyQQukCFzsVnrucDqjFSQ7fwUfPmHIo4ylkczNaxV7xapMBj+E5I0tSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766483145; c=relaxed/simple; bh=2CwjCktaAAvQP52hVAcQSiYNs442fX7cEjzBglFlmOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f/sxYoGosOAhm1XjyNK6wLvmJrLKLmItp9tiVfL4aFshuCbrFPlAQCZFAwA/mDhF59k6/Qzq5zQ33zcRGtQ9ttcacmZwvvsEc3QYRgva6deIEyGRdkUwubcA0XAWJVhD5TQYARLqHHTbThfStkncJ5TsA+ADMjjH931QhSST2TE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ktTu6UL9; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ktTu6UL9" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-42e2d5e119fso2088903f8f.2 for ; Tue, 23 Dec 2025 01:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766483141; x=1767087941; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PtmZyPmcNnWj/pPrYtT2bQOdQiTp1GNJXWQfrbQ1Sro=; b=ktTu6UL9ZqOc38FAGXPDFviiigS4hQWTaCHp9Us72HwBsRLgpg3w7wLw8q8eniXSON yT9dgYYYVJVQxx5mMpq1rJHTHDc6VifrUthKipLWpu0hbN2E4eIgrPqDz8T0K75gSODG H23avs4Zt7o+I6kDeI8Yss+H/UubE/VcLQTq1w+aDM8pl3BkiIU5eSI2Pr45Z72WMLYp kPkTpo6CQcwOy7WWvwXEoWLJW/y8mIOsWF8G96rICj0u1VrQeq7DOY0O+reZhtvSO2gV J6+QhtoXTmFz6R6s5HKoiKec4SQiD8xH1AB8yZwl3UC79PFpADh91WxmJ3fOW0zSZ5OV y12Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766483141; x=1767087941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PtmZyPmcNnWj/pPrYtT2bQOdQiTp1GNJXWQfrbQ1Sro=; b=lxxaEMXaSiMiiyZaqQxYi3a0ZF5saP+cZ3MHSuaQilwapkHFlyHcdB/45yW9uMJu1Z htHjaU/+gTpHMR+/m6heZPw/sIrTz203AnPyb3xhUAOzTu98OblYlNCfpIAb/9NQIlrr WgVuA028bI4jq9pu3zst+2G/21zI3y2WV1RfYXf2BO0S7vY049SPLhjJ/sAgQcw/GXWS 7Z/NIJazJmF6SQrp+wWTEUf5aip9HANmUZnhenl/GULg5v71+iXbhh0SB/Xho4U3chzD FgH9rqsR+iNeLRBWlX9RS0QBYmpN3KEhyxw8NGYW2j6mjwBbruHOm/LgVw0CGloFAzqa WQHQ== X-Forwarded-Encrypted: i=1; AJvYcCX/DxTFfGYaagCXuP3xnYxq5kEXcT5aRjoDsh1ZSP9HsfkRX6az2Juhd64slOLZC+yDFBTV+2ULr8IpzLM=@vger.kernel.org X-Gm-Message-State: AOJu0YzcnA8OIhPtn9kIJubR/6Yp5Jt+Df9FvaGJTat3BayZ3/1VLrWl K2M++hwzYr/OPgJhO5Sq4qiYqjEGlhNQ9yZjPctIWYsnVRbdwDcFK7RK X-Gm-Gg: AY/fxX7bX7fRGLcpgNz+jandoPFg6b8yOg1J8TuEhM6lbNZqwAoYlysOaXxgB1IgjHm UVDqzLDinT2L2BXLISo7oKp1zCsIhemsOpzDbx+9fFFG2RWN2IgroHi/v8z7tVqQ/6NMiWsZyPE ERwv7MG082I9vzAoUjucJ/G3VRe7FtGIdNZCGA+TwE6i4x53aMNMlUAQpdZheQd79wIb/5Gc43N NO3Pr+pn+XSVDQhad2lJ9OunpiG6lYVsZKZIMu0J2k+ChGcYftadOo5DNLIQvOoWys7zp0L0OR1 GnApFDqCcpXVWvTaJUR8AAqDG4BK3N/GtY5Ot31RvjY3eLKOQYv1kCZRQFwmbacK3qE1fdwp1Hq YfKStS5Dotbtl7XLzaTQmzM0rgD0kB7xo7XjSC2I9b6yYXHH0hBsAeuYc8MVeh7a9+L8HJ9ntX7 v4 X-Google-Smtp-Source: AGHT+IHrFmA3PPM8ft+5rTNEgWxkKLDHXqcquDXCom6fZSokZOHfeaGKqpPd0DmltR1qlbma/iIK0w== X-Received: by 2002:a05:6000:4305:b0:431:8ec:9372 with SMTP id ffacd0b85a97d-4324e5108c1mr12648847f8f.55.1766483140982; Tue, 23 Dec 2025 01:45:40 -0800 (PST) Received: from xeon ([188.163.112.70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea1ae12sm25759024f8f.6.2025.12.23.01.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 01:45:40 -0800 (PST) From: Svyatoslav Ryhel To: Greg Kroah-Hartman , Thierry Reding , Thierry Reding , Jonathan Hunter , Svyatoslav Ryhel , Dmitry Osipenko Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] usb: phy: tegra: add HSIC support Date: Tue, 23 Dec 2025 11:45:29 +0200 Message-ID: <20251223094529.7202-3-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251223094529.7202-1-clamor95@gmail.com> References: <20251223094529.7202-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for HSIC USB mode, which can be set for second USB controller and PHY on Tegra SoC along with already supported UTMI or ULPI. Signed-off-by: Svyatoslav Ryhel --- drivers/usb/phy/phy-tegra-usb.c | 249 ++++++++++++++++++++++++++++-- include/linux/usb/tegra_usb_phy.h | 5 + 2 files changed, 243 insertions(+), 11 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-us= b.c index 13232b074649..31c0b6e34bc8 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -29,17 +29,26 @@ #include #include =20 +#define USB_TXFILLTUNING 0x154 +#define USB_FIFO_TXFILL_THRES(x) (((x) & 0x1f) << 16) +#define USB_FIFO_TXFILL_MASK 0x1f0000 + #define ULPI_VIEWPORT 0x170 =20 /* PORTSC PTS/PHCD bits, Tegra20 only */ #define TEGRA_USB_PORTSC1 0x184 -#define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) -#define TEGRA_USB_PORTSC1_PHCD BIT(23) +#define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) +#define TEGRA_USB_PORTSC1_PHCD BIT(23) +#define TEGRA_USB_PORTSC1_WKOC BIT(22) +#define TEGRA_USB_PORTSC1_WKDS BIT(21) +#define TEGRA_USB_PORTSC1_WKCN BIT(20) =20 /* HOSTPC1 PTS/PHCD bits, Tegra30 and above */ +#define TEGRA30_USB_PORTSC1 0x174 #define TEGRA_USB_HOSTPC1_DEVLC 0x1b4 -#define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29) -#define TEGRA_USB_HOSTPC1_DEVLC_PHCD BIT(22) +#define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29) +#define TEGRA_USB_HOSTPC1_DEVLC_PHCD BIT(22) +#define TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC BIT(2) =20 /* Bits of PORTSC1, which will get cleared by writing 1 into them */ #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) @@ -51,11 +60,12 @@ #define USB_SUSP_CLR BIT(5) #define USB_PHY_CLK_VALID BIT(7) #define UTMIP_RESET BIT(11) -#define UHSIC_RESET BIT(11) #define UTMIP_PHY_ENABLE BIT(12) #define ULPI_PHY_ENABLE BIT(13) #define USB_SUSP_SET BIT(14) +#define UHSIC_RESET BIT(14) #define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16) +#define UHSIC_PHY_ENABLE BIT(19) =20 #define USB_PHY_VBUS_SENSORS 0x404 #define B_SESS_VLD_WAKEUP_EN BIT(14) @@ -156,6 +166,58 @@ #define UTMIP_BIAS_CFG1 0x83c #define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3) =20 +/* + * Tegra20 has no UTMIP registers on PHY2 and UHSIC registers start from 0= x800 + * just where UTMIP registers should have been. This is the case only with= Tegra20 + * Tegra30+ have UTMIP registers at 0x800 and UHSIC registers shifter by 0= x400 + * to 0xc00, but register layout is preserved. + */ +#define UHSIC_PLL_CFG1 0x804 +#define UHSIC_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0) +#define UHSIC_PLLU_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 14) + +#define UHSIC_HSRX_CFG0 0x808 +#define UHSIC_ELASTIC_UNDERRUN_LIMIT(x) (((x) & 0x1f) << 2) +#define UHSIC_ELASTIC_OVERRUN_LIMIT(x) (((x) & 0x1f) << 8) +#define UHSIC_IDLE_WAIT(x) (((x) & 0x1f) << 13) + +#define UHSIC_HSRX_CFG1 0x80c +#define UHSIC_HS_SYNC_START_DLY(x) (((x) & 0x1f) << 1) + +#define UHSIC_TX_CFG0 0x810 +#define UHSIC_HS_READY_WAIT_FOR_VALID BIT(9) + +#define UHSIC_MISC_CFG0 0x814 +#define UHSIC_SUSPEND_EXIT_ON_EDGE BIT(7) +#define UHSIC_DETECT_SHORT_CONNECT BIT(8) +#define UHSIC_FORCE_XCVR_MODE BIT(15) +#define UHSIC_DISABLE_BUSRESET BIT(20) + +#define UHSIC_MISC_CFG1 0x818 +#define UHSIC_PLLU_STABLE_COUNT(x) (((x) & 0xfff) << 2) + +#define UHSIC_PADS_CFG0 0x81c +#define UHSIC_TX_RTUNEN 0xf000 +#define UHSIC_TX_RTUNE(x) (((x) & 0xf) << 12) + +#define UHSIC_PADS_CFG1 0x820 +#define UHSIC_PD_BG BIT(2) +#define UHSIC_PD_TX BIT(3) +#define UHSIC_PD_TRK BIT(4) +#define UHSIC_PD_RX BIT(5) +#define UHSIC_PD_ZI BIT(6) +#define UHSIC_RX_SEL BIT(7) +#define UHSIC_RPD_DATA BIT(9) +#define UHSIC_RPD_STROBE BIT(10) +#define UHSIC_RPU_DATA BIT(11) +#define UHSIC_RPU_STROBE BIT(12) + +#define UHSIC_CMD_CFG0 0x824 +#define UHSIC_PRETEND_CONNECT_DETECT BIT(5) + +#define UHSIC_STAT_CFG0 0x828 +#define UHSIC_CONNECT_DETECT BIT(0) + /* For Tegra30 and above only, the address is different in Tegra20 */ #define USB_USBMODE 0x1f8 #define USB_USBMODE_MASK (3 << 0) @@ -174,7 +236,8 @@ struct tegra_xtal_freq { u8 enable_delay; u8 stable_count; u8 active_delay; - u8 xtal_freq_count; + u8 utmi_xtal_freq_count; + u16 hsic_xtal_freq_count; u16 debounce; }; =20 @@ -184,7 +247,8 @@ static const struct tegra_xtal_freq tegra_freq_table[] = =3D { .enable_delay =3D 0x02, .stable_count =3D 0x2F, .active_delay =3D 0x04, - .xtal_freq_count =3D 0x76, + .utmi_xtal_freq_count =3D 0x76, + .hsic_xtal_freq_count =3D 0x1CA, .debounce =3D 0x7530, }, { @@ -192,7 +256,8 @@ static const struct tegra_xtal_freq tegra_freq_table[] = =3D { .enable_delay =3D 0x02, .stable_count =3D 0x33, .active_delay =3D 0x05, - .xtal_freq_count =3D 0x7F, + .utmi_xtal_freq_count =3D 0x7F, + .hsic_xtal_freq_count =3D 0x1F0, .debounce =3D 0x7EF4, }, { @@ -200,7 +265,8 @@ static const struct tegra_xtal_freq tegra_freq_table[] = =3D { .enable_delay =3D 0x03, .stable_count =3D 0x4B, .active_delay =3D 0x06, - .xtal_freq_count =3D 0xBB, + .utmi_xtal_freq_count =3D 0xBB, + .hsic_xtal_freq_count =3D 0x2DD, .debounce =3D 0xBB80, }, { @@ -208,7 +274,8 @@ static const struct tegra_xtal_freq tegra_freq_table[] = =3D { .enable_delay =3D 0x04, .stable_count =3D 0x66, .active_delay =3D 0x09, - .xtal_freq_count =3D 0xFE, + .utmi_xtal_freq_count =3D 0xFE, + .hsic_xtal_freq_count =3D 0x3E0, .debounce =3D 0xFDE8, }, }; @@ -541,7 +608,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) val =3D readl_relaxed(base + UTMIP_PLL_CFG1); val &=3D ~(UTMIP_XTAL_FREQ_COUNT(~0) | UTMIP_PLLU_ENABLE_DLY_COUNT(~0)); - val |=3D UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | + val |=3D UTMIP_XTAL_FREQ_COUNT(phy->freq->utmi_xtal_freq_count) | UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); writel_relaxed(val, base + UTMIP_PLL_CFG1); } @@ -812,6 +879,153 @@ static int ulpi_phy_power_off(struct tegra_usb_phy *p= hy) return 0; } =20 +static u32 tegra_hsic_readl(struct tegra_usb_phy *phy, u32 reg) +{ + void __iomem *base =3D phy->regs; + u32 shift =3D phy->soc_config->uhsic_registers_shift; + + return readl_relaxed(base + shift + reg); +} + +static void tegra_hsic_writel(struct tegra_usb_phy *phy, u32 reg, u32 valu= e) +{ + void __iomem *base =3D phy->regs; + u32 shift =3D phy->soc_config->uhsic_registers_shift; + + writel_relaxed(value, base + shift + reg); +} + +static int uhsic_phy_power_on(struct tegra_usb_phy *phy) +{ + struct tegra_utmip_config *config =3D phy->config; + void __iomem *base =3D phy->regs; + u32 val; + + val =3D tegra_hsic_readl(phy, UHSIC_PADS_CFG1); + val &=3D ~(UHSIC_PD_BG | UHSIC_PD_TX | UHSIC_PD_TRK | UHSIC_PD_RX | + UHSIC_PD_ZI | UHSIC_RPD_DATA | UHSIC_RPD_STROBE); + val |=3D UHSIC_RX_SEL; + tegra_hsic_writel(phy, UHSIC_PADS_CFG1, val); + + udelay(2); + + val =3D readl_relaxed(base + USB_SUSP_CTRL); + val |=3D UHSIC_RESET; + writel_relaxed(val, base + USB_SUSP_CTRL); + + udelay(30); + + val =3D readl_relaxed(base + USB_SUSP_CTRL); + val |=3D UHSIC_PHY_ENABLE; + writel_relaxed(val, base + USB_SUSP_CTRL); + + val =3D tegra_hsic_readl(phy, UHSIC_HSRX_CFG0); + val &=3D ~(UHSIC_IDLE_WAIT(~0) | + UHSIC_ELASTIC_UNDERRUN_LIMIT(~0) | + UHSIC_ELASTIC_OVERRUN_LIMIT(~0)); + val |=3D UHSIC_IDLE_WAIT(config->idle_wait_delay) | + UHSIC_ELASTIC_UNDERRUN_LIMIT(config->elastic_limit) | + UHSIC_ELASTIC_OVERRUN_LIMIT(config->elastic_limit); + tegra_hsic_writel(phy, UHSIC_HSRX_CFG0, val); + + val =3D tegra_hsic_readl(phy, UHSIC_HSRX_CFG1); + val &=3D ~UHSIC_HS_SYNC_START_DLY(~0); + val |=3D UHSIC_HS_SYNC_START_DLY(config->hssync_start_delay); + tegra_hsic_writel(phy, UHSIC_HSRX_CFG1, val); + + val =3D tegra_hsic_readl(phy, UHSIC_MISC_CFG0); + val |=3D UHSIC_SUSPEND_EXIT_ON_EDGE; + tegra_hsic_writel(phy, UHSIC_MISC_CFG0, val); + + val =3D tegra_hsic_readl(phy, UHSIC_MISC_CFG1); + val &=3D ~UHSIC_PLLU_STABLE_COUNT(~0); + val |=3D UHSIC_PLLU_STABLE_COUNT(phy->freq->stable_count); + tegra_hsic_writel(phy, UHSIC_MISC_CFG1, val); + + val =3D tegra_hsic_readl(phy, UHSIC_PLL_CFG1); + val &=3D ~(UHSIC_XTAL_FREQ_COUNT(~0) | + UHSIC_PLLU_ENABLE_DLY_COUNT(~0)); + val |=3D UHSIC_XTAL_FREQ_COUNT(phy->freq->hsic_xtal_freq_count) | + UHSIC_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); + tegra_hsic_writel(phy, UHSIC_PLL_CFG1, val); + + val =3D readl_relaxed(base + USB_SUSP_CTRL); + val &=3D ~UHSIC_RESET; + writel_relaxed(val, base + USB_SUSP_CTRL); + + udelay(2); + + if (phy->soc_config->requires_usbmode_setup) { + val =3D readl_relaxed(base + USB_USBMODE); + val &=3D ~USB_USBMODE_MASK; + if (phy->mode =3D=3D USB_DR_MODE_HOST) + val |=3D USB_USBMODE_HOST; + else + val |=3D USB_USBMODE_DEVICE; + writel_relaxed(val, base + USB_USBMODE); + } + + if (phy->soc_config->has_hostpc) + set_pts(phy, TEGRA_USB_HOSTPC1_DEVLC_PTS_HSIC); + else + set_pts(phy, 0); + + val =3D readl_relaxed(base + USB_TXFILLTUNING); + if ((val & USB_FIFO_TXFILL_MASK) !=3D USB_FIFO_TXFILL_THRES(0x10)) { + val =3D USB_FIFO_TXFILL_THRES(0x10); + writel_relaxed(val, base + USB_TXFILLTUNING); + } + + if (phy->soc_config->has_hostpc) { + val =3D readl_relaxed(base + TEGRA30_USB_PORTSC1); + val &=3D ~(TEGRA_USB_PORTSC1_WKOC | TEGRA_USB_PORTSC1_WKDS | + TEGRA_USB_PORTSC1_WKCN); + writel_relaxed(val, base + TEGRA30_USB_PORTSC1); + } else { + val =3D readl_relaxed(base + TEGRA_USB_PORTSC1); + val &=3D ~(TEGRA_USB_PORTSC1_WKOC | TEGRA_USB_PORTSC1_WKDS | + TEGRA_USB_PORTSC1_WKCN); + writel_relaxed(val, base + TEGRA_USB_PORTSC1); + } + + val =3D tegra_hsic_readl(phy, UHSIC_PADS_CFG0); + val &=3D ~UHSIC_TX_RTUNEN; + val |=3D UHSIC_TX_RTUNE(phy->soc_config->uhsic_tx_rtune); + tegra_hsic_writel(phy, UHSIC_PADS_CFG0, val); + + if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, + USB_PHY_CLK_VALID)) + dev_err(phy->u_phy.dev, + "Timeout waiting for PHY to stabilize on enable (HSIC)\n"); + + return 0; +} + +static int uhsic_phy_power_off(struct tegra_usb_phy *phy) +{ + void __iomem *base =3D phy->regs; + u32 val; + + set_phcd(phy, true); + + val =3D tegra_hsic_readl(phy, UHSIC_PADS_CFG1); + val |=3D (UHSIC_PD_BG | UHSIC_PD_TX | UHSIC_PD_TRK | UHSIC_PD_RX | + UHSIC_PD_ZI | UHSIC_RPD_DATA | UHSIC_RPD_STROBE); + tegra_hsic_writel(phy, UHSIC_PADS_CFG1, val); + + val =3D readl_relaxed(base + USB_SUSP_CTRL); + val |=3D UHSIC_RESET; + writel_relaxed(val, base + USB_SUSP_CTRL); + + udelay(30); + + val =3D readl_relaxed(base + USB_SUSP_CTRL); + val &=3D ~UHSIC_PHY_ENABLE; + writel_relaxed(val, base + USB_SUSP_CTRL); + + return 0; +} + static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) { int err =3D 0; @@ -828,6 +1042,10 @@ static int tegra_usb_phy_power_on(struct tegra_usb_ph= y *phy) err =3D ulpi_phy_power_on(phy); break; =20 + case USBPHY_INTERFACE_MODE_HSIC: + err =3D uhsic_phy_power_on(phy); + break; + default: break; } @@ -859,6 +1077,10 @@ static int tegra_usb_phy_power_off(struct tegra_usb_p= hy *phy) err =3D ulpi_phy_power_off(phy); break; =20 + case USBPHY_INTERFACE_MODE_HSIC: + err =3D uhsic_phy_power_off(phy); + break; + default: break; } @@ -1256,6 +1478,8 @@ static const struct tegra_phy_soc_config tegra20_soc_= config =3D { .requires_usbmode_setup =3D false, .requires_extra_tuning_parameters =3D false, .requires_pmc_ao_power_up =3D false, + .uhsic_registers_shift =3D 0, + .uhsic_tx_rtune =3D 0, /* 40 ohm */ }; =20 static const struct tegra_phy_soc_config tegra30_soc_config =3D { @@ -1264,6 +1488,8 @@ static const struct tegra_phy_soc_config tegra30_soc_= config =3D { .requires_usbmode_setup =3D true, .requires_extra_tuning_parameters =3D true, .requires_pmc_ao_power_up =3D true, + .uhsic_registers_shift =3D 0x400, + .uhsic_tx_rtune =3D 8, /* 50 ohm */ }; =20 static const struct of_device_id tegra_usb_phy_id_table[] =3D { @@ -1360,6 +1586,7 @@ static int tegra_usb_phy_probe(struct platform_device= *pdev) tegra_phy->phy_type =3D of_usb_get_phy_mode(np); switch (tegra_phy->phy_type) { case USBPHY_INTERFACE_MODE_UTMI: + case USBPHY_INTERFACE_MODE_HSIC: err =3D utmi_phy_probe(tegra_phy, pdev); if (err) return err; diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_us= b_phy.h index e394f4880b7e..4e79f1c2173a 100644 --- a/include/linux/usb/tegra_usb_phy.h +++ b/include/linux/usb/tegra_usb_phy.h @@ -24,6 +24,9 @@ struct gpio_desc; * requires_extra_tuning_parameters: true if xcvr_hsslew, hssquelch_level * and hsdiscon_level should be set for adequate signal quality * requires_pmc_ao_power_up: true if USB AO is powered down by default + * uhsic_registers_shift: for Tegra30+ where HSIC registers were shifted + * comparing to Tegra20 by 0x400, since Tegra20 has no UTMIP on PHY2 + * uhsic_tx_rtune: fine tuned 50 Ohm termination resistor for NMOS/PMOS dr= iver */ =20 struct tegra_phy_soc_config { @@ -32,6 +35,8 @@ struct tegra_phy_soc_config { bool requires_usbmode_setup; bool requires_extra_tuning_parameters; bool requires_pmc_ao_power_up; + u32 uhsic_registers_shift; + u32 uhsic_tx_rtune; }; =20 struct tegra_utmip_config { --=20 2.51.0