From: Manu Gautam <mgautam@codeaurora.org>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <balbi@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
Manu Gautam <mgautam@codeaurora.org>,
Vivek Gautam <vivek.gautam@codeaurora.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
"open list:GENERIC PHY FRAMEWORK" <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 14/17] phy: qcom-qusb2: Set vbus sw-override signal in device mode
Date: Wed, 27 Sep 2017 14:29:10 +0530 [thread overview]
Message-ID: <1506502753-27408-15-git-send-email-mgautam@codeaurora.org> (raw)
In-Reply-To: <1506502753-27408-1-git-send-email-mgautam@codeaurora.org>
VBUS signal coming from PHY must be asserted in device for
controller to start operation or assert pull-up. For some
platforms where VBUS line is not connected to PHY there is
HS_PHY_CTRL register in QSCRATCH wrapper that can be used
by software to override VBUS signal going to controller.
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
---
drivers/phy/qualcomm/phy-qcom-qusb2.c | 39 +++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/phy/qualcomm/phy-qcom-qusb2.c b/drivers/phy/qualcomm/phy-qcom-qusb2.c
index bda1f4c..0e9d88b 100644
--- a/drivers/phy/qualcomm/phy-qcom-qusb2.c
+++ b/drivers/phy/qualcomm/phy-qcom-qusb2.c
@@ -68,6 +68,11 @@
#define QUSB2PHY_IMP_CTRL2 0x224
#define QUSB2PHY_CHG_CTRL2 0x23c
+/* QSCRATCH register bits */
+#define QSCRATCH_HS_PHY_CTRL 0x10
+#define UTMI_OTG_VBUS_VALID BIT(20)
+#define SW_SESSVLD_SEL BIT(28)
+
struct qusb2_phy_init_tbl {
unsigned int offset;
unsigned int val;
@@ -211,6 +216,7 @@ struct qusb2_phy_cfg {
*
* @phy: generic phy
* @base: iomapped memory space for qubs2 phy
+ * @qscratch_base: iomapped memory space for qscratch region
*
* @cfg_ahb_clk: AHB2PHY interface clock
* @ref_clk: phy reference clock
@@ -223,10 +229,12 @@ struct qusb2_phy_cfg {
*
* @cfg: phy config data
* @has_se_clk_scheme: indicate if PHY has single-ended ref clock scheme
+ * @mode: indicate current PHY mode of operation e.g. HOST or DEVICE
*/
struct qusb2_phy {
struct phy *phy;
void __iomem *base;
+ void __iomem *qscratch_base;
struct clk *cfg_ahb_clk;
struct clk *ref_clk;
@@ -239,6 +247,7 @@ struct qusb2_phy {
const struct qusb2_phy_cfg *cfg;
bool has_se_clk_scheme;
+ enum phy_mode mode;
};
static inline void qusb2_setbits(void __iomem *base, u32 offset, u32 val)
@@ -307,6 +316,25 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy)
qusb2_setbits(qphy->base, QUSB2PHY_PORT_TUNE2, val[0] << 0x4);
}
+static int qusb2_phy_set_mode(struct phy *phy, enum phy_mode mode)
+{
+ struct qusb2_phy *qphy = phy_get_drvdata(phy);
+
+ qphy->mode = mode;
+
+ /* Update VBUS override in qscratch register */
+ if (qphy->qscratch_base) {
+ if (mode == PHY_MODE_USB_DEVICE)
+ qusb2_setbits(qphy->qscratch_base, QSCRATCH_HS_PHY_CTRL,
+ UTMI_OTG_VBUS_VALID | SW_SESSVLD_SEL);
+ else
+ qusb2_clrbits(qphy->qscratch_base, QSCRATCH_HS_PHY_CTRL,
+ UTMI_OTG_VBUS_VALID | SW_SESSVLD_SEL);
+ }
+
+ return 0;
+}
+
static int qusb2_phy_init(struct phy *phy)
{
struct qusb2_phy *qphy = phy_get_drvdata(phy);
@@ -473,6 +501,7 @@ static int qusb2_phy_exit(struct phy *phy)
static const struct phy_ops qusb2_phy_gen_ops = {
.init = qusb2_phy_init,
.exit = qusb2_phy_exit,
+ .set_mode = qusb2_phy_set_mode,
.owner = THIS_MODULE,
};
@@ -507,6 +536,16 @@ static int qusb2_phy_probe(struct platform_device *pdev)
if (IS_ERR(qphy->base))
return PTR_ERR(qphy->base);
+ /* Check if platform uses qscratch wrapper */
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qscratch");
+ if (res) {
+ /* Can't request region as used by other phy and glue drivers */
+ qphy->qscratch_base = devm_ioremap(dev, res->start,
+ resource_size(res));
+ if (IS_ERR(qphy->qscratch_base))
+ return PTR_ERR(qphy->qscratch_base);
+ }
+
qphy->cfg_ahb_clk = devm_clk_get(dev, "cfg_ahb");
if (IS_ERR(qphy->cfg_ahb_clk)) {
ret = PTR_ERR(qphy->cfg_ahb_clk);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
WARNING: multiple messages have this Message-ID (diff)
From: Manu Gautam <mgautam@codeaurora.org>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <balbi@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
Manu Gautam <mgautam@codeaurora.org>,
Vivek Gautam <vivek.gautam@codeaurora.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
linux-kernel@vger.kernel.org (open list:GENERIC PHY FRAMEWORK)
Subject: [PATCH v2 14/17] phy: qcom-qusb2: Set vbus sw-override signal in device mode
Date: Wed, 27 Sep 2017 14:29:10 +0530 [thread overview]
Message-ID: <1506502753-27408-15-git-send-email-mgautam@codeaurora.org> (raw)
In-Reply-To: <1506502753-27408-1-git-send-email-mgautam@codeaurora.org>
VBUS signal coming from PHY must be asserted in device for
controller to start operation or assert pull-up. For some
platforms where VBUS line is not connected to PHY there is
HS_PHY_CTRL register in QSCRATCH wrapper that can be used
by software to override VBUS signal going to controller.
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
---
drivers/phy/qualcomm/phy-qcom-qusb2.c | 39 +++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/phy/qualcomm/phy-qcom-qusb2.c b/drivers/phy/qualcomm/phy-qcom-qusb2.c
index bda1f4c..0e9d88b 100644
--- a/drivers/phy/qualcomm/phy-qcom-qusb2.c
+++ b/drivers/phy/qualcomm/phy-qcom-qusb2.c
@@ -68,6 +68,11 @@
#define QUSB2PHY_IMP_CTRL2 0x224
#define QUSB2PHY_CHG_CTRL2 0x23c
+/* QSCRATCH register bits */
+#define QSCRATCH_HS_PHY_CTRL 0x10
+#define UTMI_OTG_VBUS_VALID BIT(20)
+#define SW_SESSVLD_SEL BIT(28)
+
struct qusb2_phy_init_tbl {
unsigned int offset;
unsigned int val;
@@ -211,6 +216,7 @@ struct qusb2_phy_cfg {
*
* @phy: generic phy
* @base: iomapped memory space for qubs2 phy
+ * @qscratch_base: iomapped memory space for qscratch region
*
* @cfg_ahb_clk: AHB2PHY interface clock
* @ref_clk: phy reference clock
@@ -223,10 +229,12 @@ struct qusb2_phy_cfg {
*
* @cfg: phy config data
* @has_se_clk_scheme: indicate if PHY has single-ended ref clock scheme
+ * @mode: indicate current PHY mode of operation e.g. HOST or DEVICE
*/
struct qusb2_phy {
struct phy *phy;
void __iomem *base;
+ void __iomem *qscratch_base;
struct clk *cfg_ahb_clk;
struct clk *ref_clk;
@@ -239,6 +247,7 @@ struct qusb2_phy {
const struct qusb2_phy_cfg *cfg;
bool has_se_clk_scheme;
+ enum phy_mode mode;
};
static inline void qusb2_setbits(void __iomem *base, u32 offset, u32 val)
@@ -307,6 +316,25 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy)
qusb2_setbits(qphy->base, QUSB2PHY_PORT_TUNE2, val[0] << 0x4);
}
+static int qusb2_phy_set_mode(struct phy *phy, enum phy_mode mode)
+{
+ struct qusb2_phy *qphy = phy_get_drvdata(phy);
+
+ qphy->mode = mode;
+
+ /* Update VBUS override in qscratch register */
+ if (qphy->qscratch_base) {
+ if (mode == PHY_MODE_USB_DEVICE)
+ qusb2_setbits(qphy->qscratch_base, QSCRATCH_HS_PHY_CTRL,
+ UTMI_OTG_VBUS_VALID | SW_SESSVLD_SEL);
+ else
+ qusb2_clrbits(qphy->qscratch_base, QSCRATCH_HS_PHY_CTRL,
+ UTMI_OTG_VBUS_VALID | SW_SESSVLD_SEL);
+ }
+
+ return 0;
+}
+
static int qusb2_phy_init(struct phy *phy)
{
struct qusb2_phy *qphy = phy_get_drvdata(phy);
@@ -473,6 +501,7 @@ static int qusb2_phy_exit(struct phy *phy)
static const struct phy_ops qusb2_phy_gen_ops = {
.init = qusb2_phy_init,
.exit = qusb2_phy_exit,
+ .set_mode = qusb2_phy_set_mode,
.owner = THIS_MODULE,
};
@@ -507,6 +536,16 @@ static int qusb2_phy_probe(struct platform_device *pdev)
if (IS_ERR(qphy->base))
return PTR_ERR(qphy->base);
+ /* Check if platform uses qscratch wrapper */
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qscratch");
+ if (res) {
+ /* Can't request region as used by other phy and glue drivers */
+ qphy->qscratch_base = devm_ioremap(dev, res->start,
+ resource_size(res));
+ if (IS_ERR(qphy->qscratch_base))
+ return PTR_ERR(qphy->qscratch_base);
+ }
+
qphy->cfg_ahb_clk = devm_clk_get(dev, "cfg_ahb");
if (IS_ERR(qphy->cfg_ahb_clk)) {
ret = PTR_ERR(qphy->cfg_ahb_clk);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-09-27 8:59 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 8:58 [PATCH v2 00/17] Support for Qualcomm QUSBv2 and QMPv3 USB PHYs Manu Gautam
2017-09-27 8:58 ` [PATCH v2 01/17] phy: qcom-qmp: Fix phy pipe clock gating Manu Gautam
2017-09-27 8:58 ` Manu Gautam
2017-09-27 8:58 ` [PATCH v2 02/17] phy: qcom-qmp: Adapt to clk_bulk_* APIs Manu Gautam
2017-09-27 8:58 ` Manu Gautam
2017-09-27 8:58 ` [PATCH v2 03/17] phy: qcom-qmp: Power-on PHY before initialization Manu Gautam
2017-09-27 8:58 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 04/17] phy: qcom-qusb2: " Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 05/17] phy: qcom-qmp: Fix PHY block reset sequence Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 06/17] phy: qcom-qmp: Move SERDES/PCS START after PHY reset Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 07/17] phy: qcom-qusb2: Add support for different register layouts Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 08/17] dt-bindings: phy-qcom-qusb2: Update binding for QUSB2 V2 version Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-10-05 22:10 ` Rob Herring
2017-09-27 8:59 ` [PATCH v2 09/17] phy: qcom-qusb2: Add support " Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 10/17] phy: qcom-qmp: Move register offsets to header file Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 11/17] phy: qcom-qmp: Add register offsets for QMP V3 PHY Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 12/17] dt-bindings: phy-qcom-qmp: Update bindings for QMP V3 USB PHY Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-10-05 22:14 ` Rob Herring
2017-09-27 8:59 ` [PATCH v2 13/17] phy: qcom-qmp: Add support for QMP V3 USB3 PHY Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 17:59 ` Jack Pham
2017-10-05 6:30 ` Manu Gautam
2017-09-27 8:59 ` Manu Gautam [this message]
2017-09-27 8:59 ` [PATCH v2 14/17] phy: qcom-qusb2: Set vbus sw-override signal in device mode Manu Gautam
2017-09-27 17:57 ` Jack Pham
2017-09-27 19:16 ` Jack Pham
2017-09-28 4:00 ` Manu Gautam
2017-09-28 16:53 ` Jack Pham
2017-10-05 9:08 ` Manu Gautam
2017-10-09 8:03 ` Manu Gautam
2017-10-23 10:49 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 15/17] phy: qcom-qusb2: Add support for runtime PM Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 16/17] phy: qcom-qmp: Override lane0_power_present signal in device mode Manu Gautam
2017-09-27 8:59 ` Manu Gautam
2017-09-27 8:59 ` [PATCH v2 17/17] phy: qcom-qmp: Add support for runtime PM Manu Gautam
2017-09-27 8:59 ` Manu Gautam
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=1506502753-27408-15-git-send-email-mgautam@codeaurora.org \
--to=mgautam@codeaurora.org \
--cc=balbi@kernel.org \
--cc=kishon@ti.com \
--cc=krzk@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=vivek.gautam@codeaurora.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.