Support qcom's HSIC USB and rewrite USB2 HS support
Subsystems (5)
v7 cover Support qcom's HSIC USB and rewrite USB2 HS support
This patch series continues the usb chipidea rewrite for Qualcommm platforms. I've dropped the patches that were applied to Peter's tree for chipidea. Now the phy drivers are left, along with a new hook to set the vbus in the phy and changes to chipidea to call the new hook.
I've left the HSIC phy driver here, because it wasn't merged in the last round. Nothing has changed in that driver, so I believe it is ready to be merged now. The real changes are the new set_vbus() hook and how we're supposed to handle that in the HS phy driver.
The only dependencies between subsystems is the set_vbus callback. If that can go into some stable branch in the phy tree, then Kishon can apply the phy patches on top of that and Peter can apply the small chipidea patch on top of that. Or everything can go in parallel, except for the chipidea patch that adds the set_vbus hook. That hook can be added after rc1 when dependencies merge.
Patches based on v4.10-rc1 + first 22 patches from v5. Full branch is here[1].
Changes from v6:
* Dropped first 22 applied patches
* Rewrote phy_set_mode() patch to be msm specific
* New set_vbus() callback in phy framework
* Updated HS phy driver for set_vbus() callback
Changes from v5:
* Replaced "Emulate OTGSC interrupt enable path" patch with a patch from Peter
* Updated HS phy driver to support set_mode callback to handle pullup
* New patch to set the mode to device or host in chipidea udc pullup function to toggle the pullup for HS mode
* New patch to drop lock around event_notify callback to avoid lockdep issues
* Removal of extcon usage from HS phy driver
* Picked up acks from Heikki and Peter on ULPI core patch
Changes from v4:
* Picked up Acks from Rob
* Updated HS phy init sequence DT property to restrict it to offsets
Changes from v3:
* Picked up Acks from Peter
* Updated extcon consolidation patch per Peter's comments
* Folded in simplification from Heikki for ULPI DT matching
Changes from v2:
* Added SoC specific compatibles in phy bindings
* Dropped AVVIS patch for OTG statemachine
* New patch to consolidate extcon handlers
* Picked up Acks from Peter
* Rebased onto v4.8-rc1
* Reworked ULPI OF code to look at vid == 0 instead of pid == 0
* Dropped ULPI bindings for vid and pid overrides
Changes from v1:
* Reworked ULPI device probing to keep using vendor/product ids that come from DT if needed and falls back to OF style match when product id is 0
* PHY init later patch was rejected so that moved to a quirk flag and the msm wrapper started managing the phy on/off
* Updated clk requirements for HSIC phy in binding doc
* Added optional clk in wrapper for "housekeeping" found on older qcom platforms
* Bug fix to OTGSC polling function
* Changed runtime PM patch to set as active instead of get/put
TODO:
* DMA fails on arm64 so we need something like [2] to make it work.
* The db410c needs a driver to toggle the onboard switch to connect the usb hub instead of micro port when the usb cable is disconnected. I've sent a patch set for this[3], which needs some further discussion/development. The current plan is to reintroduce the usb mux framework.
* apq8064 platforms need a vbus regulator to really use otg and I haven't tried out the RPM based regulators yet
* The HSIC phy on the apq8074 dragonboard is connected to a usb4604 device which requires the i2c driver to probe and send an i2c sequence before the HSIC controller enumerates or HSIC doesn't work. Right now I have a hack to force the controller to probe defer once so that usb4604 probes first. This needs a more proper solution like having the DT describe a linkage between the controller and the usb device so we can enforce probe ordering. My current plan is to use DT graphs/endpoints for this.
[1] https://git.linaro.org/people/stephen.boyd/linux.git/log/?h=usb-hsic-8074
[2] https://patchwork.kernel.org/patch/9319527/
[3] https://lkml.kernel.org/r/20160914014246.31847-1-stephen.boyd at linaro.org
Stephen Boyd (5):
phy: Add support for Qualcomm's USB HSIC phy
usb: chipidea: msm: Configure phy for appropriate mode
phy: Add set_vbus callback
usb: chipidea: Signal vbus state to phy
phy: Add support for Qualcomm's USB HS phy
.../devicetree/bindings/phy/qcom,usb-hs-phy.txt | 78 +++++++ .../devicetree/bindings/phy/qcom,usb-hsic-phy.txt | 65 ++++++ drivers/phy/Kconfig | 15 ++ drivers/phy/Makefile | 2 + drivers/phy/phy-core.c | 15 ++ drivers/phy/phy-qcom-usb-hs.c | 256 +++++++++++++++++++++ drivers/phy/phy-qcom-usb-hsic.c | 160 +++++++++++++ drivers/usb/chipidea/ci.h | 7 +- drivers/usb/chipidea/ci_hdrc_msm.c | 4 + drivers/usb/chipidea/otg.c | 7 +- include/linux/phy/phy.h | 10 + 11 files changed, 615 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/qcom,usb-hs-phy.txt create mode 100644 Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt create mode 100644 drivers/phy/phy-qcom-usb-hs.c create mode 100644 drivers/phy/phy-qcom-usb-hsic.c
Signature · 1 line
2.10.0.297.gf6727b0
PATCH v7 1/5 phy: Add support for Qualcomm's USB HSIC phy
The HSIC USB controller on qcom SoCs has an integrated all digital phy controlled via the ULPI viewport.
---
No changes.
.../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
Documentation/devicetree/bindings/phy/qcom,usb-hsic-phy.txt new file +65 -0
@@ -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>; + }; + }; +};
drivers/phy/Kconfig +7 -0
@@ -437,6 +437,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
drivers/phy/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_PHY_STIH407_USB) += phy-stih407-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
drivers/phy/phy-qcom-usb-hsic.c new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.10.0.297.gf6727b0
PATCH v7 2/5 usb: chipidea: msm: Configure phy for appropriate mode
In reply to Stephen BoydWhen the qcom chipidea controller is used with an extcon, we need to signal device mode or host mode to the phy so it can configure itself for the correct mode. This should be done after the phy is powered up, so that the register writes work correctly. Add in the appropriate phy_set_mode() call here.
To signal the correct state to the qcom glue driver we need to change the ci->role before we do the role switch. Make sure to undo the change if the role switch fails, but otherwise update the state before calling the role start function so that the glue driver knows what state to configure for.
---
Made this msm specific because of how msm handles phy powerup.
drivers/usb/chipidea/ci.h | 7 +++++-- drivers/usb/chipidea/ci_hdrc_msm.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/chipidea/ci.h +5 -2
@@ -268,6 +268,7 @@ static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)static inline int ci_role_start (struct ci_hdrc *ci,enum ci_role role) {int ret; +enum ci_role prev_role;if (role >=CI_ROLE_END )return -EINVAL ;
@@ -275,9 +276,11 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role)if (!ci->roles[role])return -ENXIO ; + prev_role = ci->role; + ci->role = role; ret = ci->roles[role]->start (ci); -if (!ret) - ci->role = role; +if (ret) + ci->role = prev_role;return ret; }
drivers/usb/chipidea/ci_hdrc_msm.c +4 -0
@@ -125,6 +125,10 @@ static int ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)hw_write (ci,OP_USBCMD ,HSPHY_SESS_VLD_CTRL ,HSPHY_SESS_VLD_CTRL ); +if (ci->role ==CI_ROLE_GADGET ) +phy_set_mode (ci->phy,PHY_MODE_USB_DEVICE ); +else if (ci->role ==CI_ROLE_HOST ) +phy_set_mode (ci->phy,PHY_MODE_USB_HOST ); }break ;case CI_HDRC_CONTROLLER_STOPPED_EVENT :
Signature · 1 line
2.10.0.297.gf6727b0
PATCH v7 3/5 phy: Add set_vbus callback
In reply to Stephen BoydSome USB PHYs need to be told about vbus changing state explicitly. For example the qcom USB HS PHY needs to toggle a bit when vbus goes from low to high (VBUSVLDEXT) to cause the "session valid" signal to toggle. This signal will pull up D+ when the phy starts running. If the vbus signal isn't routed to the PHY this "session valid" signal won't ever toggle, so we have to toggle it explicitly. This callback is used to do that.
---
New patch
drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 10 ++++++++++ 2 files changed, 25 insertions(+)
drivers/phy/phy-core.c +15 -0
@@ -357,6 +357,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_vbus (struct phy *phy,int on) +{ +int ret; + +if (!phy || !phy->ops->set_vbus) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_vbus (phy, on); +mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_vbus); +int phy_reset (struct phy *phy) {int ret;
include/linux/phy/phy.h +10 -0
@@ -36,6 +36,7 @@ enum phy_mode {* @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy +* @set_vbus: enable/disable vbus in the phy (USB) * @reset: resetting the phy * @owner: the module owner containing the ops */
@@ -45,6 +46,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*set_vbus)(struct phy *phy,int on);int (*reset)(struct phy *phy);struct module *owner; };
@@ -138,6 +140,7 @@ int phy_exit(struct phy *phy);int phy_power_on (struct phy *phy);int phy_power_off (struct phy *phy);int phy_set_mode (struct phy *phy,enum phy_mode mode); +int phy_set_vbus (struct phy *phy,int on);int phy_reset (struct phy *phy);static inline int phy_get_bus_width (struct phy *phy) {
@@ -253,6 +256,13 @@ static inline int phy_set_mode(struct phy *phy, enum phy_mode mode)return -ENOSYS ; } +static inline int phy_set_vbus (struct phy *phy,int on) +{ +if (!phy) +return 0 ; +return -ENOSYS ; +} +static inline int phy_reset (struct phy *phy) {if (!phy)
Signature · 1 line
2.10.0.297.gf6727b0
PATCH v7 4/5 usb: chipidea: Signal vbus state to phy
In reply to Stephen BoydSome USB PHYs need to be told about vbus changing state explicitly. For example the qcom USB HS PHY needs to toggle a bit when vbus goes from low to high (VBUSVLDEXT) to cause the "session valid" signal to toggle. This signal will pull up D+ when the phy starts running. Add the appropriate phy_set_vbus() call here to signal vbus state changes to the phy.
---
New patch
drivers/usb/chipidea/otg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/chipidea/otg.c +5 -2
@@ -134,10 +134,13 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)if (!ci->is_otg)return ; -if (hw_read_otgsc (ci,OTGSC_BSV ) && !ci->vbus_active) +if (hw_read_otgsc (ci,OTGSC_BSV ) && !ci->vbus_active) {usb_gadget_vbus_connect (&ci->gadget); -else if (!hw_read_otgsc (ci,OTGSC_BSV ) && ci->vbus_active) +phy_set_vbus (ci->phy,1 ); + }else if (!hw_read_otgsc (ci,OTGSC_BSV ) && ci->vbus_active) { +phy_set_vbus (ci->phy,0 );usb_gadget_vbus_disconnect (&ci->gadget); + } }/**
Signature · 1 line
2.10.0.297.gf6727b0
PATCH v7 5/5 phy: Add support for Qualcomm's USB HS phy
In reply to Stephen BoydThe high-speed phy on qcom SoCs is controlled via the ULPI viewport.
---
phy_set_mode() hook split up to toggle two bits independently with new set_vbus() hook.
.../devicetree/bindings/phy/qcom,usb-hs-phy.txt | 78 +++++++ drivers/phy/Kconfig | 8 + drivers/phy/Makefile | 1 + drivers/phy/phy-qcom-usb-hs.c | 256 +++++++++++++++++++++ 4 files changed, 343 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,usb-hs-phy.txt create mode 100644 drivers/phy/phy-qcom-usb-hs.c
Documentation/devicetree/bindings/phy/qcom,usb-hs-phy.txt new file +78 -0
@@ -0,0 +1,78 @@ +Qualcomm's USB HS PHY + +PROPERTIES + +- compatible: + Usage: required + Value type: <string> + Definition: Should contain "qcom,usb-hs-phy" and more specifically one of the + following: + + "qcom,usb-hs-phy-apq8064" + "qcom,usb-hs-phy-msm8916" + "qcom,usb-hs-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 the reference and sleep + clocks + +- clock-names: + Usage: required + Value type: <stringlist> + Definition: Should contain "ref" and "sleep" for the reference and sleep + clocks respectively + +- resets: + Usage: required + Value type: <prop-encoded-array> + Definition: Should contain the phy and POR resets + +- reset-names: + Usage: required + Value type: <stringlist> + Definition: Should contain "phy" and "por" for the phy and POR resets + respectively + +- v3p3-supply: + Usage: required + Value type: <phandle> + Definition: Should contain a reference to the 3.3V supply + +- v1p8-supply: + Usage: required + Value type: <phandle> + Definition: Should contain a reference to the 1.8V supply + +- qcom,init-seq: + Usage: optional + Value type: <u8 array> + Definition: Should contain a sequence of ULPI address and value pairs to + program into the ULPI_EXT_VENDOR_SPECIFIC area. This is related + to Device Mode Eye Diagram test. The addresses are offsets + from the ULPI_EXT_VENDOR_SPECIFIC address, for example, + <0x1 0x53> would mean "write the value 0x53 to address 0x81". + +EXAMPLE + +otg: usb-controller { + ulpi { + phy { + compatible = "qcom,usb-hs-phy-msm8974", "qcom,usb-hs-phy"; + #phy-cells = <0>; + clocks = <&xo_board>, <&gcc GCC_USB2A_PHY_SLEEP_CLK>; + clock-names = "ref", "sleep"; + resets = <&gcc GCC_USB2A_PHY_BCR>, <&otg 0>; + reset-names = "phy", "por"; + v3p3-supply = <&pm8941_l24>; + v1p8-supply = <&pm8941_l6>; + qcom,init-seq = /bits/ 8 <0x1 0x63>; + }; + }; +};
drivers/phy/Kconfig +8 -0
@@ -437,6 +437,14 @@ config PHY_QCOM_UFS help Support for UFS PHY on QCOM chipsets. +config PHY_QCOM_USB_HS + tristate "Qualcomm USB HS PHY module" + depends on USB_ULPI_BUS + select GENERIC_PHY + help + Support for the USB high-speed ULPI compliant phy on Qualcomm + chipsets. + config PHY_QCOM_USB_HSIC tristate "Qualcomm USB HSIC ULPI PHY module" depends on USB_ULPI_BUS
drivers/phy/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_PHY_STIH407_USB) += phy-stih407-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_HS) += phy-qcom-usb-hs.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
drivers/phy/phy-qcom-usb-hs.c new file +256 -0
256 lines not on this page · raw message
Signature · 1 line
2.10.0.297.gf6727b0
RE: [PATCH v7 3/5] phy: Add set_vbus callback
In reply to Stephen Boydinclude/linux/phy/phy.h struct phy_ops { · line 49
Quoted 11 lines
* @set_mode: set the mode of the phy
+ * @set_vbus: enable/disable vbus in the phy (USB)
* @reset: resetting the phy
* @owner: the module owner containing the ops */include/linux/phy/phy.h +1
-0@@ -45,6 +46,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*set_vbus)(struct phy *phy,int on);
How about using the name notify_vbus? The main purpose of this API is notify PHY vbus status.
Peter
RE: [PATCH v7 4/5] usb: chipidea: Signal vbus state to phy
In reply to Stephen BoydQuoted 14 lines
drivers/usb/chipidea/otg.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/usb/chipidea/otg.c index renamed from drivers/usb/chipidea/otg.c +0
-0
10236fe71522..6ea702beed48100644drivers/usb/chipidea/otg.c +0
-1@@ -134,10 +134,13 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)if (!ci->is_otg)return ; -if (hw_read_otgsc (ci,OTGSC_BSV ) && !ci->vbus_active)
drivers/usb/chipidea/otg.c void ci_handle_vbus_change(struct ci_hdrc *ci) · line 145
Quoted 10 lines
drivers/usb/chipidea/otg.c +5
-1+if (hw_read_otgsc (ci,OTGSC_BSV ) && !ci->vbus_active) {usb_gadget_vbus_connect (&ci->gadget); - else if (!hw_read_otgsc(ci, OTGSC_BSV) && ci->vbus_active) +phy_set_vbus (ci->phy,1 ); + }else if (!hw_read_otgsc (ci,OTGSC_BSV ) && ci->vbus_active) { +phy_set_vbus (ci->phy,0 );usb_gadget_vbus_disconnect (&ci->gadget); + } }
You can add my ack if you accept the name of phy_notify_vbus.
Peter
Re: [PATCH v7 2/5] usb: chipidea: msm: Configure phy for appropriate mode
In reply to Stephen BoydQuoted 36 lines · Stephen Boyd
When the qcom chipidea controller is used with an extcon, we need to signal device mode or host mode to the phy so it can configure itself for the correct mode. This should be done after the phy is powered up, so that the register writes work correctly. Add in the appropriate
phy_set_mode()call here.To signal the correct state to the qcom glue driver we need to change the
ci->rolebefore we do the role switch. Make sure to undo the change if the role switch fails, but otherwise update the state before calling the role start function so that the glue driver knows what state to configure for.Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Made this msm specific because of how msm handles phy powerup.
drivers/usb/chipidea/ci.h | 7 +++++-- drivers/usb/chipidea/ci_hdrc_msm.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)drivers/usb/chipidea/ci.h +1
-0@@ -268,6 +268,7 @@ static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)static inline int ci_role_start (struct ci_hdrc *ci,enum ci_role role) {int ret; +enum ci_role prev_role;if (role >=CI_ROLE_END )return -EINVAL ;@@ -275,9 +276,11 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role)if (!ci->roles[role])
drivers/usb/chipidea/ci.h static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role) · line 284
Quoted 10 lines
drivers/usb/chipidea/ci.h +4
-2return -ENXIO ; + prev_role = ci->role; + ci->role = role; ret = ci->roles[role]->start (ci); -if (!ret) - ci->role = role; +if (ret) + ci->role = prev_role;return ret;
Sorry, this changes ci->role's life cycle. You may try to get coming role at your glue layer code (eg, through usbmode), or add your changes at ci_role_start directly if the sequence can make your requirement.
Peter
Quoted 24 lines
drivers/usb/chipidea/ci.h +0
-0}drivers/usb/chipidea/ci_hdrc_msm.c +4
-0@@ -125,6 +125,10 @@ static int ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)hw_write (ci,OP_USBCMD ,HSPHY_SESS_VLD_CTRL ,HSPHY_SESS_VLD_CTRL ); +if (ci->role ==CI_ROLE_GADGET ) +phy_set_mode (ci->phy,PHY_MODE_USB_DEVICE ); +else if (ci->role ==CI_ROLE_HOST ) +phy_set_mode (ci->phy,PHY_MODE_USB_HOST ); }break ;case CI_HDRC_CONTROLLER_STOPPED_EVENT :Signature · 6 lines
2.10.0.297.gf6727b0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards, Peter Chen
Re: [PATCH v7 3/5] phy: Add set_vbus callback
In reply to Stephen BoydHi,
Quoted 57 lines · Stephen Boyd
Some USB PHYs need to be told about vbus changing state explicitly. For example the qcom USB HS PHY needs to toggle a bit when vbus goes from low to high (VBUSVLDEXT) to cause the "session valid" signal to toggle. This signal will pull up D+ when the phy starts running. If the vbus signal isn't routed to the PHY this "session valid" signal won't ever toggle, so we have to toggle it explicitly. This callback is used to do that.
Cc Peter Chen <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
New patch
drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 10 ++++++++++ 2 files changed, 25 insertions(+)drivers/phy/phy-core.c +15
-0@@ -357,6 +357,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_vbus (struct phy *phy,int on) +{ +int ret; + +if (!phy || !phy->ops->set_vbus) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_vbus (phy, on); +mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_vbus); +int phy_reset (struct phy *phy) {int ret;include/linux/phy/phy.h +1
-0@@ -36,6 +36,7 @@ enum phy_mode {* @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy +* @set_vbus: enable/disable vbus in the phy (USB) * @reset: resetting the phy * @owner: the module owner containing the ops */
include/linux/phy/phy.h struct phy_ops { · line 49
Quoted 4 lines
include/linux/phy/phy.h +1
-0@@ -45,6 +46,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*set_vbus)(struct phy *phy,int on);
please avoid adding usb specific ops in generic phy ops.
Thanks
Kishon
PATCH v7 2/5 usb: chipidea: msm: Configure phy for appropriate mode
In reply to Peter ChenQuoting Peter Chen (2017-01-21 18:10:59)
Quoted 39 lines · Stephen Boyd
Quoted 38 lines
When the qcom chipidea controller is used with an extcon, we need to signal device mode or host mode to the phy so it can configure itself for the correct mode. This should be done after the phy is powered up, so that the register writes work correctly. Add in the appropriate
phy_set_mode()call here.To signal the correct state to the qcom glue driver we need to change the
ci->rolebefore we do the role switch. Make sure to undo the change if the role switch fails, but otherwise update the state before calling the role start function so that the glue driver knows what state to configure for.Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Made this msm specific because of how msm handles phy powerup.
drivers/usb/chipidea/ci.h | 7 +++++-- drivers/usb/chipidea/ci_hdrc_msm.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)drivers/usb/chipidea/ci.h +1
-0@@ -268,6 +268,7 @@ static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)static inline int ci_role_start (struct ci_hdrc *ci,enum ci_role role) {int ret; +enum ci_role prev_role;if (role >=CI_ROLE_END )return -EINVAL ;@@ -275,9 +276,11 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role)if (!ci->roles[role])return -ENXIO ;
Quoted 13 lines
drivers/usb/chipidea/ci.h static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role) · line 284
Quoted 8 lines
drivers/usb/chipidea/ci.h +4
-2+ prev_role = ci->role; + ci->role = role; ret = ci->roles[role]->start (ci); -if (!ret) - ci->role = role; +if (ret) + ci->role = prev_role;return ret;Sorry, this changes ci->role's life cycle. You may try to get coming role at your glue layer code (eg, through usbmode), or add your changes at
ci_role_startdirectly if the sequence can make your requirement.
Ok I'll add the phy_set_mode() hooks into ci_platform_configure() and see how that goes. Both udc.c and host.c call into that function at the right time.
Re: [PATCH v7 3/5] phy: Add set_vbus callback
In reply to Kishon Vijay Abraham IQuoting Kishon Vijay Abraham I (2017-01-22 00:46:21)
Quoted 58 lines
Hi,
Quoted 55 lines · Stephen Boyd
Some USB PHYs need to be told about vbus changing state explicitly. For example the qcom USB HS PHY needs to toggle a bit when vbus goes from low to high (VBUSVLDEXT) to cause the "session valid" signal to toggle. This signal will pull up D+ when the phy starts running. If the vbus signal isn't routed to the PHY this "session valid" signal won't ever toggle, so we have to toggle it explicitly. This callback is used to do that.
Cc Peter Chen <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
New patch
drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 10 ++++++++++ 2 files changed, 25 insertions(+)drivers/phy/phy-core.c +15
-0@@ -357,6 +357,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_vbus (struct phy *phy,int on) +{ +int ret; + +if (!phy || !phy->ops->set_vbus) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_vbus (phy, on); +mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_vbus); +int phy_reset (struct phy *phy) {int ret;include/linux/phy/phy.h +1
-0@@ -36,6 +36,7 @@ enum phy_mode {* @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy +* @set_vbus: enable/disable vbus in the phy (USB) * @reset: resetting the phy * @owner: the module owner containing the ops
Quoted 9 lines
include/linux/phy/phy.h struct phy_ops { · line 49
Quoted 6 lines
include/linux/phy/phy.h +1
-0*/ @@ -45,6 +46,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*set_vbus)(struct phy *phy,int on);please avoid adding usb specific ops in generic phy ops.
Is there any alternative? Something has to happen here.
The only other thing I can think of is putting back the vbus extcon in the phy driver so it can be notified when vbus is present or not. I can rely on phy_set_mode() being called so that we don't need to figure out if we're in host mode or not like was being done before.
Re: [PATCH v7 3/5] phy: Add set_vbus callback
Hi,
Quoted 69 lines · Stephen Boyd
Quoting Kishon Vijay Abraham I (2017-01-22 00:46:21)
Quoted 58 lines
Hi,
Quoted 55 lines · Stephen Boyd
Some USB PHYs need to be told about vbus changing state explicitly. For example the qcom USB HS PHY needs to toggle a bit when vbus goes from low to high (VBUSVLDEXT) to cause the "session valid" signal to toggle. This signal will pull up D+ when the phy starts running. If the vbus signal isn't routed to the PHY this "session valid" signal won't ever toggle, so we have to toggle it explicitly. This callback is used to do that.
Cc Peter Chen <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
New patch
drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 10 ++++++++++ 2 files changed, 25 insertions(+)drivers/phy/phy-core.c +15
-0@@ -357,6 +357,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_set_vbus (struct phy *phy,int on) +{ +int ret; + +if (!phy || !phy->ops->set_vbus) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->set_vbus (phy, on); +mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_set_vbus); +int phy_reset (struct phy *phy) {int ret;include/linux/phy/phy.h +1
-0@@ -36,6 +36,7 @@ enum phy_mode {* @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy +* @set_vbus: enable/disable vbus in the phy (USB) * @reset: resetting the phy * @owner: the module owner containing the ops Quoted 9 lines
include/linux/phy/phy.h struct phy_ops { · line 49
Quoted 6 lines
include/linux/phy/phy.h +1
-0*/ @@ -45,6 +46,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*set_vbus)(struct phy *phy,int on);please avoid adding usb specific ops in generic phy ops.
Quoted 4 lines
Is there any alternative? Something has to happen here.
The only other thing I can think of is putting back the vbus extcon in the phy driver so it can be notified when vbus is present or not. I can
I think extcon should be used here to get vbus notification.
Thanks
Kishon