Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: Add a driver for the ATH79 USB phy

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 <albeu@free.fr>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Alban Bedel and committed by
Kishon Vijay Abraham I
cd3bf368 8866df25

+127 -1
+8
MAINTAINERS
··· 2326 2326 F: drivers/gpio/gpio-ath79.c 2327 2327 F: Documentation/devicetree/bindings/gpio/gpio-ath79.txt 2328 2328 2329 + ATHEROS 71XX/9XXX USB PHY DRIVER 2330 + M: Alban Bedel <albeu@free.fr> 2331 + W: https://github.com/AlbanBedel/linux 2332 + T: git git://github.com/AlbanBedel/linux 2333 + S: Maintained 2334 + F: drivers/phy/qualcomm/phy-ath79-usb.c 2335 + F: Documentation/devicetree/bindings/phy/phy-ath79-usb.txt 2336 + 2329 2337 ATHEROS ATH GENERIC UTILITIES 2330 2338 M: "Luis R. Rodriguez" <mcgrof@do-not-panic.com> 2331 2339 L: linux-wireless@vger.kernel.org
+10 -1
drivers/phy/qualcomm/Kconfig
··· 1 1 # 2 - # Phy drivers for Qualcomm platforms 2 + # Phy drivers for Qualcomm and Atheros platforms 3 3 # 4 + config PHY_ATH79_USB 5 + tristate "Atheros AR71XX/9XXX USB PHY driver" 6 + depends on OF && (ATH79 || COMPILE_TEST) 7 + default y if USB_EHCI_HCD_PLATFORM || USB_OHCI_HCD_PLATFORM 8 + select RESET_CONTROLLER 9 + select GENERIC_PHY 10 + help 11 + Enable this to support the USB PHY on Atheros AR71XX/9XXX SoCs. 12 + 4 13 config PHY_QCOM_APQ8064_SATA 5 14 tristate "Qualcomm APQ8064 SATA SerDes/PHY driver" 6 15 depends on ARCH_QCOM
+1
drivers/phy/qualcomm/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 + obj-$(CONFIG_PHY_ATH79_USB) += phy-ath79-usb.o 2 3 obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o 3 4 obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o 4 5 obj-$(CONFIG_PHY_QCOM_QMP) += phy-qcom-qmp.o
+108
drivers/phy/qualcomm/phy-ath79-usb.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Atheros AR71XX/9XXX USB PHY driver 4 + * 5 + * Copyright (C) 2015-2018 Alban Bedel <albeu@free.fr> 6 + */ 7 + 8 + #include <linux/module.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/phy/phy.h> 11 + #include <linux/reset.h> 12 + 13 + struct ath79_usb_phy { 14 + struct reset_control *reset; 15 + /* The suspend override logic is inverted, hence the no prefix 16 + * to make the code a bit easier to understand. 17 + */ 18 + struct reset_control *no_suspend_override; 19 + }; 20 + 21 + static int ath79_usb_phy_power_on(struct phy *phy) 22 + { 23 + struct ath79_usb_phy *priv = phy_get_drvdata(phy); 24 + int err = 0; 25 + 26 + if (priv->no_suspend_override) { 27 + err = reset_control_assert(priv->no_suspend_override); 28 + if (err) 29 + return err; 30 + } 31 + 32 + err = reset_control_deassert(priv->reset); 33 + if (err && priv->no_suspend_override) 34 + reset_control_assert(priv->no_suspend_override); 35 + 36 + return err; 37 + } 38 + 39 + static int ath79_usb_phy_power_off(struct phy *phy) 40 + { 41 + struct ath79_usb_phy *priv = phy_get_drvdata(phy); 42 + int err = 0; 43 + 44 + err = reset_control_assert(priv->reset); 45 + if (err) 46 + return err; 47 + 48 + if (priv->no_suspend_override) { 49 + err = reset_control_deassert(priv->no_suspend_override); 50 + if (err) 51 + reset_control_deassert(priv->reset); 52 + } 53 + 54 + return err; 55 + } 56 + 57 + static const struct phy_ops ath79_usb_phy_ops = { 58 + .power_on = ath79_usb_phy_power_on, 59 + .power_off = ath79_usb_phy_power_off, 60 + .owner = THIS_MODULE, 61 + }; 62 + 63 + static int ath79_usb_phy_probe(struct platform_device *pdev) 64 + { 65 + struct ath79_usb_phy *priv; 66 + struct phy *phy; 67 + 68 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 69 + if (!priv) 70 + return -ENOMEM; 71 + 72 + priv->reset = devm_reset_control_get(&pdev->dev, "usb-phy"); 73 + if (IS_ERR(priv->reset)) 74 + return PTR_ERR(priv->reset); 75 + 76 + priv->no_suspend_override = devm_reset_control_get_optional( 77 + &pdev->dev, "usb-suspend-override"); 78 + if (IS_ERR(priv->no_suspend_override)) 79 + return PTR_ERR(priv->no_suspend_override); 80 + 81 + phy = devm_phy_create(&pdev->dev, NULL, &ath79_usb_phy_ops); 82 + if (IS_ERR(phy)) 83 + return PTR_ERR(phy); 84 + 85 + phy_set_drvdata(phy, priv); 86 + 87 + return PTR_ERR_OR_ZERO(devm_of_phy_provider_register( 88 + &pdev->dev, of_phy_simple_xlate)); 89 + } 90 + 91 + static const struct of_device_id ath79_usb_phy_of_match[] = { 92 + { .compatible = "qca,ar7100-usb-phy" }, 93 + {} 94 + }; 95 + MODULE_DEVICE_TABLE(of, ath79_usb_phy_of_match); 96 + 97 + static struct platform_driver ath79_usb_phy_driver = { 98 + .probe = ath79_usb_phy_probe, 99 + .driver = { 100 + .of_match_table = ath79_usb_phy_of_match, 101 + .name = "ath79-usb-phy", 102 + } 103 + }; 104 + module_platform_driver(ath79_usb_phy_driver); 105 + 106 + MODULE_DESCRIPTION("ATH79 USB PHY driver"); 107 + MODULE_AUTHOR("Alban Bedel <albeu@free.fr>"); 108 + MODULE_LICENSE("GPL");