|
@@ -1,18 +1,21 @@
|
|
|
-From 633f0e08498aebfdb932bd71319b4cb136709499 Mon Sep 17 00:00:00 2001
|
|
|
-From: John Crispin <[email protected]>
|
|
|
-Date: Tue, 24 Jul 2018 14:45:49 +0200
|
|
|
-Subject: [PATCH 2/3] phy: qcom-ipq4019-usb: add driver for QCOM/IPQ4019
|
|
|
+From 3c9d8f6c03a2cda1849ec3c84f82ec030d1f49ef Mon Sep 17 00:00:00 2001
|
|
|
+From: Robert Marko <[email protected]>
|
|
|
+Date: Sun, 3 May 2020 22:18:22 +0200
|
|
|
+Subject: [PATCH] phy: add driver for Qualcomm IPQ40xx USB PHY
|
|
|
|
|
|
-Add a driver to setup the USB phy on Qualcom Dakota SoCs.
|
|
|
-The driver sets up HS and SS phys. In case of HS some magic values need to
|
|
|
-be written to magic offsets. These were taken from the SDK driver.
|
|
|
+Add a driver to setup the USB PHY-s on Qualcom m IPQ40xx series SoCs.
|
|
|
+The driver sets up HS and SS phys.
|
|
|
|
|
|
Signed-off-by: John Crispin <[email protected]>
|
|
|
+Signed-off-by: Robert Marko <[email protected]>
|
|
|
+Cc: Luka Perkov <[email protected]>
|
|
|
+Link: https://lore.kernel.org/r/[email protected]
|
|
|
+Signed-off-by: Vinod Koul <[email protected]>
|
|
|
---
|
|
|
- drivers/phy/qualcomm/Kconfig | 7 ++
|
|
|
+ drivers/phy/qualcomm/Kconfig | 7 +
|
|
|
drivers/phy/qualcomm/Makefile | 1 +
|
|
|
- drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c | 188 ++++++++++++++++++++++++++++
|
|
|
- 3 files changed, 196 insertions(+)
|
|
|
+ drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c | 148 ++++++++++++++++++++
|
|
|
+ 3 files changed, 156 insertions(+)
|
|
|
create mode 100644 drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c
|
|
|
|
|
|
--- a/drivers/phy/qualcomm/Kconfig
|
|
@@ -22,33 +25,35 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
select GENERIC_PHY
|
|
|
|
|
|
+config PHY_QCOM_IPQ4019_USB
|
|
|
-+ tristate "Qualcomm IPQ4019 USB PHY module"
|
|
|
-+ depends on OF && ARCH_QCOM
|
|
|
++ tristate "Qualcomm IPQ4019 USB PHY driver"
|
|
|
++ depends on OF && (ARCH_QCOM || COMPILE_TEST)
|
|
|
+ select GENERIC_PHY
|
|
|
+ help
|
|
|
-+ Support for the USB PHY on QCOM IPQ4019/Dakota chipsets.
|
|
|
++ Support for the USB PHY-s on Qualcomm IPQ40xx SoC-s.
|
|
|
+
|
|
|
config PHY_QCOM_IPQ806X_SATA
|
|
|
tristate "Qualcomm IPQ806x SATA SerDes/PHY driver"
|
|
|
depends on ARCH_QCOM
|
|
|
+--- 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
|
|
|
--- /dev/null
|
|
|
+++ b/drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c
|
|
|
-@@ -0,0 +1,188 @@
|
|
|
+@@ -0,0 +1,148 @@
|
|
|
++// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
+/*
|
|
|
+ * Copyright (C) 2018 John Crispin <[email protected]>
|
|
|
+ *
|
|
|
+ * Based on code from
|
|
|
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
|
|
|
+ *
|
|
|
-+ * This program is free software; you can redistribute it and/or modify
|
|
|
-+ * it under the terms of the GNU General Public License as published by
|
|
|
-+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
-+ * (at your option) any later version.
|
|
|
-+ *
|
|
|
-+ * This program is distributed in the hope that it will be useful,
|
|
|
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-+ * GNU General Public License for more details.
|
|
|
+ */
|
|
|
+
|
|
|
+#include <linux/delay.h>
|
|
@@ -58,29 +63,11 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
+#include <linux/module.h>
|
|
|
+#include <linux/mutex.h>
|
|
|
+#include <linux/of_platform.h>
|
|
|
++#include <linux/of_device.h>
|
|
|
+#include <linux/phy/phy.h>
|
|
|
+#include <linux/platform_device.h>
|
|
|
+#include <linux/reset.h>
|
|
|
+
|
|
|
-+/*
|
|
|
-+ * Magic registers copied from the SDK driver code
|
|
|
-+ */
|
|
|
-+#define PHY_CTRL0_ADDR 0x000
|
|
|
-+#define PHY_CTRL1_ADDR 0x004
|
|
|
-+#define PHY_CTRL2_ADDR 0x008
|
|
|
-+#define PHY_CTRL3_ADDR 0x00C
|
|
|
-+#define PHY_CTRL4_ADDR 0x010
|
|
|
-+#define PHY_MISC_ADDR 0x024
|
|
|
-+#define PHY_IPG_ADDR 0x030
|
|
|
-+
|
|
|
-+#define PHY_CTRL0_VAL 0xA4600015
|
|
|
-+#define PHY_CTRL1_VAL 0x09500000
|
|
|
-+#define PHY_CTRL2_VAL 0x00058180
|
|
|
-+#define PHY_CTRL3_VAL 0x6DB6DCD6
|
|
|
-+#define PHY_CTRL4_VAL 0x836DB6DB
|
|
|
-+#define PHY_MISC_VAL 0x3803FB0C
|
|
|
-+#define PHY_IPG_VAL 0x47323232
|
|
|
-+
|
|
|
+struct ipq4019_usb_phy {
|
|
|
+ struct device *dev;
|
|
|
+ struct phy *phy;
|
|
@@ -137,15 +124,6 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
+ reset_control_deassert(phy->srif_rst);
|
|
|
+ msleep(10);
|
|
|
+
|
|
|
-+ writel(PHY_CTRL0_VAL, phy->base + PHY_CTRL0_ADDR);
|
|
|
-+ writel(PHY_CTRL1_VAL, phy->base + PHY_CTRL1_ADDR);
|
|
|
-+ writel(PHY_CTRL2_VAL, phy->base + PHY_CTRL2_ADDR);
|
|
|
-+ writel(PHY_CTRL3_VAL, phy->base + PHY_CTRL3_ADDR);
|
|
|
-+ writel(PHY_CTRL4_VAL, phy->base + PHY_CTRL4_ADDR);
|
|
|
-+ writel(PHY_MISC_VAL, phy->base + PHY_MISC_ADDR);
|
|
|
-+ writel(PHY_IPG_VAL, phy->base + PHY_IPG_ADDR);
|
|
|
-+ msleep(10);
|
|
|
-+
|
|
|
+ reset_control_deassert(phy->por_rst);
|
|
|
+
|
|
|
+ return 0;
|
|
@@ -169,11 +147,6 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
+ 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)
|
|
@@ -198,7 +171,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
+ if (IS_ERR(phy->srif_rst))
|
|
|
+ return PTR_ERR(phy->srif_rst);
|
|
|
+
|
|
|
-+ phy->phy = devm_phy_create(dev, NULL, match->data);
|
|
|
++ phy->phy = devm_phy_create(dev, NULL, of_device_get_match_data(dev));
|
|
|
+ if (IS_ERR(phy->phy)) {
|
|
|
+ dev_err(dev, "failed to create PHY\n");
|
|
|
+ return PTR_ERR(phy->phy);
|
|
@@ -222,13 +195,3 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
+MODULE_DESCRIPTION("QCOM/IPQ4019 USB phy driver");
|
|
|
+MODULE_AUTHOR("John Crispin <[email protected]>");
|
|
|
+MODULE_LICENSE("GPL v2");
|
|
|
---- 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
|