From patchwork Fri Apr 5 08:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 786202 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1101:b0:343:f27d:c44e with SMTP id z1csp57349wrw; Fri, 5 Apr 2024 01:36:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWQSuYikRkrnqOM1NQqatP52R2JKCLD5OVERJCtVfaAlHVLwvC15eDhGhjXNnNORLRE50g2GaK6phsj82JrJCiS X-Google-Smtp-Source: AGHT+IEqSYkSPMVwilpZn10svQrseiavOde+4uiORasu9Ufhg9snFamRFyv//9sndnpdCd7KEOc9 X-Received: by 2002:a50:c046:0:b0:56d:faa3:7dac with SMTP id u6-20020a50c046000000b0056dfaa37dacmr846366edd.9.1712306170696; Fri, 05 Apr 2024 01:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712306170; cv=none; d=google.com; s=arc-20160816; b=qyV7tgdXqkaGYqN4iONTy7cDEUNR6jrqLRQYqhRGKHHoRF+RPDb0Aurmu52zhtwJNr vYScqh2iWE2Wz6UzaPqGcXvqnyKGAEMA0gnBJTpmRDsTAZtFVgv4e6MH7jsKEcqqkUX7 lyPSJdpmy4B+F4051l1j2d3ODb19hl7UY9FjyWbg47C6A+pm9xi0ktRR1iJ/0hnbaJgp De6sqmynq36+nKzBqw1K6qkwDpgsMM7PILQ+Mrs8568kiJBSizJkzZGL7OAK2nE+xGoj vMigGQ0LV8riOhw/4EAlbbRVdkIlqhbYTEkO4E3sWtlXxa5r9hpdViHX6V0fzHl3MxnO HuzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=wbd+4+vzLqyYdVx5elQ+F+rLnlUDfcLuUuWCsNuEOTw=; fh=F+Wp1cjN2WwcrhGpY0cI2eVSX5UKI3VOL/XTDkhvQVs=; b=NGpw9CE1xoo5QNgCe4/ffL7TcU3CpI8wj27CjZPERB9JUKJeXLWJX5z+Tt4RxsZzKD l/Dzg3nMoB1Zo19w2tr9+04vMM+FUx3RwwahjZkBQymKYkH1GPOvQlB0B3V3+2gulkLX UQkt8gxEOphrl2Sxt4VE6tvLssMV1MJ+yosGO6TEPPO0dwUbhVRKTHe6Jz3ycJTQwCss 3/wQwUdkyfAViKLrakQEjwCSy61UmvRUZQzR9Vg/ya8thWrzSGhZ9kDVO6T/Sqg/FbYQ Rps6pIwGnOjCgazl4cj/BdoGEZev1TEM395/MXzpsQKPJsOE1qDTEDUz6lG7BLkEwsp0 UmVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O2Q0divp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id u26-20020a50951a000000b0056df9749489si498061eda.651.2024.04.05.01.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O2Q0divp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9A9288848A; Fri, 5 Apr 2024 10:36:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="O2Q0divp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C949F884D5; Fri, 5 Apr 2024 10:36:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E32B6884CE for ; Fri, 5 Apr 2024 10:36:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6ecee5c08e6so1559595b3a.3 for ; Fri, 05 Apr 2024 01:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712306161; x=1712910961; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wbd+4+vzLqyYdVx5elQ+F+rLnlUDfcLuUuWCsNuEOTw=; b=O2Q0divp7H3EIL/3JmD0qjp+BFgg/DUVFJcJahmnbZazFFnPn8RFpQPxo4x/zth1/A yeEF8QVPYcPZ/qmCfu/HbPst5JBWRhZal7if4wdf9V+NmNF3t5Np9X/c5AItFC06OviY YST2BVP+wNS8aQJs4VAmMtpatFw6BOqjCHvoAG6ecD0BEGq2rr8nC9MEPBWLaQsOroU5 kZ2gFhCJqG32xBfVeZVTR436bls9YbdW4qo1me+yZEt7IRgFCaWky3hvcLr7t0bPhVM1 IskdYx0+2Ia3gf1seqrhDvQYCCzwgI8LIhvtp79EAdb/WNQgQigPuNawgkRcybW6gapd P2VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712306161; x=1712910961; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wbd+4+vzLqyYdVx5elQ+F+rLnlUDfcLuUuWCsNuEOTw=; b=gEDegH0tyw8Zl6JafXIFjH+lWZhRyVVxgng6VxYd8VeOgZsxCjyZW0Vh2Awdg7ZfZq vHPMVb7JepHL8vn1ECjaKi3K2MwcSER4LI7hFOL5i3vWNsL10p0cLM6EPrRUsP1rWHpJ 2xst7JFRVzLwy4Uv3WzQlM/4BH557XQyTuLUse9/Sa5ApwtCBFQRxnqby3wq7wIRiD+D O8LmKgD5xIdixgxh/hRYRPDOPjQuSSAW5D8oataHpSLQsV57il6JXqVz6ojXkBe4LuvW lm4z4xn1iFSrsIMERrkgGVepN5RF+aeLc3HHojfESOCHJPYhofF9hsFmj3gnfa5H5RyX Gh1A== X-Gm-Message-State: AOJu0YxRfxYR4YQ8cdn3qKvPUSnx2PRBlnynBzALgj635u0pRPcNMx7N 2SjOTCIR/j8/0h1Sa7NbiuqHDZGbDjqCo+aMQBWXpQ81XCtvjhdgNmQyXwv9WKA= X-Received: by 2002:a05:6a21:7794:b0:1a7:1b6e:4da with SMTP id bd20-20020a056a21779400b001a71b6e04damr873277pzc.27.1712306161153; Fri, 05 Apr 2024 01:36:01 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id b12-20020a170902650c00b001e27e52a7e4sm1006572plk.285.2024.04.05.01.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:36:00 -0700 (PDT) From: Neil Armstrong Date: Fri, 05 Apr 2024 10:35:48 +0200 Subject: [PATCH 1/2] phy: qcom: add Synopsys eUSB2 PHY driver MIME-Version: 1.0 Message-Id: <20240405-topic-sm8x50-usb-phy-v1-1-8a8604bf818f@linaro.org> References: <20240405-topic-sm8x50-usb-phy-v1-0-8a8604bf818f@linaro.org> In-Reply-To: <20240405-topic-sm8x50-usb-phy-v1-0-8a8604bf818f@linaro.org> To: Tom Rini , Caleb Connolly , Sumit Garg Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=13606; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=fsi1edW9v875tRgBlvMZrXErsat7dNJJ9PpKPAqec7E=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmD7fpGLpi/DPpH18MrZxgenqcqZVnWI8DLgxjddea 12IM3HOJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZg+36QAKCRB33NvayMhJ0dT2D/ 0SH9h4IMqfo8oqiLtRjGAOjOZfCUqF11ZMLXXwZfLgTjqMg36UlOFbeBEGwDL3KhECaaWky/su0eyc PBhrnCJ/mrSVM2qmDDaro9Gpb8gShz6klcgSYx0WAu9qTrpDen+CtB4uQjd7Qe027p8P6ViIqArs5A 4p7TRNSyILkQW2b027bIO9LqMcaocFOd9ny46L8XecX0u1PS3KeizzD6ryJ/vylLPJ0yXvgz6ictL9 h8c8hVyj8ACzuU1K255KsbJgZS7M5lJqyMFfDN8C+H/EX2lozlg4/ib9gx1mzvw4XT5CGPurWqfwGZ 2kGH4duhlQPdqai82fAtqxCAVJi9PSAazwHfCpM+AWklPLvLaFgGdPRsDputB/jQrGtd4k69Kz5NXv Cv02M/ICcM7tE8ypLAYJ4d+E0wsCSbfnrZY3WXNo1CGX7swmHiFBI/SN6oLDYQEZyb7miVyZ2rnsPJ +SMnu8TBjT8CFnLddsyCcf1QFFylRfYX/c9QBZeMFK0Nrm8UvZQyJ0eA62IvLwhDwGwWfFMetK0c8C k4cOp/6kLFDtjih8a59f5dU9tOmKpXX9b/kZtLT72GVFDqjnelHobYZEVuY82dAw4Yt8DQyp5iO4EV liGCKFZGTKNR7UE7tvbFYZVNAxGHhaIxP51SrCRpMTlPRqVptpplCx2ip3CA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add a driver for the new Synopsys eUSB2 PHY found in the SM8550 and SM8650 SoCs. Signed-off-by: Neil Armstrong --- drivers/phy/qcom/Kconfig | 8 + drivers/phy/qcom/Makefile | 1 + drivers/phy/qcom/phy-qcom-snps-eusb2.c | 365 +++++++++++++++++++++++++++++++++ 3 files changed, 374 insertions(+) diff --git a/drivers/phy/qcom/Kconfig b/drivers/phy/qcom/Kconfig index b9fe608c279..3aae1813352 100644 --- a/drivers/phy/qcom/Kconfig +++ b/drivers/phy/qcom/Kconfig @@ -27,6 +27,14 @@ config PHY_QCOM_USB_SNPS_FEMTO_V2 High-Speed PHY driver. This driver supports the Hi-Speed PHY which is usually paired with Synopsys DWC3 USB IPs on MSM SOCs. +config PHY_QCOM_SNPS_EUSB2 + tristate "Qualcomm Synopsys eUSB2 High-Speed PHY" + depends on PHY && ARCH_SNAPDRAGON + help + Enable this to support the Qualcomm Synopsys DesignWare eUSB2 + High-Speed PHY driver. This driver supports the Hi-Speed PHY which + is usually paired with Synopsys DWC3 USB IPs on MSM SOCs. + config PHY_QCOM_USB_HS_28NM tristate "Qualcomm 28nm High-Speed PHY" depends on PHY && ARCH_SNAPDRAGON diff --git a/drivers/phy/qcom/Makefile b/drivers/phy/qcom/Makefile index 5f4db4a5378..a5153061dfb 100644 --- a/drivers/phy/qcom/Makefile +++ b/drivers/phy/qcom/Makefile @@ -2,5 +2,6 @@ obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2) += phy-qcom-snps-femto-v2.o +obj-$(CONFIG_PHY_QCOM_SNPS_EUSB2) += phy-qcom-snps-eusb2.o obj-$(CONFIG_PHY_QCOM_USB_HS_28NM) += phy-qcom-usb-hs-28nm.o obj-$(CONFIG_PHY_QCOM_USB_SS) += phy-qcom-usb-ss.o diff --git a/drivers/phy/qcom/phy-qcom-snps-eusb2.c b/drivers/phy/qcom/phy-qcom-snps-eusb2.c new file mode 100644 index 00000000000..853b88458b7 --- /dev/null +++ b/drivers/phy/qcom/phy-qcom-snps-eusb2.c @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2023-2024, Linaro Limited + * + * Based on the Linux phy-qcom-snps-eusb2.c driver + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define USB_PHY_UTMI_CTRL0 (0x3c) +#define SLEEPM BIT(0) +#define OPMODE_MASK GENMASK(4, 3) +#define OPMODE_NONDRIVING BIT(3) + +#define USB_PHY_UTMI_CTRL5 (0x50) +#define POR BIT(1) + +#define USB_PHY_HS_PHY_CTRL_COMMON0 (0x54) +#define PHY_ENABLE BIT(0) +#define SIDDQ_SEL BIT(1) +#define SIDDQ BIT(2) +#define RETENABLEN BIT(3) +#define FSEL_MASK GENMASK(6, 4) +#define FSEL_19_2_MHZ_VAL (0x0) +#define FSEL_38_4_MHZ_VAL (0x4) + +#define USB_PHY_CFG_CTRL_1 (0x58) +#define PHY_CFG_PLL_CPBIAS_CNTRL_MASK GENMASK(7, 1) + +#define USB_PHY_CFG_CTRL_2 (0x5c) +#define PHY_CFG_PLL_FB_DIV_7_0_MASK GENMASK(7, 0) +#define DIV_7_0_19_2_MHZ_VAL (0x90) +#define DIV_7_0_38_4_MHZ_VAL (0xc8) + +#define USB_PHY_CFG_CTRL_3 (0x60) +#define PHY_CFG_PLL_FB_DIV_11_8_MASK GENMASK(3, 0) +#define DIV_11_8_19_2_MHZ_VAL (0x1) +#define DIV_11_8_38_4_MHZ_VAL (0x0) + +#define PHY_CFG_PLL_REF_DIV GENMASK(7, 4) +#define PLL_REF_DIV_VAL (0x0) + +#define USB_PHY_HS_PHY_CTRL2 (0x64) +#define VBUSVLDEXT0 BIT(0) +#define USB2_SUSPEND_N BIT(2) +#define USB2_SUSPEND_N_SEL BIT(3) +#define VBUS_DET_EXT_SEL BIT(4) + +#define USB_PHY_CFG_CTRL_4 (0x68) +#define PHY_CFG_PLL_GMP_CNTRL_MASK GENMASK(1, 0) +#define PHY_CFG_PLL_INT_CNTRL_MASK GENMASK(7, 2) + +#define USB_PHY_CFG_CTRL_5 (0x6c) +#define PHY_CFG_PLL_PROP_CNTRL_MASK GENMASK(4, 0) +#define PHY_CFG_PLL_VREF_TUNE_MASK GENMASK(7, 6) + +#define USB_PHY_CFG_CTRL_6 (0x70) +#define PHY_CFG_PLL_VCO_CNTRL_MASK GENMASK(2, 0) + +#define USB_PHY_CFG_CTRL_7 (0x74) + +#define USB_PHY_CFG_CTRL_8 (0x78) +#define PHY_CFG_TX_FSLS_VREF_TUNE_MASK GENMASK(1, 0) +#define PHY_CFG_TX_FSLS_VREG_BYPASS BIT(2) +#define PHY_CFG_TX_HS_VREF_TUNE_MASK GENMASK(5, 3) +#define PHY_CFG_TX_HS_XV_TUNE_MASK GENMASK(7, 6) + +#define USB_PHY_CFG_CTRL_9 (0x7c) +#define PHY_CFG_TX_PREEMP_TUNE_MASK GENMASK(2, 0) +#define PHY_CFG_TX_RES_TUNE_MASK GENMASK(4, 3) +#define PHY_CFG_TX_RISE_TUNE_MASK GENMASK(6, 5) +#define PHY_CFG_RCAL_BYPASS BIT(7) + +#define USB_PHY_CFG_CTRL_10 (0x80) + +#define USB_PHY_CFG0 (0x94) +#define DATAPATH_CTRL_OVERRIDE_EN BIT(0) +#define CMN_CTRL_OVERRIDE_EN BIT(1) + +#define UTMI_PHY_CMN_CTRL0 (0x98) +#define TESTBURNIN BIT(6) + +#define USB_PHY_FSEL_SEL (0xb8) +#define FSEL_SEL BIT(0) + +#define USB_PHY_APB_ACCESS_CMD (0x130) +#define RW_ACCESS BIT(0) +#define APB_START_CMD BIT(1) +#define APB_LOGIC_RESET BIT(2) + +#define USB_PHY_APB_ACCESS_STATUS (0x134) +#define ACCESS_DONE BIT(0) +#define TIMED_OUT BIT(1) +#define ACCESS_ERROR BIT(2) +#define ACCESS_IN_PROGRESS BIT(3) + +#define USB_PHY_APB_ADDRESS (0x138) +#define APB_REG_ADDR_MASK GENMASK(7, 0) + +#define USB_PHY_APB_WRDATA_LSB (0x13c) +#define APB_REG_WRDATA_7_0_MASK GENMASK(3, 0) + +#define USB_PHY_APB_WRDATA_MSB (0x140) +#define APB_REG_WRDATA_15_8_MASK GENMASK(7, 4) + +#define USB_PHY_APB_RDDATA_LSB (0x144) +#define APB_REG_RDDATA_7_0_MASK GENMASK(3, 0) + +#define USB_PHY_APB_RDDATA_MSB (0x148) +#define APB_REG_RDDATA_15_8_MASK GENMASK(7, 4) + +struct qcom_snps_eusb2_phy_priv { + void __iomem *base; + struct clk *ref_clk; + struct reset_ctl_bulk resets; +}; + +static void qcom_snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset, + u32 mask, u32 val) +{ + u32 reg; + + reg = readl_relaxed(base + offset); + reg &= ~mask; + reg |= val & mask; + writel_relaxed(reg, base + offset); + + /* Ensure above write is completed */ + readl_relaxed(base + offset); +} + +static void qcom_eusb2_default_parameters(struct qcom_snps_eusb2_phy_priv *qcom_snps_eusb2) +{ + /* default parameters: tx pre-emphasis */ + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_9, + PHY_CFG_TX_PREEMP_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_PREEMP_TUNE_MASK, 0)); + + /* tx rise/fall time */ + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_9, + PHY_CFG_TX_RISE_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_RISE_TUNE_MASK, 0x2)); + + /* source impedance adjustment */ + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_9, + PHY_CFG_TX_RES_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_RES_TUNE_MASK, 0x1)); + + /* dc voltage level adjustement */ + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_8, + PHY_CFG_TX_HS_VREF_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_HS_VREF_TUNE_MASK, 0x3)); + + /* transmitter HS crossover adjustement */ + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_8, + PHY_CFG_TX_HS_XV_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_HS_XV_TUNE_MASK, 0x0)); +} + +static int qcom_eusb2_ref_clk_init(struct qcom_snps_eusb2_phy_priv *qcom_snps_eusb2) +{ + unsigned long ref_clk_freq = clk_get_rate(qcom_snps_eusb2->ref_clk); + + switch (ref_clk_freq) { + case 19200000: + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL_COMMON0, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_19_2_MHZ_VAL)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_2, + PHY_CFG_PLL_FB_DIV_7_0_MASK, + DIV_7_0_19_2_MHZ_VAL); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_3, + PHY_CFG_PLL_FB_DIV_11_8_MASK, + DIV_11_8_19_2_MHZ_VAL); + break; + + case 38400000: + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL_COMMON0, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_38_4_MHZ_VAL)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_2, + PHY_CFG_PLL_FB_DIV_7_0_MASK, + DIV_7_0_38_4_MHZ_VAL); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_3, + PHY_CFG_PLL_FB_DIV_11_8_MASK, + DIV_11_8_38_4_MHZ_VAL); + break; + + default: + printf("%s: unsupported ref_clk_freq:%lu\n", __func__, ref_clk_freq); + return -EINVAL; + } + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_3, + PHY_CFG_PLL_REF_DIV, PLL_REF_DIV_VAL); + + return 0; +} + +static int qcom_snps_eusb2_usb_init(struct phy *phy) +{ + struct qcom_snps_eusb2_phy_priv *qcom_snps_eusb2 = dev_get_priv(phy->dev); + int ret; + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG0, + CMN_CTRL_OVERRIDE_EN, CMN_CTRL_OVERRIDE_EN); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_UTMI_CTRL5, POR, POR); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL_COMMON0, + PHY_ENABLE | RETENABLEN, PHY_ENABLE | RETENABLEN); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_APB_ACCESS_CMD, + APB_LOGIC_RESET, APB_LOGIC_RESET); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, UTMI_PHY_CMN_CTRL0, TESTBURNIN, 0); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_FSEL_SEL, + FSEL_SEL, FSEL_SEL); + + /* update ref_clk related registers */ + ret = qcom_eusb2_ref_clk_init(qcom_snps_eusb2); + if (ret) + return ret; + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_1, + PHY_CFG_PLL_CPBIAS_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_CPBIAS_CNTRL_MASK, 0x1)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_4, + PHY_CFG_PLL_INT_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_INT_CNTRL_MASK, 0x8)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_4, + PHY_CFG_PLL_GMP_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_GMP_CNTRL_MASK, 0x1)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_5, + PHY_CFG_PLL_PROP_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_PROP_CNTRL_MASK, 0x10)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_6, + PHY_CFG_PLL_VCO_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_VCO_CNTRL_MASK, 0x0)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_CFG_CTRL_5, + PHY_CFG_PLL_VREF_TUNE_MASK, + FIELD_PREP(PHY_CFG_PLL_VREF_TUNE_MASK, 0x1)); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL2, + VBUS_DET_EXT_SEL, VBUS_DET_EXT_SEL); + + /* set default parameters */ + qcom_eusb2_default_parameters(qcom_snps_eusb2); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL2, + USB2_SUSPEND_N_SEL | USB2_SUSPEND_N, + USB2_SUSPEND_N_SEL | USB2_SUSPEND_N); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_UTMI_CTRL0, SLEEPM, SLEEPM); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL_COMMON0, + SIDDQ_SEL, SIDDQ_SEL); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL_COMMON0, + SIDDQ, 0); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_UTMI_CTRL5, POR, 0); + + qcom_snps_eusb2_hsphy_write_mask(qcom_snps_eusb2->base, USB_PHY_HS_PHY_CTRL2, + USB2_SUSPEND_N_SEL, 0); + + return 0; +} + +static int qcom_snps_eusb2_phy_power_on(struct phy *phy) +{ + struct qcom_snps_eusb2_phy_priv *qcom_snps_eusb2 = dev_get_priv(phy->dev); + int ret; + + /* TODO Repeater */ + + clk_prepare_enable(qcom_snps_eusb2->ref_clk); + + ret = reset_deassert_bulk(&qcom_snps_eusb2->resets); + if (ret) + return ret; + + ret = qcom_snps_eusb2_usb_init(phy); + if (ret) + return ret; + + return 0; +} + +static int qcom_snps_eusb2_phy_power_off(struct phy *phy) +{ + struct qcom_snps_eusb2_phy_priv *qcom_snps_eusb2 = dev_get_priv(phy->dev); + + reset_assert_bulk(&qcom_snps_eusb2->resets); + clk_disable_unprepare(qcom_snps_eusb2->ref_clk); + + return 0; +} + +static int qcom_snps_eusb2_phy_probe(struct udevice *dev) +{ + struct qcom_snps_eusb2_phy_priv *qcom_snps_eusb2 = dev_get_priv(dev); + int ret; + + qcom_snps_eusb2->base = (void __iomem *)dev_read_addr(dev); + if (IS_ERR(qcom_snps_eusb2->base)) + return PTR_ERR(qcom_snps_eusb2->base); + + qcom_snps_eusb2->ref_clk = devm_clk_get(dev, "ref"); + if (IS_ERR(qcom_snps_eusb2->ref_clk)) { + printf("%s: failed to get ref clk %d\n", __func__, ret); + return PTR_ERR(qcom_snps_eusb2->ref_clk); + } + + ret = reset_get_bulk(dev, &qcom_snps_eusb2->resets); + if (ret < 0) { + printf("failed to get resets, ret = %d\n", ret); + return ret; + + return 0; +} + +static struct phy_ops qcom_snps_eusb2_phy_ops = { + .power_on = qcom_snps_eusb2_phy_power_on, + .power_off = qcom_snps_eusb2_phy_power_off, +}; + +static const struct udevice_id qcom_snps_eusb2_phy_ids[] = { + { + .compatible = "qcom,sm8550-snps-eusb2-phy", + }, + {} +}; + +U_BOOT_DRIVER(qcom_usb_qcom_snps_eusb2) = { + .name = "qcom-snps-eusb2-hsphy", + .id = UCLASS_PHY, + .of_match = qcom_snps_eusb2_phy_ids, + .ops = &qcom_snps_eusb2_phy_ops, + .probe = qcom_snps_eusb2_phy_probe, + .priv_auto = sizeof(struct qcom_snps_eusb2_phy_priv), +}; From patchwork Fri Apr 5 08:35:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 786203 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1101:b0:343:f27d:c44e with SMTP id z1csp57405wrw; Fri, 5 Apr 2024 01:36:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW9FUbavezWovbjkdRZxFpBAC+aBbcKBBW8nCQ78+UrgtYDOmLtfDPE2C9udxAYxsDzFzz/QYTVKgoxjLAEm2Ma X-Google-Smtp-Source: AGHT+IHESyEgZID7dcK3eu04bCVtcHjsfP66VkQNi3QTUDkR68rW3r2Oxy3NKPo/SWGFY1KUXv2s X-Received: by 2002:a17:907:b9cf:b0:a51:996b:f94a with SMTP id xa15-20020a170907b9cf00b00a51996bf94amr555298ejc.26.1712306179994; Fri, 05 Apr 2024 01:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712306179; cv=none; d=google.com; s=arc-20160816; b=TuaZMFde6XCsr4o0l6rD5bwImXPoFhG650SFZq6Gq1baH4eqSpeP7aBR1lr1uG19V5 I07qpAV/8gqiADU8mQvV9znh1fKufzRD9VxJ9pKwsoeu8brBRH0QXN9ZfV2XJIGVqaZA H+DNSmxqrnB5iuoDBk3uxDSLS5WmE5x4jRoKp6W6aM/hBfK3tc2SxXQvPWt49uiX65nK mxUd+ieoCgsA1mX7P+MJkMYRwvnrVdk2GoYqbSKbYy46YZq/JllFuPjSADayAql9wlrk V7NNy0TIpW3OYrBKHnwABn6NGEVN1vYONnXB+yrrUltetrrRDJuvHy2V11mH2tDh0fQ1 7B1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=U397QMxjRPtL4eZUzJ/Kl79N5zgnre2QvU7AvDmK8pI=; fh=F+Wp1cjN2WwcrhGpY0cI2eVSX5UKI3VOL/XTDkhvQVs=; b=FetZCuVfZvxShJvZPgF/avZSZWpNeBtP94NPkZa3PIk2eyfZDJVP96lCU3oWGY7diT 7ryHdZ6oR3V96sMAOg39/XNBg2ajp3wDY39rilyt9tshbb/Nbrs7xobU+zhye6+XQmfN pfCs8RzMLZZSiN7Q9AApr4hv69hrje1M3S86vuTC/IrDv7+TNPogQmrLoefWr4xcW6IL u556pQCvh3vFwbDBSCwpqm1TkGNbLjnoYvDkz3MNlE5fPJq+GrxLs0dNsm4gqhym7hzu 6aZks4RMbs1+l2IJ3Z6SPXAGotKdLmstlRU0dwtTVmhQVClR/eFfyD556OCWUO+BQ4bn DwKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kj9nki1N; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id i22-20020a170906265600b00a4720ded990si481068ejc.305.2024.04.05.01.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:36:19 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kj9nki1N; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 099F1884D2; Fri, 5 Apr 2024 10:36:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Kj9nki1N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 277CC884D2; Fri, 5 Apr 2024 10:36:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 13957884D5 for ; Fri, 5 Apr 2024 10:36:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e0ae065d24so16141605ad.1 for ; Fri, 05 Apr 2024 01:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712306164; x=1712910964; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=U397QMxjRPtL4eZUzJ/Kl79N5zgnre2QvU7AvDmK8pI=; b=Kj9nki1NoIQM7/YEG24Gd3ol6D3hPpiKJK1KbAp2Ao/oBtWo455tUHUxUWtOSbgLwP mNxVm3RQmzxJy9KR175TYsKTf1N3mgfazoZ4DQrOv5NkDCbBopFRQKJKfHKs3JrLr7s2 9Ov2VpVVT4KDnL3cTqOpsrE2RNb9hPegI4IdC0FR14maxF6b10yHXzep/H+smKcp5qmi lgWVAuWoRrQFWpvdBT/ZfvWrg/71bpSuy1/Xq2liHnDwlEdp8U2HAy0rDU8EKrZX1FL7 Q1Kk2CFibDLhoJ5PSxAq+qYGPZw5y3D9remImCnowXBJc5l6Itqr5NgBv2wYJIm5z9gC hBvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712306164; x=1712910964; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U397QMxjRPtL4eZUzJ/Kl79N5zgnre2QvU7AvDmK8pI=; b=skgkBcZD5Z9bSZXMXFgWdMlSXU3DC0EtEDzMLLviA24l9l2wAAPsjGXjnhGvQyU3kJ n1pRYnZ6/Q1XtHAhMeZ8V4W7kMMOD/NQfRF1Arwrg+VeKzZMSKsWk+jWfG8kLBDYdpbx BQTcARGA1hVo4iMwL2fwDxNWdfZbRJBRqIJEns+/p0gmMnAbh44opvf3OSQn1daqmSNM qz9GRwdlsjLAGvv2f9gI0OLKcW9PKWX7OKpVUgMGTYSP09znGq1+CPIymJ618nkb+yof sOZ+Abm9bQ/fSQ9ehXQ1uDHU4uOR9279GQyu0r0eQZYJO+FwrHYgNbRiUUHWa1KMh4XL 0QNg== X-Gm-Message-State: AOJu0Yz+cs2rY46Q4VOtXjoJFuVBgLOGeAGC2hVvmi/Z8MO0GadHoM94 qogoI8D32UxeJC4HVEOXOZ/hYXPEmtbA3gsWbT6SH6rhPWtsTrjpBQtboHCb5i4= X-Received: by 2002:a17:902:7484:b0:1e2:8eee:ca5a with SMTP id h4-20020a170902748400b001e28eeeca5amr672217pll.52.1712306164494; Fri, 05 Apr 2024 01:36:04 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id b12-20020a170902650c00b001e27e52a7e4sm1006572plk.285.2024.04.05.01.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:36:04 -0700 (PDT) From: Neil Armstrong Date: Fri, 05 Apr 2024 10:35:49 +0200 Subject: [PATCH 2/2] qcom_defconfig: enable the Qualcomm Synopsys eUSB2 PHY driver MIME-Version: 1.0 Message-Id: <20240405-topic-sm8x50-usb-phy-v1-2-8a8604bf818f@linaro.org> References: <20240405-topic-sm8x50-usb-phy-v1-0-8a8604bf818f@linaro.org> In-Reply-To: <20240405-topic-sm8x50-usb-phy-v1-0-8a8604bf818f@linaro.org> To: Tom Rini , Caleb Connolly , Sumit Garg Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=603; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=boXUB3s3CNQ8QkpPwrcBtwUbJTpUbLx5DIWT8T92m44=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmD7fqV7GiGbRzaUVIb+jYf2WLjaM92haItM1kkFQP wVCVlaWJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZg+36gAKCRB33NvayMhJ0bIfD/ 4kwZgRARlM2fWNbZdltfzdaQKC+x65qSUHT8rRWPvCP5IMienJkmBF8Tv5z83hAR61fxRsf/Uj5UO9 AvsHTjy2FZTiI362WHmqstUNbFgNmpAIIwJxiuE1Ps8hWYoNV6Nf+gjawjVN5hjnoY6AyKwN0NTfg5 r9ewWCpeV0IpjmE1iDs95RHgX90/aABfJz4zSJw11yV3JTHjgGCgfKdF+Gaex6BiBK96cXYGM0Uvaj eBH4ZIabe/vVe4jHgjylIbaIar7m3hb3pC3e97sH5R2Lq/7qGJ+QblZEFSsMfgfXVzTCuO48fHhv5O XfGX45kQg3WzfGWhWFbngpoNi5J2IMSa/wXrYAQJiXbuxo5a0o8WM3eOKixYKs+HqlJvhBVTX2+U7e pl05roQldReor34TPP4dWF6g5Bgyb/M8XyK2AoWGe4uCYU4FNrgkvzmTS4yIG10pH//5Np8LLmYLIh hRlZHjq5MaGYiJhbe0+eoh3cxVYH/v8eIeEIGsVLgEutPUCCrEig49cRv1vJPYa3e139f0CBqEFZ4i avHXYSo6hbf1CDUCTcyRqgxLQ1w6ytYO4hDFaGc1rmaH1aaHzz07eNVCJdrI0jIyh2QfZeVZ+mzdVC QNtNeu4ROUaKy3d3dx6h3FYxztdYMMJ1Cn85bWhrjrCLtFiAQOt7c4z6sfMQ== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Enable the Qualcomm Synopsys eUSB2 PHY driver in Qualcomm defconfig. Signed-off-by: Neil Armstrong --- configs/qcom_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig index 1abb57345ff..b0ae5eb4df3 100644 --- a/configs/qcom_defconfig +++ b/configs/qcom_defconfig @@ -63,6 +63,7 @@ CONFIG_RGMII=y CONFIG_PHY=y CONFIG_PHY_QCOM_QUSB2=y CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2=y +CONFIG_PHY_QCOM_SNPS_EUSB2=y CONFIG_PINCTRL=y CONFIG_PINCTRL_QCOM_QCS404=y CONFIG_PINCTRL_QCOM_SDM845=y