[PATCH v2] usb: phy: msm: Unregister VBUS and ID events notifiers
Right now even if driver failed to probe extcon framework will still deliver its VBUS and ID events, which will lead to random exception codes. Fix this by removing VBUS and ID events notifiers when probe fail. Fixes: 591fc116f330 ("usb: phy: msm: Use extcon framework for VBUS and ID detection") Reported-by: Tim Bird <tim.b...@sonymobile.com> Signed-off-by: Ivan T. Ivanov <ivan.iva...@linaro.org> --- Patch reworked to use new extcon API. drivers/usb/phy/phy-msm-usb.c | 25 - 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index c58c3c0dbe35..0fd21c147c7e 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1598,6 +1598,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) ret = extcon_register_notifier(ext_id, EXTCON_USB_HOST, >id.nb); if (ret < 0) { + extcon_unregister_notifier(motg->vbus.extcon, + EXTCON_USB, >vbus.nb); dev_err(>dev, "register ID notifier failed\n"); return ret; } @@ -1660,15 +1662,6 @@ static int msm_otg_probe(struct platform_device *pdev) if (!motg) return -ENOMEM; - pdata = dev_get_platdata(>dev); - if (!pdata) { - if (!np) - return -ENXIO; - ret = msm_otg_read_dt(pdev, motg); - if (ret) - return ret; - } - motg->phy.otg = devm_kzalloc(>dev, sizeof(struct usb_otg), GFP_KERNEL); if (!motg->phy.otg) @@ -1731,6 +1724,15 @@ static int msm_otg_probe(struct platform_device *pdev) return motg->irq; } + pdata = dev_get_platdata(>dev); + if (!pdata) { + if (!np) + return -ENXIO; + ret = msm_otg_read_dt(pdev, motg); + if (ret) + return ret; + } + regs[0].supply = "vddcx"; regs[1].supply = "v3p3"; regs[2].supply = "v1p8"; @@ -1834,6 +1836,11 @@ disable_clks: clk_disable_unprepare(motg->clk); if (!IS_ERR(motg->core_clk)) clk_disable_unprepare(motg->core_clk); + + extcon_unregister_notifier(motg->id.extcon, + EXTCON_USB_HOST, >id.nb); + extcon_unregister_notifier(motg->vbus.extcon, + EXTCON_USB, >vbus.nb); return ret; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: phy: msm: Unregister driver interest for VBUS and ID events
On Mon, 2015-08-24 at 10:11 -0700, Tim Bird wrote: > On 08/18/2015 12:56 AM, Ivan T. Ivanov wrote: > > Right now even if driver failed to probe extcon framework will > > still deliver its VBUS and ID events, which will lead to random > > exception codes. > > > > Fix this by removing driver interest for VBUS and ID events when > > probe fail. > > > > Fixes: 591fc116f330 ("usb: phy: msm: Use extcon framework for VBUS and ID > > detection") > > > > Reported-by: Tim Bird b...@sonymobile.com> > > Signed-off-by: Ivan T. Ivanov iva...@linaro.org> > > --- > > drivers/usb/phy/phy-msm-usb.c | 26 +- > > 1 file changed, 17 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c > > index 00c49bb1bd29..a9082567f114 100644 > > --- a/drivers/usb/phy/phy-msm-usb.c > > +++ b/drivers/usb/phy/phy-msm-usb.c > > @@ -1581,6 +1581,8 @@ static int msm_otg_read_dt(struct platform_device > > *pdev, struct msm_otg *motg) > > ret = extcon_register_interest(>id.conn, ext_id->name, > > > > "USB-HOST", >id.nb); > > if (ret < 0) { > > + if (!IS_ERR(ext_vbus)) > > + > > extcon_unregister_interest(>vbus.conn); > > dev_err(>dev, "register ID notifier > > failed\n"); > > return ret; > > } > ... > > This patch is obsoleted by commit 83b7b67c7, which changes the extcon API > a bit (from register_interest to register_notifier, among other things). Ah, sorry, missed this. New version is coming. Regards, Ivan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: phy: qcom: Switch to new extcon framework API
[un]register_interest and reading cable state by name have been deprecated. Switch to new API. Signed-off-by: Ivan T. Ivanov <ivan.iva...@linaro.org> --- drivers/usb/phy/phy-qcom-8x16-usb.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/usb/phy/phy-qcom-8x16-usb.c b/drivers/usb/phy/phy-qcom-8x16-usb.c index 5d357a94599e..579587d97217 100644 --- a/drivers/usb/phy/phy-qcom-8x16-usb.c +++ b/drivers/usb/phy/phy-qcom-8x16-usb.c @@ -71,7 +71,7 @@ struct phy_8x16 { struct reset_control*phy_reset; - struct extcon_specific_cable_nb vbus_cable; + struct extcon_dev *vbus_edev; struct notifier_block vbus_notify; struct gpio_desc*switch_gpio; @@ -234,7 +234,7 @@ static int phy_8x16_init(struct usb_phy *phy) val = ULPI_PWR_OTG_COMP_DISABLE; usb_phy_io_write(phy, val, ULPI_SET(ULPI_PWR_CLK_MNG_REG)); - state = extcon_get_cable_state(qphy->vbus_cable.edev, "USB"); + state = extcon_get_cable_state_(qphy->vbus_edev, EXTCON_USB); if (state) phy_8x16_vbus_on(qphy); else @@ -314,7 +314,6 @@ static int phy_8x16_reboot_notify(struct notifier_block *this, static int phy_8x16_probe(struct platform_device *pdev) { - struct extcon_dev *edev; struct phy_8x16 *qphy; struct resource *res; struct usb_phy *phy; @@ -349,9 +348,9 @@ static int phy_8x16_probe(struct platform_device *pdev) if (ret < 0) return ret; - edev = extcon_get_edev_by_phandle(phy->dev, 0); - if (IS_ERR(edev)) - return PTR_ERR(edev); + qphy->vbus_edev = extcon_get_edev_by_phandle(phy->dev, 0); + if (IS_ERR(qphy->vbus_edev)) + return PTR_ERR(qphy->vbus_edev); ret = clk_set_rate(qphy->core_clk, INT_MAX); if (ret < 0) @@ -370,8 +369,8 @@ static int phy_8x16_probe(struct platform_device *pdev) goto off_clks; qphy->vbus_notify.notifier_call = phy_8x16_vbus_notify; - ret = extcon_register_interest(>vbus_cable, edev->name, - "USB", >vbus_notify); + ret = extcon_register_notifier(qphy->vbus_edev, EXTCON_USB, + >vbus_notify); if (ret < 0) goto off_power; @@ -385,7 +384,8 @@ static int phy_8x16_probe(struct platform_device *pdev) return 0; off_extcon: - extcon_unregister_interest(>vbus_cable); + extcon_unregister_notifier(qphy->vbus_edev, EXTCON_USB, + >vbus_notify); off_power: phy_8x16_regulators_disable(qphy); off_clks: @@ -400,7 +400,8 @@ static int phy_8x16_remove(struct platform_device *pdev) struct phy_8x16 *qphy = platform_get_drvdata(pdev); unregister_reboot_notifier(>reboot_notify); - extcon_unregister_interest(>vbus_cable); + extcon_unregister_notifier(qphy->vbus_edev, EXTCON_USB, + >vbus_notify); /* * Ensure that D+/D- lines are routed to uB connector, so -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] usb: chipidea: Use extcon framework for VBUS and ID detect
On Fri, 2015-06-05 at 17:26 +0800, Peter Chen wrote: > On Fri, Jun 05, 2015 at 10:37:07AM +0300, Ivan T. Ivanov wrote: > > > > > + > > > > +static int ci_id_notifier(struct notifier_block *nb, unsigned long > > > > event, > > > > + void *ptr) > > > > +{ > > > > + struct ci_hdrc_cable *id = container_of(nb, struct > > > > ci_hdrc_cable, nb); > > > > + struct ci_hdrc *ci = id->ci; > > > > + > > > > + if (event) > > > > + id->state = false; > > > > + else > > > > + id->state = true; > > > > + > > > > + id->changed = true; > > > > + > > How to know the id value must be changed? > How about using id->changed = (event != id->state) ? true : false? > of cos, it needs to move before if {}. This is handled already by extcon framework. > > The same change may need to add to vbus notifier. > > > > > + ci_irq(ci->irq, ci); > > > > + return NOTIFY_DONE; > > > > +} > > > > + > > > > static int ci_get_platdata(struct device *dev, > > > > struct ci_hdrc_platform_data *platdata) > > > > { > > > > + struct extcon_dev *ext_vbus, *ext_id; > > > > + struct ci_hdrc_cable *cable; > > > > + int ret; > > > > + > > > > if (!platdata->phy_mode) > > > > platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); > > > > > > > > @@ -591,9 +630,89 @@ static int ci_get_platdata(struct device *dev, > > > > if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) > > > > platdata->flags |= CI_HDRC_FORCE_FULLSPEED; > > > > > > > > + ext_id = ERR_PTR(-ENODEV); > > > > + ext_vbus = ERR_PTR(-ENODEV); > > > > + if (of_property_read_bool(dev->of_node, "extcon")) { > > > > + /* Each one of them is not mandatory */ > > > > + ext_vbus = extcon_get_edev_by_phandle(dev, 0); > > > > + if (IS_ERR(ext_vbus) && PTR_ERR(ext_vbus) != -ENODEV) > > > > + return PTR_ERR(ext_vbus); > > > > + > > > > + ext_id = extcon_get_edev_by_phandle(dev, 1); > > > > + if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV) > > > > + return PTR_ERR(ext_id); > > > > + } > > > > + > > > > + cable = >vbus_extcon; > > > > + cable->nb.notifier_call = ci_vbus_notifier; > > > > + cable->edev = ext_vbus; > > > > + > > > > + if (!IS_ERR(ext_vbus)) { > > > > + ret = extcon_get_cable_state(cable->edev, "USB"); > > I have not read extcon framework too much, but seems you should only > can get cable state after register it (through ci_extcon_register)? > ci_get_platdata is called before ci core probe. No that is not a problem, you can always read cable state if you have reference to extcon device. Will fix remaining comments in next version. Regards, Ivan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4] usb: chipidea: Use extcon framework for VBUS and ID detect
On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov <ivan.iva...@linaro.org> --- Changes sice v3 [1]: * Migrate to new extcon framework API * Address comments from Peter Chen. Tested DRD role with "qcom,ci-hdrc" and "qcom,usb-8x16-phy" on DB410c [1] https://lkml.org/lkml/2015/6/2/333 .../devicetree/bindings/usb/ci-hdrc-usb2.txt | 6 + drivers/usb/chipidea/Kconfig | 1 + drivers/usb/chipidea/core.c| 125 + drivers/usb/chipidea/otg.c | 39 ++- include/linux/usb/chipidea.h | 23 5 files changed, 193 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt index d71ef07bca5d..aea7d0af5fd6 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt @@ -45,6 +45,11 @@ Optional properties: (4 bytes), This register represents the maximum length of a the burst in 32-bit words while moving data from the USB bus to system memory, changing this value takes effect only the SBUSCFG.AHBBRST is 0. +- extcon: phandles to external connector devices. First phandle should point to + external connector, which provide "USB" cable events, the second should point + to external connector device, which provide "USB-HOST" cable events. If one + of the external connector devices is not required, empty <0> phandle should + be specified. Example: @@ -61,4 +66,5 @@ Example: ahb-burst-config = <0x0>; tx-burst-size-dword = <0x10>; /* 64 bytes */ rx-burst-size-dword = <0x10>; + extcon = <0>, <_id>; }; diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 5ce3f1d6a6ed..5619b8ca3bf3 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -1,6 +1,7 @@ config USB_CHIPIDEA tristate "ChipIdea Highspeed Dual Role Controller" depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA + select EXTCON help Say Y here if your system has a dual role high speed USB controller based on ChipIdea silicon IP. Currently, only the diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 3feebf7f31f0..573c2876b263 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -602,9 +603,45 @@ static irqreturn_t ci_irq(int irq, void *data) return ret; } +static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct ci_hdrc_cable *vbus = container_of(nb, struct ci_hdrc_cable, nb); + struct ci_hdrc *ci = vbus->ci; + + if (event) + vbus->state = true; + else + vbus->state = false; + + vbus->changed = true; + + ci_irq(ci->irq, ci); + return NOTIFY_DONE; +} + +static int ci_id_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct ci_hdrc_cable *id = container_of(nb, struct ci_hdrc_cable, nb); + struct ci_hdrc *ci = id->ci; + + if (event) + id->state = false; + else + id->state = true; + + id->changed = true; + + ci_irq(ci->irq, ci); + return NOTIFY_DONE; +} + static int ci_get_platdata(struct device *dev, struct ci_hdrc_platform_data *platdata) { + struct extcon_dev *ext_vbus, *ext_id; + struct ci_hdrc_cable *cable; int ret; if (!platdata->phy_mode) @@ -695,9 +732,91 @@ static int ci_get_platdata(struct device *dev, platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST; } + ext_id = ERR_PTR(-ENODEV); + ext_vbus = ERR_PTR(-ENODEV); + if (of_property_read_bool(dev->of_node, "extcon")) { + /* Each one of them is not mandatory */ + ext_vbus = extcon_get_edev_by_phandle(dev, 0); + if (IS_ERR(ext_vbus) && PTR_ERR(ext_vbus) != -ENODEV) + return PTR_ERR(ext_vbus); + + ext_id = extcon_get_edev_by_phandle(dev, 1); + if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV) + return PTR_ERR(ext_id); + } + + cable = >vbus_extcon; + cable->nb.notifier_call = ci_vbus_notifier; + cabl
[PATCH] usb: phy: msm: Unregister driver interest for VBUS and ID events
Right now even if driver failed to probe extcon framework will still deliver its VBUS and ID events, which will lead to random exception codes. Fix this by removing driver interest for VBUS and ID events when probe fail. Fixes: 591fc116f330 (usb: phy: msm: Use extcon framework for VBUS and ID detection) Reported-by: Tim Bird tim.b...@sonymobile.com Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- drivers/usb/phy/phy-msm-usb.c | 26 +- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 00c49bb1bd29..a9082567f114 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1581,6 +1581,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) ret = extcon_register_interest(motg-id.conn, ext_id-name, USB-HOST, motg-id.nb); if (ret 0) { + if (!IS_ERR(ext_vbus)) + extcon_unregister_interest(motg-vbus.conn); dev_err(pdev-dev, register ID notifier failed\n); return ret; } @@ -1630,15 +1632,6 @@ static int msm_otg_probe(struct platform_device *pdev) if (!motg) return -ENOMEM; - pdata = dev_get_platdata(pdev-dev); - if (!pdata) { - if (!np) - return -ENXIO; - ret = msm_otg_read_dt(pdev, motg); - if (ret) - return ret; - } - motg-phy.otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg), GFP_KERNEL); if (!motg-phy.otg) @@ -1709,6 +1702,15 @@ static int msm_otg_probe(struct platform_device *pdev) if (ret) return ret; + pdata = dev_get_platdata(pdev-dev); + if (!pdata) { + if (!np) + return -ENXIO; + ret = msm_otg_read_dt(pdev, motg); + if (ret) + return ret; + } + motg-vddcx = regs[0].consumer; motg-v3p3 = regs[1].consumer; motg-v1p8 = regs[2].consumer; @@ -1793,6 +1795,12 @@ disable_clks: clk_disable_unprepare(motg-clk); if (!IS_ERR(motg-core_clk)) clk_disable_unprepare(motg-core_clk); + + if (motg-id.conn.edev) + extcon_unregister_interest(motg-id.conn); + if (motg-vbus.conn.edev) + extcon_unregister_interest(motg-vbus.conn); + return ret; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: repeat... Re: BUG: usb: phy: msm: problem with EPROBE defer and extcon cleanup
On Mon, 2015-08-17 at 16:46 -0700, Tim Bird wrote: Sorry - I mistyped Ivan's e-mail the first time. On 08/17/2015 04:43 PM, Tim Bird wrote: Ivan, I'm seeing a bug in the phy-msm-usb.c code, when I get an EPROBE defer during probing the driver. The code is statically linked in the kernel, and the dts for my board is specifying an extcon phandle for the ID pin. Below is a fragment of the kernel output for a boot of this code. Messages prefixed with TRB are my own debug printks. Note that the notifier block (at ee23513c) that gets registered with extcon before the first probe failure, ultimately gets used during an ID pin event (status change) by raw_notifier_call_chain(). This notifier block should be unregistered if the probe fails, so that only the second one registered is on the call chain. Right, I have missed to send one patch, sorry. Please, could you try this one [1]. Regards, Ivan [1] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg957405.html -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] usb: chipidea: Use extcon framework for VBUS and ID detect
On Wed, 2015-07-29 at 12:10 -0700, Tim Bird wrote: On Tue, Jun 2, 2015 at 6:14 AM, Ivan T. Ivanov iva...@linaro.org wrote: On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov iva...@linaro.org --- Changes sice v2 [1]. * Simulate IRQ on extcon event - used to trigger OTG state machine. I have to admit that I couldn't test complete Chipidea OTG state machine, because my setup is little weird. I am using qcom,usb-otg-ci as PHY/OTG provider, qcom,ehci-host as host controller driver and qcom,ci-hdrc for device role. Ivan, Do you have patches for the code (presumably pmic code) where the vbus and id lines are signaled? Presumably you've added some extcon_set_cable_state() calls somewhere in your source tree, for this to work. I'm wondering if you can share your work in progress, or let me know when you plan to push that upstream? Well, not exactly. Maybe change description is badly worded. I have DB410c where VBUS and ID lines are not routed to USB controller, but to GPIO. So from the chipidea core driver point of view ID and VBUS changes/IRQs are triggered from extcon driver linux,extcon-usb-gpio I'm interested in testing the msm usb code (specifically host mode support) on my dragonboard here. Since yesterday, Felipe kindly merged simple usb-phy driver for 8x16[1]. Which allow just using qcom,ci-hdrc and qcom,usb-8x16-phy to have DRD support on 8x16 chipsets. I have tried to use chipidea,usb2, but unfortunately quirks in qcom,ci-hdrc are required. Once we have similar usb-phy drivers for 8x60, 8064, 8074 and 8084, I believe the we can remove qcom,usb-otg-xxx monster. usb-phy driver for 8074 should be very similar to 8x16 one. Regards, Ivan [1] http://bit.ly/1U6IjK4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: phy: msm: Add D+/D- lines route control
apq8016-sbc board is using Dual SPDT USB Switch (TC7USB40MU), witch is controlled by GPIO to de/multiplex D+/D- USB lines to USB2513B Hub and uB connector. Add support for this. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- * Rebased on current testing/next. .../devicetree/bindings/usb/msm-hsusb.txt | 4 ++ drivers/usb/phy/phy-msm-usb.c | 47 ++ include/linux/usb/msm_hsusb.h | 7 3 files changed, 58 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index bd8d9e7..8654a3e 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -52,6 +52,10 @@ Required properties: Optional properties: - dr_mode: One of host, peripheral or otg. Defaults to otg +- switch-gpio: A phandle + gpio-specifier pair. Some boards are using Dual +SPDT USB Switch, witch is cotrolled by GPIO to de/multiplex +D+/D- USB lines between connectors. + - qcom,phy-init-sequence: PHY configuration sequence values. This is related to Device Mode Eye Diagram test. Start address at which these values will be written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 61d86d8..c58c3c0 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -18,6 +18,7 @@ #include linux/module.h #include linux/device.h +#include linux/gpio/consumer.h #include linux/platform_device.h #include linux/clk.h #include linux/slab.h @@ -32,6 +33,7 @@ #include linux/pm_runtime.h #include linux/of.h #include linux/of_device.h +#include linux/reboot.h #include linux/reset.h #include linux/usb.h @@ -1471,6 +1473,14 @@ static int msm_otg_vbus_notifier(struct notifier_block *nb, unsigned long event, else clear_bit(B_SESS_VLD, motg-inputs); + if (test_bit(B_SESS_VLD, motg-inputs)) { + /* Switch D+/D- lines to Device connector */ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + } else { + /* Switch D+/D- lines to Hub */ + gpiod_set_value_cansleep(motg-switch_gpio, 1); + } + schedule_work(motg-sm_work); return NOTIFY_DONE; @@ -1546,6 +1556,11 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) motg-manual_pullup = of_property_read_bool(node, qcom,manual-pullup); + motg-switch_gpio = devm_gpiod_get_optional(pdev-dev, switch, + GPIOD_OUT_LOW); + if (IS_ERR(motg-switch_gpio)) + return PTR_ERR(motg-switch_gpio); + ext_id = ERR_PTR(-ENODEV); ext_vbus = ERR_PTR(-ENODEV); if (of_property_read_bool(node, extcon)) { @@ -1617,6 +1632,19 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) return 0; } +static int msm_otg_reboot_notify(struct notifier_block *this, +unsigned long code, void *unused) +{ + struct msm_otg *motg = container_of(this, struct msm_otg, reboot); + + /* +* Ensure that D+/D- lines are routed to uB connector, so +* we could load bootloader/kernel at next reboot +*/ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + return NOTIFY_DONE; +} + static int msm_otg_probe(struct platform_device *pdev) { struct regulator_bulk_data regs[3]; @@ -1781,6 +1809,17 @@ static int msm_otg_probe(struct platform_device *pdev) dev_dbg(pdev-dev, Can not create mode change file\n); } + if (test_bit(B_SESS_VLD, motg-inputs)) { + /* Switch D+/D- lines to Device connector */ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + } else { + /* Switch D+/D- lines to Hub */ + gpiod_set_value_cansleep(motg-switch_gpio, 1); + } + + motg-reboot.notifier_call = msm_otg_reboot_notify; + register_reboot_notifier(motg-reboot); + pm_runtime_set_active(pdev-dev); pm_runtime_enable(pdev-dev); @@ -1807,6 +1846,14 @@ static int msm_otg_remove(struct platform_device *pdev) if (phy-otg-host || phy-otg-gadget) return -EBUSY; + unregister_reboot_notifier(motg-reboot); + + /* +* Ensure that D+/D- lines are routed to uB connector, so +* we could load bootloader/kernel at next reboot +*/ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + extcon_unregister_notifier(motg-id.extcon, EXTCON_USB_HOST, motg-id.nb); extcon_unregister_notifier(motg-vbus.extcon, EXTCON_USB, motg-vbus.nb); diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 5df2c8f..8c8f685 100644
[PATCH] usb: phy: msm: Add D+/D- lines route control
apq8016-sbc board is using Dual SPDT USB Switch (TC7USB40MU), witch is controlled by GPIO to de/multiplex D+/D- USB lines to USB2513B Hub and uB connector. Add support for this. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- .../devicetree/bindings/usb/msm-hsusb.txt | 4 ++ drivers/usb/phy/phy-msm-usb.c | 47 ++ include/linux/usb/msm_hsusb.h | 7 3 files changed, 58 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index bd8d9e7..8654a3e 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -52,6 +52,10 @@ Required properties: Optional properties: - dr_mode: One of host, peripheral or otg. Defaults to otg +- switch-gpio: A phandle + gpio-specifier pair. Some boards are using Dual +SPDT USB Switch, witch is cotrolled by GPIO to de/multiplex +D+/D- USB lines between connectors. + - qcom,phy-init-sequence: PHY configuration sequence values. This is related to Device Mode Eye Diagram test. Start address at which these values will be written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 00c49bb..57c75fb 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -18,6 +18,7 @@ #include linux/module.h #include linux/device.h +#include linux/gpio/consumer.h #include linux/platform_device.h #include linux/clk.h #include linux/slab.h @@ -32,6 +33,7 @@ #include linux/pm_runtime.h #include linux/of.h #include linux/of_device.h +#include linux/reboot.h #include linux/reset.h #include linux/usb.h @@ -1471,6 +1473,14 @@ static int msm_otg_vbus_notifier(struct notifier_block *nb, unsigned long event, else clear_bit(B_SESS_VLD, motg-inputs); + if (test_bit(B_SESS_VLD, motg-inputs)) { + /* Switch D+/D- lines to Device connector */ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + } else { + /* Switch D+/D- lines to Hub */ + gpiod_set_value_cansleep(motg-switch_gpio, 1); + } + schedule_work(motg-sm_work); return NOTIFY_DONE; @@ -1546,6 +1556,11 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) motg-manual_pullup = of_property_read_bool(node, qcom,manual-pullup); + motg-switch_gpio = devm_gpiod_get_optional(pdev-dev, switch, + GPIOD_OUT_LOW); + if (IS_ERR(motg-switch_gpio)) + return PTR_ERR(motg-switch_gpio); + ext_id = ERR_PTR(-ENODEV); ext_vbus = ERR_PTR(-ENODEV); if (of_property_read_bool(node, extcon)) { @@ -1615,6 +1630,19 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) return 0; } +static int msm_otg_reboot_notify(struct notifier_block *this, +unsigned long code, void *unused) +{ + struct msm_otg *motg = container_of(this, struct msm_otg, reboot); + + /* +* Ensure that D+/D- lines are routed to uB connector, so +* we could load bootloader/kernel at next reboot +*/ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + return NOTIFY_DONE; +} + static int msm_otg_probe(struct platform_device *pdev) { struct regulator_bulk_data regs[3]; @@ -1779,6 +1807,17 @@ static int msm_otg_probe(struct platform_device *pdev) dev_dbg(pdev-dev, Can not create mode change file\n); } + if (test_bit(B_SESS_VLD, motg-inputs)) { + /* Switch D+/D- lines to Device connector */ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + } else { + /* Switch D+/D- lines to Hub */ + gpiod_set_value_cansleep(motg-switch_gpio, 1); + } + + motg-reboot.notifier_call = msm_otg_reboot_notify; + register_reboot_notifier(motg-reboot); + pm_runtime_set_active(pdev-dev); pm_runtime_enable(pdev-dev); @@ -1805,11 +1844,19 @@ static int msm_otg_remove(struct platform_device *pdev) if (phy-otg-host || phy-otg-gadget) return -EBUSY; + unregister_reboot_notifier(motg-reboot); + if (motg-id.conn.edev) extcon_unregister_interest(motg-id.conn); if (motg-vbus.conn.edev) extcon_unregister_interest(motg-vbus.conn); + /* +* Ensure that D+/D- lines are routed to uB connector, so +* we could load bootloader/kernel at next reboot +*/ + gpiod_set_value_cansleep(motg-switch_gpio, 0); + msm_otg_debugfs_cleanup(); cancel_delayed_work_sync(motg-chg_work); cancel_work_sync(motg-sm_work
[PATCH] usb: phy: qcom: New APQ8016/MSM8916 USB transceiver driver
Driver handles PHY initialization, clock management, power management and workarounds required after resetting the hardware. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- .../devicetree/bindings/usb/qcom,usb-8x16-phy.txt | 76 drivers/usb/phy/Kconfig| 14 + drivers/usb/phy/Makefile | 1 + drivers/usb/phy/phy-qcom-8x16-usb.c| 436 + 4 files changed, 527 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/qcom,usb-8x16-phy.txt create mode 100644 drivers/usb/phy/phy-qcom-8x16-usb.c diff --git a/Documentation/devicetree/bindings/usb/qcom,usb-8x16-phy.txt b/Documentation/devicetree/bindings/usb/qcom,usb-8x16-phy.txt new file mode 100644 index 000..2cb2168 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/qcom,usb-8x16-phy.txt @@ -0,0 +1,76 @@ +Qualcomm's APQ8016/MSM8916 USB transceiver controller + +- compatible: +Usage: required +Value type: string +Definition: Should contain qcom,usb-8x16-phy. + +- reg: +Usage: required +Value type: prop-encoded-array +Definition: USB PHY base address and length of the register map + +- clocks: +Usage: required +Value type: prop-encoded-array +Definition: See clock-bindings.txt section consumers. List of +two clock specifiers for interface and core controller +clocks. + +- clock-names: +Usage: required +Value type: string +Definition: Must contain iface and core strings. + +- vddcx-supply: +Usage: required +Value type: phandle +Definition: phandle to the regulator VDCCX supply node. + +- v1p8-supply: +Usage: required +Value type: phandle +Definition: phandle to the regulator 1.8V supply node. + +- v3p3-supply: +Usage: required +Value type: phandle +Definition: phandle to the regulator 3.3V supply node. + +- resets: +Usage: required +Value type: prop-encoded-array +Definition: See reset.txt section consumers. PHY reset specifier. + +- reset-names: +Usage: required +Value type: string +Definition: Must contain phy string. + +- switch-gpio: +Usage: optional +Value type: prop-encoded-array +Definition: Some boards are using Dual SPDT USB Switch, witch is +controlled by GPIO to de/multiplex D+/D- USB lines +between connectors. + +Example: + usb_phy: phy@78d9000 { + compatible = qcom,usb-8x16-phy; + reg = 0x78d9000 0x400; + + vddcx-supply = pm8916_s1_corner; + v1p8-supply = pm8916_l7; + v3p3-supply = pm8916_l13; + + clocks = gcc GCC_USB_HS_AHB_CLK, +gcc GCC_USB_HS_SYSTEM_CLK; + clock-names = iface, core; + + resets = gcc GCC_USB2A_PHY_BCR; + reset-names = phy; + + // D+/D- lines: 1 - Routed to HUB, 0 - Device connector + switch-gpio = pm8916_gpios 4 GPIO_ACTIVE_HIGH; + }; + diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 869c0cfcad..7d3beee 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -152,6 +152,20 @@ config USB_MSM_OTG This driver is not supported on boards like trout which has an external PHY. +config USB_QCOM_8X16_PHY + tristate Qualcomm APQ8016/MSM8916 on-chip USB PHY controller support + depends on ARCH_QCOM || COMPILE_TEST + depends on RESET_CONTROLLER + select USB_PHY + select USB_ULPI_VIEWPORT + help + Enable this to support the USB transceiver on Qualcomm 8x16 chipsets. + It handles PHY initialization, clock management, power management, + and workarounds required after resetting the hardware. + + To compile this driver as a module, choose M here: the + module will be called phy-qcom-8x16-usb. + config USB_MV_OTG tristate Marvell USB OTG support depends on USB_EHCI_MV USB_MV_UDC PM diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index e36ab1d..19c0dcc 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o obj-$(CONFIG_USB_GPIO_VBUS)+= phy-gpio-vbus-usb.o obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o +obj-$(CONFIG_USB_QCOM_8X16_PHY)+= phy-qcom-8x16-usb.o obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o diff --git a/drivers/usb/phy/phy-qcom-8x16-usb.c b/drivers/usb/phy/phy-qcom-8x16-usb.c new file mode 100644 index 000..5d357a9 --- /dev/null +++ b/drivers/usb/phy/phy-qcom-8x16-usb.c @@ -0,0 +1,436 @@ +/* + * Copyright (c) 2015, Linaro Limited + * + * This program is free software
Re: [PATCH 1/2] extcon: fix hang and extcon_get/set_cable_state().
On Mon, 2015-07-06 at 17:46 +0300, Roger Quadros wrote: -static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) +static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) { - unsigned int id = EXTCON_NONE; + unsigned int id = -EINVAL; int i = 0; - if (edev-max_supported == 0) - return -EINVAL; - - /* Find the the number of extcon cable */ + /* Find the id of extcon cable */ while (extcon_name[i]) { if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) { id = i; @@ -140,6 +137,19 @@ static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) } } Thank you Roger, but this still hang. 'i' is not incremented. Ivan + return id; +}; -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] extcon: fix hang and extcon_get/set_cable_state().
On Tue, 2015-07-07 at 16:06 +0300, Roger Quadros wrote: Users of find_cable_index_by_name() will cause a kernel hang as the while loop counter is never incremented and end condition is never reached. extcon_get_cable_state() and extcon_set_cable_state() are broken because they use cable index instead of cable id. This causes the first cable state (cable.0) to be always invalid in sysfs or extcon_get_cable_state() users. Introduce a new function find_cable_id_by_name() that fixes both of the above issues. Fixes: commit 73b6ecdb93e8 (extcon: Redefine the unique id of supported external connectors without 'enum extcon' type) Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Roger Quadros rog...@ti.com --- Thank you. It is fine now. For both patches. Tested-by: Ivan T. Ivanov ivan.iva...@linaro.org -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3] usb: chipidea: Use extcon framework for VBUS and ID detect
On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- Changes sice v2 [1]. * Simulate IRQ on extcon event - used to trigger OTG state machine. I have to admit that I couldn't test complete Chipidea OTG state machine, because my setup is little weird. I am using qcom,usb-otg-ci as PHY/OTG provider, qcom,ehci-host as host controller driver and qcom,ci-hdrc for device role. There could be patch conflict regarding ci-hdrc-qcom.txt, because Rob Herring is consolidating DT binding for all vendors which integrate this device [2] [1] https://lkml.org/lkml/2015/4/15/283 [2] http://www.spinics.net/lists/linux-usb/msg125453.html .../devicetree/bindings/usb/ci-hdrc-qcom.txt | 9 ++ drivers/usb/chipidea/Kconfig | 1 + drivers/usb/chipidea/core.c| 125 + drivers/usb/chipidea/otg.c | 55 - include/linux/usb/chipidea.h | 24 5 files changed, 212 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt index f2899b5..c635aca 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt @@ -7,6 +7,14 @@ Required properties: - usb-phy: phandle for the PHY device - dr_mode: Should be peripheral +Optional properties: +- extcon: phandles to external connector devices. First phandle +should point to external connector, which provide USB +cable events, the second should point to external connector +device, which provide USB-HOST cable events. If one of +the external connector devices is not required, empty 0 +phandle should be specified. + Examples: gadget@f9a55000 { compatible = qcom,ci-hdrc; @@ -14,4 +22,5 @@ Examples: dr_mode = peripheral; interrupts = 0 134 0; usb-phy = usbphy0; + extcon = 0, usb_id; }; diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 5ce3f1d..5619b8c 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -1,6 +1,7 @@ config USB_CHIPIDEA tristate ChipIdea Highspeed Dual Role Controller depends on ((USB_EHCI_HCD USB_GADGET) || (USB_EHCI_HCD !USB_GADGET) || (!USB_EHCI_HCD USB_GADGET)) HAS_DMA + select EXTCON help Say Y here if your system has a dual role high speed USB controller based on ChipIdea silicon IP. Currently, only the diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 74fea4f..2ae2c09 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -47,6 +47,7 @@ #include linux/delay.h #include linux/device.h #include linux/dma-mapping.h +#include linux/extcon.h #include linux/phy/phy.h #include linux/platform_device.h #include linux/module.h @@ -557,9 +558,47 @@ static irqreturn_t ci_irq(int irq, void *data) return ret; } +static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct ci_hdrc_cable *vbus = container_of(nb, struct ci_hdrc_cable, nb); + struct ci_hdrc *ci = vbus-ci; + + if (event) + vbus-state = true; + else + vbus-state = false; + + vbus-changed = true; + + ci_irq(ci-irq, ci); + return NOTIFY_DONE; +} + +static int ci_id_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct ci_hdrc_cable *id = container_of(nb, struct ci_hdrc_cable, nb); + struct ci_hdrc *ci = id-ci; + + if (event) + id-state = false; + else + id-state = true; + + id-changed = true; + + ci_irq(ci-irq, ci); + return NOTIFY_DONE; +} + static int ci_get_platdata(struct device *dev, struct ci_hdrc_platform_data *platdata) { + struct extcon_dev *ext_vbus, *ext_id; + struct ci_hdrc_cable *cable; + int ret; + if (!platdata-phy_mode) platdata-phy_mode = of_usb_get_phy_mode(dev-of_node); @@ -591,9 +630,89 @@ static int ci_get_platdata(struct device *dev, if (of_usb_get_maximum_speed(dev-of_node) == USB_SPEED_FULL) platdata-flags |= CI_HDRC_FORCE_FULLSPEED; + ext_id = ERR_PTR(-ENODEV); + ext_vbus = ERR_PTR(-ENODEV); + if (of_property_read_bool(dev-of_node, extcon)) { + /* Each one of them is not mandatory */ + ext_vbus = extcon_get_edev_by_phandle(dev, 0); + if (IS_ERR(ext_vbus) PTR_ERR(ext_vbus
Re: [PATCH v3 4/6] dt-bindings: Consolidate ChipIdea USB ci13xxx bindings
On Fri, 2015-05-29 at 11:38 -0500, Rob Herring wrote: Combine the ChipIdea USB binding into a single document to reduce duplication and fragmentation. This marks use of the old PHY bindings as deprecated. Future compatible bindings should use generic PHY binding. Signed-off-by: Rob Herring r...@kernel.org Cc: Ivan T. Ivanov iiva...@mm-sol.com Cc: Peter Chen c...@freescale.com Cc: Daniel Tang ta...@gmail.com Cc: Pawel Moll m...@arm.com Cc: Mark Rutland rutl...@arm.com Cc: Ian Campbell ijc+devicet...@hellion.org.uk Cc: Kumar Gala ga...@codeaurora.org Cc: devicet...@vger.kernel.org --- .../devicetree/bindings/usb/ci-hdrc-imx.txt| 35 -- .../devicetree/bindings/usb/ci-hdrc-qcom.txt | 17 --- .../devicetree/bindings/usb/ci-hdrc-usb2.txt | 22 +- .../devicetree/bindings/usb/ci-hdrc-zevio.txt | 17 --- 4 files changed, 21 insertions(+), 70 deletions(-) delete mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt delete mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt delete mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-zevio.txt Thanks. For Qualcomm part: Acked-by: Ivan T. Ivanov iiva...@mm-sol.com -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: chipidea: Use extcon framework for VBUS and ID detect
On Wed, 2015-04-15 at 16:35 +0300, Ivan T. Ivanov wrote: On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov iva...@linaro.org --- Changes since v0 [1], as per Peter Chen suggestions: * Moved external connector parsing code to ci_get_platdata() * Moved external connector related variables to struct ci_hdrc_platform_data * Rename ci_host_notifier() to ci_id_notifier() * Fixed device bindings description * Use select EXTCON framework, instead of depends on. [1] https://lkml.org/lkml/2015/4/9/116 Hi Peter, Did you have any further comments on this patch or what is your plan about it. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] Revert usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap
This reverts commit 70843f623b58 (usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap) and commit e507bf577e5a (host: ehci-msm: remove duplicate check on resource), because msm_otg and this driver are using same address space to access AHB mode and USB command registers. Cc: Vivek Gautam gautam.vi...@samsung.com Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- Changes since v0: * Add note to patch description that also commit e507bf577e5a is reverted. drivers/usb/host/ehci-msm.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 9db74ca..275c92e 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -88,13 +88,20 @@ static int ehci_msm_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hcd-regs = devm_ioremap_resource(pdev-dev, res); - if (IS_ERR(hcd-regs)) { - ret = PTR_ERR(hcd-regs); + if (!res) { + dev_err(pdev-dev, Unable to get memory resource\n); + ret = -ENODEV; goto put_hcd; } + hcd-rsrc_start = res-start; hcd-rsrc_len = resource_size(res); + hcd-regs = devm_ioremap(pdev-dev, hcd-rsrc_start, hcd-rsrc_len); + if (!hcd-regs) { + dev_err(pdev-dev, ioremap failed\n); + ret = -ENOMEM; + goto put_hcd; + } /* * OTG driver takes care of PHY initialization, clock management, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] usb: phy: msm: Use extcon framework for VBUS and ID detection
On Thu, 2015-04-09 at 11:34 +0300, Ivan T. Ivanov wrote: On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov iva...@linaro.org Hi Felipe, Did you have any comments on this and/or following patches? Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Revert usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap
This reverts commit 70843f623b58 (usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap), because msm_otg and this driver are using same address space to access AHB mode and USB command registers. Cc: Vivek Gautam gautam.vi...@samsung.com Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- drivers/usb/host/ehci-msm.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 9db74ca..275c92e 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -88,13 +88,20 @@ static int ehci_msm_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hcd-regs = devm_ioremap_resource(pdev-dev, res); - if (IS_ERR(hcd-regs)) { - ret = PTR_ERR(hcd-regs); + if (!res) { + dev_err(pdev-dev, Unable to get memory resource\n); + ret = -ENODEV; goto put_hcd; } + hcd-rsrc_start = res-start; hcd-rsrc_len = resource_size(res); + hcd-regs = devm_ioremap(pdev-dev, hcd-rsrc_start, hcd-rsrc_len); + if (!hcd-regs) { + dev_err(pdev-dev, ioremap failed\n); + ret = -ENOMEM; + goto put_hcd; + } /* * OTG driver takes care of PHY initialization, clock management, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Revert usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap
On Tue, 2015-04-21 at 16:46 +0530, Vivek Gautam wrote: Hi, On Tuesday, April 21, 2015 12:41 PM Ivan T. Ivanov iva...@linaro.org wrote: This reverts commit 70843f623b58 (usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap), because msm_otg and this driver are using same address space to access AHB mode and USB command registers. Cc: Vivek Gautam vi...@samsung.com Since ehci-msm and msm_otg both want to control few USB registers, it makes sense to request ioremap'ed region in both drivers. Acked-by: Vivek Gautam vi...@samsung.com I can see a patch in mailing list for adding both ehci-host and otg on msm [1]. But I think it has not yet made it to mainline kernel. [1] [v3,04/11] ARM: dts: apq8064: Add USB OTG support https://patches.linaro.org/47067/ Thanks. Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Revert usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap
On Tue, 2015-04-21 at 11:04 -0400, Alan Stern wrote: On Tue, 21 Apr 2015, Ivan T. Ivanov wrote: This reverts commit 70843f623b58 (usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap), because msm_otg and this driver are using same address space to access AHB mode and USB command registers. Um, this patch is in fact _not_ a reversion of 70843f623b58. That commit removed 4 lines of code and added 3. If this were truly a reversion, it would remove 3 lines and add 4. Instead it adds 10. Please make this a true reversion. Right, but I will have to revert 2 commits then, is this ok? Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: ehci-msm: Don't ioremap configuration space exclusively
On Thu, 2015-04-16 at 10:42 +0300, Ivan T. Ivanov wrote: Hi, On Wed, 2015-04-15 at 21:28 +0530, Vivek Gautam wrote: On Thu, Apr 9, 2015 at 8:19 PM, Alan Stern st...@rowland.harvard.edu wrote: On Thu, 9 Apr 2015, Ivan T. Ivanov wrote: This allow same IO space to be shared between HCD and Device controller driver. Which can be loaded simultaneously and started/stopped on demand by USB OTG PHY driver. Are you sure ? No. Will ehci controller registers overlap with the Device controller's register region ? Well, not exactly DC vs HC region, but at least USB_AHBBURST, USB_AHBMODE, USB_USBMODE are used by both OTG phy-msm-usb and this ehci-msm driver. And this is broken right now. Hi Alan, Perhaps I have to resend this patch with updated commit message? Are they any other obstacles? Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: ehci-msm: Don't ioremap configuration space exclusively
On Mon, 2015-04-20 at 10:14 -0400, Alan Stern wrote: On Mon, 20 Apr 2015, Ivan T. Ivanov wrote: Hi Alan, Perhaps I have to resend this patch with updated commit message? Are they any other obstacles? Instead of submitting this new patch, would it be okay to revert commit 70843f623b58? That would be simpler. Sure, wherever is working better for you. Also, I'd like to get an Acked-by from Vivek before accepting this. Alan Stern Do you expect something from my side? Thanks, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: ehci-msm: Don't ioremap configuration space exclusively
Hi, On Wed, 2015-04-15 at 21:28 +0530, Vivek Gautam wrote: On Thu, Apr 9, 2015 at 8:19 PM, Alan Stern st...@rowland.harvard.edu wrote: On Thu, 9 Apr 2015, Ivan T. Ivanov wrote: This allow same IO space to be shared between HCD and Device controller driver. Which can be loaded simultaneously and started/stopped on demand by USB OTG PHY driver. Are you sure ? No. Will ehci controller registers overlap with the Device controller's register region ? Well, not exactly DC vs HC region, but at least USB_AHBBURST, USB_AHBMODE, USB_USBMODE are used by both OTG phy-msm-usb and this ehci-msm driver. And this is broken right now. Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: chipidea: Use extcon framework for VBUS and ID detect
On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- Changes since v0 [1], as per Peter Chen suggestions: * Moved external connector parsing code to ci_get_platdata() * Moved external connector related variables to struct ci_hdrc_platform_data * Rename ci_host_notifier() to ci_id_notifier() * Fixed device bindings description * Use select EXTCON framework, instead of depends on. [1] https://lkml.org/lkml/2015/4/9/116 .../devicetree/bindings/usb/ci-hdrc-qcom.txt | 9 +++ drivers/usb/chipidea/Kconfig | 1 + drivers/usb/chipidea/core.c| 87 ++ drivers/usb/chipidea/otg.c | 26 ++- include/linux/usb/chipidea.h | 17 + 5 files changed, 139 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt index f2899b5..c635aca 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt @@ -7,6 +7,14 @@ Required properties: - usb-phy: phandle for the PHY device - dr_mode: Should be peripheral +Optional properties: +- extcon: phandles to external connector devices. First phandle +should point to external connector, which provide USB +cable events, the second should point to external connector +device, which provide USB-HOST cable events. If one of +the external connector devices is not required, empty 0 +phandle should be specified. + Examples: gadget@f9a55000 { compatible = qcom,ci-hdrc; @@ -14,4 +22,5 @@ Examples: dr_mode = peripheral; interrupts = 0 134 0; usb-phy = usbphy0; + extcon = 0, usb_id; }; diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 5ce3f1d..5619b8c 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -1,6 +1,7 @@ config USB_CHIPIDEA tristate ChipIdea Highspeed Dual Role Controller depends on ((USB_EHCI_HCD USB_GADGET) || (USB_EHCI_HCD !USB_GADGET) || (!USB_EHCI_HCD USB_GADGET)) HAS_DMA + select EXTCON help Say Y here if your system has a dual role high speed USB controller based on ChipIdea silicon IP. Currently, only the diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 74fea4f..e1d495d 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -47,6 +47,7 @@ #include linux/delay.h #include linux/device.h #include linux/dma-mapping.h +#include linux/extcon.h #include linux/phy/phy.h #include linux/platform_device.h #include linux/module.h @@ -557,9 +558,39 @@ static irqreturn_t ci_irq(int irq, void *data) return ret; } +static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event, +void *ptr) +{ + struct ci_hdrc_cable *vbus = container_of(nb, struct ci_hdrc_cable, nb); + + if (event) + vbus-state = true; + else + vbus-state = false; + + return NOTIFY_DONE; +} + +static int ci_id_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct ci_hdrc_cable *id = container_of(nb, struct ci_hdrc_cable, nb); + + if (event) + id-state = false; + else + id-state = true; + + return NOTIFY_DONE; +} + static int ci_get_platdata(struct device *dev, struct ci_hdrc_platform_data *platdata) { + struct extcon_dev *ext_vbus, *ext_id; + struct ci_hdrc_cable *cable; + int ret; + if (!platdata-phy_mode) platdata-phy_mode = of_usb_get_phy_mode(dev-of_node); @@ -591,6 +622,53 @@ static int ci_get_platdata(struct device *dev, if (of_usb_get_maximum_speed(dev-of_node) == USB_SPEED_FULL) platdata-flags |= CI_HDRC_FORCE_FULLSPEED; + ext_id = ERR_PTR(-ENODEV); + ext_vbus = ERR_PTR(-ENODEV); + if (of_property_read_bool(dev-of_node, extcon)) { + /* Each one of them is not mandatory */ + ext_vbus = extcon_get_edev_by_phandle(dev, 0); + if (IS_ERR(ext_vbus) PTR_ERR(ext_vbus) != -ENODEV) + return PTR_ERR(ext_vbus); + + ext_id = extcon_get_edev_by_phandle(dev, 1); + if (IS_ERR(ext_id) PTR_ERR(ext_id) != -ENODEV) + return PTR_ERR(ext_id); + } + + if (!IS_ERR(ext_vbus)) { + cable = platdata-vbus_extcon; + cable-nb.notifier_call = ci_vbus_notifier; + ret
Re: [PATCH v2] usb: chipidea: Use extcon framework for VBUS and ID detect
Hi Robert, On Wed, 2015-04-15 at 16:11 +0200, Robert Baldyga wrote: Hi Ivan, On 04/15/2015 03:35 PM, Ivan T. Ivanov wrote: On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov iva...@linaro.org --- Changes since v0 [1], as per Peter Chen suggestions: * Moved external connector parsing code to ci_get_platdata() * Moved external connector related variables to struct ci_hdrc_platform_data * Rename ci_host_notifier() to ci_id_notifier() * Fixed device bindings description * Use select EXTCON framework, instead of depends on. [1] https://lkml.org/lkml/2015/4/9/116 .../devicetree/bindings/usb/ci-hdrc-qcom.txt | 9 +++ drivers/usb/chipidea/Kconfig | 1 + drivers/usb/chipidea/core.c| 87 ++ drivers/usb/chipidea/otg.c | 26 ++- include/linux/usb/chipidea.h | 17 + 5 files changed, 139 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt index f2899b5..c635aca 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt @@ -7,6 +7,14 @@ Required properties: - usb-phy: phandle for the PHY device - dr_mode: Should be peripheral +Optional properties: +- extcon: phandles to external connector devices. First phandle +should point to external connector, which provide USB +cable events, the second should point to external connector +device, which provide USB-HOST cable events. If one of +the external connector devices is not required, empty 0 +phandle should be specified. Do you expect to have USB and USB-HOST notifiers supplied by two different extcon drivers? It looks strange. I don't think so that we ever will need to deal with such weird configuration. Yes. That is what I have today on my desk. + Examples: gadget@f9a55000 { compatible = qcom,ci-hdrc; @@ -14,4 +22,5 @@ Examples: dr_mode = peripheral; interrupts = 0 134 0; usb-phy = usbphy0; + extcon = 0, usb_id; }; diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 5ce3f1d..5619b8c 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -1,6 +1,7 @@ config USB_CHIPIDEA tristate ChipIdea Highspeed Dual Role Controller depends on ((USB_EHCI_HCD USB_GADGET) || (USB_EHCI_HCD !USB_GADGET) || (!USB_EHCI_HCD USB_GADGET)) HAS_DMA + select EXTCON help Say Y here if your system has a dual role high speed USB controller based on ChipIdea silicon IP. Currently, only the diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 74fea4f..e1d495d 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -47,6 +47,7 @@ #include linux/delay.h #include linux/device.h #include linux/dma-mapping.h +#include linux/extcon.h #include linux/phy/phy.h #include linux/platform_device.h #include linux/module.h @@ -557,9 +558,39 @@ static irqreturn_t ci_irq(int irq, void *data) return ret; } +static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct ci_hdrc_cable *vbus = container_of(nb, struct ci_hdrc_cable, nb); + + if (event) + vbus-state = true; + else + vbus-state = false; + + return NOTIFY_DONE; +} Actually it's not true that USB cable state is equal to VBUS state. But this is how it supposed to work right now, no? I have to admit that the naming is really confusing. USB and USB-HOST are mutually exclusive, and when you have ID=0, which means USB-HOST is connected, USB cable will be seen as disconnected even when VBUS=1. We are currently discussing how to pass VBUS state to USB OTG drivers. You can find discussion here: http://www.spinics.net/lists/linux-usb/msg123895.html Sure, I am following this discussion. When it settles down, I can change this as appropriate, until then this is what we will have in 4.1. It will be messy refactoring, I think. All extcon providers and consumers are using strings to denote cable names. Not to mention that extcon-class is using USB-Host, while all others are using USB-HOST. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message
Re: [PATCH] usb: chipidea: Use extcon framework for VBUS and ID detection
On Apr 13, 2015, at 6:53 AM, Peter Chen peter.c...@freescale.com wrote: On Thu, Apr 09, 2015 at 11:33:38AM +0300, Ivan T. Ivanov wrote: On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. snip +Optional properties: +- extcon: phandles to external connector devices. First phandle +should point to external connector, which provide USB +cable events, the second should point to external connector +device, which provide USB-HOST cable events. If one of +the external connector devices is not required empty 0 +phandle should be specified. You mean if id connector is not needed, we write dts like below: extcon = usb_vbus, 0; If it is, you may miss ',' between required and empty 0”. Yes. Will fix it. u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask) { -return hw_read(ci, OP_OTGSC, mask); +u32 val = hw_read(ci, OP_OTGSC, mask); + +if ((mask OTGSC_BSV) ci-vbus.conn.edev) { You may use || since you can't get vbus and id value from cpu register (otgsc). The idea is to not rely on the register content for these bits if user have defined these DT bindings. Will fix rest of the comments and resend. Thank you, Ivan-- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] usb: phy: msm: Manual PHY and LINK controller VBUS change notification
VBUS is not routed to USB PHY on recent Qualcomm platforms. USB controller must see VBUS in order to pull-up DP when setting RS bit. Henc configure USB PHY and LINK registers sense VBUS and enable manual pullup on D+ line. Cc: Vamsi Krishna vskri...@codeaurora.org Cc: Mayank Rana mr...@codeaurora.org Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- .../devicetree/bindings/usb/msm-hsusb.txt | 4 drivers/usb/phy/phy-msm-usb.c | 26 ++ include/linux/usb/msm_hsusb.h | 5 + include/linux/usb/msm_hsusb_hw.h | 9 4 files changed, 44 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index f26bcfa..bd8d9e7 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -69,6 +69,10 @@ Optional properties: (no, min, max) where each value represents either a voltage in microvolts or a value corresponding to voltage corner. +- qcom,manual-pullup: If present, vbus is not routed to USB controller/phy +and controller driver therefore enables pull-up explicitly +before starting controller using usbcmd run/stop bit. + - extcon: phandles to external connector devices. First phandle should point to external connector, which provide USB cable events, the second should point to external connector diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index d47c3eb..4a928f7 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -245,8 +245,14 @@ static void ulpi_init(struct msm_otg *motg) static int msm_phy_notify_disconnect(struct usb_phy *phy, enum usb_device_speed speed) { + struct msm_otg *motg = container_of(phy, struct msm_otg, phy); int val; + if (motg-manual_pullup) { + val = ULPI_MISC_A_VBUSVLDEXT | ULPI_MISC_A_VBUSVLDEXTSEL; + usb_phy_io_write(phy, val, ULPI_CLR(ULPI_MISC_A)); + } + /* * Put the transceiver in non-driving mode. Otherwise host * may not detect soft-disconnection. @@ -431,6 +437,24 @@ static int msm_phy_init(struct usb_phy *phy) ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL); } + if (motg-manual_pullup) { + val = ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT; + ulpi_write(phy, val, ULPI_SET(ULPI_MISC_A)); + + val = readl(USB_GENCONFIG_2); + val |= GENCONFIG_2_SESS_VLD_CTRL_EN; + writel(val, USB_GENCONFIG_2); + + val = readl(USB_USBCMD); + val |= USBCMD_SESS_VLD_CTRL; + writel(val, USB_USBCMD); + + val = ulpi_read(phy, ULPI_FUNC_CTRL); + val = ~ULPI_FUNC_CTRL_OPMODE_MASK; + val |= ULPI_FUNC_CTRL_OPMODE_NORMAL; + ulpi_write(phy, val, ULPI_FUNC_CTRL); + } + if (motg-phy_number) writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); @@ -1529,6 +1553,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) motg-vdd_levels[VDD_LEVEL_MAX] = tmp[VDD_LEVEL_MAX]; } + motg-manual_pullup = of_property_read_bool(node, qcom,manual-pullup); + ext_id = ERR_PTR(-ENODEV); ext_vbus = ERR_PTR(-ENODEV); if (of_property_read_bool(node, extcon)) { diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 9a38e77..a5edc8d 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h @@ -153,6 +153,9 @@ struct msm_usb_cable { * @chg_type: The type of charger attached. * @dcd_retires: The retry count used to track Data contact * detection process. + * @manual_pullup: true if VBUS is not routed to USB controller/phy + * and controller driver therefore enables pull-up explicitly before + * starting controller using usbcmd run/stop bit. * @vbus: VBUS signal state trakining, using extcon framework * @id: ID signal state trakining, using extcon framework */ @@ -185,6 +188,8 @@ struct msm_otg { struct reset_control *link_rst; int vdd_levels[3]; + bool manual_pullup; + struct msm_usb_cable vbus; struct msm_usb_cable id; }; diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index a29f603..e159b39 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b/include/linux/usb/msm_hsusb_hw.h @@ -21,6 +21,8 @@ #define USB_AHBBURST (MSM_USB_BASE + 0x0090) #define USB_AHBMODE (MSM_USB_BASE + 0x0098) +#define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00a0) + #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */ #define USB_USBCMD
[PATCH] usb: chipidea: Use extcon framework for VBUS and ID detection
On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- Suggestions for better solution are welcome! .../devicetree/bindings/usb/ci-hdrc-qcom.txt | 9 +++ drivers/usb/chipidea/Kconfig | 1 + drivers/usb/chipidea/ci.h | 18 + drivers/usb/chipidea/core.c| 77 ++ drivers/usb/chipidea/otg.c | 19 +- 5 files changed, 123 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt index f2899b5..788da49 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt @@ -7,6 +7,14 @@ Required properties: - usb-phy: phandle for the PHY device - dr_mode: Should be peripheral +Optional properties: +- extcon: phandles to external connector devices. First phandle +should point to external connector, which provide USB +cable events, the second should point to external connector +device, which provide USB-HOST cable events. If one of +the external connector devices is not required empty 0 +phandle should be specified. + Examples: gadget@f9a55000 { compatible = qcom,ci-hdrc; @@ -14,4 +22,5 @@ Examples: dr_mode = peripheral; interrupts = 0 134 0; usb-phy = usbphy0; + extcon = usb_vbus, usb_id; }; diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 77b47d8..a67b67f 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -1,6 +1,7 @@ config USB_CHIPIDEA tristate ChipIdea Highspeed Dual Role Controller depends on ((USB_EHCI_HCD USB_GADGET) || (USB_EHCI_HCD !USB_GADGET) || (!USB_EHCI_HCD USB_GADGET)) HAS_DMA + depends on EXTCON help Say Y here if your system has a dual role high speed USB controller based on ChipIdea silicon IP. Currently, only the diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 65913d4..04e7aee 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -13,6 +13,7 @@ #ifndef __DRIVERS_USB_CHIPIDEA_CI_H #define __DRIVERS_USB_CHIPIDEA_CI_H +#include linux/extcon.h #include linux/list.h #include linux/irqreturn.h #include linux/usb.h @@ -132,6 +133,18 @@ struct hw_bank { }; /** + * struct ci_hdrc - structure for exteternal connector cable state tracking + * @state: current state of the line + * @nb: hold event notification callback + * @conn: used for notification registration + */ +struct ci_cable { + boolstate; + struct notifier_block nb; + struct extcon_specific_cable_nb conn; +}; + +/** * struct ci_hdrc - chipidea device representation * @dev: pointer to parent device * @lock: access synchronization @@ -169,6 +182,8 @@ struct hw_bank { * @b_sess_valid_event: indicates there is a vbus event, and handled * at ci_otg_work * @imx28_write_fix: Freescale imx28 needs swp instruction for writing + * @vbus: VBUS signal state trakining, using extcon framework + * @id: ID signal state trakining, using extcon framework */ struct ci_hdrc { struct device *dev; @@ -211,6 +226,9 @@ struct ci_hdrc { boolid_event; boolb_sess_valid_event; boolimx28_write_fix; + + struct ci_cable vbus; + struct ci_cable id; }; static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index a57dc88..0f805bd 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -47,6 +47,7 @@ #include linux/delay.h #include linux/device.h #include linux/dma-mapping.h +#include linux/extcon.h #include linux/phy/phy.h #include linux/platform_device.h #include linux/module.h @@ -646,9 +647,36 @@ static void ci_get_otg_capable(struct ci_hdrc *ci) dev_dbg(ci-dev, It is OTG capable controller\n); } +static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event, +void *ptr) +{ + struct ci_cable *vbus = container_of(nb, struct ci_cable, nb); + + if (event) + vbus-state = true; + else + vbus-state = false; + + return NOTIFY_DONE; +} + +static int ci_host_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct ci_cable *id = container_of(nb, struct ci_cable
[PATCH 1/2] usb: phy: msm: Use extcon framework for VBUS and ID detection
On recent Qualcomm platforms VBUS and ID lines are not routed to USB PHY LINK controller. Use extcon framework to receive connect and disconnect ID and VBUS notification. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- .../devicetree/bindings/usb/msm-hsusb.txt | 7 ++ drivers/usb/phy/Kconfig| 1 + drivers/usb/phy/phy-msm-usb.c | 84 ++ include/linux/usb/msm_hsusb.h | 17 + 4 files changed, 109 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index 2826f2a..f26bcfa 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -69,6 +69,13 @@ Optional properties: (no, min, max) where each value represents either a voltage in microvolts or a value corresponding to voltage corner. +- extcon: phandles to external connector devices. First phandle +should point to external connector, which provide USB +cable events, the second should point to external connector +device, which provide USB-HOST cable events. If one of +the external connector devices is not required empty 0 +phandle should be specified. + Example HSUSB OTG controller device node: usb@f9a55000 { diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 52d3d58..ca584ef 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -141,6 +141,7 @@ config USB_MSM_OTG tristate Qualcomm on-chip USB OTG controller support depends on (USB || USB_GADGET) (ARCH_MSM || ARCH_QCOM || COMPILE_TEST) depends on RESET_CONTROLLER + depends on EXTCON select USB_PHY help Enable this to support the USB OTG transceiver on Qualcomm chips. It diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 000fd89..d47c3eb 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1445,9 +1445,42 @@ static const struct of_device_id msm_otg_dt_match[] = { }; MODULE_DEVICE_TABLE(of, msm_otg_dt_match); +static int msm_otg_vbus_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct msm_usb_cable *vbus = container_of(nb, struct msm_usb_cable, nb); + struct msm_otg *motg = container_of(vbus, struct msm_otg, vbus); + + if (event) + set_bit(B_SESS_VLD, motg-inputs); + else + clear_bit(B_SESS_VLD, motg-inputs); + + schedule_work(motg-sm_work); + + return NOTIFY_DONE; +} + +static int msm_otg_id_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) +{ + struct msm_usb_cable *id = container_of(nb, struct msm_usb_cable, nb); + struct msm_otg *motg = container_of(id, struct msm_otg, id); + + if (event) + clear_bit(ID, motg-inputs); + else + set_bit(ID, motg-inputs); + + schedule_work(motg-sm_work); + + return NOTIFY_DONE; +} + static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) { struct msm_otg_platform_data *pdata; + struct extcon_dev *ext_id, *ext_vbus; const struct of_device_id *id; struct device_node *node = pdev-dev.of_node; struct property *prop; @@ -1496,6 +1529,52 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) motg-vdd_levels[VDD_LEVEL_MAX] = tmp[VDD_LEVEL_MAX]; } + ext_id = ERR_PTR(-ENODEV); + ext_vbus = ERR_PTR(-ENODEV); + if (of_property_read_bool(node, extcon)) { + + /* Each one of them is not mandatory */ + ext_vbus = extcon_get_edev_by_phandle(pdev-dev, 0); + if (IS_ERR(ext_vbus) PTR_ERR(ext_vbus) != -ENODEV) + return PTR_ERR(ext_vbus); + + ext_id = extcon_get_edev_by_phandle(pdev-dev, 1); + if (IS_ERR(ext_id) PTR_ERR(ext_id) != -ENODEV) + return PTR_ERR(ext_id); + } + + if (!IS_ERR(ext_vbus)) { + motg-vbus.nb.notifier_call = msm_otg_vbus_notifier; + ret = extcon_register_interest(motg-vbus.conn, ext_vbus-name, + USB, motg-vbus.nb); + if (ret 0) { + dev_err(pdev-dev, register VBUS notifier failed\n); + return ret; + } + + ret = extcon_get_cable_state(ext_vbus, USB); + if (ret) + set_bit(B_SESS_VLD, motg-inputs); + else + clear_bit(B_SESS_VLD, motg-inputs); + } + + if (!IS_ERR(ext_id)) { + motg-id.nb.notifier_call
[PATCH] usb: ehci-msm: Don't ioremap configuration space exclusively
This allow same IO space to be shared between HCD and Device controller driver. Which can be loaded simultaneously and started/stopped on demand by USB OTG PHY driver. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- drivers/usb/host/ehci-msm.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 9db74ca..f059e15 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -88,13 +88,17 @@ static int ehci_msm_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hcd-regs = devm_ioremap_resource(pdev-dev, res); + if (!res) + return -ENODEV; + + hcd-rsrc_start = res-start; + hcd-rsrc_len = resource_size(res); + + hcd-regs = devm_ioremap(pdev-dev, hcd-rsrc_start, hcd-rsrc_len); if (IS_ERR(hcd-regs)) { ret = PTR_ERR(hcd-regs); goto put_hcd; } - hcd-rsrc_start = res-start; - hcd-rsrc_len = resource_size(res); /* * OTG driver takes care of PHY initialization, clock management, -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: phy: Fix USB_ULPI_VIEWPORT Kconfig dependency
USB_ULPI_VIEWPORT didn't depend on USB_ULPI, while USB_ULPI is using non user selectable USB_ULPI_VIEWPORT. Fix this. Signed-off-by: Ivan T. Ivanov ivan.iva...@linaro.org --- drivers/usb/phy/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 52d3d58..3017e4a 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -202,13 +202,13 @@ config USB_RCAR_GEN2_PHY config USB_ULPI bool Generic ULPI Transceiver Driver depends on ARM || ARM64 + select USB_ULPI_VIEWPORT help Enable this to support ULPI connected USB OTG transceivers which are likely found on embedded boards. config USB_ULPI_VIEWPORT bool - depends on USB_ULPI help Provides read/write operations to the ULPI phy register set for controllers with a viewport register (e.g. Chipidea/ARC controllers). -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/1] extcon: usb-gpio: Introduce gpio usb extcon driver
Hi, On Mon, 2015-02-02 at 12:21 +0200, Roger Quadros wrote: This driver observes the USB ID pin connected over a GPIO and updates the USB cable extcon states accordingly. The existing GPIO extcon driver is not suitable for this purpose as it needs to be taught to understand USB cable states and it can't handle more than one cable per instance. For the USB case we need to handle 2 cable states. 1) USB (attach/detach) 2) USB-HOST (attach/detach) This driver can be easily updated in the future to handle VBUS events in case it happens to be available on GPIO for any platform. Signed-off-by: Roger Quadros rog...@ti.com --- v4: - got rid of id_irqwake flag. Fail if enable/disable_irq_wake() fails - changed host cable name to USB-HOST I am sorry that I am getting a bit little late into this. Isn't supposed that we have to use strings defined in const char extcon_cable_name[][]? + +/* List of detectable cables */ +enum { + EXTCON_CABLE_USB = 0, + EXTCON_CABLE_USB_HOST, + Same here: duplicated with enum extcon_cable_name + EXTCON_CABLE_END, +}; + +static const char *usb_extcon_cable[] = { + [EXTCON_CABLE_USB] = USB, + [EXTCON_CABLE_USB_HOST] = USB-HOST, + NULL, +}; snip + +static int usb_extcon_probe(struct platform_device *pdev) +{ snip + + ret = devm_request_threaded_irq(dev, info-id_irq, NULL, + usb_irq_handler, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, Shouldn't triggers be defined in DTS files? Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/1] extcon: usb-gpio: Introduce gpio usb extcon driver
Hi Roger, On Mon, 2015-03-16 at 15:11 +0200, Roger Quadros wrote: Hi Ivan, On 16/03/15 14:32, Ivan T. Ivanov wrote: Hi, On Mon, 2015-02-02 at 12:21 +0200, Roger Quadros wrote: This driver observes the USB ID pin connected over a GPIO and updates the USB cable extcon states accordingly. The existing GPIO extcon driver is not suitable for this purpose as it needs to be taught to understand USB cable states and it can't handle more than one cable per instance. For the USB case we need to handle 2 cable states. 1) USB (attach/detach) 2) USB-HOST (attach/detach) This driver can be easily updated in the future to handle VBUS events in case it happens to be available on GPIO for any platform. Signed-off-by: Roger Quadros rog...@ti.com --- v4: - got rid of id_irqwake flag. Fail if enable/disable_irq_wake() fails - changed host cable name to USB-HOST I am sorry that I am getting a bit little late into this. Isn't supposed that we have to use strings defined in const char extcon_cable_name[][]? + +/* List of detectable cables */ +enum { + EXTCON_CABLE_USB = 0, + EXTCON_CABLE_USB_HOST, + Same here: duplicated with enum extcon_cable_name + EXTCON_CABLE_END, +}; + +static const char *usb_extcon_cable[] = { + [EXTCON_CABLE_USB] = USB, + [EXTCON_CABLE_USB_HOST] = USB-HOST, + NULL, +}; I'm not exactly sure how else it is supposed to work if we support only a subset of cables from the global extcon_cable_name[][]. I don't see issue that we use just 2 events. I think that we can reuse enum extcon_cable_name and strings already defined in extcon_cable_name[][] global variable. It is defined extern in extcon.h file exactly for this purpose, no? snip + +static int usb_extcon_probe(struct platform_device *pdev) +{ snip + + ret = devm_request_threaded_irq(dev, info-id_irq, NULL, + usb_irq_handler, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, Shouldn't triggers be defined in DTS files? Could be but we're sure that we always need the trigger for both rising/falling edges in this case. So the usage is more appropriately decided from application point of view rather than h/w point of view. h/w is generic GPIO. No strong opinion on this. Could it be that GPIO did't support edge triggered interrupt, but just level triggered? Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: Remove .owner field for driver
On Wed, 2014-09-24 at 16:48 +0530, Kiran Padwal wrote: There is no need to init .owner field. Based on the patch from Peter Griffin peter.grif...@linaro.org mmc: remove .owner field for drivers using module_platform_driver This patch removes the superflous .owner field for drivers which use the module_platform_driver API, as this is overriden in platform_driver_register anyway. Signed-off-by: Kiran Padwal kiran.pad...@smartplayin.com Thank you Kiran. Reviewed-by: Ivan T. Ivanov iiva...@mm-sol.com -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Fwd: Status of chipidea msm USB reset patch
On Fri, 2014-09-05 at 09:01 +0800, Peter Chen wrote: On Thu, Sep 04, 2014 at 07:47:40AM -0700, Tim Bird wrote: On Fri, Aug 15, 2014 at 12:08 AM, Ivan T. Ivanov iiva...@mm-sol.com wrote: On Fri, 2014-08-15 at 08:23 +0800, Peter Chen wrote: On Thu, Aug 14, 2014 at 11:54:02AM -0500, Felipe Balbi wrote: Hi, On Thu, Aug 14, 2014 at 09:53:10AM -0700, Tim Bird wrote: Ping. Anybody know the status of this patch? Is it queued in someone's tree? Without it the USB driver for the Qualcomm 8974 (hsusb phy) doesn't work (at least for me). It looks like it got dropped from Ivan's original patch series, back in May. I don't maintain chipidea, Peter's the guy you want Below patch was not at msm chipidea patchset Ivan sent me. http://markmail.org/search/?q=%5BPATCH+v4+0%2F3%5D+usb%3A+chipidea%3A+msm%3A+Clean+and+fix+#query:%5BPATCH%20v4%200%2F3%5D%20usb%3A%20chipidea%3A%20msm%3A%20Clean%20and%20fix%20from%3A%22Ivan%20T.%20Ivanov%22+page:1+mid:mt7hgr7yamyzegg3+state:results My fault. I have waiting PHY patches to be accepted to send this one. Will rebase and resend. Peter, There appears to be no progress on this. Can we just add the existing patch, get it into Linus' tree asap as a bugfix (preferably in this RC cycle)? Then ask Ivan to rebase his patches on top of this, instead of rebasing this patch as part of a larger effort with an unclear delivery date? Note that without this patch, the driver in mainline doesn't work at all, so adding it couldn't possibly make mainline worse. IMHO this should be CC:'ed to stable for the 3.16 kernel as well. No other files are affected, and it applies and builds on 3.16 without problems. Wait, the below patch was not exactly the Ivan sent to me, it has no below change at Ivan's recent patch - writel(0, USB_AHBBURST); - writel(0, USB_AHBMODE); https://github.com/hzpeterchen/linux-usb/commit/be3473c05639dc84696c5e66e524ca22180cbe88 https://github.com/hzpeterchen/linux-usb/commit/b59838118bcc14a6a4ea1efec85c3452a705bfe0 I am sorry Tim, I have forgot to Cc you in updated patches. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RESEND] usb: chipidea: msm: Use USB PHY API to control PHY state
On Tue, 2014-08-19 at 14:06 -0500, Felipe Balbi wrote: On Fri, Aug 15, 2014 at 12:21:19PM +0300, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com PHY drivers keep track of the current state of the hardware, so don't change PHY settings under it. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com looks correct to me from a PHY API perspective, so: Acked-by: Felipe Balbi ba...@ti.com Thanks. However, it doesn't look like msm_phy_init() is equivalent to the lines removes. Care to comment ? What I have to actually do is just add phy_init(). No need to remove controller reinitialization. Tested and is working. Will post 2 new patches shortly. Regards, Ivan --- drivers/usb/chipidea/ci_hdrc_msm.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index d72b9d2..81de834 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -20,13 +20,11 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) { struct device *dev = ci-gadget.dev.parent; - int val; switch (event) { case CI_HDRC_CONTROLLER_RESET_EVENT: dev_dbg(dev, CI_HDRC_CONTROLLER_RESET_EVENT received\n); - writel(0, USB_AHBBURST); - writel(0, USB_AHBMODE); + usb_phy_init(ci-transceiver); break; case CI_HDRC_CONTROLLER_STOPPED_EVENT: dev_dbg(dev, CI_HDRC_CONTROLLER_STOPPED_EVENT received\n); @@ -34,10 +32,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) * Put the transceiver in non-driving mode. Otherwise host * may not detect soft-disconnection. */ - val = usb_phy_io_read(ci-transceiver, ULPI_FUNC_CTRL); - val = ~ULPI_FUNC_CTRL_OPMODE_MASK; - val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; - usb_phy_io_write(ci-transceiver, val, ULPI_FUNC_CTRL); + usb_phy_notify_disconnect(ci-transceiver, USB_SPEED_UNKNOWN); break; default: dev_dbg(dev, unknown ci_hdrc event\n); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] usb: chipidea: msm: Use USB PHY API to control PHY state
PHY drivers keep track of the current state of the hardware, so don't change PHY settings under it. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/chipidea/ci_hdrc_msm.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index d72b9d2..30bdd51 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -20,7 +20,6 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) { struct device *dev = ci-gadget.dev.parent; - int val; switch (event) { case CI_HDRC_CONTROLLER_RESET_EVENT: @@ -34,10 +33,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) * Put the transceiver in non-driving mode. Otherwise host * may not detect soft-disconnection. */ - val = usb_phy_io_read(ci-transceiver, ULPI_FUNC_CTRL); - val = ~ULPI_FUNC_CTRL_OPMODE_MASK; - val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; - usb_phy_io_write(ci-transceiver, val, ULPI_FUNC_CTRL); + usb_phy_notify_disconnect(ci-transceiver, USB_SPEED_UNKNOWN); break; default: dev_dbg(dev, unknown ci_hdrc event\n); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] usb: chipidea: msm: Initialize PHY on reset event
Initialize USB PHY after every Link controller reset Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/chipidea/ci_hdrc_msm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 30bdd51..4935ac3 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -26,6 +26,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) dev_dbg(dev, CI_HDRC_CONTROLLER_RESET_EVENT received\n); writel(0, USB_AHBBURST); writel(0, USB_AHBMODE); + usb_phy_init(ci-transceiver); break; case CI_HDRC_CONTROLLER_STOPPED_EVENT: dev_dbg(dev, CI_HDRC_CONTROLLER_STOPPED_EVENT received\n); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Fwd: Status of chipidea msm USB reset patch
On Fri, 2014-08-15 at 08:23 +0800, Peter Chen wrote: On Thu, Aug 14, 2014 at 11:54:02AM -0500, Felipe Balbi wrote: Hi, On Thu, Aug 14, 2014 at 09:53:10AM -0700, Tim Bird wrote: Ping. Anybody know the status of this patch? Is it queued in someone's tree? Without it the USB driver for the Qualcomm 8974 (hsusb phy) doesn't work (at least for me). It looks like it got dropped from Ivan's original patch series, back in May. I don't maintain chipidea, Peter's the guy you want Below patch was not at msm chipidea patchset Ivan sent me. http://markmail.org/search/?q=%5BPATCH+v4+0%2F3%5D+usb%3A+chipidea%3A+msm%3A+Clean+and+fix+#query:%5BPATCH%20v4%200%2F3%5D%20usb%3A%20chipidea%3A%20msm%3A%20Clean%20and%20fix%20from%3A%22Ivan%20T.%20Ivanov%22+page:1+mid:mt7hgr7yamyzegg3+state:results My fault. I have waiting PHY patches to be accepted to send this one. Will rebase and resend. Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RESEND] usb: chipidea: msm: Use USB PHY API to control PHY state
From: Ivan T. Ivanov iiva...@mm-sol.com PHY drivers keep track of the current state of the hardware, so don't change PHY settings under it. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/chipidea/ci_hdrc_msm.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index d72b9d2..81de834 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -20,13 +20,11 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) { struct device *dev = ci-gadget.dev.parent; - int val; switch (event) { case CI_HDRC_CONTROLLER_RESET_EVENT: dev_dbg(dev, CI_HDRC_CONTROLLER_RESET_EVENT received\n); - writel(0, USB_AHBBURST); - writel(0, USB_AHBMODE); + usb_phy_init(ci-transceiver); break; case CI_HDRC_CONTROLLER_STOPPED_EVENT: dev_dbg(dev, CI_HDRC_CONTROLLER_STOPPED_EVENT received\n); @@ -34,10 +32,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) * Put the transceiver in non-driving mode. Otherwise host * may not detect soft-disconnection. */ - val = usb_phy_io_read(ci-transceiver, ULPI_FUNC_CTRL); - val = ~ULPI_FUNC_CTRL_OPMODE_MASK; - val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; - usb_phy_io_write(ci-transceiver, val, ULPI_FUNC_CTRL); + usb_phy_notify_disconnect(ci-transceiver, USB_SPEED_UNKNOWN); break; default: dev_dbg(dev, unknown ci_hdrc event\n); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Patch v7 3/3] usb: dwc3: qcom: Add device tree binding
Hi, On Tue, 2014-07-01 at 14:47 -0500, Rob Herring wrote: On Tue, Jul 1, 2014 at 1:01 PM, Andy Gross agr...@codeaurora.org wrote: On Tue, Jul 01, 2014 at 12:04:35AM -0500, Rob Herring wrote: snip snip + + ranges; + + status = disabled; + + dwc3@1100 { + compatible = snps,dwc3; This sub-node is just wrong. Why can't you have a single node with ' qcom,dwc3, snps,dwc3 ' for the compatible property? All you are adding here is clocks. Does the Synopsys block have no clocks? I guess this is copied from other broken dwc3 bindings... That doesn't mean you have to copy it. The dwc3 core does not deal with clocks. That is why everyone has a wrapper. That, in addition to pm, has to be handled from the wrapper. That's my take anyway. I am sure Felipe can speak more to this. That is a Linux driver issue which is irrelevant to the binding. DWC3 IP core from Synopsys is the same across SoC's (OMAP, Exynos..), vendors are adding glue IP to provide necessary clocks and voltages. I think that the DT bindings properly reflect this fact. Regards, Ivan Rob -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch] usb: phy: msm: fix bug in probe()
On Mon, 2014-05-19 at 23:35 +0300, Dan Carpenter wrote: My previous patch introduced a bug which prevented this driver from loading. devm_ioremap_resource() has a call to devm_request_mem_region() which will fail because the address space is shared between this PHY driver and CI device controller driver. Fixes: 10f0577aa5cb ('usb: phy: msm: change devm_ioremap() to devm_ioremap_resource()') Reported-by:Ivan T. Ivanov iiva...@mm-sol.com Signed-off-by: Dan Carpenter dan.carpen...@oracle.com diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 4f88174..ced34f3 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1586,9 +1586,11 @@ static int msm_otg_probe(struct platform_device *pdev) np ? alt_core : usb_hs_core_clk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - motg-regs = devm_ioremap_resource(pdev-dev, res); - if (IS_ERR(motg-regs)) - return PTR_ERR(motg-regs); + if (!res) + return -EINVAL; + motg-regs = devm_ioremap(pdev-dev, res-start, resource_size(res)); + if (!motg-regs) + return -ENOMEM; Well, I don't think that your previous patch was merged anywhere. Or I am missing something? So you have to just made v3 of your original patch. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch v2] usb: phy: msm: change devm_ioremap() to devm_ioremap_resource()
On Wed, 2014-05-14 at 16:54 +0300, Dan Carpenter wrote: There are several issues here: 1) platform_get_resource() can return NULL and that wasn't handled. 2) We should request the memory before we remap it, and devm_ioremap_resource() does that. 3) devm_ioremap() returns a NULL but we were checking for IS_ERR(). Fixes: 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation') Signed-off-by: Dan Carpenter dan.carpen...@oracle.com --- v2: the first version just swapped the IS_ERR() check for a NULL check Thanks everyone for the review. In the end, it was still a one line fix so I forgive you Ivan. diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index c522c4f..4f88174 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1586,7 +1586,7 @@ static int msm_otg_probe(struct platform_device *pdev) np ? alt_core : usb_hs_core_clk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - motg-regs = devm_ioremap(pdev-dev, res-start, resource_size(res)); + motg-regs = devm_ioremap_resource(pdev-dev, res); Thank you Dan, but this will not going to work. Address space is shared between this PHY driver and CI device controller driver. First version plus adding required check for 'res' as suggested by Sergei will fix this. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: phy: msm: make it depend on RESET_CONTROLLER
On Tue, 2014-05-13 at 12:07 -0400, Alan Stern wrote: On Tue, 13 May 2014, Bird, Tim wrote: I don't think so. I haven't tested, but I believe the driver now relies on operational (not stub) resets. I think this comment is a bit off. I think it would be better to just say that the driver now depends on the reset sub-system, and thus needs the config dependency. Maybe there's a case where the driver works fine even without the resets, but if so it's not obvious to me. Out of curiosity - is this something that many sub-systems do: provide stubs for compilation, and support operating with or without real functionality. This seems kind of odd. Some subsystems do it when the functionality they provide is optional. Runtime PM is a good example. If I could add. clk and regulator frameworks also provide stub API's, why reset framework should be different? Probably none of the drivers, which use clk or regulator, did not have dependency to these frameworks. I am pretty sure that these drivers will not work properly without proper back end implementation. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: usb: phy: msm: Migrate to Managed Device Resource allocation
On Tue, 2014-05-13 at 23:20 +0300, Dan Carpenter wrote: Hello Ivan T. Ivanov, The patch 6b99c68ec1f9: usb: phy: msm: Migrate to Managed Device Resource allocation from Apr 28, 2014, leads to the following static checker warning: drivers/usb/phy/phy-msm-usb.c:1590 msm_otg_probe() warn: 'motg-regs' isn't an ERR_PTR drivers/usb/phy/phy-msm-usb.c 1587 1588 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1589 motg-regs = devm_ioremap(pdev-dev, res-start, resource_size(res)); 1590 if (IS_ERR(motg-regs)) Should be a check for NULL. True. Thanks. Patch is welcome :-) Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: phy: msm: reset controller is mandatory now
On Tue, 2014-05-13 at 21:46 +0200, Arnd Bergmann wrote: Commit a27345434134 usb: phy: msm: Use reset framework for LINK and PHY resets introduced a mandatory call to reset_control_get into the msm usb phy driver, which means we have to add a Kconfig dependency on the API to avoid this build error: phy/phy-msm-usb.c: In function 'msm_otg_read_dt': phy/phy-msm-usb.c:1461:2: error: implicit declaration of function 'devm_reset_control_get' [-Werror=implicit-function-declaration] motg-link_rst = devm_reset_control_get(pdev-dev, link); ^ Since the usb-ehci-msm driver currently selects the OTG driver, we could still get a broken dependency here. To solve that, this patch also removes the 'select', which turns out to be unnecessary. Signed-off-by: Arnd Bergmann a...@arndb.de Cc: Ivan T. Ivanov iiva...@mm-sol.com Thank you. Reviewed-by: Ivan T. Ivanov iiva...@mm-sol.com -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/8] usb: phy: msm: reset controller is mandatory now
Hi Arnd, On Thu, 2014-05-08 at 15:52 +0200, Arnd Bergmann wrote: Commit a27345434134 usb: phy: msm: Use reset framework for LINK and PHY resets introduced a mandatory call to reset_control_get into the msm usb phy driver, which means we have to add a Kconfig dependency on the API to avoid this build error: phy/phy-msm-usb.c: In function 'msm_otg_read_dt': phy/phy-msm-usb.c:1461:2: error: implicit declaration of function 'devm_reset_control_get' [-Werror=implicit-function-declaration] motg-link_rst = devm_reset_control_get(pdev-dev, link); ^ Signed-off-by: Arnd Bergmann a...@arndb.de Cc: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/host/Kconfig | 2 +- drivers/usb/phy/Kconfig | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 3d9e540..890fc8c 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -168,7 +168,7 @@ config USB_EHCI_HCD_AT91 config USB_EHCI_MSM tristate Support for Qualcomm QSD/MSM on-chip EHCI USB controller - depends on ARCH_MSM + depends on ARCH_MSM RESET_CONTROLLER This driver did not use reset controller API. select USB_EHCI_ROOT_HUB_TT select USB_MSM_OTG ---help--- diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 359a6c1..65bec8f 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -165,6 +165,7 @@ config USB_ISP1301 config USB_MSM_OTG tristate Qualcomm on-chip USB OTG controller support depends on (USB || USB_GADGET) (ARCH_MSM || ARCH_QCOM) + depends on RESET_CONTROLLER This is fine. Thank you. Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/8] usb: phy: msm: reset controller is mandatory now
On Thu, 2014-05-08 at 16:27 +0200, Arnd Bergmann wrote: On Thursday 08 May 2014 17:21:49 Ivan T. Ivanov wrote: @@ -168,7 +168,7 @@ config USB_EHCI_HCD_AT91 config USB_EHCI_MSM tristate Support for Qualcomm QSD/MSM on-chip EHCI USB controller - depends on ARCH_MSM + depends on ARCH_MSM RESET_CONTROLLER This driver did not use reset controller API. select USB_EHCI_ROOT_HUB_TT select USB_MSM_OTG It does select USB_MSM_OTG though, which uses it: Maybe that 'select' is wrong? Driver have run time dependency to USB_PHY framework. Probably just removing select line will be fine? Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: phy: msm: cast to unsigned long int
On Wed, 2014-04-30 at 11:38 -0500, Felipe Balbi wrote: this solves the following build warning found when running compile tests. drivers/usb/phy/phy-msm-usb.c: In function ‘msm_otg_read_dt’: drivers/usb/phy/phy-msm-usb.c:1459:20: warning: cast from pointer \ to integer of different size [-Wpointer-to-int-cast] pdata-phy_type = (int) id-data; ^ Signed-off-by: Felipe Balbi ba...@ti.com --- all patches are on top of Ivan's 20 patch series. drivers/usb/phy/phy-msm-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 9dc7918..c9963c8 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1456,7 +1456,7 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) motg-pdata = pdata; id = of_match_device(msm_otg_dt_match, pdev-dev); - pdata-phy_type = (int) id-data; + pdata-phy_type = (unsigned long int) id-data; Probably cast to enum msm_usb_phy_type will be better. Regards, Ivan motg-link_rst = devm_reset_control_get(pdev-dev, link); if (IS_ERR(motg-link_rst)) -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] usb: phy: msm: switch over to writel()
On Wed, 2014-04-30 at 11:38 -0500, Felipe Balbi wrote: Remove that single instance of writel_relaxed() call which is only available on ARM architecture. This will let us build test this driver on all different architectures. Signed-off-by: Felipe Balbi ba...@ti.com Reviewed-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index c9963c8..13b59ad 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1600,7 +1600,7 @@ static int msm_otg_probe(struct platform_device *pdev) if (IS_ERR(phy_select)) return PTR_ERR(phy_select); /* Enable second PHY with the OTG port */ - writel_relaxed(0x1, phy_select); + writel(0x1, phy_select); } dev_info(pdev-dev, OTG regs = %p\n, motg-regs); -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] usb: phy: msm: enable build on other architectures
On Wed, 2014-04-30 at 11:38 -0500, Felipe Balbi wrote: By adding COMPILE_TEST to the list of dependencies we can build test this driver on all other architectures which is very valuable for maintainers applying patches and to find silly mistakes during development. Signed-off-by: Felipe Balbi ba...@ti.com Reviewed-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 0c668a3..fbbced8 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -172,7 +172,7 @@ config USB_ISP1301 config USB_MSM_OTG tristate Qualcomm on-chip USB OTG controller support - depends on (USB || USB_GADGET) (ARCH_MSM || ARCH_QCOM) + depends on (USB || USB_GADGET) (ARCH_MSM || ARCH_QCOM || COMPILE_TEST) select USB_PHY help Enable this to support the USB OTG transceiver on Qualcomm chips. It -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 16/20] usb: phy: msm: Fix PTS definitions for MSM USB controller
On Wed, 2014-04-30 at 11:27 -0500, Felipe Balbi wrote: On Thu, Apr 24, 2014 at 06:48:11PM +0300, Ivan T. Ivanov wrote: From: Tim Bird tbird...@gmail.com Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB controller. This is a standard chipidea PORTSC definition, where a PHY_TYPE of 10b (30) is ULPI and 11b (30) is SERIAL. Fix the definitions and use them correctly in the driver code. Signed-off-by: Tim Bird tim.b...@sonymobile.com since you're the one sending the patch, you must add your signed-off-by too. If you reply with your SoB I'll add to proper patches. Sure. Signed-of-by: Ivan T. Ivanov iiva...@mm-sol.com Thanks. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver
On Tue, 2014-04-29 at 08:45 +0800, Peter Chen wrote: Applied, thanks Thank you, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation
On Fri, 2014-04-25 at 15:53 -0500, Felipe Balbi wrote: On Thu, Apr 24, 2014 at 01:49:38PM -0300, Fabio Estevam wrote: On Thu, Apr 24, 2014 at 12:48 PM, Ivan T. Ivanov iiva...@mm-sol.com wrote: + motg-vddcx = devm_regulator_get(motg-phy.dev, HSUSB_VDDCX); + if (IS_ERR(motg-vddcx)) { + dev_err(motg-phy.dev, unable to get hsusb vddcx\n); + return PTR_ERR(motg-vddcx); + } + + motg-v3p3 = devm_regulator_get(motg-phy.dev, HSUSB_3p3); + if (IS_ERR(motg-v3p3)) { + dev_err(motg-phy.dev, unable to get hsusb 3p3\n); + return PTR_ERR(motg-v3p3); + } + + motg-v1p8 = devm_regulator_get(motg-phy.dev, HSUSB_1p8); + if (IS_ERR(motg-v1p8)) { + dev_err(motg-phy.dev, unable to get hsusb 1p8\n); + return PTR_ERR(motg-v1p8); + } It seems that calling devm_regulator_bulk_get() here would simplify the code here. Sure. any comments here ?? Should I expect a new version ? Will fix rest of the comments and send updated patch set. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device
On Fri, 2014-04-25 at 15:53 -0500, Felipe Balbi wrote: On Thu, Apr 24, 2014 at 09:06:24PM +0400, Sergei Shtylyov wrote: Hello. On 04/24/2014 07:48 PM, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com They could be more than one USB2.0 PHY's on the platform. s/They/There/ This will allow all of them to be registred successfuly. s/registred successfuly/registered successfully/ Ouch. will fix it. Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 03/20] usb: phy: msm: Move global regulators variables to driver state
From: Ivan T. Ivanov iiva...@mm-sol.com Eliminating global variables allows driver to handle multiple device instances. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 82 --- include/linux/usb/msm_hsusb.h | 3 ++ 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 6ae4d2f..6bae936 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -58,47 +58,43 @@ #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */ #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */ -static struct regulator *hsusb_3p3; -static struct regulator *hsusb_1p8; -static struct regulator *hsusb_vddcx; - static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) { int ret = 0; if (init) { - hsusb_vddcx = regulator_get(motg-phy.dev, HSUSB_VDDCX); - if (IS_ERR(hsusb_vddcx)) { + motg-vddcx = regulator_get(motg-phy.dev, HSUSB_VDDCX); + if (IS_ERR(motg-vddcx)) { dev_err(motg-phy.dev, unable to get hsusb vddcx\n); - return PTR_ERR(hsusb_vddcx); + return PTR_ERR(motg-vddcx); } - ret = regulator_set_voltage(hsusb_vddcx, + ret = regulator_set_voltage(motg-vddcx, USB_PHY_VDD_DIG_VOL_MIN, USB_PHY_VDD_DIG_VOL_MAX); if (ret) { dev_err(motg-phy.dev, unable to set the voltage for hsusb vddcx\n); - regulator_put(hsusb_vddcx); + regulator_put(motg-vddcx); return ret; } - ret = regulator_enable(hsusb_vddcx); + ret = regulator_enable(motg-vddcx); if (ret) { dev_err(motg-phy.dev, unable to enable hsusb vddcx\n); - regulator_put(hsusb_vddcx); + regulator_put(motg-vddcx); } } else { - ret = regulator_set_voltage(hsusb_vddcx, 0, + ret = regulator_set_voltage(motg-vddcx, 0, USB_PHY_VDD_DIG_VOL_MAX); if (ret) dev_err(motg-phy.dev, unable to set the voltage for hsusb vddcx\n); - ret = regulator_disable(hsusb_vddcx); + ret = regulator_disable(motg-vddcx); if (ret) dev_err(motg-phy.dev, unable to disable hsusb vddcx\n); - regulator_put(hsusb_vddcx); + regulator_put(motg-vddcx); } return ret; @@ -109,38 +105,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) int rc = 0; if (init) { - hsusb_3p3 = regulator_get(motg-phy.dev, HSUSB_3p3); - if (IS_ERR(hsusb_3p3)) { + motg-v3p3 = regulator_get(motg-phy.dev, HSUSB_3p3); + if (IS_ERR(motg-v3p3)) { dev_err(motg-phy.dev, unable to get hsusb 3p3\n); - return PTR_ERR(hsusb_3p3); + return PTR_ERR(motg-v3p3); } - rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN, + rc = regulator_set_voltage(motg-v3p3, USB_PHY_3P3_VOL_MIN, USB_PHY_3P3_VOL_MAX); if (rc) { dev_err(motg-phy.dev, unable to set voltage level for hsusb 3p3\n); goto put_3p3; } - rc = regulator_enable(hsusb_3p3); + rc = regulator_enable(motg-v3p3); if (rc) { dev_err(motg-phy.dev, unable to enable the hsusb 3p3\n); goto put_3p3; } - hsusb_1p8 = regulator_get(motg-phy.dev, HSUSB_1p8); - if (IS_ERR(hsusb_1p8)) { + motg-v1p8 = regulator_get(motg-phy.dev, HSUSB_1p8); + if (IS_ERR(motg-v1p8)) { dev_err(motg-phy.dev, unable to get hsusb 1p8\n); - rc = PTR_ERR(hsusb_1p8); + rc = PTR_ERR(motg-v1p8); goto disable_3p3; } - rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN, + rc = regulator_set_voltage(motg-v1p8, USB_PHY_1P8_VOL_MIN, USB_PHY_1P8_VOL_MAX); if (rc) { dev_err(motg-phy.dev, unable to set voltage level for hsusb 1p8\n); goto put_1p8; } - rc = regulator_enable
[PATCH v8 19/20] usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX
From: Ivan T. Ivanov iiva...@mm-sol.com New platform uses RBCPR hardware feature, with that voting for absolute voltage of VDD CX is not required. Hence vote for corner of VDD CX which uses nominal corner voltage on VDD CX. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Cc: Mayank Rana mr...@codeaurora.org --- .../devicetree/bindings/usb/msm-hsusb.txt | 5 drivers/usb/phy/phy-msm-usb.c | 35 +- include/linux/usb/msm_hsusb.h | 1 + 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index 0669667..2826f2a 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -65,6 +65,10 @@ Optional properties: Some platforms may have configuration to allow USB controller work with any of the two HSPHYs present. +- qcom,vdd-levels: This property must be a list of three integer values +(no, min, max) where each value represents either a voltage +in microvolts or a value corresponding to voltage corner. + Example HSUSB OTG controller device node: usb@f9a55000 { @@ -87,4 +91,5 @@ Example HSUSB OTG controller device node: qcom,otg-control = 1; qcom,phy-init-sequence = -1 0x63 ; +qcom,vdd-levels = 1 5 7; }; diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 366527e..8e7956e 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -62,6 +62,13 @@ #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */ #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */ +#define USB_PHY_SUSP_DIG_VOL 50 /* uV */ + +enum vdd_levels { + VDD_LEVEL_NONE = 0, + VDD_LEVEL_MIN, + VDD_LEVEL_MAX, +}; static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) { @@ -69,8 +76,8 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) if (init) { ret = regulator_set_voltage(motg-vddcx, - USB_PHY_VDD_DIG_VOL_MIN, - USB_PHY_VDD_DIG_VOL_MAX); + motg-vdd_levels[VDD_LEVEL_MIN], + motg-vdd_levels[VDD_LEVEL_MAX]); if (ret) { dev_err(motg-phy.dev, Cannot set vddcx voltage\n); return ret; @@ -81,7 +88,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) dev_err(motg-phy.dev, unable to enable hsusb vddcx\n); } else { ret = regulator_set_voltage(motg-vddcx, 0, - USB_PHY_VDD_DIG_VOL_MAX); + motg-vdd_levels[VDD_LEVEL_MAX]); if (ret) dev_err(motg-phy.dev, Cannot set vddcx voltage\n); ret = regulator_disable(motg-vddcx); @@ -435,17 +442,16 @@ static int msm_phy_init(struct usb_phy *phy) #ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 50 static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high) { - int max_vol = USB_PHY_VDD_DIG_VOL_MAX; + int max_vol = motg-vdd_levels[VDD_LEVEL_MAX]; int min_vol; int ret; if (high) - min_vol = USB_PHY_VDD_DIG_VOL_MIN; + min_vol = motg-vdd_levels[VDD_LEVEL_MIN]; else - min_vol = USB_PHY_SUSP_DIG_VOL; + min_vol = motg-vdd_levels[VDD_LEVEL_NONE]; ret = regulator_set_voltage(motg-vddcx, min_vol, max_vol); if (ret) { @@ -1441,7 +1447,7 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) struct device_node *node = pdev-dev.of_node; struct property *prop; int len, ret, words; - u32 val; + u32 val, tmp[3]; pdata = devm_kzalloc(pdev-dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) @@ -1472,6 +1478,19 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) if (!of_property_read_u32(node, qcom,phy-num, val) val 2) motg-phy_number = val; + motg-vdd_levels[VDD_LEVEL_NONE] = USB_PHY_SUSP_DIG_VOL; + motg-vdd_levels[VDD_LEVEL_MIN] = USB_PHY_VDD_DIG_VOL_MIN; + motg-vdd_levels[VDD_LEVEL_MAX] = USB_PHY_VDD_DIG_VOL_MAX; + + if (of_get_property(node, qcom,vdd-levels, len) + len == sizeof(tmp)) { + of_property_read_u32_array(node, qcom,vdd-levels, + tmp, len / sizeof(*tmp)); + motg-vdd_levels[VDD_LEVEL_NONE] = tmp[VDD_LEVEL_NONE]; + motg-vdd_levels[VDD_LEVEL_MIN] = tmp[VDD_LEVEL_MIN]; + motg-vdd_levels[VDD_LEVEL_MAX] = tmp[VDD_LEVEL_MAX]; + } + prop = of_find_property(node, qcom,phy-init-sequence
[PATCH v8 17/20] usb: phy: msm: Select secondary PHY via TCSR
From: Tim Bird tbird...@gmail.com Select the secondary PHY using the TCSR register, if phy-num=1 in the DTS (or phy_number is set in the platform data). The SOC has 2 PHYs which can be used with the OTG port, and this code allows configuring the correct one. Note: This resolves the problem I was seeing where I couldn't get the USB driver working at all on a dragonboard, from cold boot. This patch depends on patch 5/14 from Ivan's msm USB patch set. It does not use DT for the register address, as there's no evidence that this address changes between SoC versions. Signed-off-by: Tim Bird tim.b...@sonymobile.com --- drivers/usb/phy/phy-msm-usb.c| 14 ++ include/linux/usb/msm_hsusb_hw.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index db8d963..9437bcf 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1489,6 +1489,7 @@ static int msm_otg_probe(struct platform_device *pdev) struct resource *res; struct msm_otg *motg; struct usb_phy *phy; + void __iomem *phy_select; motg = devm_kzalloc(pdev-dev, sizeof(struct msm_otg), GFP_KERNEL); if (!motg) { @@ -1553,6 +1554,19 @@ static int msm_otg_probe(struct platform_device *pdev) if (IS_ERR(motg-regs)) return PTR_ERR(motg-regs); + /* +* NOTE: The PHYs can be multiplexed between the chipidea controller +* and the dwc3 controller, using a single bit. It is important that +* the dwc3 driver does not set this bit in an incompatible way. +*/ + if (motg-phy_number) { + phy_select = devm_ioremap_nocache(pdev-dev, USB2_PHY_SEL, 4); + if (IS_ERR(phy_select)) + return PTR_ERR(phy_select); + /* Enable second PHY with the OTG port */ + writel_relaxed(0x1, phy_select); + } + dev_info(pdev-dev, OTG regs = %p\n, motg-regs); motg-irq = platform_get_irq(pdev, 0); diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index 98d3dd8..a29f603 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b/include/linux/usb/msm_hsusb_hw.h @@ -16,6 +16,9 @@ #ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__ #define __LINUX_USB_GADGET_MSM72K_UDC_H__ +/* USB phy selector - in TCSR address range */ +#define USB2_PHY_SEL 0xfd4ab000 + #define USB_AHBBURST (MSM_USB_BASE + 0x0090) #define USB_AHBMODE (MSM_USB_BASE + 0x0098) #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */ -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 14/20] usb: phy: msm: Add support for secondary PHY control
From: Ivan T. Ivanov iiva...@mm-sol.com Allow support to use 2nd HSPHY with USB2 Core. Some platforms may have configuration to allow USB controller work with any of the two HSPHYs present. By default driver configures USB core to use primary HSPHY. Add support to allow user select 2nd HSPHY using DT parameter. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Cc: Manu Gautam mgau...@codeaurora.org --- .../devicetree/bindings/usb/msm-hsusb.txt | 6 ++ drivers/usb/phy/phy-msm-usb.c | 24 -- include/linux/usb/msm_hsusb.h | 1 + include/linux/usb/msm_hsusb_hw.h | 1 + 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index ee4123d..0669667 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -59,6 +59,12 @@ Optional properties: For example: qcom,phy-init-sequence = -1 0x63 ; Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1. +- qcom,phy-num: Select number of pyco-phy to use, can be one of +0 - PHY one, default +1 - Second PHY +Some platforms may have configuration to allow USB +controller work with any of the two HSPHYs present. + Example HSUSB OTG controller device node: usb@f9a55000 { diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index a6abb1b..8d57045 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -314,6 +314,9 @@ static int msm_otg_phy_reset(struct msm_otg *motg) if (!retries) return -ETIMEDOUT; + if (motg-phy_number) + writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + dev_info(motg-phy.dev, phy_reset: success\n); return 0; } @@ -368,6 +371,9 @@ static int msm_otg_reset(struct usb_phy *phy) ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL); } + if (motg-phy_number) + writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + return 0; } @@ -404,6 +410,7 @@ static int msm_otg_suspend(struct msm_otg *motg) struct usb_phy *phy = motg-phy; struct usb_bus *bus = phy-otg-host; struct msm_otg_platform_data *pdata = motg-pdata; + void __iomem *addr; int cnt = 0; if (atomic_read(motg-in_lpm)) @@ -463,9 +470,13 @@ static int msm_otg_suspend(struct msm_otg *motg) */ writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD); + addr = USB_PHY_CTRL; + if (motg-phy_number) + addr = USB_PHY_CTRL2; + if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY motg-pdata-otg_control == OTG_PMIC_CONTROL) - writel(readl(USB_PHY_CTRL) | PHY_RETEN, USB_PHY_CTRL); + writel(readl(addr) | PHY_RETEN, addr); clk_disable_unprepare(motg-pclk); clk_disable_unprepare(motg-clk); @@ -495,6 +506,7 @@ static int msm_otg_resume(struct msm_otg *motg) { struct usb_phy *phy = motg-phy; struct usb_bus *bus = phy-otg-host; + void __iomem *addr; int cnt = 0; unsigned temp; @@ -508,9 +520,14 @@ static int msm_otg_resume(struct msm_otg *motg) if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY motg-pdata-otg_control == OTG_PMIC_CONTROL) { + + addr = USB_PHY_CTRL; + if (motg-phy_number) + addr = USB_PHY_CTRL2; + msm_hsusb_ldo_set_mode(motg, 1); msm_hsusb_config_vddcx(motg, 1); - writel(readl(USB_PHY_CTRL) ~PHY_RETEN, USB_PHY_CTRL); + writel(readl(addr) ~PHY_RETEN, addr); } temp = readl(USB_USBCMD); @@ -1399,6 +1416,9 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) if (val == OTG_PMIC_CONTROL) pdata-otg_control = val; + if (!of_property_read_u32(node, qcom,phy-num, val) val 2) + motg-phy_number = val; + prop = of_find_property(node, qcom,phy-init-sequence, len); if (!prop || !len) return 0; diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 4e5d916..4628f1a 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h @@ -158,6 +158,7 @@ struct msm_otg { atomic_t in_lpm; int async_int; unsigned cur_power; + int phy_number; struct delayed_work chg_work; enum usb_chg_state chg_state; enum usb_chg_type chg_type; diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index 6e97a2d..e6d7035 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b
[PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method
From: Ivan T. Ivanov iiva...@mm-sol.com This fixes following: WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in reference from the variable msm_otg_driver to the function .init.text:msm_otg_probe() The variable msm_otg_driver references the function __init msm_otg_probe() Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 5b37b81..6ae4d2f 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1406,7 +1406,7 @@ static void msm_otg_debugfs_cleanup(void) debugfs_remove(msm_otg_dbg_root); } -static int __init msm_otg_probe(struct platform_device *pdev) +static int msm_otg_probe(struct platform_device *pdev) { int ret = 0; struct resource *res; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device
From: Ivan T. Ivanov iiva...@mm-sol.com There could be more than one USB2.0 PHY's on the platform. This will allow all of them to be registered successfully. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 8e7956e..9dc7918 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1663,6 +1663,7 @@ static int msm_otg_probe(struct platform_device *pdev) phy-init = msm_phy_init; phy-set_power = msm_otg_set_power; phy-notify_disconnect = msm_phy_notify_disconnect; + phy-type = USB_PHY_TYPE_USB2; phy-io_ops = msm_otg_io_ops; @@ -1672,7 +1673,7 @@ static int msm_otg_probe(struct platform_device *pdev) msm_usb_reset(phy); - ret = usb_add_phy(motg-phy, USB_PHY_TYPE_USB2); + ret = usb_add_phy_dev(motg-phy); if (ret) { dev_err(pdev-dev, usb_add_phy failed\n); goto disable_ldo; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 18/20] usb: phy: msm: Handle disconnect events
From: Ivan T. Ivanov iiva...@mm-sol.com Put the transceiver in non-driving mode. Otherwise host may not detect soft-disconnection. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Cc: Pavankumar Kondeti pkond...@codeaurora.org --- drivers/usb/phy/phy-msm-usb.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 9437bcf..366527e 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -235,6 +235,23 @@ static void ulpi_init(struct msm_otg *motg) } } +static int msm_phy_notify_disconnect(struct usb_phy *phy, + enum usb_device_speed speed) +{ + int val; + + /* +* Put the transceiver in non-driving mode. Otherwise host +* may not detect soft-disconnection. +*/ + val = ulpi_read(phy, ULPI_FUNC_CTRL); + val = ~ULPI_FUNC_CTRL_OPMODE_MASK; + val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; + ulpi_write(phy, val, ULPI_FUNC_CTRL); + + return 0; +} + static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) { int ret; @@ -1626,6 +1643,7 @@ static int msm_otg_probe(struct platform_device *pdev) phy-init = msm_phy_init; phy-set_power = msm_otg_set_power; + phy-notify_disconnect = msm_phy_notify_disconnect; phy-io_ops = msm_otg_io_ops; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 16/20] usb: phy: msm: Fix PTS definitions for MSM USB controller
From: Tim Bird tbird...@gmail.com Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB controller. This is a standard chipidea PORTSC definition, where a PHY_TYPE of 10b (30) is ULPI and 11b (30) is SERIAL. Fix the definitions and use them correctly in the driver code. Signed-off-by: Tim Bird tim.b...@sonymobile.com --- drivers/usb/phy/phy-msm-usb.c| 8 +--- include/linux/usb/msm_hsusb_hw.h | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index bb33996..db8d963 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -287,8 +287,9 @@ static int msm_link_reset(struct msm_otg *motg) if (motg-phy_number) writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + /* put transceiver in serial mode as part of reset */ val = readl(USB_PORTSC) ~PORTSC_PTS_MASK; - writel(val | PORTSC_PTS_ULPI, USB_PORTSC); + writel(val | PORTSC_PTS_SERIAL, USB_PORTSC); return 0; } @@ -308,8 +309,9 @@ static int msm_otg_reset(struct usb_phy *phy) if (cnt = LINK_RESET_TIMEOUT_USEC) return -ETIMEDOUT; - /* select ULPI phy */ - writel(0x8000, USB_PORTSC); + /* select ULPI phy and clear other status/control bits in PORTSC */ + writel(PORTSC_PTS_ULPI, USB_PORTSC); + writel(0x0, USB_AHBBURST); writel(0x08, USB_AHBMODE); diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index 575c743..98d3dd8 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b/include/linux/usb/msm_hsusb_hw.h @@ -31,8 +31,9 @@ #define USB_USBINTR (MSM_USB_BASE + 0x0148) #define PORTSC_PHCD(1 23) /* phy suspend mode */ -#define PORTSC_PTS_MASK (3 30) -#define PORTSC_PTS_ULPI (3 30) +#define PORTSC_PTS_MASK(3 30) +#define PORTSC_PTS_ULPI(2 30) +#define PORTSC_PTS_SERIAL (3 30) #define USB_ULPI_VIEWPORT(MSM_USB_BASE + 0x0170) #define ULPI_RUN (1 30) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 09/20] usb: phy: msm: Remove unused pclk_src_name
From: Ivan T. Ivanov iiva...@mm-sol.com There are no references to 'pclk_src_name' in plaform code, so it is unused. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 26 +- include/linux/usb/msm_hsusb.h | 5 - 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 7eb2abf..c2361bf 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -464,9 +464,6 @@ static int msm_otg_suspend(struct msm_otg *motg) if (!IS_ERR(motg-core_clk)) clk_disable_unprepare(motg-core_clk); - if (!IS_ERR(motg-pclk_src)) - clk_disable_unprepare(motg-pclk_src); - if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY motg-pdata-otg_control == OTG_PMIC_CONTROL) { msm_hsusb_ldo_set_mode(motg, 0); @@ -496,9 +493,6 @@ static int msm_otg_resume(struct msm_otg *motg) if (!atomic_read(motg-in_lpm)) return 0; - if (!IS_ERR(motg-pclk_src)) - clk_prepare_enable(motg-pclk_src); - clk_prepare_enable(motg-pclk); clk_prepare_enable(motg-clk); if (!IS_ERR(motg-core_clk)) @@ -1396,17 +1390,8 @@ static int msm_otg_probe(struct platform_device *pdev) * If USB Core is running its protocol engine based on CORE CLK, * CORE CLK must be running at 55Mhz for correct HSUSB * operation and USB core cannot tolerate frequency changes on -* CORE CLK. For such USB cores, vote for maximum clk frequency -* on pclk source +* CORE CLK. */ -motg-pclk_src = ERR_PTR(-ENOENT); -if (motg-pdata-pclk_src_name) { - motg-pclk_src = devm_clk_get(pdev-dev, - motg-pdata-pclk_src_name); - if (IS_ERR(motg-pclk_src)) - return PTR_ERR(motg-pclk_src); - } - motg-pclk = devm_clk_get(pdev-dev, usb_hs_pclk); if (IS_ERR(motg-pclk)) { dev_err(pdev-dev, failed to get usb_hs_pclk\n); @@ -1446,10 +1431,6 @@ static int msm_otg_probe(struct platform_device *pdev) motg-v1p8 = regs[2].consumer; clk_set_rate(motg-clk, 6000); - if (!IS_ERR(motg-pclk_src)) { - clk_set_rate(motg-pclk_src, INT_MAX); - clk_prepare_enable(motg-pclk_src); - } clk_prepare_enable(motg-clk); clk_prepare_enable(motg-pclk); @@ -1525,8 +1506,6 @@ disable_clks: clk_disable_unprepare(motg-clk); if (!IS_ERR(motg-core_clk)) clk_disable_unprepare(motg-core_clk); - if (!IS_ERR(motg-pclk_src)) - clk_disable_unprepare(motg-pclk_src); return ret; } @@ -1571,9 +1550,6 @@ static int msm_otg_remove(struct platform_device *pdev) clk_disable_unprepare(motg-clk); if (!IS_ERR(motg-core_clk)) clk_disable_unprepare(motg-core_clk); - if (!IS_ERR(motg-pclk_src)) - clk_disable_unprepare(motg-pclk_src); - msm_hsusb_ldo_init(motg, 0); pm_runtime_set_suspended(pdev-dev); diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 72c5830..262ed80 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h @@ -106,8 +106,6 @@ enum usb_chg_type { * @power_budget: VBUS power budget in mA (0 will be treated as 500mA). * @mode: Supported mode (OTG/peripheral/host). * @otg_control: OTG switch controlled by user/Id pin - * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k - * dfab_usb_hs_clk in case of 8660 and 8960. */ struct msm_otg_platform_data { int *phy_init_seq; @@ -117,7 +115,6 @@ struct msm_otg_platform_data { enum otg_control_type otg_control; enum msm_usb_phy_type phy_type; void (*setup_gpio)(enum usb_otg_state state); - char *pclk_src_name; int (*link_clk_reset)(struct clk *link_clk, bool assert); int (*phy_clk_reset)(struct clk *phy_clk); }; @@ -129,7 +126,6 @@ struct msm_otg_platform_data { * @irq: IRQ number assigned for HSUSB controller. * @clk: clock struct of usb_hs_clk. * @pclk: clock struct of usb_hs_pclk. - * @pclk_src: pclk source for voting. * @phy_reset_clk: clock struct of usb_phy_clk. * @core_clk: clock struct of usb_hs_core_clk. * @regs: ioremapped register base address. @@ -150,7 +146,6 @@ struct msm_otg { int irq; struct clk *clk; struct clk *pclk; - struct clk *pclk_src; struct clk *phy_reset_clk; struct clk *core_clk; void __iomem *regs; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 07/20] usb: phy: msm: Fix checkpatch.pl warnings
From: Ivan T. Ivanov iiva...@mm-sol.com This fixes following: WARNING: quoted string split across lines WARNING: Prefer seq_puts to seq_printf Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 39 ++- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index d7b8360..874c51a 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -67,8 +67,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) USB_PHY_VDD_DIG_VOL_MIN, USB_PHY_VDD_DIG_VOL_MAX); if (ret) { - dev_err(motg-phy.dev, unable to set the voltage - for hsusb vddcx\n); + dev_err(motg-phy.dev, Cannot set vddcx voltage\n); return ret; } @@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) ret = regulator_set_voltage(motg-vddcx, 0, USB_PHY_VDD_DIG_VOL_MAX); if (ret) - dev_err(motg-phy.dev, unable to set the voltage - for hsusb vddcx\n); + dev_err(motg-phy.dev, Cannot set vddcx voltage\n); ret = regulator_disable(motg-vddcx); if (ret) dev_err(motg-phy.dev, unable to disable hsusb vddcx\n); @@ -97,8 +95,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) rc = regulator_set_voltage(motg-v3p3, USB_PHY_3P3_VOL_MIN, USB_PHY_3P3_VOL_MAX); if (rc) { - dev_err(motg-phy.dev, unable to set voltage level - for hsusb 3p3\n); + dev_err(motg-phy.dev, Cannot set v3p3 voltage\n); goto exit; } rc = regulator_enable(motg-v3p3); @@ -109,8 +106,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) rc = regulator_set_voltage(motg-v1p8, USB_PHY_1P8_VOL_MIN, USB_PHY_1P8_VOL_MAX); if (rc) { - dev_err(motg-phy.dev, unable to set voltage level - for hsusb 1p8\n); + dev_err(motg-phy.dev, Cannot set v1p8 voltage\n); goto disable_3p3; } rc = regulator_enable(motg-v1p8); @@ -137,15 +133,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) ret = regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_HPM_LOAD); if (ret 0) { - pr_err(%s: Unable to set HPM of the regulator - HSUSB_1p8\n, __func__); + pr_err(Could not set HPM for v1p8\n); return ret; } ret = regulator_set_optimum_mode(motg-v3p3, USB_PHY_3P3_HPM_LOAD); if (ret 0) { - pr_err(%s: Unable to set HPM of the regulator - HSUSB_3p3\n, __func__); + pr_err(Could not set HPM for v3p3\n); regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_LPM_LOAD); return ret; @@ -154,13 +148,11 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) ret = regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_LPM_LOAD); if (ret 0) - pr_err(%s: Unable to set LPM of the regulator - HSUSB_1p8\n, __func__); + pr_err(Could not set LPM for v1p8\n); ret = regulator_set_optimum_mode(motg-v3p3, USB_PHY_3P3_LPM_LOAD); if (ret 0) - pr_err(%s: Unable to set LPM of the regulator - HSUSB_3p3\n, __func__); + pr_err(Could not set LPM for v3p3\n); } pr_debug(reg (%s)\n, on ? HPM : LPM); @@ -390,8 +382,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high) ret = regulator_set_voltage(motg-vddcx, min_vol, max_vol); if (ret) { - pr_err(%s: unable to set the voltage for regulator - HSUSB_VDDCX\n, __func__); + pr_err(Cannot set vddcx voltage\n); return ret; } @@ -546,8 +537,7 @@ static int msm_otg_resume(struct msm_otg *motg) * PHY. USB state can not be restored. Re-insertion * of USB cable
[PATCH v8 15/20] usb: phy: msm: Correct USB PHY Reset sequence for newer platform
From: Ivan T. Ivanov iiva...@mm-sol.com On few legacy platforms, USB PHY is having dedicated reset clk. It is used to reset USB PHY after putting USB PHY into low power mode and for calibration of USB PHY. Putting USB PHY into low power mode is causing ulpi read/write timeout as expected. USB PHY reset clk is not available on newer platform. For 28nm PHY, reset USB PHY after resetting USB LINK. Also reset USB PHY using USB_PHY_PON bit with USB_OTG_HS_PHY_CTRL register after programming USB PHY Override registers as suggested with hardware programming guidelines. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Signed-off-by: Tim Bird tim.b...@sonymobile.com Cc: Mayank Rana mr...@codeaurora.org --- drivers/usb/phy/phy-msm-usb.c| 140 --- include/linux/usb/msm_hsusb_hw.h | 5 ++ 2 files changed, 93 insertions(+), 52 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 8d57045..bb33996 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -48,6 +48,7 @@ #define DRIVER_NAMEmsm_otg #define ULPI_IO_TIMEOUT_USEC (10 * 1000) +#define LINK_RESET_TIMEOUT_USEC(250 * 1000) #define USB_PHY_3P3_VOL_MIN305 /* uV */ #define USB_PHY_3P3_VOL_MAX330 /* uV */ @@ -267,77 +268,35 @@ static int msm_otg_phy_clk_reset(struct msm_otg *motg) return ret; } -static int msm_otg_phy_reset(struct msm_otg *motg) +static int msm_link_reset(struct msm_otg *motg) { u32 val; int ret; - int retries; ret = msm_otg_link_clk_reset(motg, 1); if (ret) return ret; - ret = msm_otg_phy_clk_reset(motg); - if (ret) - return ret; - ret = msm_otg_link_clk_reset(motg, 0); - if (ret) - return ret; - val = readl(USB_PORTSC) ~PORTSC_PTS_MASK; - writel(val | PORTSC_PTS_ULPI, USB_PORTSC); - - for (retries = 3; retries 0; retries--) { - ret = ulpi_write(motg-phy, ULPI_FUNC_CTRL_SUSPENDM, - ULPI_CLR(ULPI_FUNC_CTRL)); - if (!ret) - break; - ret = msm_otg_phy_clk_reset(motg); - if (ret) - return ret; - } - if (!retries) - return -ETIMEDOUT; + /* wait for 1ms delay as suggested in HPG. */ + usleep_range(1000, 1200); - /* This reset calibrates the phy, if the above write succeeded */ - ret = msm_otg_phy_clk_reset(motg); + ret = msm_otg_link_clk_reset(motg, 0); if (ret) return ret; - for (retries = 3; retries 0; retries--) { - ret = ulpi_read(motg-phy, ULPI_DEBUG); - if (ret != -ETIMEDOUT) - break; - ret = msm_otg_phy_clk_reset(motg); - if (ret) - return ret; - } - if (!retries) - return -ETIMEDOUT; - if (motg-phy_number) writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); - dev_info(motg-phy.dev, phy_reset: success\n); + val = readl(USB_PORTSC) ~PORTSC_PTS_MASK; + writel(val | PORTSC_PTS_ULPI, USB_PORTSC); + return 0; } -#define LINK_RESET_TIMEOUT_USEC(250 * 1000) static int msm_otg_reset(struct usb_phy *phy) { struct msm_otg *motg = container_of(phy, struct msm_otg, phy); - struct msm_otg_platform_data *pdata = motg-pdata; int cnt = 0; - int ret; - u32 val = 0; - u32 ulpi_val = 0; - - ret = msm_otg_phy_reset(motg); - if (ret) { - dev_err(phy-dev, phy_reset failed\n); - return ret; - } - - ulpi_init(motg); writel(USBCMD_RESET, USB_USBCMD); while (cnt LINK_RESET_TIMEOUT_USEC) { @@ -351,11 +310,86 @@ static int msm_otg_reset(struct usb_phy *phy) /* select ULPI phy */ writel(0x8000, USB_PORTSC); + writel(0x0, USB_AHBBURST); + writel(0x08, USB_AHBMODE); + + if (motg-phy_number) + writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + return 0; +} + +static void msm_phy_reset(struct msm_otg *motg) +{ + void __iomem *addr; + + if (motg-pdata-phy_type != SNPS_28NM_INTEGRATED_PHY) { + msm_otg_phy_clk_reset(motg); + return; + } + + addr = USB_PHY_CTRL; + if (motg-phy_number) + addr = USB_PHY_CTRL2; + + /* Assert USB PHY_POR */ + writel(readl(addr) | PHY_POR_ASSERT, addr); + + /* +* wait for minimum 10 microseconds as suggested in HPG. +* Use a slightly larger value since the exact value didn't +* work 100% of the time. +*/ + udelay(12); + + /* Deassert USB PHY_POR */ + writel(readl(addr) ~PHY_POR_ASSERT, addr); +} + +static int msm_usb_reset(struct usb_phy *phy
[PATCH v8 11/20] usb: phy: msm: Properly check result from platform_get_irq()
From: Ivan T. Ivanov iiva...@mm-sol.com Function return negative code on error. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index bd9e286..7e968aa 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1413,7 +1413,7 @@ static int msm_otg_probe(struct platform_device *pdev) dev_info(pdev-dev, OTG regs = %p\n, motg-regs); motg-irq = platform_get_irq(pdev, 0); - if (!motg-irq) { + if (motg-irq 0) { dev_err(pdev-dev, platform_get_irq failed\n); return motg-irq; } -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation
From: Ivan T. Ivanov iiva...@mm-sol.com Move memory, regulators, clocks and irq allocation to devm_* variants. Properly check for valid clk handles. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 187 +++--- 1 file changed, 68 insertions(+), 119 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index b7d73f2..67705fc 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) int ret = 0; if (init) { - motg-vddcx = regulator_get(motg-phy.dev, HSUSB_VDDCX); - if (IS_ERR(motg-vddcx)) { - dev_err(motg-phy.dev, unable to get hsusb vddcx\n); - return PTR_ERR(motg-vddcx); - } - ret = regulator_set_voltage(motg-vddcx, USB_PHY_VDD_DIG_VOL_MIN, USB_PHY_VDD_DIG_VOL_MAX); if (ret) { dev_err(motg-phy.dev, unable to set the voltage for hsusb vddcx\n); - regulator_put(motg-vddcx); return ret; } ret = regulator_enable(motg-vddcx); - if (ret) { + if (ret) dev_err(motg-phy.dev, unable to enable hsusb vddcx\n); - regulator_put(motg-vddcx); - } } else { ret = regulator_set_voltage(motg-vddcx, 0, USB_PHY_VDD_DIG_VOL_MAX); @@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) ret = regulator_disable(motg-vddcx); if (ret) dev_err(motg-phy.dev, unable to disable hsusb vddcx\n); - - regulator_put(motg-vddcx); } return ret; @@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) int rc = 0; if (init) { - motg-v3p3 = regulator_get(motg-phy.dev, HSUSB_3p3); - if (IS_ERR(motg-v3p3)) { - dev_err(motg-phy.dev, unable to get hsusb 3p3\n); - return PTR_ERR(motg-v3p3); - } - rc = regulator_set_voltage(motg-v3p3, USB_PHY_3P3_VOL_MIN, USB_PHY_3P3_VOL_MAX); if (rc) { dev_err(motg-phy.dev, unable to set voltage level for hsusb 3p3\n); - goto put_3p3; + goto exit; } rc = regulator_enable(motg-v3p3); if (rc) { dev_err(motg-phy.dev, unable to enable the hsusb 3p3\n); - goto put_3p3; - } - motg-v1p8 = regulator_get(motg-phy.dev, HSUSB_1p8); - if (IS_ERR(motg-v1p8)) { - dev_err(motg-phy.dev, unable to get hsusb 1p8\n); - rc = PTR_ERR(motg-v1p8); - goto disable_3p3; + goto exit; } rc = regulator_set_voltage(motg-v1p8, USB_PHY_1P8_VOL_MIN, USB_PHY_1P8_VOL_MAX); if (rc) { dev_err(motg-phy.dev, unable to set voltage level for hsusb 1p8\n); - goto put_1p8; + goto disable_3p3; } rc = regulator_enable(motg-v1p8); if (rc) { dev_err(motg-phy.dev, unable to enable the hsusb 1p8\n); - goto put_1p8; + goto disable_3p3; } return 0; } regulator_disable(motg-v1p8); -put_1p8: - regulator_put(motg-v1p8); disable_3p3: regulator_disable(motg-v3p3); -put_3p3: - regulator_put(motg-v3p3); +exit: return rc; } @@ -506,7 +480,7 @@ static int msm_otg_suspend(struct msm_otg *motg) clk_disable_unprepare(motg-pclk); clk_disable_unprepare(motg-clk); - if (motg-core_clk) + if (!IS_ERR(motg-core_clk)) clk_disable_unprepare(motg-core_clk); if (!IS_ERR(motg-pclk_src)) @@ -546,7 +520,7 @@ static int msm_otg_resume(struct msm_otg *motg) clk_prepare_enable(motg-pclk); clk_prepare_enable(motg-clk); - if (motg-core_clk) + if (!IS_ERR(motg-core_clk)) clk_prepare_enable(motg-core_clk); if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY @@ -1404,6 +1378,7 @@ static void msm_otg_debugfs_cleanup(void) static int msm_otg_probe(struct platform_device *pdev) { + struct
[PATCH v8 06/20] usb: phy: msm: Remove unnecessarily check for valid regulators.
From: Ivan T. Ivanov iiva...@mm-sol.com Whether regulators are available or not is checked at driver probe. If they are not available driver will refuse to load, so no need to check them again. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 67705fc..d7b8360 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -133,16 +133,6 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) { int ret = 0; - if (!motg-v1p8 || IS_ERR(motg-v1p8)) { - pr_err(%s: HSUSB_1p8 is not initialized\n, __func__); - return -ENODEV; - } - - if (!motg-v3p3 || IS_ERR(motg-v3p3)) { - pr_err(%s: HSUSB_3p3 is not initialized\n, __func__); - return -ENODEV; - } - if (on) { ret = regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_HPM_LOAD); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 04/20] usb: phy: msm: Enable deferred driver probing
From: Ivan T. Ivanov iiva...@mm-sol.com Using platform_driver_probe() prevent driver from requesting probe deferral. Fix this. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 6bae936..b7d73f2 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1736,6 +1736,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = { }; static struct platform_driver msm_otg_driver = { + .probe = msm_otg_probe, .remove = msm_otg_remove, .driver = { .name = DRIVER_NAME, @@ -1744,7 +1745,7 @@ static struct platform_driver msm_otg_driver = { }, }; -module_platform_driver_probe(msm_otg_driver, msm_otg_probe); +module_platform_driver(msm_otg_driver); MODULE_LICENSE(GPL v2); MODULE_DESCRIPTION(MSM USB transceiver driver); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 08/20] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode
From: Ivan T. Ivanov iiva...@mm-sol.com Use enum usb_dr_mode and drop default usb_dr_mode from platform data. USB DT bindings states: dr_mode: ...In case this attribute isn't passed via DT, USB DRD controllers should default to OTG..., so remove redundand field. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Acked-by: David Brown dav...@codeaurora.org --- arch/arm/mach-msm/board-msm7x30.c | 2 +- arch/arm/mach-msm/board-qsd8x50.c | 2 +- drivers/usb/phy/phy-msm-usb.c | 41 --- include/linux/usb/msm_hsusb.h | 20 +-- 4 files changed, 20 insertions(+), 45 deletions(-) diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c index 46de789..0c4c200 100644 --- a/arch/arm/mach-msm/board-msm7x30.c +++ b/arch/arm/mach-msm/board-msm7x30.c @@ -95,7 +95,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk) static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, - .mode = USB_PERIPHERAL, + .mode = USB_DR_MODE_PERIPHERAL, .otg_control= OTG_PHY_CONTROL, .link_clk_reset = hsusb_link_clk_reset, .phy_clk_reset = hsusb_phy_clk_reset, diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c index 9169ec3..4c74861 100644 --- a/arch/arm/mach-msm/board-qsd8x50.c +++ b/arch/arm/mach-msm/board-qsd8x50.c @@ -116,7 +116,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk) static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, - .mode = USB_PERIPHERAL, + .mode = USB_DR_MODE_PERIPHERAL, .otg_control= OTG_PHY_CONTROL, .link_clk_reset = hsusb_link_clk_reset, .phy_clk_reset = hsusb_phy_clk_reset, diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 874c51a..7eb2abf 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -348,10 +348,10 @@ static int msm_otg_reset(struct usb_phy *phy) if (pdata-otg_control == OTG_PHY_CONTROL) { val = readl(USB_OTGSC); - if (pdata-mode == USB_OTG) { + if (pdata-mode == USB_DR_MODE_OTG) { ulpi_val = ULPI_INT_IDGRD | ULPI_INT_SESS_VALID; val |= OTGSC_IDIE | OTGSC_BSVIE; - } else if (pdata-mode == USB_PERIPHERAL) { + } else if (pdata-mode == USB_DR_MODE_PERIPHERAL) { ulpi_val = ULPI_INT_SESS_VALID; val |= OTGSC_BSVIE; } @@ -637,7 +637,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) * Fail host registration if this board can support * only peripheral configuration. */ - if (motg-pdata-mode == USB_PERIPHERAL) { + if (motg-pdata-mode == USB_DR_MODE_PERIPHERAL) { dev_info(otg-phy-dev, Host mode is not supported\n); return -ENODEV; } @@ -666,7 +666,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) * Kick the state machine work, if peripheral is not supported * or peripheral is already registered with us. */ - if (motg-pdata-mode == USB_HOST || otg-gadget) { + if (motg-pdata-mode == USB_DR_MODE_HOST || otg-gadget) { pm_runtime_get_sync(otg-phy-dev); schedule_work(motg-sm_work); } @@ -710,7 +710,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg, * Fail peripheral registration if this board can support * only host configuration. */ - if (motg-pdata-mode == USB_HOST) { + if (motg-pdata-mode == USB_DR_MODE_HOST) { dev_info(otg-phy-dev, Peripheral mode is not supported\n); return -ENODEV; } @@ -735,7 +735,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg, * Kick the state machine work, if host is not supported * or host is already registered with us. */ - if (motg-pdata-mode == USB_PERIPHERAL || otg-host) { + if (motg-pdata-mode == USB_DR_MODE_PERIPHERAL || otg-host) { pm_runtime_get_sync(otg-phy-dev); schedule_work(motg-sm_work); } @@ -1056,7 +1056,7 @@ static void msm_otg_init_sm(struct msm_otg *motg) u32 otgsc = readl(USB_OTGSC); switch (pdata-mode) { - case USB_OTG: + case USB_DR_MODE_OTG: if (pdata-otg_control == OTG_PHY_CONTROL) { if (otgsc OTGSC_ID) set_bit(ID, motg-inputs); @@ -1068,21 +1068,14 @@ static void msm_otg_init_sm(struct msm_otg *motg) else clear_bit(B_SESS_VLD, motg-inputs
[PATCH v8 01/20] usb: phy: msm: Make driver selectable on ARCH_QCOM
From: Ivan T. Ivanov iiva...@mm-sol.com Controller could be found on APQ and MSM platforms, make configuration description more generic. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 416e0c8..0c668a3 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -171,11 +171,11 @@ config USB_ISP1301 module will be called phy-isp1301. config USB_MSM_OTG - tristate OTG support for Qualcomm on-chip USB controller - depends on (USB || USB_GADGET) ARCH_MSM + tristate Qualcomm on-chip USB OTG controller support + depends on (USB || USB_GADGET) (ARCH_MSM || ARCH_QCOM) select USB_PHY help - Enable this to support the USB OTG transceiver on MSM chips. It + Enable this to support the USB OTG transceiver on Qualcomm chips. It handles PHY initialization, clock management, and workarounds required after resetting the hardware and power management. This driver is required even for peripheral only or host only -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 12/20] usb: phy: msm: Add device tree support and binding information
From: Ivan T. Ivanov iiva...@mm-sol.com Allows controller to be specified via device tree. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- .../devicetree/bindings/usb/msm-hsusb.txt | 67 drivers/usb/phy/phy-msm-usb.c | 113 + include/linux/usb/msm_hsusb.h | 6 +- 3 files changed, 165 insertions(+), 21 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index 5ea26c6..ee4123d 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -15,3 +15,70 @@ Example EHCI controller device node: usb-phy = usb_otg; }; +USB PHY with optional OTG: + +Required properties: +- compatible: Should contain: + qcom,usb-otg-ci for chipsets with ChipIdea 45nm PHY + qcom,usb-otg-snps for chipsets with Synopsys 28nm PHY + +- regs: Offset and length of the register set in the memory map +- interrupts: interrupt-specifier for the OTG interrupt. + +- clocks: A list of phandle + clock-specifier pairs for the +clocks listed in clock-names +- clock-names: Should contain the following: + phy USB PHY reference clock + coreProtocol engine clock + iface Interface bus clock + alt_coreProtocol engine clock for targets with asynchronous +reset methodology. (optional) + +- vdccx-supply: phandle to the regulator for the vdd supply for +digital circuit operation. +- v1p8-supply: phandle to the regulator for the 1.8V supply +- v3p3-supply: phandle to the regulator for the 3.3V supply + +- resets: A list of phandle + reset-specifier pairs for the +resets listed in reset-names +- reset-names: Should contain the following: + phy USB PHY controller reset + linkUSB LINK controller reset + +- qcom,otg-control: OTG control (VBUS and ID notifications) can be one of +1 - PHY control +2 - PMIC control + +Optional properties: +- dr_mode: One of host, peripheral or otg. Defaults to otg + +- qcom,phy-init-sequence: PHY configuration sequence values. This is related to Device +Mode Eye Diagram test. Start address at which these values will be +written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as +do not overwrite default value at this address. +For example: qcom,phy-init-sequence = -1 0x63 ; +Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1. + +Example HSUSB OTG controller device node: + +usb@f9a55000 { +compatible = qcom,usb-otg-snps; +reg = 0xf9a55000 0x400; +interrupts = 0 134 0; +dr_mode = peripheral; + +clocks = gcc GCC_XO_CLK, gcc GCC_USB_HS_SYSTEM_CLK, +gcc GCC_USB_HS_AHB_CLK; + +clock-names = phy, core, iface; + +vddcx-supply = pm8841_s2_corner; +v1p8-supply = pm8941_l6; +v3p3-supply = pm8941_l24; + +resets = gcc GCC_USB2A_PHY_BCR, gcc GCC_USB_HS_BCR; +reset-names = phy, link; + +qcom,otg-control = 1; +qcom,phy-init-sequence = -1 0x63 ; + }; diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 7e968aa..1bf2d4e 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -30,9 +30,12 @@ #include linux/debugfs.h #include linux/seq_file.h #include linux/pm_runtime.h +#include linux/of.h +#include linux/of_device.h #include linux/usb.h #include linux/usb/otg.h +#include linux/usb/of.h #include linux/usb/ulpi.h #include linux/usb/gadget.h #include linux/usb/hcd.h @@ -217,16 +220,16 @@ static struct usb_phy_io_ops msm_otg_io_ops = { static void ulpi_init(struct msm_otg *motg) { struct msm_otg_platform_data *pdata = motg-pdata; - int *seq = pdata-phy_init_seq; + int *seq = pdata-phy_init_seq, idx; + u32 addr = ULPI_EXT_VENDOR_SPECIFIC; - if (!seq) - return; + for (idx = 0; idx pdata-phy_init_sz; idx++) { + if (seq[idx] == -1) + continue; - while (seq[0] = 0) { dev_vdbg(motg-phy.dev, ulpi: write 0x%02x to 0x%02x\n, - seq[0], seq[1]); - ulpi_write(motg-phy, seq[0], seq[1]); - seq += 2; + seq[idx], addr + idx); + ulpi_write(motg-phy, seq[idx], addr + idx); } } @@ -1343,26 +1346,96 @@ static void msm_otg_debugfs_cleanup(void) debugfs_remove(msm_otg_dbg_root); } +static struct of_device_id msm_otg_dt_match[] = { + { + .compatible = qcom,usb-otg-ci, + .data = (void *) CI_45NM_INTEGRATED_PHY + }, + { + .compatible = qcom,usb-otg-snps
[PATCH v8 13/20] usb: phy: msm: Use reset framework for LINK and PHY resets
From: Ivan T. Ivanov iiva...@mm-sol.com Using reset framework eliminate need of platform specific callbacks and enable reset lines to be specified in DT files. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 29 + include/linux/usb/msm_hsusb.h | 3 +++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 1bf2d4e..a6abb1b 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -32,6 +32,7 @@ #include linux/pm_runtime.h #include linux/of.h #include linux/of_device.h +#include linux/reset.h #include linux/usb.h #include linux/usb/otg.h @@ -235,12 +236,15 @@ static void ulpi_init(struct msm_otg *motg) static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) { - int ret = 0; + int ret; - if (!motg-pdata-link_clk_reset) - return ret; + if (motg-pdata-link_clk_reset) + ret = motg-pdata-link_clk_reset(motg-clk, assert); + else if (assert) + ret = reset_control_assert(motg-link_rst); + else + ret = reset_control_deassert(motg-link_rst); - ret = motg-pdata-link_clk_reset(motg-clk, assert); if (ret) dev_err(motg-phy.dev, usb link clk reset %s failed\n, assert ? assert : deassert); @@ -250,12 +254,13 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) static int msm_otg_phy_clk_reset(struct msm_otg *motg) { - int ret = 0; + int ret; - if (!motg-pdata-phy_clk_reset) - return ret; + if (motg-pdata-phy_clk_reset) + ret = motg-pdata-phy_clk_reset(motg-phy_reset_clk); + else + ret = reset_control_reset(motg-phy_rst); - ret = motg-pdata-phy_clk_reset(motg-phy_reset_clk); if (ret) dev_err(motg-phy.dev, usb phy clk reset failed\n); @@ -1377,6 +1382,14 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) id = of_match_device(msm_otg_dt_match, pdev-dev); pdata-phy_type = (int) id-data; + motg-link_rst = devm_reset_control_get(pdev-dev, link); + if (IS_ERR(motg-link_rst)) + return PTR_ERR(motg-link_rst); + + motg-phy_rst = devm_reset_control_get(pdev-dev, phy); + if (IS_ERR(motg-phy_rst)) + return PTR_ERR(motg-phy_rst); + pdata-mode = of_usb_get_dr_mode(node); if (pdata-mode == USB_DR_MODE_UNKNOWN) pdata-mode = USB_DR_MODE_OTG; diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index bd68299..4e5d916 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h @@ -165,6 +165,9 @@ struct msm_otg { struct regulator *v3p3; struct regulator *v1p8; struct regulator *vddcx; + + struct reset_control *phy_rst; + struct reset_control *link_rst; }; #endif -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 00/20] usb: phy: msm: Fixes, cleanups and DT support
From: Ivan T. Ivanov iiva...@mm-sol.com Hi, This is a new version of patches posted earlier[1]. Changes since v7 - Use bulk regulator request function in patch #05 - Fix errors in patch #20 commit message [1] http://www.spinics.net/lists/linux-arm-msm/msg08997.html Ivan T. Ivanov (18): usb: phy: msm: Make driver selectable on ARCH_QCOM usb: phy: msm: Remove __init macro from driver probe method usb: phy: msm: Move global regulators variables to driver state usb: phy: msm: Enable deferred driver probing usb: phy: msm: Migrate to Managed Device Resource allocation usb: phy: msm: Remove unnecessarily check for valid regulators. usb: phy: msm: Fix checkpatch.pl warnings usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode usb: phy: msm: Remove unused pclk_src_name usb: phy: msm: Remove HSUSB prefix from regulator names usb: phy: msm: Properly check result from platform_get_irq() usb: phy: msm: Add device tree support and binding information usb: phy: msm: Use reset framework for LINK and PHY resets usb: phy: msm: Add support for secondary PHY control usb: phy: msm: Correct USB PHY Reset sequence for newer platform usb: phy: msm: Handle disconnect events usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX usb: phy: msm: Use usb_add_phy_dev() to register device Tim Bird (2): usb: phy: msm: Fix PTS definitions for MSM USB controller usb: phy: msm: Select secondary PHY via TCSR .../devicetree/bindings/usb/msm-hsusb.txt | 78 +++ arch/arm/mach-msm/board-msm7x30.c | 2 +- arch/arm/mach-msm/board-qsd8x50.c | 2 +- drivers/usb/phy/Kconfig| 6 +- drivers/usb/phy/phy-msm-usb.c | 700 - include/linux/usb/msm_hsusb.h | 39 +- include/linux/usb/msm_hsusb_hw.h | 14 +- 7 files changed, 504 insertions(+), 337 deletions(-) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 10/20] usb: phy: msm: Remove HSUSB prefix from regulator names
From: Ivan T. Ivanov iiva...@mm-sol.com Prefix did not bring any useful information. Currently none of the MSM platforms define these regulators, so it is safe to rename them. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index c2361bf..bd9e286 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1418,9 +1418,9 @@ static int msm_otg_probe(struct platform_device *pdev) return motg-irq; } - regs[0].supply = HSUSB_VDDCX; - regs[1].supply = HSUSB_3p3; - regs[2].supply = HSUSB_1p8; + regs[0].supply = vddcx; + regs[1].supply = v3p3; + regs[2].supply = v1p8; ret = devm_regulator_bulk_get(motg-phy.dev, ARRAY_SIZE(regs), regs); if (ret) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver
On Fri, 2014-04-25 at 03:10 +, Peter Chen wrote: On Thu, 2014-04-24 at 08:38 +0800, Peter Chen wrote: On Wed, Apr 23, 2014 at 03:28:01PM +0300, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com This series intend to fix driver, which was broken for a while. It is used to create peripheral role device, which in coordination with phy-usb-msm driver could provide USB2.0 gadget support for Qualcomm targets. Changes since version 3. - Fix typo in devicetree description file. Previews version can be found here: Since in your phy's patchset, you also access portsc which is in chipidea register region, it is not a standard way. In case, you will change something at chipidea driver in future when you re-work your next revision phy's patchset, I do not send this patchset to Greg right now. Did you see problems with _this_ particular patch set? There is no direct dependency between PHY patches and these changes. I have not seen problems for this patch set, if you make sure the current phy operation (eg, phy_type) at chipidea core does not affect you, I am glad to accept this. You mean phy_mode? Peripheral functionality is tested on top of current linus/master and it looks fine. Regards, Ivan Peter NrybXǧv^){.n+{zXܨ}Ơzj:+vzZ++zfh~izw?)ߢf^jǫym@Aa0hi -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method
On Mon, 2014-04-28 at 12:03 -0500, Felipe Balbi wrote: On Mon, Apr 28, 2014 at 09:00:43PM +0400, Sergei Shtylyov wrote: Hello. On 04/28/2014 05:34 PM, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com This fixes following: WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in reference from the variable msm_otg_driver to the function .init.text:msm_otg_probe() The variable msm_otg_driver references the function __init msm_otg_probe() Hm, this warning shouldn't occur before patch #4, no? good catch, this could probably be merged there. True. Should I resend it? Regards, Ivan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method
On Mon, 2014-04-28 at 12:54 -0500, Felipe Balbi wrote: On Mon, Apr 28, 2014 at 08:52:48PM +0300, Ivan T. Ivanov wrote: On Mon, 2014-04-28 at 12:03 -0500, Felipe Balbi wrote: On Mon, Apr 28, 2014 at 09:00:43PM +0400, Sergei Shtylyov wrote: Hello. On 04/28/2014 05:34 PM, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com This fixes following: WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in reference from the variable msm_otg_driver to the function .init.text:msm_otg_probe() The variable msm_otg_driver references the function __init msm_otg_probe() Hm, this warning shouldn't occur before patch #4, no? good catch, this could probably be merged there. True. Should I resend it? hold on, that's simple enough to sort out while applying. Unless there are any other big comments with your series, no need to resend. Sure, I will wait for more comments. Thanks, Ivan cheers -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver
Hi Peter, On Thu, 2014-04-24 at 08:38 +0800, Peter Chen wrote: On Wed, Apr 23, 2014 at 03:28:01PM +0300, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com This series intend to fix driver, which was broken for a while. It is used to create peripheral role device, which in coordination with phy-usb-msm driver could provide USB2.0 gadget support for Qualcomm targets. Changes since version 3. - Fix typo in devicetree description file. Previews version can be found here: Since in your phy's patchset, you also access portsc which is in chipidea register region, it is not a standard way. In case, you will change something at chipidea driver in future when you re-work your next revision phy's patchset, I do not send this patchset to Greg right now. Did you see problems with _this_ particular patch set? There is no direct dependency between PHY patches and these changes. Regards, Ivan Once your phy's patchset has accepted, notify me. I will send this patchset to Greg. Peter https://lkml.org/lkml/2014/4/22/195 Ivan T. Ivanov (3): usb: chipidea: msm: Add device tree binding information usb: chipidea: msm: Add device tree support usb: chipidea: msm: Initialize offset of the capability registers .../devicetree/bindings/usb/ci-hdrc-qcom.txt | 17 +++ drivers/usb/chipidea/ci_hdrc_msm.c | 24 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device
From: Ivan T. Ivanov iiva...@mm-sol.com They could be more than one USB2.0 PHY's on the platform. This will allow all of them to be registred successfuly. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 9240f5b..7283005 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1668,6 +1668,7 @@ static int msm_otg_probe(struct platform_device *pdev) phy-init = msm_phy_init; phy-set_power = msm_otg_set_power; phy-notify_disconnect = msm_phy_notify_disconnect; + phy-type = USB_PHY_TYPE_USB2; phy-io_ops = msm_otg_io_ops; @@ -1677,7 +1678,7 @@ static int msm_otg_probe(struct platform_device *pdev) msm_usb_reset(phy); - ret = usb_add_phy(motg-phy, USB_PHY_TYPE_USB2); + ret = usb_add_phy_dev(motg-phy); if (ret) { dev_err(pdev-dev, usb_add_phy failed\n); goto disable_ldo; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 04/20] usb: phy: msm: Enable deferred driver probing
From: Ivan T. Ivanov iiva...@mm-sol.com Using platform_driver_probe() prevent driver from requesting probe deferral. Fix this. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 6bae936..b7d73f2 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1736,6 +1736,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = { }; static struct platform_driver msm_otg_driver = { + .probe = msm_otg_probe, .remove = msm_otg_remove, .driver = { .name = DRIVER_NAME, @@ -1744,7 +1745,7 @@ static struct platform_driver msm_otg_driver = { }, }; -module_platform_driver_probe(msm_otg_driver, msm_otg_probe); +module_platform_driver(msm_otg_driver); MODULE_LICENSE(GPL v2); MODULE_DESCRIPTION(MSM USB transceiver driver); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 18/20] usb: phy: msm: Handle disconnect events
From: Ivan T. Ivanov iiva...@mm-sol.com Put the transceiver in non-driving mode. Otherwise host may not detect soft-disconnection. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Cc: Pavankumar Kondeti pkond...@codeaurora.org --- drivers/usb/phy/phy-msm-usb.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 1554f69..602e6c8 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -235,6 +235,23 @@ static void ulpi_init(struct msm_otg *motg) } } +static int msm_phy_notify_disconnect(struct usb_phy *phy, + enum usb_device_speed speed) +{ + int val; + + /* +* Put the transceiver in non-driving mode. Otherwise host +* may not detect soft-disconnection. +*/ + val = ulpi_read(phy, ULPI_FUNC_CTRL); + val = ~ULPI_FUNC_CTRL_OPMODE_MASK; + val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; + ulpi_write(phy, val, ULPI_FUNC_CTRL); + + return 0; +} + static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) { int ret; @@ -1631,6 +1648,7 @@ static int msm_otg_probe(struct platform_device *pdev) phy-init = msm_phy_init; phy-set_power = msm_otg_set_power; + phy-notify_disconnect = msm_phy_notify_disconnect; phy-io_ops = msm_otg_io_ops; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 13/20] usb: phy: msm: Use reset framework for LINK and PHY resets
From: Ivan T. Ivanov iiva...@mm-sol.com Using reset framework eliminate need of platform specific callbacks and enable reset lines to be specified in DT files. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 29 + include/linux/usb/msm_hsusb.h | 3 +++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 4ed1ded..6ad1396 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -32,6 +32,7 @@ #include linux/pm_runtime.h #include linux/of.h #include linux/of_device.h +#include linux/reset.h #include linux/usb.h #include linux/usb/otg.h @@ -235,12 +236,15 @@ static void ulpi_init(struct msm_otg *motg) static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) { - int ret = 0; + int ret; - if (!motg-pdata-link_clk_reset) - return ret; + if (motg-pdata-link_clk_reset) + ret = motg-pdata-link_clk_reset(motg-clk, assert); + else if (assert) + ret = reset_control_assert(motg-link_rst); + else + ret = reset_control_deassert(motg-link_rst); - ret = motg-pdata-link_clk_reset(motg-clk, assert); if (ret) dev_err(motg-phy.dev, usb link clk reset %s failed\n, assert ? assert : deassert); @@ -250,12 +254,13 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) static int msm_otg_phy_clk_reset(struct msm_otg *motg) { - int ret = 0; + int ret; - if (!motg-pdata-phy_clk_reset) - return ret; + if (motg-pdata-phy_clk_reset) + ret = motg-pdata-phy_clk_reset(motg-phy_reset_clk); + else + ret = reset_control_reset(motg-phy_rst); - ret = motg-pdata-phy_clk_reset(motg-phy_reset_clk); if (ret) dev_err(motg-phy.dev, usb phy clk reset failed\n); @@ -1377,6 +1382,14 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) id = of_match_device(msm_otg_dt_match, pdev-dev); pdata-phy_type = (int) id-data; + motg-link_rst = devm_reset_control_get(pdev-dev, link); + if (IS_ERR(motg-link_rst)) + return PTR_ERR(motg-link_rst); + + motg-phy_rst = devm_reset_control_get(pdev-dev, phy); + if (IS_ERR(motg-phy_rst)) + return PTR_ERR(motg-phy_rst); + pdata-mode = of_usb_get_dr_mode(node); if (pdata-mode == USB_DR_MODE_UNKNOWN) pdata-mode = USB_DR_MODE_OTG; diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index bd68299..4e5d916 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h @@ -165,6 +165,9 @@ struct msm_otg { struct regulator *v3p3; struct regulator *v1p8; struct regulator *vddcx; + + struct reset_control *phy_rst; + struct reset_control *link_rst; }; #endif -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 15/20] usb: phy: msm: Correct USB PHY Reset sequence for newer platform
From: Ivan T. Ivanov iiva...@mm-sol.com On few legacy platforms, USB PHY is having dedicated reset clk. It is used to reset USB PHY after putting USB PHY into low power mode and for calibration of USB PHY. Putting USB PHY into low power mode is causing ulpi read/write timeout as expected. USB PHY reset clk is not available on newer platform. For 28nm PHY, reset USB PHY after resestting USB LINK. Also reset USB PHY using USB_PHY_PON bit with USB_OTG_HS_PHY_CTRL register after programming USB PHY Override registers as suggested with hardware programming guidelines. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Signed-off-by: Tim Bird tim.b...@sonymobile.com Cc: Mayank Rana mr...@codeaurora.org --- drivers/usb/phy/phy-msm-usb.c| 140 --- include/linux/usb/msm_hsusb_hw.h | 5 ++ 2 files changed, 93 insertions(+), 52 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index c3877ec..d949018 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -48,6 +48,7 @@ #define DRIVER_NAMEmsm_otg #define ULPI_IO_TIMEOUT_USEC (10 * 1000) +#define LINK_RESET_TIMEOUT_USEC(250 * 1000) #define USB_PHY_3P3_VOL_MIN305 /* uV */ #define USB_PHY_3P3_VOL_MAX330 /* uV */ @@ -267,77 +268,35 @@ static int msm_otg_phy_clk_reset(struct msm_otg *motg) return ret; } -static int msm_otg_phy_reset(struct msm_otg *motg) +static int msm_link_reset(struct msm_otg *motg) { u32 val; int ret; - int retries; ret = msm_otg_link_clk_reset(motg, 1); if (ret) return ret; - ret = msm_otg_phy_clk_reset(motg); - if (ret) - return ret; - ret = msm_otg_link_clk_reset(motg, 0); - if (ret) - return ret; - val = readl(USB_PORTSC) ~PORTSC_PTS_MASK; - writel(val | PORTSC_PTS_ULPI, USB_PORTSC); - - for (retries = 3; retries 0; retries--) { - ret = ulpi_write(motg-phy, ULPI_FUNC_CTRL_SUSPENDM, - ULPI_CLR(ULPI_FUNC_CTRL)); - if (!ret) - break; - ret = msm_otg_phy_clk_reset(motg); - if (ret) - return ret; - } - if (!retries) - return -ETIMEDOUT; + /* wait for 1ms delay as suggested in HPG. */ + usleep_range(1000, 1200); - /* This reset calibrates the phy, if the above write succeeded */ - ret = msm_otg_phy_clk_reset(motg); + ret = msm_otg_link_clk_reset(motg, 0); if (ret) return ret; - for (retries = 3; retries 0; retries--) { - ret = ulpi_read(motg-phy, ULPI_DEBUG); - if (ret != -ETIMEDOUT) - break; - ret = msm_otg_phy_clk_reset(motg); - if (ret) - return ret; - } - if (!retries) - return -ETIMEDOUT; - if (motg-phy_number) writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); - dev_info(motg-phy.dev, phy_reset: success\n); + val = readl(USB_PORTSC) ~PORTSC_PTS_MASK; + writel(val | PORTSC_PTS_ULPI, USB_PORTSC); + return 0; } -#define LINK_RESET_TIMEOUT_USEC(250 * 1000) static int msm_otg_reset(struct usb_phy *phy) { struct msm_otg *motg = container_of(phy, struct msm_otg, phy); - struct msm_otg_platform_data *pdata = motg-pdata; int cnt = 0; - int ret; - u32 val = 0; - u32 ulpi_val = 0; - - ret = msm_otg_phy_reset(motg); - if (ret) { - dev_err(phy-dev, phy_reset failed\n); - return ret; - } - - ulpi_init(motg); writel(USBCMD_RESET, USB_USBCMD); while (cnt LINK_RESET_TIMEOUT_USEC) { @@ -351,11 +310,86 @@ static int msm_otg_reset(struct usb_phy *phy) /* select ULPI phy */ writel(0x8000, USB_PORTSC); + writel(0x0, USB_AHBBURST); + writel(0x08, USB_AHBMODE); + + if (motg-phy_number) + writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + return 0; +} + +static void msm_phy_reset(struct msm_otg *motg) +{ + void __iomem *addr; + + if (motg-pdata-phy_type != SNPS_28NM_INTEGRATED_PHY) { + msm_otg_phy_clk_reset(motg); + return; + } + + addr = USB_PHY_CTRL; + if (motg-phy_number) + addr = USB_PHY_CTRL2; + + /* Assert USB PHY_POR */ + writel(readl(addr) | PHY_POR_ASSERT, addr); + + /* +* wait for minimum 10 microseconds as suggested in HPG. +* Use a slightly larger value since the exact value didn't +* work 100% of the time. +*/ + udelay(12); + + /* Deassert USB PHY_POR */ + writel(readl(addr) ~PHY_POR_ASSERT, addr); +} + +static int msm_usb_reset(struct usb_phy *phy
[PATCH v7 02/20] usb: phy: msm: Remove __init macro from driver probe method
From: Ivan T. Ivanov iiva...@mm-sol.com This fixes following: WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in reference from the variable msm_otg_driver to the function .init.text:msm_otg_probe() The variable msm_otg_driver references the function __init msm_otg_probe() Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 5b37b81..6ae4d2f 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1406,7 +1406,7 @@ static void msm_otg_debugfs_cleanup(void) debugfs_remove(msm_otg_dbg_root); } -static int __init msm_otg_probe(struct platform_device *pdev) +static int msm_otg_probe(struct platform_device *pdev) { int ret = 0; struct resource *res; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 17/20] usb: phy: msm: Select secondary PHY via TCSR
From: Tim Bird tbird...@gmail.com Select the secondary PHY using the TCSR register, if phy-num=1 in the DTS (or phy_number is set in the platform data). The SOC has 2 PHYs which can be used with the OTG port, and this code allows configuring the correct one. Note: This resolves the problem I was seeing where I couldn't get the USB driver working at all on a dragonboard, from cold boot. This patch depends on patch 5/14 from Ivan's msm USB patch set. It does not use DT for the register address, as there's no evidence that this address changes between SoC versions. Signed-off-by: Tim Bird tim.b...@sonymobile.com --- drivers/usb/phy/phy-msm-usb.c| 14 ++ include/linux/usb/msm_hsusb_hw.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 06d79c1..1554f69 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1488,6 +1488,7 @@ static int msm_otg_probe(struct platform_device *pdev) struct resource *res; struct msm_otg *motg; struct usb_phy *phy; + void __iomem *phy_select; motg = devm_kzalloc(pdev-dev, sizeof(struct msm_otg), GFP_KERNEL); if (!motg) { @@ -1552,6 +1553,19 @@ static int msm_otg_probe(struct platform_device *pdev) if (IS_ERR(motg-regs)) return PTR_ERR(motg-regs); + /* +* NOTE: The PHYs can be multiplexed between the chipidea controller +* and the dwc3 controller, using a single bit. It is important that +* the dwc3 driver does not set this bit in an incompatible way. +*/ + if (motg-phy_number) { + phy_select = devm_ioremap_nocache(pdev-dev, USB2_PHY_SEL, 4); + if (IS_ERR(phy_select)) + return PTR_ERR(phy_select); + /* Enable second PHY with the OTG port */ + writel_relaxed(0x1, phy_select); + } + dev_info(pdev-dev, OTG regs = %p\n, motg-regs); motg-irq = platform_get_irq(pdev, 0); diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index 98d3dd8..a29f603 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b/include/linux/usb/msm_hsusb_hw.h @@ -16,6 +16,9 @@ #ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__ #define __LINUX_USB_GADGET_MSM72K_UDC_H__ +/* USB phy selector - in TCSR address range */ +#define USB2_PHY_SEL 0xfd4ab000 + #define USB_AHBBURST (MSM_USB_BASE + 0x0090) #define USB_AHBMODE (MSM_USB_BASE + 0x0098) #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */ -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 16/20] usb: phy: msm: Fix PTS definitions for MSM USB controller
From: Tim Bird tbird...@gmail.com Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB controller. This is a standard chipidea PORTSC definition, where a PHY_TYPE of 10b (30) is ULPI and 11b (30) is SERIAL. Fix the definitions and use them correctly in the driver code. Signed-off-by: Tim Bird tim.b...@sonymobile.com --- drivers/usb/phy/phy-msm-usb.c| 8 +--- include/linux/usb/msm_hsusb_hw.h | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index d949018..06d79c1 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -287,8 +287,9 @@ static int msm_link_reset(struct msm_otg *motg) if (motg-phy_number) writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + /* put transceiver in serial mode as part of reset */ val = readl(USB_PORTSC) ~PORTSC_PTS_MASK; - writel(val | PORTSC_PTS_ULPI, USB_PORTSC); + writel(val | PORTSC_PTS_SERIAL, USB_PORTSC); return 0; } @@ -308,8 +309,9 @@ static int msm_otg_reset(struct usb_phy *phy) if (cnt = LINK_RESET_TIMEOUT_USEC) return -ETIMEDOUT; - /* select ULPI phy */ - writel(0x8000, USB_PORTSC); + /* select ULPI phy and clear other status/control bits in PORTSC */ + writel(PORTSC_PTS_ULPI, USB_PORTSC); + writel(0x0, USB_AHBBURST); writel(0x08, USB_AHBMODE); diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index 575c743..98d3dd8 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b/include/linux/usb/msm_hsusb_hw.h @@ -31,8 +31,9 @@ #define USB_USBINTR (MSM_USB_BASE + 0x0148) #define PORTSC_PHCD(1 23) /* phy suspend mode */ -#define PORTSC_PTS_MASK (3 30) -#define PORTSC_PTS_ULPI (3 30) +#define PORTSC_PTS_MASK(3 30) +#define PORTSC_PTS_ULPI(2 30) +#define PORTSC_PTS_SERIAL (3 30) #define USB_ULPI_VIEWPORT(MSM_USB_BASE + 0x0170) #define ULPI_RUN (1 30) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 14/20] usb: phy: msm: Add support for secondary PHY control
From: Ivan T. Ivanov iiva...@mm-sol.com Allow support to use 2nd HSPHY with USB2 Core. Some platforms may have configuration to allow USB controller work with any of the two HSPHYs present. By default driver configures USB core to use primary HSPHY. Add support to allow user select 2nd HSPHY using DT parameter. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Cc: Manu Gautam mgau...@codeaurora.org --- .../devicetree/bindings/usb/msm-hsusb.txt | 6 ++ drivers/usb/phy/phy-msm-usb.c | 24 -- include/linux/usb/msm_hsusb.h | 1 + include/linux/usb/msm_hsusb_hw.h | 1 + 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index ee4123d..0669667 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt @@ -59,6 +59,12 @@ Optional properties: For example: qcom,phy-init-sequence = -1 0x63 ; Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1. +- qcom,phy-num: Select number of pyco-phy to use, can be one of +0 - PHY one, default +1 - Second PHY +Some platforms may have configuration to allow USB +controller work with any of the two HSPHYs present. + Example HSUSB OTG controller device node: usb@f9a55000 { diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 6ad1396..c3877ec 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -314,6 +314,9 @@ static int msm_otg_phy_reset(struct msm_otg *motg) if (!retries) return -ETIMEDOUT; + if (motg-phy_number) + writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + dev_info(motg-phy.dev, phy_reset: success\n); return 0; } @@ -368,6 +371,9 @@ static int msm_otg_reset(struct usb_phy *phy) ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL); } + if (motg-phy_number) + writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2); + return 0; } @@ -404,6 +410,7 @@ static int msm_otg_suspend(struct msm_otg *motg) struct usb_phy *phy = motg-phy; struct usb_bus *bus = phy-otg-host; struct msm_otg_platform_data *pdata = motg-pdata; + void __iomem *addr; int cnt = 0; if (atomic_read(motg-in_lpm)) @@ -463,9 +470,13 @@ static int msm_otg_suspend(struct msm_otg *motg) */ writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD); + addr = USB_PHY_CTRL; + if (motg-phy_number) + addr = USB_PHY_CTRL2; + if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY motg-pdata-otg_control == OTG_PMIC_CONTROL) - writel(readl(USB_PHY_CTRL) | PHY_RETEN, USB_PHY_CTRL); + writel(readl(addr) | PHY_RETEN, addr); clk_disable_unprepare(motg-pclk); clk_disable_unprepare(motg-clk); @@ -495,6 +506,7 @@ static int msm_otg_resume(struct msm_otg *motg) { struct usb_phy *phy = motg-phy; struct usb_bus *bus = phy-otg-host; + void __iomem *addr; int cnt = 0; unsigned temp; @@ -508,9 +520,14 @@ static int msm_otg_resume(struct msm_otg *motg) if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY motg-pdata-otg_control == OTG_PMIC_CONTROL) { + + addr = USB_PHY_CTRL; + if (motg-phy_number) + addr = USB_PHY_CTRL2; + msm_hsusb_ldo_set_mode(motg, 1); msm_hsusb_config_vddcx(motg, 1); - writel(readl(USB_PHY_CTRL) ~PHY_RETEN, USB_PHY_CTRL); + writel(readl(addr) ~PHY_RETEN, addr); } temp = readl(USB_USBCMD); @@ -1399,6 +1416,9 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) if (val == OTG_PMIC_CONTROL) pdata-otg_control = val; + if (!of_property_read_u32(node, qcom,phy-num, val) val 2) + motg-phy_number = val; + prop = of_find_property(node, qcom,phy-init-sequence, len); if (!prop || !len) return 0; diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 4e5d916..4628f1a 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h @@ -158,6 +158,7 @@ struct msm_otg { atomic_t in_lpm; int async_int; unsigned cur_power; + int phy_number; struct delayed_work chg_work; enum usb_chg_state chg_state; enum usb_chg_type chg_type; diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index 6e97a2d..e6d7035 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b
[PATCH v7 11/20] usb: phy: msm: Properly check result from platform_get_irq()
From: Ivan T. Ivanov iiva...@mm-sol.com Function return negative code on error. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 5d64038..8a7a324 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1412,7 +1412,7 @@ static int msm_otg_probe(struct platform_device *pdev) dev_info(pdev-dev, OTG regs = %p\n, motg-regs); motg-irq = platform_get_irq(pdev, 0); - if (!motg-irq) { + if (motg-irq 0) { dev_err(pdev-dev, platform_get_irq failed\n); return motg-irq; } -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 08/20] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode
From: Ivan T. Ivanov iiva...@mm-sol.com Use enum usb_dr_mode and drop default usb_dr_mode from platform data. USB DT bindings states: dr_mode: ...In case this attribute isn't passed via DT, USB DRD controllers should default to OTG..., so remove redundand field. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Acked-by: David Brown dav...@codeaurora.org --- arch/arm/mach-msm/board-msm7x30.c | 2 +- arch/arm/mach-msm/board-qsd8x50.c | 2 +- drivers/usb/phy/phy-msm-usb.c | 41 --- include/linux/usb/msm_hsusb.h | 20 +-- 4 files changed, 20 insertions(+), 45 deletions(-) diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c index 46de789..0c4c200 100644 --- a/arch/arm/mach-msm/board-msm7x30.c +++ b/arch/arm/mach-msm/board-msm7x30.c @@ -95,7 +95,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk) static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, - .mode = USB_PERIPHERAL, + .mode = USB_DR_MODE_PERIPHERAL, .otg_control= OTG_PHY_CONTROL, .link_clk_reset = hsusb_link_clk_reset, .phy_clk_reset = hsusb_phy_clk_reset, diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c index 9169ec3..4c74861 100644 --- a/arch/arm/mach-msm/board-qsd8x50.c +++ b/arch/arm/mach-msm/board-qsd8x50.c @@ -116,7 +116,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk) static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, - .mode = USB_PERIPHERAL, + .mode = USB_DR_MODE_PERIPHERAL, .otg_control= OTG_PHY_CONTROL, .link_clk_reset = hsusb_link_clk_reset, .phy_clk_reset = hsusb_phy_clk_reset, diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 3855217..a67c8a2 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -348,10 +348,10 @@ static int msm_otg_reset(struct usb_phy *phy) if (pdata-otg_control == OTG_PHY_CONTROL) { val = readl(USB_OTGSC); - if (pdata-mode == USB_OTG) { + if (pdata-mode == USB_DR_MODE_OTG) { ulpi_val = ULPI_INT_IDGRD | ULPI_INT_SESS_VALID; val |= OTGSC_IDIE | OTGSC_BSVIE; - } else if (pdata-mode == USB_PERIPHERAL) { + } else if (pdata-mode == USB_DR_MODE_PERIPHERAL) { ulpi_val = ULPI_INT_SESS_VALID; val |= OTGSC_BSVIE; } @@ -637,7 +637,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) * Fail host registration if this board can support * only peripheral configuration. */ - if (motg-pdata-mode == USB_PERIPHERAL) { + if (motg-pdata-mode == USB_DR_MODE_PERIPHERAL) { dev_info(otg-phy-dev, Host mode is not supported\n); return -ENODEV; } @@ -666,7 +666,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) * Kick the state machine work, if peripheral is not supported * or peripheral is already registered with us. */ - if (motg-pdata-mode == USB_HOST || otg-gadget) { + if (motg-pdata-mode == USB_DR_MODE_HOST || otg-gadget) { pm_runtime_get_sync(otg-phy-dev); schedule_work(motg-sm_work); } @@ -710,7 +710,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg, * Fail peripheral registration if this board can support * only host configuration. */ - if (motg-pdata-mode == USB_HOST) { + if (motg-pdata-mode == USB_DR_MODE_HOST) { dev_info(otg-phy-dev, Peripheral mode is not supported\n); return -ENODEV; } @@ -735,7 +735,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg, * Kick the state machine work, if host is not supported * or host is already registered with us. */ - if (motg-pdata-mode == USB_PERIPHERAL || otg-host) { + if (motg-pdata-mode == USB_DR_MODE_PERIPHERAL || otg-host) { pm_runtime_get_sync(otg-phy-dev); schedule_work(motg-sm_work); } @@ -1056,7 +1056,7 @@ static void msm_otg_init_sm(struct msm_otg *motg) u32 otgsc = readl(USB_OTGSC); switch (pdata-mode) { - case USB_OTG: + case USB_DR_MODE_OTG: if (pdata-otg_control == OTG_PHY_CONTROL) { if (otgsc OTGSC_ID) set_bit(ID, motg-inputs); @@ -1068,21 +1068,14 @@ static void msm_otg_init_sm(struct msm_otg *motg) else clear_bit(B_SESS_VLD, motg-inputs
[PATCH v7 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation
From: Ivan T. Ivanov iiva...@mm-sol.com Move memory, regulators, clocks and irq allocation to devm_* variants. Properly check for valid clk handles. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 192 -- 1 file changed, 73 insertions(+), 119 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index b7d73f2..67cac96 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) int ret = 0; if (init) { - motg-vddcx = regulator_get(motg-phy.dev, HSUSB_VDDCX); - if (IS_ERR(motg-vddcx)) { - dev_err(motg-phy.dev, unable to get hsusb vddcx\n); - return PTR_ERR(motg-vddcx); - } - ret = regulator_set_voltage(motg-vddcx, USB_PHY_VDD_DIG_VOL_MIN, USB_PHY_VDD_DIG_VOL_MAX); if (ret) { dev_err(motg-phy.dev, unable to set the voltage for hsusb vddcx\n); - regulator_put(motg-vddcx); return ret; } ret = regulator_enable(motg-vddcx); - if (ret) { + if (ret) dev_err(motg-phy.dev, unable to enable hsusb vddcx\n); - regulator_put(motg-vddcx); - } } else { ret = regulator_set_voltage(motg-vddcx, 0, USB_PHY_VDD_DIG_VOL_MAX); @@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) ret = regulator_disable(motg-vddcx); if (ret) dev_err(motg-phy.dev, unable to disable hsusb vddcx\n); - - regulator_put(motg-vddcx); } return ret; @@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) int rc = 0; if (init) { - motg-v3p3 = regulator_get(motg-phy.dev, HSUSB_3p3); - if (IS_ERR(motg-v3p3)) { - dev_err(motg-phy.dev, unable to get hsusb 3p3\n); - return PTR_ERR(motg-v3p3); - } - rc = regulator_set_voltage(motg-v3p3, USB_PHY_3P3_VOL_MIN, USB_PHY_3P3_VOL_MAX); if (rc) { dev_err(motg-phy.dev, unable to set voltage level for hsusb 3p3\n); - goto put_3p3; + goto exit; } rc = regulator_enable(motg-v3p3); if (rc) { dev_err(motg-phy.dev, unable to enable the hsusb 3p3\n); - goto put_3p3; - } - motg-v1p8 = regulator_get(motg-phy.dev, HSUSB_1p8); - if (IS_ERR(motg-v1p8)) { - dev_err(motg-phy.dev, unable to get hsusb 1p8\n); - rc = PTR_ERR(motg-v1p8); - goto disable_3p3; + goto exit; } rc = regulator_set_voltage(motg-v1p8, USB_PHY_1P8_VOL_MIN, USB_PHY_1P8_VOL_MAX); if (rc) { dev_err(motg-phy.dev, unable to set voltage level for hsusb 1p8\n); - goto put_1p8; + goto disable_3p3; } rc = regulator_enable(motg-v1p8); if (rc) { dev_err(motg-phy.dev, unable to enable the hsusb 1p8\n); - goto put_1p8; + goto disable_3p3; } return 0; } regulator_disable(motg-v1p8); -put_1p8: - regulator_put(motg-v1p8); disable_3p3: regulator_disable(motg-v3p3); -put_3p3: - regulator_put(motg-v3p3); +exit: return rc; } @@ -506,7 +480,7 @@ static int msm_otg_suspend(struct msm_otg *motg) clk_disable_unprepare(motg-pclk); clk_disable_unprepare(motg-clk); - if (motg-core_clk) + if (!IS_ERR(motg-core_clk)) clk_disable_unprepare(motg-core_clk); if (!IS_ERR(motg-pclk_src)) @@ -546,7 +520,7 @@ static int msm_otg_resume(struct msm_otg *motg) clk_prepare_enable(motg-pclk); clk_prepare_enable(motg-clk); - if (motg-core_clk) + if (!IS_ERR(motg-core_clk)) clk_prepare_enable(motg-core_clk); if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY @@ -1415,37 +1389,34 @@ static int msm_otg_probe(struct platform_device *pdev) return -ENODEV; } - motg = kzalloc
[PATCH v7 07/20] usb: phy: msm: Fix checkpatch.pl warnings
From: Ivan T. Ivanov iiva...@mm-sol.com This fixes following: WARNING: quoted string split across lines WARNING: Prefer seq_puts to seq_printf Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 39 ++- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 4045301..3855217 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -67,8 +67,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) USB_PHY_VDD_DIG_VOL_MIN, USB_PHY_VDD_DIG_VOL_MAX); if (ret) { - dev_err(motg-phy.dev, unable to set the voltage - for hsusb vddcx\n); + dev_err(motg-phy.dev, Cannot set vddcx voltage\n); return ret; } @@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) ret = regulator_set_voltage(motg-vddcx, 0, USB_PHY_VDD_DIG_VOL_MAX); if (ret) - dev_err(motg-phy.dev, unable to set the voltage - for hsusb vddcx\n); + dev_err(motg-phy.dev, Cannot set vddcx voltage\n); ret = regulator_disable(motg-vddcx); if (ret) dev_err(motg-phy.dev, unable to disable hsusb vddcx\n); @@ -97,8 +95,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) rc = regulator_set_voltage(motg-v3p3, USB_PHY_3P3_VOL_MIN, USB_PHY_3P3_VOL_MAX); if (rc) { - dev_err(motg-phy.dev, unable to set voltage level - for hsusb 3p3\n); + dev_err(motg-phy.dev, Cannot set v3p3 voltage\n); goto exit; } rc = regulator_enable(motg-v3p3); @@ -109,8 +106,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) rc = regulator_set_voltage(motg-v1p8, USB_PHY_1P8_VOL_MIN, USB_PHY_1P8_VOL_MAX); if (rc) { - dev_err(motg-phy.dev, unable to set voltage level - for hsusb 1p8\n); + dev_err(motg-phy.dev, Cannot set v1p8 voltage\n); goto disable_3p3; } rc = regulator_enable(motg-v1p8); @@ -137,15 +133,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) ret = regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_HPM_LOAD); if (ret 0) { - pr_err(%s: Unable to set HPM of the regulator - HSUSB_1p8\n, __func__); + pr_err(Could not set HPM for v1p8\n); return ret; } ret = regulator_set_optimum_mode(motg-v3p3, USB_PHY_3P3_HPM_LOAD); if (ret 0) { - pr_err(%s: Unable to set HPM of the regulator - HSUSB_3p3\n, __func__); + pr_err(Could not set HPM for v3p3\n); regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_LPM_LOAD); return ret; @@ -154,13 +148,11 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) ret = regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_LPM_LOAD); if (ret 0) - pr_err(%s: Unable to set LPM of the regulator - HSUSB_1p8\n, __func__); + pr_err(Could not set LPM for v1p8\n); ret = regulator_set_optimum_mode(motg-v3p3, USB_PHY_3P3_LPM_LOAD); if (ret 0) - pr_err(%s: Unable to set LPM of the regulator - HSUSB_3p3\n, __func__); + pr_err(Could not set LPM for v3p3\n); } pr_debug(reg (%s)\n, on ? HPM : LPM); @@ -390,8 +382,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high) ret = regulator_set_voltage(motg-vddcx, min_vol, max_vol); if (ret) { - pr_err(%s: unable to set the voltage for regulator - HSUSB_VDDCX\n, __func__); + pr_err(Cannot set vddcx voltage\n); return ret; } @@ -546,8 +537,7 @@ static int msm_otg_resume(struct msm_otg *motg) * PHY. USB state can not be restored. Re-insertion * of USB cable
[PATCH v7 10/20] usb: phy: msm: Remove HSUSB prefix from regulator names
From: Ivan T. Ivanov iiva...@mm-sol.com Prefix did not bring any useful information. Currently none of the MSM platforms define these regulators, so it is safe to rename them. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 8b84821..5d64038 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1417,19 +1417,19 @@ static int msm_otg_probe(struct platform_device *pdev) return motg-irq; } - motg-vddcx = devm_regulator_get(motg-phy.dev, HSUSB_VDDCX); + motg-vddcx = devm_regulator_get(motg-phy.dev, vddcx); if (IS_ERR(motg-vddcx)) { dev_err(motg-phy.dev, unable to get hsusb vddcx\n); return PTR_ERR(motg-vddcx); } - motg-v3p3 = devm_regulator_get(motg-phy.dev, HSUSB_3p3); + motg-v3p3 = devm_regulator_get(motg-phy.dev, v3p3); if (IS_ERR(motg-v3p3)) { dev_err(motg-phy.dev, unable to get hsusb 3p3\n); return PTR_ERR(motg-v3p3); } - motg-v1p8 = devm_regulator_get(motg-phy.dev, HSUSB_1p8); + motg-v1p8 = devm_regulator_get(motg-phy.dev, v1p8); if (IS_ERR(motg-v1p8)) { dev_err(motg-phy.dev, unable to get hsusb 1p8\n); return PTR_ERR(motg-v1p8); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 06/20] usb: phy: msm: Remove unnecessarily check for valid regulators.
From: Ivan T. Ivanov iiva...@mm-sol.com Whether regulators are available or not is checked at driver probe. If they are not available driver will refuse to load, so no need to check them again. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/phy/phy-msm-usb.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 67cac96..4045301 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -133,16 +133,6 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) { int ret = 0; - if (!motg-v1p8 || IS_ERR(motg-v1p8)) { - pr_err(%s: HSUSB_1p8 is not initialized\n, __func__); - return -ENODEV; - } - - if (!motg-v3p3 || IS_ERR(motg-v3p3)) { - pr_err(%s: HSUSB_3p3 is not initialized\n, __func__); - return -ENODEV; - } - if (on) { ret = regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_HPM_LOAD); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 06/19] usb: phy: msm: Fix checkpatch.pl warnings
On Tue, 2014-04-22 at 16:30 +0100, Srinivas Kandagatla wrote: On 22/04/14 10:20, Ivan T. Ivanov wrote: @@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) ret = regulator_set_voltage(motg-vddcx, 0, USB_PHY_VDD_DIG_VOL_MAX); if (ret) - dev_err(motg-phy.dev, unable to set the voltage - for hsusb vddcx\n); + dev_err(motg-phy.dev, Cannot set vddcx voltage\n); @@ -137,15 +133,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) ret = regulator_set_optimum_mode(motg-v1p8, USB_PHY_1P8_HPM_LOAD); if (ret 0) { - pr_err(%s: Unable to set HPM of the regulator - HSUSB_1p8\n, __func__); + pr_err(Could not set HPM for v1p8\n); return ret; } @@ -390,8 +382,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high) ret = regulator_set_voltage(motg-vddcx, min_vol, max_vol); if (ret) { - pr_err(%s: unable to set the voltage for regulator - HSUSB_VDDCX\n, __func__); + dev_err(motg-phy.dev, Cannot set vddcx voltage\n); return ret; } I see some of pr_err not moved to dev_err?, while others have been moved. Right, intention was to just shorten messages to fit one line, to make checkpatch.pl happy. Thanks, Ivan Also noticed that the error messages are changed as part of this fix. IMHO, changing an error message would have a side-effects on logging tools, anyway Am not sure if its true in this case. Thanks, srini -- -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 2/3] usb: chipidea: msm: Add device tree support
From: Ivan T. Ivanov iiva...@mm-sol.com Allows controller to be specified via device tree. Pass PHY phandle specified in DT to core driver. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/chipidea/ci_hdrc_msm.c | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 2d51d85..736aeb2 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -57,9 +57,21 @@ static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = { static int ci_hdrc_msm_probe(struct platform_device *pdev) { struct platform_device *plat_ci; + struct usb_phy *phy; dev_dbg(pdev-dev, ci_hdrc_msm_probe\n); + /* +* OTG(PHY) driver takes care of PHY initialization, clock management, +* powering up VBUS, mapping of registers address space and power +* management. +*/ + phy = devm_usb_get_phy_by_phandle(pdev-dev, usb-phy, 0); + if (IS_ERR(phy)) + return PTR_ERR(phy); + + ci_hdrc_msm_platdata.phy = phy; + plat_ci = ci_hdrc_add_device(pdev-dev, pdev-resource, pdev-num_resources, ci_hdrc_msm_platdata); @@ -86,10 +98,19 @@ static int ci_hdrc_msm_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id msm_ci_dt_match[] = { + { .compatible = qcom,ci-hdrc, }, + { } +}; +MODULE_DEVICE_TABLE(of, msm_ci_dt_match); + static struct platform_driver ci_hdrc_msm_driver = { .probe = ci_hdrc_msm_probe, .remove = ci_hdrc_msm_remove, - .driver = { .name = msm_hsusb, }, + .driver = { + .name = msm_hsusb, + .of_match_table = msm_ci_dt_match, + }, }; module_platform_driver(ci_hdrc_msm_driver); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 3/3] usb: chipidea: msm: Initialize offset of the capability registers
From: Ivan T. Ivanov iiva...@mm-sol.com Since commit 62bb84e (usb: gadget: ci13xxx: convert to platform device) start address of the capability registers is not passed correctly to udc_probe(). Fix this. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- drivers/usb/chipidea/ci_hdrc_msm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 736aeb2..d72b9d2 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -47,6 +47,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = { .name = ci_hdrc_msm, + .capoffset = DEF_CAPOFFSET, .flags = CI_HDRC_REGS_SHARED | CI_HDRC_REQUIRE_TRANSCEIVER | CI_HDRC_DISABLE_STREAMING, -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 1/3] usb: chipidea: msm: Add device tree binding information
From: Ivan T. Ivanov iiva...@mm-sol.com Document device tree binding information as required by the Qualcomm USB controller. Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com --- Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt | 17 + 1 file changed, 17 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt new file mode 100644 index 000..f2899b5 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt @@ -0,0 +1,17 @@ +Qualcomm CI13xxx (Chipidea) USB controllers + +Required properties: +- compatible: should contain qcom,ci-hdrc +- reg: offset and length of the register set in the memory map +- interrupts: interrupt-specifier for the controller interrupt. +- usb-phy: phandle for the PHY device +- dr_mode: Should be peripheral + +Examples: + gadget@f9a55000 { + compatible = qcom,ci-hdrc; + reg = 0xf9a55000 0x400; + dr_mode = peripheral; + interrupts = 0 134 0; + usb-phy = usbphy0; + }; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html