Received: by 10.213.65.68 with SMTP id h4csp118860imn; Sat, 24 Mar 2018 15:40:04 -0700 (PDT) X-Google-Smtp-Source: AG47ELuUjHhZf4LMy6nEXAhu16045MqCvU+q9mWKpd82zul3B+cGSp6lEr4/Eopsol0vz4tjT5PM X-Received: by 10.99.122.80 with SMTP id j16mr24762647pgn.5.1521931204810; Sat, 24 Mar 2018 15:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521931204; cv=none; d=google.com; s=arc-20160816; b=uV6pH16YnOAL7Ay6Rj8OePi7tszEqKml1vj673oqv70tsLuIqioG66jY746EwJybjI 2ECbCj2xZLOU3+CvBfcIiWhcs5BDJU+L5+4Gz2qu7Rb7qPDVF01y+uvOy8SzdCZ4Wj14 frgssYVbZYNNJ9a1/x8ALiN1I0sRq2hvYAaxJ55Gy7OYjPrJQ8K0AeLWyrHRpiQAVcme egudDB4L4WGKLilK3+oKxIVfqPE91JNWQHbN0RqQt0jHJLsSmb+ATYIeySOc5EQR6FiK IHN479YA5BBGDPydYQvb3Twcoa0/NRJ96EtYwclfeR0W3AZi8p7+RKgGyGNKGneeDXcj uGog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=xCXIIftv4fCuD7IjNhl/VkkiM6fbzQiEu8682WuYhS0=; b=T3Cla20DZp/W4jvT7pCLr9i6elh9Q0zqNkdFIM/8nlfPMWN+AOa90/X9Q3JzsNAThn CdX+PXUrln1udtF7vsi9ccvrJJjGmy/sW3Bv2x4cP/EngcVq2WYfKAgpxIqExiTthMTg aBfx2q40VsI9LdBd6a1HQcthjJ9QbBAYtFZFp6nMEQPu4nmMQ8NncopZVXsOg/dhHbTz F0pHASYloYzWikGTpBpv0In8+kBkFl8kyMYHDtDxdLxXVaOHDvT7vb9sSBp2i+BVp/3f BBhI9U3uUTm7tG24dJ5BorxE56QL0mosxrcjNZSVPUlmClqTH8p3uRbbEgIhJ/cHD312 cWuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b72si9285591pfk.135.2018.03.24.15.39.50; Sat, 24 Mar 2018 15:40:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752754AbeCXWiy (ORCPT + 99 others); Sat, 24 Mar 2018 18:38:54 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:38576 "EHLO smtp4-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752686AbeCXWiw (ORCPT ); Sat, 24 Mar 2018 18:38:52 -0400 Received: from tock.home (unknown [IPv6:2a02:8108:4740:3978:85fa:b641:9ec1:a586]) (Authenticated sender: albeu) by smtp4-g21.free.fr (Postfix) with ESMTPA id C6E4B19F4EA; Sat, 24 Mar 2018 23:38:45 +0100 (CET) From: Alban Bedel To: Kishon Vijay Abraham I Cc: Alban Bedel , linux-kernel@vger.kernel.org Subject: [PATCH] phy: Add a driver for the ATH79 USB phy Date: Sat, 24 Mar 2018 23:38:40 +0100 Message-Id: <1521931120-31118-1-git-send-email-albeu@free.fr> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ATH79 USB phy is very simple, it only have a reset. On some SoC a second reset is used to force the phy in suspend mode regardless of the USB controller status. This driver is added to the qualcom directory as atheros is now part of qualcom and newer SoC of this familly are marketed under the qualcom name. Signed-off-by: Alban Bedel --- MAINTAINERS | 8 +++ drivers/phy/qualcomm/Kconfig | 11 +++- drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-ath79-usb.c | 108 +++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 drivers/phy/qualcomm/phy-ath79-usb.c diff --git a/MAINTAINERS b/MAINTAINERS index 73c0cda..ce5ecd6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2294,6 +2294,14 @@ S: Maintained F: drivers/gpio/gpio-ath79.c F: Documentation/devicetree/bindings/gpio/gpio-ath79.txt +ATHEROS 71XX/9XXX USB PHY DRIVER +M: Alban Bedel +W: https://github.com/AlbanBedel/linux +T: git git://github.com/AlbanBedel/linux +S: Maintained +F: drivers/phy/qualcomm/phy-ath79-usb.c +F: Documentation/devicetree/bindings/phy/phy-ath79-usb.txt + ATHEROS ATH GENERIC UTILITIES M: "Luis R. Rodriguez" L: linux-wireless@vger.kernel.org diff --git a/drivers/phy/qualcomm/Kconfig b/drivers/phy/qualcomm/Kconfig index 7bfa64b..632a0e7 100644 --- a/drivers/phy/qualcomm/Kconfig +++ b/drivers/phy/qualcomm/Kconfig @@ -1,6 +1,15 @@ # -# Phy drivers for Qualcomm platforms +# Phy drivers for Qualcomm and Atheros platforms # +config PHY_ATH79_USB + tristate "Atheros AR71XX/9XXX USB PHY driver" + depends on OF && (ATH79 || COMPILE_TEST) + default y if USB_EHCI_HCD_PLATFORM || USB_OHCI_HCD_PLATFORM + select RESET_CONTROLLER + select GENERIC_PHY + help + Enable this to support the USB PHY on Atheros AR71XX/9XXX SoCs. + config PHY_QCOM_APQ8064_SATA tristate "Qualcomm APQ8064 SATA SerDes/PHY driver" depends on ARCH_QCOM diff --git a/drivers/phy/qualcomm/Makefile b/drivers/phy/qualcomm/Makefile index 9abb789..deb831f4 100644 --- a/drivers/phy/qualcomm/Makefile +++ b/drivers/phy/qualcomm/Makefile @@ -1,4 +1,5 @@ # 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_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o obj-$(CONFIG_PHY_QCOM_QMP) += phy-qcom-qmp.o diff --git a/drivers/phy/qualcomm/phy-ath79-usb.c b/drivers/phy/qualcomm/phy-ath79-usb.c new file mode 100644 index 0000000..6fd6e07 --- /dev/null +++ b/drivers/phy/qualcomm/phy-ath79-usb.c @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Atheros AR71XX/9XXX USB PHY driver + * + * Copyright (C) 2015-2018 Alban Bedel + */ + +#include +#include +#include +#include + +struct ath79_usb_phy { + struct reset_control *reset; + /* The suspend override logic is inverted, hence the no prefix + * to make the code a bit easier to understand. + */ + struct reset_control *no_suspend_override; +}; + +static int ath79_usb_phy_power_on(struct phy *phy) +{ + struct ath79_usb_phy *priv = phy_get_drvdata(phy); + int err = 0; + + if (priv->no_suspend_override) { + err = reset_control_assert(priv->no_suspend_override); + if (err) + return err; + } + + err = reset_control_deassert(priv->reset); + if (err && priv->no_suspend_override) + reset_control_assert(priv->no_suspend_override); + + return err; +} + +static int ath79_usb_phy_power_off(struct phy *phy) +{ + struct ath79_usb_phy *priv = phy_get_drvdata(phy); + int err = 0; + + err = reset_control_assert(priv->reset); + if (err) + return err; + + if (priv->no_suspend_override) { + err = reset_control_deassert(priv->no_suspend_override); + if (err) + reset_control_deassert(priv->reset); + } + + return err; +} + +static const struct phy_ops ath79_usb_phy_ops = { + .power_on = ath79_usb_phy_power_on, + .power_off = ath79_usb_phy_power_off, + .owner = THIS_MODULE, +}; + +static int ath79_usb_phy_probe(struct platform_device *pdev) +{ + struct ath79_usb_phy *priv; + struct phy *phy; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->reset = devm_reset_control_get(&pdev->dev, "usb-phy"); + if (IS_ERR(priv->reset)) + return PTR_ERR(priv->reset); + + priv->no_suspend_override = devm_reset_control_get_optional( + &pdev->dev, "usb-suspend-override"); + if (IS_ERR(priv->no_suspend_override)) + return PTR_ERR(priv->no_suspend_override); + + phy = devm_phy_create(&pdev->dev, NULL, &ath79_usb_phy_ops); + if (IS_ERR(phy)) + return PTR_ERR(phy); + + phy_set_drvdata(phy, priv); + + return PTR_ERR_OR_ZERO(devm_of_phy_provider_register( + &pdev->dev, of_phy_simple_xlate)); +} + +static const struct of_device_id ath79_usb_phy_of_match[] = { + { .compatible = "qca,ar7100-usb-phy" }, + {} +}; +MODULE_DEVICE_TABLE(of, ath79_usb_phy_of_match); + +static struct platform_driver ath79_usb_phy_driver = { + .probe = ath79_usb_phy_probe, + .driver = { + .of_match_table = ath79_usb_phy_of_match, + .name = "ath79-usb-phy", + } +}; +module_platform_driver(ath79_usb_phy_driver); + +MODULE_DESCRIPTION("ATH79 USB PHY driver"); +MODULE_AUTHOR("Alban Bedel "); +MODULE_LICENSE("GPL"); -- 2.7.4