From patchwork Wed Apr 1 16:35:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 189783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97D4FC2D0F0 for ; Wed, 1 Apr 2020 16:36:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C32C20BED for ; Wed, 1 Apr 2020 16:36:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sartura-hr.20150623.gappssmtp.com header.i=@sartura-hr.20150623.gappssmtp.com header.b="rd+Awazg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388862AbgDAQgh (ORCPT ); Wed, 1 Apr 2020 12:36:37 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40447 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388853AbgDAQgg (ORCPT ); Wed, 1 Apr 2020 12:36:36 -0400 Received: by mail-wm1-f66.google.com with SMTP id a81so421232wmf.5 for ; Wed, 01 Apr 2020 09:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sartura-hr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NMjjibIIWKkjS3mT8K/LaAOt0umug6ECpFrUMrbf80Q=; b=rd+AwazgQtjycidexmpripXlv6sExR1iyC9NGpGdwXNOdf5HXtivEGNSm7y3HEEW01 pO5Jcwx099a+TbdeSZKSCeC1Ws3zT5LF11bALAwwG114zulw0YKnHuONg2uZjPUE5Wti uUMWUreMFRKj/XmfUiQVmXMRDhpHIEPsD+FEv409H2NuerOeYprfUCqL8ETi9Nu8DY0/ NqV8nhW4Rbik9ODqKHqhbHvDzLVlOHpluFOP5cGxsy9TQVSda31sUxDJ2wl3M0HABAt6 QuVJPJuT2ZIMelKRJBgK/3PeZWTk+MUaG/fVCo1YqRLYzkwalQ9PvsLDmlt3zMGKwAa5 cBXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NMjjibIIWKkjS3mT8K/LaAOt0umug6ECpFrUMrbf80Q=; b=ac5a9eAgbmmwBIAmCVm99wshpc0DKAPSboc0rVVK+O4MZkoarffRvvX793XrzwPTNH B3zMT6EsIqmdJanxUdZ7fx8ZEHfYflJuaxwOrZaUV2+szE1zghBY+yLOmTW5/q4boL6W jfbOc+YqwmuXF/+kkkIk0HORqIZ2ohp44B3DpsNX7knrdX3dfZut6KLi6LgcgXzyjR+k MQXu+ggmT/JbGO/+f/LHrIanMvCNqMF0qG0X+YrINzDzjGWk0olR+EhvKKZCgoWgq3/j /5Y6Xjka0X9ZY77F4pbs+gEQXCht7wNTxIKbFEL2bNJ+xDVJRJ88pYZ/7HB1omoxWBtH MFRA== X-Gm-Message-State: AGi0PuZ7lZMXyAIC5oC5obJ1dtQ5TMCLHvoyT+TXQxxuK+2e42A9uvWr 3St10+obFtQLvWtN1tJNAVD+2g== X-Google-Smtp-Source: APiQypISXBhfigkZ3U0+m3gPPPo3LeeW8N/Ua3b1ew6ttu1W9GvhfhsGF28tOPyyiAZWPly5FNy+Zw== X-Received: by 2002:a7b:c45a:: with SMTP id l26mr5149681wmi.22.1585758993767; Wed, 01 Apr 2020 09:36:33 -0700 (PDT) Received: from localhost.localdomain (dh207-97-209.xnet.hr. [88.207.97.209]) by smtp.googlemail.com with ESMTPSA id t5sm3763573wrr.93.2020.04.01.09.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 09:36:32 -0700 (PDT) From: Robert Marko To: agross@kernel.org, bjorn.andersson@linaro.org, kishon@ti.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org Cc: John Crispin , Robert Marko , Luka Perkov Subject: [PATCH v6 1/3] phy: add driver for Qualcomm IPQ40xx USB PHY Date: Wed, 1 Apr 2020 18:35:41 +0200 Message-Id: <20200401163542.83278-1-robert.marko@sartura.hr> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: John Crispin Add a driver to setup the USB phy on Qualcom Dakota SoCs. The driver sets up HS and SS phys. Signed-off-by: John Crispin Signed-off-by: Robert Marko Cc: Luka Perkov Reviewed-by: Rob Herring --- Changes from v2 to v3: * Remove magic writes as they are not needed * Correct commit message drivers/phy/qualcomm/Kconfig | 7 + drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c | 152 ++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c diff --git a/drivers/phy/qualcomm/Kconfig b/drivers/phy/qualcomm/Kconfig index e46824da29f6..964bd5d784d2 100644 --- a/drivers/phy/qualcomm/Kconfig +++ b/drivers/phy/qualcomm/Kconfig @@ -18,6 +18,13 @@ config PHY_QCOM_APQ8064_SATA depends on OF select GENERIC_PHY +config PHY_QCOM_IPQ4019_USB + tristate "Qualcomm IPQ4019 USB PHY module" + depends on OF && ARCH_QCOM + select GENERIC_PHY + help + Support for the USB PHY on QCOM IPQ4019/Dakota chipsets. + config PHY_QCOM_IPQ806X_SATA tristate "Qualcomm IPQ806x SATA SerDes/PHY driver" depends on ARCH_QCOM diff --git a/drivers/phy/qualcomm/Makefile b/drivers/phy/qualcomm/Makefile index 283251d6a5d9..8afe6c4f5178 100644 --- a/drivers/phy/qualcomm/Makefile +++ b/drivers/phy/qualcomm/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PHY_ATH79_USB) += phy-ath79-usb.o obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o +obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o obj-$(CONFIG_PHY_QCOM_PCIE2) += phy-qcom-pcie2.o obj-$(CONFIG_PHY_QCOM_QMP) += phy-qcom-qmp.o diff --git a/drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c new file mode 100644 index 000000000000..7efebae6b6fd --- /dev/null +++ b/drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2018 John Crispin + * + * Based on code from + * Allwinner Technology Co., Ltd. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct ipq4019_usb_phy { + struct device *dev; + struct phy *phy; + void __iomem *base; + struct reset_control *por_rst; + struct reset_control *srif_rst; +}; + +static int ipq4019_ss_phy_power_off(struct phy *_phy) +{ + struct ipq4019_usb_phy *phy = phy_get_drvdata(_phy); + + reset_control_assert(phy->por_rst); + msleep(10); + + return 0; +} + +static int ipq4019_ss_phy_power_on(struct phy *_phy) +{ + struct ipq4019_usb_phy *phy = phy_get_drvdata(_phy); + + ipq4019_ss_phy_power_off(_phy); + + reset_control_deassert(phy->por_rst); + + return 0; +} + +static struct phy_ops ipq4019_usb_ss_phy_ops = { + .power_on = ipq4019_ss_phy_power_on, + .power_off = ipq4019_ss_phy_power_off, +}; + +static int ipq4019_hs_phy_power_off(struct phy *_phy) +{ + struct ipq4019_usb_phy *phy = phy_get_drvdata(_phy); + + reset_control_assert(phy->por_rst); + msleep(10); + + reset_control_assert(phy->srif_rst); + msleep(10); + + return 0; +} + +static int ipq4019_hs_phy_power_on(struct phy *_phy) +{ + struct ipq4019_usb_phy *phy = phy_get_drvdata(_phy); + + ipq4019_hs_phy_power_off(_phy); + + reset_control_deassert(phy->srif_rst); + msleep(10); + + reset_control_deassert(phy->por_rst); + + return 0; +} + +static struct phy_ops ipq4019_usb_hs_phy_ops = { + .power_on = ipq4019_hs_phy_power_on, + .power_off = ipq4019_hs_phy_power_off, +}; + +static const struct of_device_id ipq4019_usb_phy_of_match[] = { + { .compatible = "qcom,usb-hs-ipq4019-phy", .data = &ipq4019_usb_hs_phy_ops}, + { .compatible = "qcom,usb-ss-ipq4019-phy", .data = &ipq4019_usb_ss_phy_ops}, + { }, +}; +MODULE_DEVICE_TABLE(of, ipq4019_usb_phy_of_match); + +static int ipq4019_usb_phy_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *res; + struct phy_provider *phy_provider; + struct ipq4019_usb_phy *phy; + const struct of_device_id *match; + + match = of_match_device(ipq4019_usb_phy_of_match, &pdev->dev); + if (!match) + return -ENODEV; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + + phy->dev = &pdev->dev; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + phy->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(phy->base)) { + dev_err(dev, "failed to remap register memory\n"); + return PTR_ERR(phy->base); + } + + phy->por_rst = devm_reset_control_get(phy->dev, "por_rst"); + if (IS_ERR(phy->por_rst)) { + if (PTR_ERR(phy->por_rst) != -EPROBE_DEFER) + dev_err(dev, "POR reset is missing\n"); + return PTR_ERR(phy->por_rst); + } + + phy->srif_rst = devm_reset_control_get_optional(phy->dev, "srif_rst"); + if (IS_ERR(phy->srif_rst)) + return PTR_ERR(phy->srif_rst); + + phy->phy = devm_phy_create(dev, NULL, match->data); + if (IS_ERR(phy->phy)) { + dev_err(dev, "failed to create PHY\n"); + return PTR_ERR(phy->phy); + } + phy_set_drvdata(phy->phy, phy); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + + return PTR_ERR_OR_ZERO(phy_provider); +} + +static struct platform_driver ipq4019_usb_phy_driver = { + .probe = ipq4019_usb_phy_probe, + .driver = { + .of_match_table = ipq4019_usb_phy_of_match, + .name = "ipq4019-usb-phy", + } +}; +module_platform_driver(ipq4019_usb_phy_driver); + +MODULE_DESCRIPTION("QCOM/IPQ4019 USB phy driver"); +MODULE_AUTHOR("John Crispin "); +MODULE_LICENSE("GPL v2"); From patchwork Wed Apr 1 16:35:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 189782 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB2BEC2D0F3 for ; Wed, 1 Apr 2020 16:51:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 818882071A for ; Wed, 1 Apr 2020 16:51:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sartura-hr.20150623.gappssmtp.com header.i=@sartura-hr.20150623.gappssmtp.com header.b="qY/eIwjW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388459AbgDAQiU (ORCPT ); Wed, 1 Apr 2020 12:38:20 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36499 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388928AbgDAQiT (ORCPT ); Wed, 1 Apr 2020 12:38:19 -0400 Received: by mail-wr1-f66.google.com with SMTP id 31so860838wrs.3 for ; Wed, 01 Apr 2020 09:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sartura-hr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u01MPjpNUTMHsez0F0H9AHhzrsoSor9pky3lmIVAZDI=; b=qY/eIwjWTJXKU3CMhFdA1LcoLfpQ+XQGJxcAMpPitVGg7GUr0q+Gip5HQYnBJNykG9 wzz+YsTE/68V7BAzrlqRdKXR+UcQpvqQzlvHstuYoLqTYH3L7t8BZ+sQw9U7pEC/VSQt UR+LYCtHGoOWedutWOaIJRVahsrvvioBitka8d8IdFfNA9XIDizaRUypbKgO5cVl4j4L 6uObLc8/uVhhZX1T8sTRUM0PcUKWt21lfBJp7yip+pP2GrjDNE37T+NNWw9qRtuHSOm3 CbN1UCpp1mrbdVowPqp0QPh7VVmEZQlw8rl3aVyGP9DZLiyYOJmKdIoYZ0W/190EAnHY /rdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u01MPjpNUTMHsez0F0H9AHhzrsoSor9pky3lmIVAZDI=; b=gSSenYJGwdPwx6omVWdGMb2TRY54JLm+vx5K1eqhgIBxqrdMCRugc5tZX03kX0E6uo hKIpzuNUqoAe6nxjW9MOkN5UAfz5u01PI0gqkWfIf3hAwM6oXrXsmFt1ybmHnDDFL+dY tjZIdAtY0bwVhc/KC4d3KND4b032TK+zQGufQCh0fbBBJBX1HRLZUDz4OO4Qm0tj8GAs rtz+lH3Zi4EzI05kt1B7UD2OhLUY4j0W7bpx/K/m9MuVVlYXe79bW5GG5pGPsz4qSDlU 1f00w7kdL8inKR1/g7bAM7XMBaccHTIHssYh4nAZGI/6TlyA5sjB0PX0TGMMBjs3gV1T txyQ== X-Gm-Message-State: ANhLgQ3ofG336Y+yqOq0FPFg6oAxkfr5ksLUK2UGjDcf64VI+bXBKOUd HxNXe34s3igqPlh81fFq1t4sbA== X-Google-Smtp-Source: ADFU+vu1nqgecFP77p8CwVLBYzELE8ooG1GeOW2OyfzUyCSFMSM9HZ3jS1LNuW/MdP4VWhz9/hi/7w== X-Received: by 2002:adf:e403:: with SMTP id g3mr25456194wrm.333.1585759097402; Wed, 01 Apr 2020 09:38:17 -0700 (PDT) Received: from localhost.localdomain (dh207-97-209.xnet.hr. [88.207.97.209]) by smtp.googlemail.com with ESMTPSA id t5sm3763573wrr.93.2020.04.01.09.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 09:38:14 -0700 (PDT) From: Robert Marko To: agross@kernel.org, bjorn.andersson@linaro.org, kishon@ti.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org Cc: John Crispin , Robert Marko , Luka Perkov Subject: [PATCH v6 3/3] ARM: dts: qcom: ipq4019: add USB devicetree nodes Date: Wed, 1 Apr 2020 18:35:45 +0200 Message-Id: <20200401163542.83278-3-robert.marko@sartura.hr> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401163542.83278-1-robert.marko@sartura.hr> References: <20200401163542.83278-1-robert.marko@sartura.hr> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: John Crispin Since we now have driver for the USB PHY, lets add the necessary nodes to DTSI. Signed-off-by: John Crispin Signed-off-by: Robert Marko Cc: Luka Perkov --- arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi | 20 +++++ arch/arm/boot/dts/qcom-ipq4019.dtsi | 74 +++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi index 418f9a022336..2ee5f05d5a43 100644 --- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi +++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi @@ -109,5 +109,25 @@ wifi@a000000 { wifi@a800000 { status = "ok"; }; + + usb3_ss_phy: ssphy@9a000 { + status = "ok"; + }; + + usb3_hs_phy: hsphy@a6000 { + status = "ok"; + }; + + usb3: usb3@8af8800 { + status = "ok"; + }; + + usb2_hs_phy: hsphy@a8000 { + status = "ok"; + }; + + usb2: usb2@60f8800 { + status = "ok"; + }; }; }; diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi b/arch/arm/boot/dts/qcom-ipq4019.dtsi index bfa9ce4c6e69..ee45253361cb 100644 --- a/arch/arm/boot/dts/qcom-ipq4019.dtsi +++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi @@ -576,5 +576,79 @@ wifi1: wifi@a800000 { "legacy"; status = "disabled"; }; + + usb3_ss_phy: ssphy@9a000 { + compatible = "qcom,usb-ss-ipq4019-phy"; + #phy-cells = <0>; + reg = <0x9a000 0x800>; + reg-names = "phy_base"; + resets = <&gcc USB3_UNIPHY_PHY_ARES>; + reset-names = "por_rst"; + status = "disabled"; + }; + + usb3_hs_phy: hsphy@a6000 { + compatible = "qcom,usb-hs-ipq4019-phy"; + #phy-cells = <0>; + reg = <0xa6000 0x40>; + reg-names = "phy_base"; + resets = <&gcc USB3_HSPHY_POR_ARES>, <&gcc USB3_HSPHY_S_ARES>; + reset-names = "por_rst", "srif_rst"; + status = "disabled"; + }; + + usb3@8af8800 { + compatible = "qcom,dwc3"; + reg = <0x8af8800 0x100>; + #address-cells = <1>; + #size-cells = <1>; + clocks = <&gcc GCC_USB3_MASTER_CLK>, + <&gcc GCC_USB3_SLEEP_CLK>, + <&gcc GCC_USB3_MOCK_UTMI_CLK>; + clock-names = "master", "sleep", "mock_utmi"; + ranges; + status = "disabled"; + + dwc3@8a00000 { + compatible = "snps,dwc3"; + reg = <0x8a00000 0xf8000>; + interrupts = ; + phys = <&usb3_hs_phy>, <&usb3_ss_phy>; + phy-names = "usb2-phy", "usb3-phy"; + dr_mode = "host"; + }; + }; + + usb2_hs_phy: hsphy@a8000 { + compatible = "qcom,usb-hs-ipq4019-phy"; + #phy-cells = <0>; + reg = <0xa8000 0x40>; + reg-names = "phy_base"; + resets = <&gcc USB2_HSPHY_POR_ARES>, <&gcc USB2_HSPHY_S_ARES>; + reset-names = "por_rst", "srif_rst"; + status = "disabled"; + }; + + usb2@60f8800 { + compatible = "qcom,dwc3"; + reg = <0x60f8800 0x100>; + #address-cells = <1>; + #size-cells = <1>; + clocks = <&gcc GCC_USB2_MASTER_CLK>, + <&gcc GCC_USB2_SLEEP_CLK>, + <&gcc GCC_USB2_MOCK_UTMI_CLK>; + clock-names = "master", "sleep", "mock_utmi"; + ranges; + status = "disabled"; + + dwc3@6000000 { + compatible = "snps,dwc3"; + reg = <0x6000000 0xf8000>; + interrupts = ; + phys = <&usb2_hs_phy>; + phy-names = "usb2-phy"; + dr_mode = "host"; + }; + }; }; };