From: Stephen Boyd <stephen.boyd@linaro.org>
To: linux-usb@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Andy Gross <andy.gross@linaro.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Neil Armstrong <narmstrong@baylibre.com>,
Arnd Bergmann <arnd@arndb.de>, Felipe Balbi <balbi@kernel.org>,
Peter Chen <peter.chen@nxp.com>,
Kishon Vijay Abraham I <kishon@ti.com>,
devicetree@vger.kernel.org
Subject: [PATCH v5 22/23] phy: Add support for Qualcomm's USB HSIC phy
Date: Mon, 17 Oct 2016 18:56:35 -0700 [thread overview]
Message-ID: <20161018015636.11701-23-stephen.boyd@linaro.org> (raw)
In-Reply-To: <20161018015636.11701-1-stephen.boyd@linaro.org>
The HSIC USB controller on qcom SoCs has an integrated all
digital phy controlled via the ULPI viewport.
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Rob Herring <robh@kernel.org>
Cc: <devicetree@vger.kernel.org>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---
.../devicetree/bindings/phy/qcom,usb-hsic-phy.txt | 65 +++++++++
drivers/phy/Kconfig | 7 +
drivers/phy/Makefile | 1 +
drivers/phy/phy-qcom-usb-hsic.c | 160 +++++++++++++++++++++
4 files changed, 233 insertions(+)
create mode 100644 Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt
create mode 100644 drivers/phy/phy-qcom-usb-hsic.c
diff --git a/Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt b/Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt
new file mode 100644
index 000000000000..3c7cb2be4b12
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt
@@ -0,0 +1,65 @@
+Qualcomm's USB HSIC PHY
+
+PROPERTIES
+
+- compatible:
+ Usage: required
+ Value type: <string>
+ Definition: Should contain "qcom,usb-hsic-phy" and more specifically one of the
+ following:
+
+ "qcom,usb-hsic-phy-mdm9615"
+ "qcom,usb-hsic-phy-msm8974"
+
+- #phy-cells:
+ Usage: required
+ Value type: <u32>
+ Definition: Should contain 0
+
+- clocks:
+ Usage: required
+ Value type: <prop-encoded-array>
+ Definition: Should contain clock specifier for phy, calibration and
+ a calibration sleep clock
+
+- clock-names:
+ Usage: required
+ Value type: <stringlist>
+ Definition: Should contain "phy, "cal" and "cal_sleep"
+
+- pinctrl-names:
+ Usage: required
+ Value type: <stringlist>
+ Definition: Should contain "init" and "default" in that order
+
+- pinctrl-0:
+ Usage: required
+ Value type: <prop-encoded-array>
+ Definition: List of pinctrl settings to apply to keep HSIC pins in a glitch
+ free state
+
+- pinctrl-1:
+ Usage: required
+ Value type: <prop-encoded-array>
+ Definition: List of pinctrl settings to apply to mux out the HSIC pins
+
+EXAMPLE
+
+usb-controller {
+ ulpi {
+ phy {
+ compatible = "qcom,usb-hsic-phy-msm8974",
+ "qcom,usb-hsic-phy";
+ #phy-cells = <0>;
+ pinctrl-names = "init", "default";
+ pinctrl-0 = <&hsic_sleep>;
+ pinctrl-1 = <&hsic_default>;
+ clocks = <&gcc GCC_USB_HSIC_CLK>,
+ <&gcc GCC_USB_HSIC_IO_CAL_CLK>,
+ <&gcc GCC_USB_HSIC_IO_CAL_SLEEP_CLK>;
+ clock-names = "phy", "cal", "cal_sleep";
+ assigned-clocks = <&gcc GCC_USB_HSIC_IO_CAL_CLK>;
+ assigned-clock-rates = <960000>;
+ };
+ };
+};
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index fe00f9134d51..6bfc91a8ea3e 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -453,6 +453,13 @@ config PHY_QCOM_UFS
help
Support for UFS PHY on QCOM chipsets.
+config PHY_QCOM_USB_HSIC
+ tristate "Qualcomm USB HSIC ULPI PHY module"
+ depends on USB_ULPI_BUS
+ select GENERIC_PHY
+ help
+ Support for the USB HSIC ULPI compliant PHY on QCOM chipsets.
+
config PHY_TUSB1210
tristate "TI TUSB1210 ULPI PHY module"
depends on USB_ULPI_BUS
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index a534cf5be07d..914b843eac13 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o
obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o
obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o
obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o
+obj-$(CONFIG_PHY_QCOM_USB_HSIC) += phy-qcom-usb-hsic.o
obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o
obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
diff --git a/drivers/phy/phy-qcom-usb-hsic.c b/drivers/phy/phy-qcom-usb-hsic.c
new file mode 100644
index 000000000000..47690f9945b9
--- /dev/null
+++ b/drivers/phy/phy-qcom-usb-hsic.c
@@ -0,0 +1,160 @@
+/**
+ * Copyright (C) 2016 Linaro Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/ulpi/driver.h>
+#include <linux/ulpi/regs.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/pinctrl-state.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+
+#include "ulpi_phy.h"
+
+#define ULPI_HSIC_CFG 0x30
+#define ULPI_HSIC_IO_CAL 0x33
+
+struct qcom_usb_hsic_phy {
+ struct ulpi *ulpi;
+ struct phy *phy;
+ struct pinctrl *pctl;
+ struct clk *phy_clk;
+ struct clk *cal_clk;
+ struct clk *cal_sleep_clk;
+};
+
+static int qcom_usb_hsic_phy_power_on(struct phy *phy)
+{
+ struct qcom_usb_hsic_phy *uphy = phy_get_drvdata(phy);
+ struct ulpi *ulpi = uphy->ulpi;
+ struct pinctrl_state *pins_default;
+ int ret;
+
+ ret = clk_prepare_enable(uphy->phy_clk);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(uphy->cal_clk);
+ if (ret)
+ goto err_cal;
+
+ ret = clk_prepare_enable(uphy->cal_sleep_clk);
+ if (ret)
+ goto err_sleep;
+
+ /* Set periodic calibration interval to ~2.048sec in HSIC_IO_CAL_REG */
+ ret = ulpi_write(ulpi, ULPI_HSIC_IO_CAL, 0xff);
+ if (ret)
+ goto err_ulpi;
+
+ /* Enable periodic IO calibration in HSIC_CFG register */
+ ret = ulpi_write(ulpi, ULPI_HSIC_CFG, 0xa8);
+ if (ret)
+ goto err_ulpi;
+
+ /* Configure pins for HSIC functionality */
+ pins_default = pinctrl_lookup_state(uphy->pctl, PINCTRL_STATE_DEFAULT);
+ if (IS_ERR(pins_default))
+ return PTR_ERR(pins_default);
+
+ ret = pinctrl_select_state(uphy->pctl, pins_default);
+ if (ret)
+ goto err_ulpi;
+
+ /* Enable HSIC mode in HSIC_CFG register */
+ ret = ulpi_write(ulpi, ULPI_SET(ULPI_HSIC_CFG), 0x01);
+ if (ret)
+ goto err_ulpi;
+
+ /* Disable auto-resume */
+ ret = ulpi_write(ulpi, ULPI_CLR(ULPI_IFC_CTRL),
+ ULPI_IFC_CTRL_AUTORESUME);
+ if (ret)
+ goto err_ulpi;
+
+ return ret;
+err_ulpi:
+ clk_disable_unprepare(uphy->cal_sleep_clk);
+err_sleep:
+ clk_disable_unprepare(uphy->cal_clk);
+err_cal:
+ clk_disable_unprepare(uphy->phy_clk);
+ return ret;
+}
+
+static int qcom_usb_hsic_phy_power_off(struct phy *phy)
+{
+ struct qcom_usb_hsic_phy *uphy = phy_get_drvdata(phy);
+
+ clk_disable_unprepare(uphy->cal_sleep_clk);
+ clk_disable_unprepare(uphy->cal_clk);
+ clk_disable_unprepare(uphy->phy_clk);
+
+ return 0;
+}
+
+static const struct phy_ops qcom_usb_hsic_phy_ops = {
+ .power_on = qcom_usb_hsic_phy_power_on,
+ .power_off = qcom_usb_hsic_phy_power_off,
+ .owner = THIS_MODULE,
+};
+
+static int qcom_usb_hsic_phy_probe(struct ulpi *ulpi)
+{
+ struct qcom_usb_hsic_phy *uphy;
+ struct phy_provider *p;
+ struct clk *clk;
+
+ uphy = devm_kzalloc(&ulpi->dev, sizeof(*uphy), GFP_KERNEL);
+ if (!uphy)
+ return -ENOMEM;
+ ulpi_set_drvdata(ulpi, uphy);
+
+ uphy->ulpi = ulpi;
+ uphy->pctl = devm_pinctrl_get(&ulpi->dev);
+ if (IS_ERR(uphy->pctl))
+ return PTR_ERR(uphy->pctl);
+
+ uphy->phy_clk = clk = devm_clk_get(&ulpi->dev, "phy");
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ uphy->cal_clk = clk = devm_clk_get(&ulpi->dev, "cal");
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ uphy->cal_sleep_clk = clk = devm_clk_get(&ulpi->dev, "cal_sleep");
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ uphy->phy = devm_phy_create(&ulpi->dev, ulpi->dev.of_node,
+ &qcom_usb_hsic_phy_ops);
+ if (IS_ERR(uphy->phy))
+ return PTR_ERR(uphy->phy);
+ phy_set_drvdata(uphy->phy, uphy);
+
+ p = devm_of_phy_provider_register(&ulpi->dev, of_phy_simple_xlate);
+ return PTR_ERR_OR_ZERO(p);
+}
+
+static const struct of_device_id qcom_usb_hsic_phy_match[] = {
+ { .compatible = "qcom,usb-hsic-phy", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, qcom_usb_hsic_phy_match);
+
+static struct ulpi_driver qcom_usb_hsic_phy_driver = {
+ .probe = qcom_usb_hsic_phy_probe,
+ .driver = {
+ .name = "qcom_usb_hsic_phy",
+ .of_match_table = qcom_usb_hsic_phy_match,
+ },
+};
+module_ulpi_driver(qcom_usb_hsic_phy_driver);
+
+MODULE_DESCRIPTION("Qualcomm USB HSIC phy");
+MODULE_LICENSE("GPL v2");
--
2.10.0.297.gf6727b0
prev parent reply other threads:[~2016-10-18 1:56 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 1:56 [PATCH v5 00/23] Support qcom's HSIC USB and rewrite USB2 HS support Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 03/23] usb: ulpi: Support device discovery via DT Stephen Boyd
2016-10-18 16:44 ` Rob Herring
2016-11-11 11:02 ` Heikki Krogerus
2016-10-18 1:56 ` [PATCH v5 04/23] usb: chipidea: Only read/write OTGSC from one place Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 05/23] usb: chipidea: Handle extcon events properly Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 06/23] usb: chipidea: Add platform flag for wrapper phy management Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 07/23] usb: chipidea: Notify events when switching host mode Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 08/23] usb: chipidea: Remove locking in ci_udc_start() Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 09/23] usb: chipidea: Add support for ULPI PHY bus Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 10/23] usb: chipidea: Consolidate extcon notifiers Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 11/23] usb: chipidea: Emulate OTGSC interrupt enable path Stephen Boyd
2016-10-19 1:15 ` Peter Chen
2016-10-19 1:53 ` Stephen Boyd
2016-10-19 8:02 ` Peter Chen
2016-10-20 6:55 ` Stephen Boyd
2016-10-20 10:10 ` Peter Chen
2016-10-20 20:36 ` Stephen Boyd
2016-10-21 2:14 ` Peter Chen
2016-10-21 17:57 ` Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 12/23] usb: chipidea: msm: Mark device as runtime pm active Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 13/23] usb: chipidea: msm: Rely on core to override AHBBURST Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 14/23] usb: chipidea: msm: Use hw_write_id_reg() instead of writel Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 15/23] usb: chipidea: msm: Add proper clk and reset support Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 16/23] usb: chipidea: msm: Mux over secondary phy at the right time Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 17/23] usb: chipidea: msm: Restore wrapper settings after reset Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 18/23] usb: chipidea: msm: Make platform data driver local instead of global Stephen Boyd
[not found] ` <20161018015636.11701-1-stephen.boyd-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-10-18 1:56 ` [PATCH v5 01/23] of: device: Support loading a module with OF based modalias Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 02/23] of: device: Export of_device_{get_modalias,uvent_modalias} to modules Stephen Boyd
[not found] ` <20161018015636.11701-3-stephen.boyd-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-10-18 5:20 ` [PATCH v5 02/23] of: device: Export of_device_{get_modalias, uvent_modalias} " Chen-Yu Tsai
2016-10-24 12:19 ` Chen-Yu Tsai
2016-10-24 19:48 ` Stephen Boyd
2016-10-25 1:16 ` Peter Chen
2016-11-04 20:51 ` Stephen Boyd
2016-11-07 1:29 ` Peter Chen
2016-11-07 1:56 ` Chen-Yu Tsai
[not found] ` <CAGb2v66C15fU1b2+xNDV8Fv2kmmKXyUknA8=9wXztUcs8CNKLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-10 21:42 ` Rob Herring
2016-11-11 3:01 ` Chen-Yu Tsai
2016-11-11 4:25 ` Javier Martinez Canillas
2016-10-18 1:56 ` [PATCH v5 19/23] usb: chipidea: msm: Add reset controller for PHY POR bit Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 20/23] usb: chipidea: msm: Handle phy power states Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 23/23] phy: Add support for Qualcomm's USB HS phy Stephen Boyd
2016-10-18 16:46 ` Rob Herring
2016-10-18 16:47 ` Rob Herring
[not found] ` <20161018015636.11701-24-stephen.boyd-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-10-20 23:20 ` Stephen Boyd
2016-10-21 2:20 ` Peter Chen
2016-10-21 19:33 ` Stephen Boyd
2016-10-24 2:14 ` Peter Chen
2016-10-18 9:31 ` [PATCH v5 00/23] Support qcom's HSIC USB and rewrite USB2 HS support Peter Chen
2016-10-18 20:51 ` Stephen Boyd
2016-11-11 7:40 ` Peter Chen
2016-11-14 19:35 ` Stephen Boyd
2016-10-18 1:56 ` [PATCH v5 21/23] usb: chipidea: msm: Be silent on probe defer errors Stephen Boyd
2016-10-18 1:56 ` Stephen Boyd [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161018015636.11701-23-stephen.boyd@linaro.org \
--to=stephen.boyd@linaro.org \
--cc=andy.gross@linaro.org \
--cc=arnd@arndb.de \
--cc=balbi@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=narmstrong@baylibre.com \
--cc=peter.chen@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).